1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
42 (eval-when-compile (require 'mm-url))
44 (defcustom gnus-group-archive-directory
45 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
46 "*The address of the (ding) archives."
47 :group 'gnus-group-foreign
50 (defcustom gnus-group-recent-archive-directory
51 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
52 "*The address of the most recent (ding) articles."
53 :group 'gnus-group-foreign
56 (defcustom gnus-no-groups-message "No gnus is bad news"
57 "*Message displayed by Gnus when no groups are available."
61 (defcustom gnus-keep-same-level nil
62 "*Non-nil means that the next newsgroup after the current will be on the same level.
63 When you type, for instance, `n' after reading the last article in the
64 current newsgroup, you will go to the next newsgroup. If this variable
65 is nil, the next newsgroup will be the next from the group
67 If this variable is non-nil, Gnus will either put you in the
68 next newsgroup with the same level, or, if no such newsgroup is
69 available, the next newsgroup with the lowest possible level higher
70 than the current level.
71 If this variable is `best', Gnus will make the next newsgroup the one
73 :group 'gnus-group-levels
74 :type '(choice (const nil)
76 (sexp :tag "other" t)))
78 (defcustom gnus-group-goto-unread t
79 "*If non-nil, movement commands will go to the next unread and subscribed group."
80 :link '(custom-manual "(gnus)Group Maneuvering")
81 :group 'gnus-group-various
84 (defcustom gnus-goto-next-group-when-activating t
85 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
86 :link '(custom-manual "(gnus)Scanning New Messages")
87 :group 'gnus-group-various
90 (defcustom gnus-permanently-visible-groups nil
91 "*Regexp to match groups that should always be listed in the group buffer.
92 This means that they will still be listed even when there are no
93 unread articles in the groups.
95 If nil, no groups are permanently visible."
96 :group 'gnus-group-listing
97 :type '(choice regexp (const nil)))
99 (defcustom gnus-list-groups-with-ticked-articles t
100 "*If non-nil, list groups that have only ticked articles.
101 If nil, only list groups that have unread articles."
102 :group 'gnus-group-listing
105 (defcustom gnus-group-default-list-level gnus-level-subscribed
106 "*Default listing level.
107 Ignored if `gnus-group-use-permanent-levels' is non-nil."
108 :group 'gnus-group-listing
111 (defcustom gnus-group-list-inactive-groups t
112 "*If non-nil, inactive groups will be listed."
113 :group 'gnus-group-listing
114 :group 'gnus-group-levels
117 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
118 "*Function used for sorting the group buffer.
119 This function will be called with group info entries as the arguments
120 for the groups to be sorted. Pre-made functions include
121 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
122 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
123 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
124 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
126 This variable can also be a list of sorting functions. In that case,
127 the most significant sort function should be the last function in the
129 :group 'gnus-group-listing
130 :link '(custom-manual "(gnus)Sorting Groups")
131 :type '(repeat :value-to-internal (lambda (widget value)
132 (if (listp value) value (list value)))
133 :match (lambda (widget value)
135 (widget-editable-list-match widget value)))
136 (choice (function-item gnus-group-sort-by-alphabet)
137 (function-item gnus-group-sort-by-real-name)
138 (function-item gnus-group-sort-by-unread)
139 (function-item gnus-group-sort-by-level)
140 (function-item gnus-group-sort-by-score)
141 (function-item gnus-group-sort-by-method)
142 (function-item gnus-group-sort-by-server)
143 (function-item gnus-group-sort-by-rank)
144 (function :tag "other" nil))))
146 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%l %O\n"
147 "*Format of group lines.
148 It works along the same lines as a normal formatting string,
149 with some simple extensions.
151 %M Only marked articles (character, \"*\" or \" \")
152 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
153 %L Level of subscribedness (integer)
154 %N Number of unread articles (integer)
155 %I Number of dormant articles (integer)
156 %i Number of ticked and dormant (integer)
157 %T Number of ticked articles (integer)
158 %R Number of read articles (integer)
159 %U Number of unseen articles (integer)
160 %t Estimated total number of articles (integer)
161 %y Number of unread, unticked articles (integer)
162 %G Group name (string)
163 %g Qualified group name (string)
164 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
165 %C Group comment (string)
166 %D Group description (string)
167 %s Select method (string)
168 %o Moderated group (char, \"m\")
169 %p Process mark (char)
170 %B Whether a summary buffer for the group is open (char, \"*\")
171 %O Moderated group (string, \"(m)\" or \"\")
172 %P Topic indentation (string)
173 %m Whether there is new(ish) mail in the group (char, \"%\")
174 %l Whether there are GroupLens predictions for this group (string)
175 %n Select from where (string)
176 %z A string that look like `<%s:%n>' if a foreign select method is used
177 %d The date the group was last entered.
178 %E Icon as defined by `gnus-group-icon-list'.
179 %u User defined specifier. The next character in the format string should
180 be a letter. Gnus will call the function gnus-user-format-function-X,
181 where X is the letter following %u. The function will be passed a
182 single dummy parameter as argument.. The function should return a
183 string, which will be inserted into the buffer just like information
184 from any other group specifier.
186 Note that this format specification is not always respected. For
187 reasons of efficiency, when listing killed groups, this specification
188 is ignored altogether. If the spec is changed considerably, your
189 output may end up looking strange when listing both alive and killed
192 If you use %o or %O, reading the active file will be slower and quite
193 a bit of extra memory will be used. %D will also worsen performance.
194 Also note that if you change the format specification to include any
195 of these specs, you must probably re-start Gnus to see them go into
198 General format specifiers can also be used.
199 See Info node `(gnus)Formatting Variables'."
200 :link '(custom-manual "(gnus)Formatting Variables")
201 :group 'gnus-group-visual
204 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
205 "*The format specification for the group mode line.
206 It works along the same lines as a normal formatting string,
207 with some simple extensions:
209 %S The native news server.
210 %M The native select method.
211 %: \":\" if %S isn't \"\"."
212 :group 'gnus-group-visual
215 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
216 (when (featurep 'xemacs)
217 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
218 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
220 (defcustom gnus-group-menu-hook nil
221 "Hook run after the creation of the group mode menu."
222 :group 'gnus-group-various
225 (defcustom gnus-group-catchup-group-hook nil
226 "Hook run when catching up a group from the group buffer."
227 :group 'gnus-group-various
228 :link '(custom-manual "(gnus)Group Data")
231 (defcustom gnus-group-update-group-hook nil
232 "Hook called when updating group lines."
233 :group 'gnus-group-visual
236 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
237 "*A function that is called to generate the group buffer.
238 The function is called with three arguments: The first is a number;
239 all group with a level less or equal to that number should be listed,
240 if the second is non-nil, empty groups should also be displayed. If
241 the third is non-nil, it is a number. No groups with a level lower
242 than this number should be displayed.
244 The only current function implemented is `gnus-group-prepare-flat'."
245 :group 'gnus-group-listing
248 (defcustom gnus-group-prepare-hook nil
249 "Hook called after the group buffer has been generated.
250 If you want to modify the group buffer, you can use this hook."
251 :group 'gnus-group-listing
254 (defcustom gnus-suspend-gnus-hook nil
255 "Hook called when suspending (not exiting) Gnus."
259 (defcustom gnus-exit-gnus-hook nil
260 "Hook called when exiting Gnus."
264 (defcustom gnus-after-exiting-gnus-hook nil
265 "Hook called after exiting Gnus."
269 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
270 "Hook called when a group line is changed.
271 The hook will not be called if `gnus-visual' is nil.
273 The default function `gnus-group-highlight-line' will
274 highlight the line according to the `gnus-group-highlight'
276 :group 'gnus-group-visual
279 (defcustom gnus-useful-groups
280 '(("(ding) mailing list mirrored at sunsite.auc.dk"
282 (nntp "sunsite.auc.dk"
283 (nntp-address "sunsite.auc.dk")))
286 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
290 (nndoc-article-type mbox)
291 (eval `(nndoc-address
292 ,(let ((file (nnheader-find-etc-directory
295 (error "Couldn't find doc group"))
297 "*Alist of useful group-server pairs."
298 :group 'gnus-group-listing
299 :type '(repeat (list (string :tag "Description")
301 (sexp :tag "Method"))))
303 (defcustom gnus-group-highlight
305 ((and mailp (= unread 0) (eq level 1)) .
306 gnus-group-mail-1-empty-face)
307 ((and mailp (eq level 1)) .
308 gnus-group-mail-1-face)
309 ((and mailp (= unread 0) (eq level 2)) .
310 gnus-group-mail-2-empty-face)
311 ((and mailp (eq level 2)) .
312 gnus-group-mail-2-face)
313 ((and mailp (= unread 0) (eq level 3)) .
314 gnus-group-mail-3-empty-face)
315 ((and mailp (eq level 3)) .
316 gnus-group-mail-3-face)
317 ((and mailp (= unread 0)) .
318 gnus-group-mail-low-empty-face)
320 gnus-group-mail-low-face)
322 ((and (= unread 0) (eq level 1)) .
323 gnus-group-news-1-empty-face)
324 ((and (eq level 1)) .
325 gnus-group-news-1-face)
326 ((and (= unread 0) (eq level 2)) .
327 gnus-group-news-2-empty-face)
328 ((and (eq level 2)) .
329 gnus-group-news-2-face)
330 ((and (= unread 0) (eq level 3)) .
331 gnus-group-news-3-empty-face)
332 ((and (eq level 3)) .
333 gnus-group-news-3-face)
334 ((and (= unread 0) (eq level 4)) .
335 gnus-group-news-4-empty-face)
336 ((and (eq level 4)) .
337 gnus-group-news-4-face)
338 ((and (= unread 0) (eq level 5)) .
339 gnus-group-news-5-empty-face)
340 ((and (eq level 5)) .
341 gnus-group-news-5-face)
342 ((and (= unread 0) (eq level 6)) .
343 gnus-group-news-6-empty-face)
344 ((and (eq level 6)) .
345 gnus-group-news-6-face)
346 ((and (= unread 0)) .
347 gnus-group-news-low-empty-face)
349 gnus-group-news-low-face))
350 "*Controls the highlighting of group buffer lines.
352 Below is a list of `Form'/`Face' pairs. When deciding how a a
353 particular group line should be displayed, each form is
354 evaluated. The content of the face field after the first true form is
355 used. You can change how those group lines are displayed by
356 editing the face field.
358 It is also possible to change and add form fields, but currently that
359 requires an understanding of Lisp expressions. Hopefully this will
360 change in a future release. For now, you can use the following
361 variables in the Lisp expression:
363 group: The name of the group.
364 unread: The number of unread articles in the group.
365 method: The select method used.
366 mailp: Whether it's a mail group or not.
367 level: The level of the group.
368 score: The score of the group.
369 ticked: The number of ticked articles."
370 :group 'gnus-group-visual
371 :type '(repeat (cons (sexp :tag "Form") face)))
373 (defcustom gnus-new-mail-mark ?%
374 "Mark used for groups with new mail."
375 :group 'gnus-group-visual
378 (defgroup gnus-group-icons nil
379 "Add Icons to your group buffer. "
380 :group 'gnus-group-visual)
382 (defcustom gnus-group-icon-list
384 "*Controls the insertion of icons into group buffer lines.
386 Below is a list of `Form'/`File' pairs. When deciding how a
387 particular group line should be displayed, each form is evaluated.
388 The icon from the file field after the first true form is used. You
389 can change how those group lines are displayed by editing the file
390 field. The File will either be found in the
391 `gnus-group-glyph-directory' or by designating absolute path to the
394 It is also possible to change and add form fields, but currently that
395 requires an understanding of Lisp expressions. Hopefully this will
396 change in a future release. For now, you can use the following
397 variables in the Lisp expression:
399 group: The name of the group.
400 unread: The number of unread articles in the group.
401 method: The select method used.
402 mailp: Whether it's a mail group or not.
403 newsp: Whether it's a news group or not
404 level: The level of the group.
405 score: The score of the group.
406 ticked: The number of ticked articles."
407 :group 'gnus-group-icons
408 :type '(repeat (cons (sexp :tag "Form") file)))
410 (defcustom gnus-group-name-charset-method-alist nil
411 "Alist of method and the charset for group names.
414 (((nntp \"news.com.cn\") . cn-gb-2312))"
417 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
419 (defcustom gnus-group-name-charset-group-alist
420 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
421 (and (fboundp 'coding-system-p) (coding-system-p 'utf-8)))
424 "Alist of group regexp and the charset for group names.
427 ((\"\\.com\\.cn:\" . cn-gb-2312))"
429 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
431 (defcustom gnus-group-jump-to-group-prompt nil
432 "Default prompt for `gnus-group-jump-to-group'.
433 If non-nil, the value should be a string, e.g. \"nnml:\",
434 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
435 in the minibuffer prompt."
436 :group 'gnus-group-various
437 :type '(choice (string :tag "Prompt string")
438 (const :tag "Empty" nil)))
440 (defvar gnus-group-listing-limit 1000
441 "*A limit of the number of groups when listing.
442 If the number of groups is larger than the limit, list them in a
445 ;;; Internal variables
447 (defvar gnus-group-is-exiting-p nil)
448 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
449 "Function for sorting the group buffer.")
451 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
452 "Function for sorting the selected groups in the group buffer.")
454 (defvar gnus-group-indentation-function nil)
455 (defvar gnus-goto-missing-group-function nil)
456 (defvar gnus-group-update-group-function nil)
457 (defvar gnus-group-goto-next-group-function nil
458 "Function to override finding the next group after listing groups.")
460 (defvar gnus-group-edit-buffer nil)
462 (defvar gnus-group-line-format-alist
463 `((?M gnus-tmp-marked-mark ?c)
464 (?S gnus-tmp-subscribed ?c)
465 (?L gnus-tmp-level ?d)
466 (?N (cond ((eq number t) "*" )
470 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
471 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
473 (?R gnus-tmp-number-of-read ?s)
474 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?s)
475 (?t gnus-tmp-number-total ?d)
476 (?y gnus-tmp-number-of-unread ?s)
477 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
478 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
479 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
480 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
481 (?g gnus-tmp-group ?s)
482 (?G gnus-tmp-qualified-group ?s)
483 (?c (gnus-short-group-name gnus-tmp-group) ?s)
484 (?C gnus-tmp-comment ?s)
485 (?D gnus-tmp-newsgroup-description ?s)
486 (?o gnus-tmp-moderated ?c)
487 (?O gnus-tmp-moderated-string ?s)
488 (?p gnus-tmp-process-marked ?c)
489 (?s gnus-tmp-news-server ?s)
490 (?n gnus-tmp-news-method ?s)
491 (?P gnus-group-indentation ?s)
492 (?E gnus-tmp-group-icon ?s)
493 (?B gnus-tmp-summary-live ?c)
494 (?l gnus-tmp-grouplens ?s)
495 (?z gnus-tmp-news-method-string ?s)
496 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
497 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
498 (?u gnus-tmp-user-defined ?s)))
500 (defvar gnus-group-mode-line-format-alist
501 `((?S gnus-tmp-news-server ?s)
502 (?M gnus-tmp-news-method ?s)
503 (?u gnus-tmp-user-defined ?s)
504 (?: gnus-tmp-colon ?s)))
506 (defvar gnus-topic-topology nil
507 "The complete topic hierarchy.")
509 (defvar gnus-topic-alist nil
510 "The complete topic-group alist.")
512 (defvar gnus-group-marked nil)
514 (defvar gnus-group-list-mode nil)
517 (defvar gnus-group-icon-cache nil)
519 (defvar gnus-group-listed-groups nil)
520 (defvar gnus-group-list-option nil)
526 (put 'gnus-group-mode 'mode-class 'special)
529 (gnus-define-keys gnus-group-mode-map
530 " " gnus-group-read-group
531 "=" gnus-group-select-group
532 "\r" gnus-group-select-group
533 "\M-\r" gnus-group-quick-select-group
534 "\M- " gnus-group-visible-select-group
535 [(meta control return)] gnus-group-select-group-ephemerally
536 "j" gnus-group-jump-to-group
537 "n" gnus-group-next-unread-group
538 "p" gnus-group-prev-unread-group
539 "\177" gnus-group-prev-unread-group
540 [delete] gnus-group-prev-unread-group
541 [backspace] gnus-group-prev-unread-group
542 "N" gnus-group-next-group
543 "P" gnus-group-prev-group
544 "\M-n" gnus-group-next-unread-group-same-level
545 "\M-p" gnus-group-prev-unread-group-same-level
546 "," gnus-group-best-unread-group
547 "." gnus-group-first-unread-group
548 "u" gnus-group-unsubscribe-current-group
549 "U" gnus-group-unsubscribe-group
550 "c" gnus-group-catchup-current
551 "C" gnus-group-catchup-current-all
552 "\M-c" gnus-group-clear-data
553 "l" gnus-group-list-groups
554 "L" gnus-group-list-all-groups
557 "g" gnus-group-get-new-news
558 "\M-g" gnus-group-get-new-news-this-group
559 "R" gnus-group-restart
560 "r" gnus-group-read-init-file
561 "B" gnus-group-browse-foreign-server
562 "b" gnus-group-check-bogus-groups
563 "F" gnus-group-find-new-groups
564 "\C-c\C-d" gnus-group-describe-group
565 "\M-d" gnus-group-describe-all-groups
566 "\C-c\C-a" gnus-group-apropos
567 "\C-c\M-\C-a" gnus-group-description-apropos
568 "a" gnus-group-post-news
569 "\ek" gnus-group-edit-local-kill
570 "\eK" gnus-group-edit-global-kill
571 "\C-k" gnus-group-kill-group
572 "\C-y" gnus-group-yank-group
573 "\C-w" gnus-group-kill-region
574 "\C-x\C-t" gnus-group-transpose-groups
575 "\C-c\C-l" gnus-group-list-killed
576 "\C-c\C-x" gnus-group-expire-articles
577 "\C-c\M-\C-x" gnus-group-expire-all-groups
579 "s" gnus-group-save-newsrc
580 "z" gnus-group-suspend
583 "?" gnus-group-describe-briefly
584 "\C-c\C-i" gnus-info-find-node
585 "\M-e" gnus-group-edit-group-method
586 "^" gnus-group-enter-server-mode
587 gnus-mouse-2 gnus-mouse-pick-group
588 "<" beginning-of-buffer
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 "E" gnus-group-edit-group
619 "e" gnus-group-edit-group-method
620 "p" gnus-group-edit-group-parameters
621 "v" gnus-group-add-to-virtual
622 "V" gnus-group-make-empty-virtual
623 "D" gnus-group-enter-directory
624 "f" gnus-group-make-doc-group
625 "w" gnus-group-make-web-group
626 "r" gnus-group-rename-group
627 "c" gnus-group-customize
628 "x" gnus-group-nnimap-expunge
629 "\177" gnus-group-delete-group
630 [delete] gnus-group-delete-group)
632 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
633 "b" gnus-group-brew-soup
634 "w" gnus-soup-save-areas
635 "s" gnus-soup-send-replies
636 "p" gnus-soup-pack-packet
637 "r" nnsoup-pack-replies)
639 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
640 "s" gnus-group-sort-groups
641 "a" gnus-group-sort-groups-by-alphabet
642 "u" gnus-group-sort-groups-by-unread
643 "l" gnus-group-sort-groups-by-level
644 "v" gnus-group-sort-groups-by-score
645 "r" gnus-group-sort-groups-by-rank
646 "m" gnus-group-sort-groups-by-method
647 "n" gnus-group-sort-groups-by-real-name)
649 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
650 "s" gnus-group-sort-selected-groups
651 "a" gnus-group-sort-selected-groups-by-alphabet
652 "u" gnus-group-sort-selected-groups-by-unread
653 "l" gnus-group-sort-selected-groups-by-level
654 "v" gnus-group-sort-selected-groups-by-score
655 "r" gnus-group-sort-selected-groups-by-rank
656 "m" gnus-group-sort-selected-groups-by-method
657 "n" gnus-group-sort-selected-groups-by-real-name)
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 "c" gnus-group-fetch-charter
714 "C" gnus-group-fetch-control
715 "d" gnus-group-describe-group
716 "f" gnus-group-fetch-faq
719 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
720 "l" gnus-group-set-current-level
721 "t" gnus-group-unsubscribe-current-group
722 "s" gnus-group-unsubscribe-group
723 "k" gnus-group-kill-group
724 "y" gnus-group-yank-group
725 "w" gnus-group-kill-region
726 "\C-k" gnus-group-kill-level
727 "z" gnus-group-kill-all-zombies))
729 (defun gnus-group-make-menu-bar ()
730 (gnus-turn-off-edit-menu 'group)
731 (unless (boundp 'gnus-group-reading-menu)
734 gnus-group-reading-menu gnus-group-mode-map ""
736 ["Read" gnus-group-read-group (gnus-group-group-name)]
737 ["Select" gnus-group-select-group (gnus-group-group-name)]
738 ["See old articles" (gnus-group-select-group 'all)
739 :keys "C-u SPC" :active (gnus-group-group-name)]
740 ["Catch up" gnus-group-catchup-current :active (gnus-group-group-name)
741 ,@(if (featurep 'xemacs) nil
742 '(:help "Mark unread articles in the current group as read"))]
743 ["Catch up all articles" gnus-group-catchup-current-all
744 (gnus-group-group-name)]
745 ["Check for new articles" gnus-group-get-new-news-this-group
746 :active (gnus-group-group-name)
747 ,@(if (featurep 'xemacs) nil
748 '(:help "Check for new messages in current group"))]
749 ["Toggle subscription" gnus-group-unsubscribe-current-group
750 (gnus-group-group-name)]
751 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
752 ,@(if (featurep 'xemacs) nil
753 '(:help "Kill (remove) current group"))]
754 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
755 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
756 ,@(if (featurep 'xemacs) nil
757 '(:help "Display description of the current group"))]
758 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
759 ["Fetch charter" gnus-group-fetch-charter :active (gnus-group-group-name)
760 ,@(if (featurep 'xemacs) nil
761 '(:help "Display the charter of the current group"))]
762 ["Fetch control message" gnus-group-fetch-control :active (gnus-group-group-name)
763 ,@(if (featurep 'xemacs) nil
764 '(:help "Display the archived control message for the current group"))]
765 ;; Actually one should check, if any of the marked groups gives t for
766 ;; (gnus-check-backend-function 'request-expire-articles ...)
767 ["Expire articles" gnus-group-expire-articles
768 (or (and (gnus-group-group-name)
769 (gnus-check-backend-function
770 'request-expire-articles
771 (gnus-group-group-name))) gnus-group-marked)]
772 ["Set group level..." gnus-group-set-current-level
773 (gnus-group-group-name)]
774 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
775 ["Customize" gnus-group-customize (gnus-group-group-name)]
777 ["Parameters" gnus-group-edit-group-parameters
778 (gnus-group-group-name)]
779 ["Select method" gnus-group-edit-group-method
780 (gnus-group-group-name)]
781 ["Info" gnus-group-edit-group (gnus-group-group-name)]
782 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
783 ["Global kill file" gnus-group-edit-global-kill t])))
786 gnus-group-group-menu gnus-group-mode-map ""
789 ["List unread subscribed groups" gnus-group-list-groups t]
790 ["List (un)subscribed groups" gnus-group-list-all-groups t]
791 ["List killed groups" gnus-group-list-killed gnus-killed-list]
792 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
793 ["List level..." gnus-group-list-level t]
794 ["Describe all groups" gnus-group-describe-all-groups t]
795 ["Group apropos..." gnus-group-apropos t]
796 ["Group and description apropos..." gnus-group-description-apropos t]
797 ["List groups matching..." gnus-group-list-matching t]
798 ["List all groups matching..." gnus-group-list-all-matching t]
799 ["List active file" gnus-group-list-active t]
800 ["List groups with cached" gnus-group-list-cached t]
801 ["List groups with dormant" gnus-group-list-dormant t])
803 ["Default sort" gnus-group-sort-groups t]
804 ["Sort by method" gnus-group-sort-groups-by-method t]
805 ["Sort by rank" gnus-group-sort-groups-by-rank t]
806 ["Sort by score" gnus-group-sort-groups-by-score t]
807 ["Sort by level" gnus-group-sort-groups-by-level t]
808 ["Sort by unread" gnus-group-sort-groups-by-unread t]
809 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
810 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
811 ("Sort process/prefixed"
812 ["Default sort" gnus-group-sort-selected-groups
813 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
814 ["Sort by method" gnus-group-sort-selected-groups-by-method
815 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
816 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
817 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
818 ["Sort by score" gnus-group-sort-selected-groups-by-score
819 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
820 ["Sort by level" gnus-group-sort-selected-groups-by-level
821 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
822 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
823 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
824 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
825 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
826 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
827 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
829 ["Mark group" gnus-group-mark-group
830 (and (gnus-group-group-name)
831 (not (memq (gnus-group-group-name) gnus-group-marked)))]
832 ["Unmark group" gnus-group-unmark-group
833 (and (gnus-group-group-name)
834 (memq (gnus-group-group-name) gnus-group-marked))]
835 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
836 ["Mark regexp..." gnus-group-mark-regexp t]
837 ["Mark region" gnus-group-mark-region t]
838 ["Mark buffer" gnus-group-mark-buffer t]
839 ["Execute command" gnus-group-universal-argument
840 (or gnus-group-marked (gnus-group-group-name))])
842 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
843 ["Kill all newsgroups in region" gnus-group-kill-region t]
844 ["Kill all zombie groups" gnus-group-kill-all-zombies
846 ["Kill all groups on level..." gnus-group-kill-level t])
848 ["Make a foreign group..." gnus-group-make-group t]
849 ["Add a directory group..." gnus-group-make-directory-group t]
850 ["Add the help group" gnus-group-make-help-group t]
851 ["Add the archive group" gnus-group-make-archive-group t]
852 ["Make a doc group..." gnus-group-make-doc-group t]
853 ["Make a web group..." gnus-group-make-web-group t]
854 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
855 ["Make a virtual group..." gnus-group-make-empty-virtual t]
856 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
857 ["Rename group..." gnus-group-rename-group
858 (gnus-check-backend-function
859 'request-rename-group (gnus-group-group-name))]
860 ["Delete group" gnus-group-delete-group
861 (gnus-check-backend-function
862 'request-delete-group (gnus-group-group-name))])
864 ["Next" gnus-group-next-group t]
865 ["Previous" gnus-group-prev-group t]
866 ["Next unread" gnus-group-next-unread-group t]
867 ["Previous unread" gnus-group-prev-unread-group t]
868 ["Next unread same level" gnus-group-next-unread-group-same-level t]
869 ["Previous unread same level"
870 gnus-group-prev-unread-group-same-level t]
871 ["Jump to group..." gnus-group-jump-to-group t]
872 ["First unread group" gnus-group-first-unread-group t]
873 ["Best unread group" gnus-group-best-unread-group t])
875 ["Generate" gnus-sieve-generate t]
876 ["Generate and update" gnus-sieve-update t])
877 ["Delete bogus groups" gnus-group-check-bogus-groups t]
878 ["Find new newsgroups" gnus-group-find-new-groups t]
879 ["Transpose" gnus-group-transpose-groups
880 (gnus-group-group-name)]
881 ["Read a directory as a group..." gnus-group-enter-directory t]))
884 gnus-group-misc-menu gnus-group-mode-map ""
887 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
888 ["Send replies" gnus-soup-send-replies
889 (fboundp 'gnus-soup-pack-packet)]
890 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
891 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
892 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
893 ["Send a mail" gnus-group-mail t]
894 ["Send a message (mail or news)" gnus-group-post-news t]
895 ["Create a local message" gnus-group-news t]
896 ["Check for new news" gnus-group-get-new-news
897 ,@(if (featurep 'xemacs) '(t)
898 '(:help "Get newly arrived articles"))
900 ["Send queued messages" gnus-delay-send-queue
901 ,@(if (featurep 'xemacs) '(t)
902 '(:help "Send all messages that are scheduled to be sent now"))
904 ["Activate all groups" gnus-activate-all-groups t]
905 ["Restart Gnus" gnus-group-restart t]
906 ["Read init file" gnus-group-read-init-file t]
907 ["Browse foreign server..." gnus-group-browse-foreign-server t]
908 ["Enter server buffer" gnus-group-enter-server-mode t]
909 ["Expire all expirable articles" gnus-group-expire-all-groups t]
910 ["Generate any kiboze groups" nnkiboze-generate-groups t]
911 ["Gnus version" gnus-version t]
912 ["Save .newsrc files" gnus-group-save-newsrc t]
913 ["Suspend Gnus" gnus-group-suspend t]
914 ["Clear dribble buffer" gnus-group-clear-dribble t]
915 ["Read manual" gnus-info-find-node t]
916 ["Flush score cache" gnus-score-flush-cache t]
917 ["Toggle topics" gnus-topic-mode t]
918 ["Send a bug report" gnus-bug t]
919 ["Exit from Gnus" gnus-group-exit
920 ,@(if (featurep 'xemacs) '(t)
921 '(:help "Quit reading news"))]
922 ["Exit without saving" gnus-group-quit t]))
924 (gnus-run-hooks 'gnus-group-menu-hook)))
926 (defvar gnus-group-toolbar-map nil)
928 ;; Emacs 21 tool bar. Should be no-op otherwise.
929 (defun gnus-group-make-tool-bar ()
931 (condition-case nil (require 'tool-bar) (error nil))
932 (fboundp 'tool-bar-add-item-from-menu)
933 (default-value 'tool-bar-mode)
934 (not gnus-group-toolbar-map))
935 (setq gnus-group-toolbar-map
936 (let ((tool-bar-map (make-sparse-keymap))
937 (load-path (mm-image-load-path)))
938 (tool-bar-add-item-from-menu
939 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
940 (tool-bar-add-item-from-menu
941 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
942 (tool-bar-add-item-from-menu
943 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
944 (tool-bar-add-item-from-menu
945 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
946 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
947 :help "Subscribe to the current group")
948 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
950 :help "Unsubscribe from the current group")
951 (tool-bar-add-item-from-menu
952 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
954 (if gnus-group-toolbar-map
955 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
957 (defun gnus-group-mode ()
958 "Major mode for reading news.
960 All normal editing commands are switched off.
961 \\<gnus-group-mode-map>
962 The group buffer lists (some of) the groups available. For instance,
963 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
964 lists all zombie groups.
966 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
967 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
969 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
971 The following commands are available:
973 \\{gnus-group-mode-map}"
975 (kill-all-local-variables)
976 (when (gnus-visual-p 'group-menu 'menu)
977 (gnus-group-make-menu-bar)
978 (gnus-group-make-tool-bar))
979 (gnus-simplify-mode-line)
980 (setq major-mode 'gnus-group-mode)
981 (setq mode-name "Group")
982 (gnus-group-set-mode-line)
983 (setq mode-line-process nil)
984 (use-local-map gnus-group-mode-map)
985 (buffer-disable-undo)
986 (setq truncate-lines t)
987 (setq buffer-read-only t)
988 (gnus-set-default-directory)
989 (gnus-update-format-specifications nil 'group 'group-mode)
990 (gnus-update-group-mark-positions)
995 (gnus-run-hooks 'gnus-group-mode-hook))
997 (defun gnus-update-group-mark-positions ()
999 (let ((gnus-process-mark ?\200)
1000 (gnus-group-update-hook nil)
1001 (gnus-group-marked '("dummy.group"))
1002 (gnus-active-hashtb (make-vector 10 0))
1004 (gnus-set-active "dummy.group" '(0 . 0))
1005 (gnus-set-work-buffer)
1006 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1007 (goto-char (point-min))
1008 (setq gnus-group-mark-positions
1009 (list (cons 'process (and (search-forward "\200" nil t)
1010 (- (point) 2))))))))
1012 (defun gnus-mouse-pick-group (e)
1013 "Enter the group under the mouse pointer."
1016 (gnus-group-read-group nil))
1018 ;; Look at LEVEL and find out what the level is really supposed to be.
1019 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1020 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1021 (defun gnus-group-default-level (&optional level number-or-nil)
1023 (gnus-group-use-permanent-levels
1024 (or (setq gnus-group-use-permanent-levels
1025 (or level (if (numberp gnus-group-use-permanent-levels)
1026 gnus-group-use-permanent-levels
1027 (or gnus-group-default-list-level
1028 gnus-level-subscribed))))
1029 gnus-group-default-list-level gnus-level-subscribed))
1033 (or level gnus-group-default-list-level gnus-level-subscribed))))
1035 (defun gnus-group-setup-buffer ()
1036 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1037 (unless (eq major-mode 'gnus-group-mode)
1040 (gnus-carpal-setup-buffer 'group))))
1042 (defun gnus-group-name-charset (method group)
1044 (setq method (gnus-find-method-for-group group)))
1045 (let ((item (assoc method gnus-group-name-charset-method-alist))
1046 (alist gnus-group-name-charset-group-alist)
1050 (while (setq item (pop alist))
1051 (if (string-match (car item) group)
1053 result (cdr item))))
1056 (defun gnus-group-name-decode (string charset)
1057 (if (and string charset (featurep 'mule))
1058 (mm-decode-coding-string string charset)
1061 (defun gnus-group-decoded-name (string)
1062 (let ((charset (gnus-group-name-charset nil string)))
1063 (gnus-group-name-decode string charset)))
1065 (defun gnus-group-list-groups (&optional level unread lowest)
1066 "List newsgroups with level LEVEL or lower that have unread articles.
1067 Default is all subscribed groups.
1068 If argument UNREAD is non-nil, groups with no unread articles are also
1071 Also see the `gnus-group-use-permanent-levels' variable."
1073 (list (if current-prefix-arg
1074 (prefix-numeric-value current-prefix-arg)
1076 (gnus-group-default-level nil t)
1077 gnus-group-default-list-level
1078 gnus-level-subscribed))))
1080 (setq level (car gnus-group-list-mode)
1081 unread (cdr gnus-group-list-mode)))
1082 (setq level (gnus-group-default-level level))
1083 (gnus-group-setup-buffer)
1084 (gnus-update-format-specifications nil 'group 'group-mode)
1085 (let ((case-fold-search nil)
1086 (props (text-properties-at (gnus-point-at-bol)))
1087 (empty (= (point-min) (point-max)))
1088 (group (gnus-group-group-name))
1090 (set-buffer gnus-group-buffer)
1091 (setq number (funcall gnus-group-prepare-function level unread lowest))
1092 (when (or (and (numberp number)
1094 (zerop (buffer-size)))
1095 ;; No groups in the buffer.
1096 (gnus-message 5 gnus-no-groups-message))
1097 ;; We have some groups displayed.
1098 (goto-char (point-max))
1099 (when (or (not gnus-group-goto-next-group-function)
1100 (not (funcall gnus-group-goto-next-group-function
1104 (goto-char (point-min)))
1106 ;; Go to the first group with unread articles.
1107 (gnus-group-search-forward t))
1109 ;; Find the right group to put point on. If the current group
1110 ;; has disappeared in the new listing, try to find the next
1111 ;; one. If no next one can be found, just leave point at the
1112 ;; first newsgroup in the buffer.
1113 (when (not (gnus-goto-char
1115 (point-min) (point-max)
1116 'gnus-group (gnus-intern-safe
1117 group gnus-active-hashtb))))
1118 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1120 (not (gnus-goto-char
1122 (point-min) (point-max) 'gnus-group
1124 (caar newsrc) gnus-active-hashtb)))))
1125 (setq newsrc (cdr newsrc)))
1127 (goto-char (point-max))
1128 (forward-line -1)))))))
1129 ;; Adjust cursor point.
1130 (gnus-group-position-point)))
1132 (defun gnus-group-list-level (level &optional all)
1133 "List groups on LEVEL.
1134 If ALL (the prefix), also list groups that have no unread articles."
1135 (interactive "nList groups on level: \nP")
1136 (gnus-group-list-groups level all level))
1138 (defun gnus-group-prepare-logic (group test)
1139 (or (and gnus-group-listed-groups
1140 (null gnus-group-list-option)
1141 (member group gnus-group-listed-groups))
1143 ((null gnus-group-listed-groups) test)
1144 ((null gnus-group-list-option) test)
1145 (t (and (member group gnus-group-listed-groups)
1146 (if (eq gnus-group-list-option 'flush)
1150 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1151 "List all newsgroups with unread articles of level LEVEL or lower.
1152 If PREDICATE is a function, list groups that the function returns non-nil;
1153 if it is t, list groups that have no unread articles.
1154 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1155 If REGEXP is a function, list dead groups that the function returns non-nil;
1156 if it is a string, only list groups matching REGEXP."
1157 (set-buffer gnus-group-buffer)
1158 (let ((buffer-read-only nil)
1159 (newsrc (cdr gnus-newsrc-alist))
1160 (lowest (or lowest 1))
1161 (not-in-list (and gnus-group-listed-groups
1162 (copy-sequence gnus-group-listed-groups)))
1163 info clevel unread group params)
1165 (when (or (< lowest gnus-level-zombie)
1166 gnus-group-listed-groups)
1167 ;; List living groups.
1169 (setq info (car newsrc)
1170 group (gnus-info-group info)
1171 params (gnus-info-params info)
1173 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1175 (setq not-in-list (delete group not-in-list)))
1176 (when (gnus-group-prepare-logic
1178 (and unread ; This group might be unchecked
1179 (or (not (stringp regexp))
1180 (string-match regexp group))
1181 (<= (setq clevel (gnus-info-level info)) level)
1184 ((functionp predicate)
1185 (funcall predicate info))
1186 (predicate t) ; We list all groups?
1189 (if (eq unread t) ; Unactivated?
1190 gnus-group-list-inactive-groups
1191 ; We list unactivated
1193 ; We list groups with unread articles
1194 (and gnus-list-groups-with-ticked-articles
1195 (cdr (assq 'tick (gnus-info-marks info))))
1196 ; And groups with tickeds
1197 ;; Check for permanent visibility.
1198 (and gnus-permanently-visible-groups
1199 (string-match gnus-permanently-visible-groups
1201 (memq 'visible params)
1202 (cdr (assq 'visible params)))))))
1203 (gnus-group-insert-group-line
1204 group (gnus-info-level info)
1205 (gnus-info-marks info) unread (gnus-info-method info)))))
1207 ;; List dead groups.
1208 (when (or gnus-group-listed-groups
1209 (and (>= level gnus-level-zombie)
1210 (<= lowest gnus-level-zombie)))
1211 (gnus-group-prepare-flat-list-dead
1212 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1213 gnus-level-zombie ?Z
1216 (dolist (group gnus-zombie-list)
1217 (setq not-in-list (delete group not-in-list))))
1218 (when (or gnus-group-listed-groups
1219 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1220 (gnus-group-prepare-flat-list-dead
1223 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1224 gnus-level-killed ?K regexp))
1226 (gnus-group-set-mode-line)
1227 (setq gnus-group-list-mode (cons level predicate))
1228 (gnus-run-hooks 'gnus-group-prepare-hook)
1231 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1232 ;; List zombies and killed lists somewhat faster, which was
1233 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1234 ;; this by ignoring the group format specification altogether.
1236 (if (> (length groups) gnus-group-listing-limit)
1238 (setq group (pop groups))
1239 (when (gnus-group-prepare-logic
1242 (and (stringp regexp) (string-match regexp group))
1243 (and (functionp regexp) (funcall regexp group))))
1244 (gnus-add-text-properties
1245 (point) (prog1 (1+ (point))
1246 (insert " " mark " *: "
1247 (gnus-group-decoded-name group)
1249 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1251 'gnus-level level))))
1253 (setq group (pop groups))
1254 (when (gnus-group-prepare-logic
1257 (and (stringp regexp) (string-match regexp group))
1258 (and (functionp regexp) (funcall regexp group))))
1259 (gnus-group-insert-group-line
1261 (let ((active (gnus-active group)))
1263 (if (zerop (cdr active))
1265 (- (1+ (cdr active)) (car active)))
1267 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1269 (defun gnus-group-update-group-line ()
1270 "Update the current line in the group buffer."
1271 (let* ((buffer-read-only nil)
1272 (group (gnus-group-group-name))
1273 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1274 gnus-group-indentation)
1277 (not (gnus-ephemeral-group-p group))
1279 (concat "(gnus-group-set-info '"
1280 (gnus-prin1-to-string (nth 2 entry))
1282 (setq gnus-group-indentation (gnus-group-group-indentation))
1284 (gnus-group-insert-group-line-info group)
1286 (gnus-group-position-point))))
1288 (defun gnus-group-insert-group-line-info (group)
1289 "Insert GROUP on the current line."
1290 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1291 (gnus-group-indentation (gnus-group-group-indentation))
1295 ;; (Un)subscribed group.
1296 (setq info (nth 2 entry))
1297 (gnus-group-insert-group-line
1298 group (gnus-info-level info) (gnus-info-marks info)
1299 (or (car entry) t) (gnus-info-method info)))
1300 ;; This group is dead.
1301 (gnus-group-insert-group-line
1303 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1305 (if (setq active (gnus-active group))
1306 (if (zerop (cdr active))
1308 (- (1+ (cdr active)) (car active)))
1310 (gnus-method-simplify (gnus-find-method-for-group group))))))
1312 (defun gnus-number-of-unseen-articles-in-group (group)
1313 (let* ((info (nth 2 (gnus-group-entry group)))
1314 (marked (gnus-info-marks info))
1315 (seen (cdr (assq 'seen marked)))
1316 (active (gnus-active group)))
1317 (length (gnus-uncompress-range
1318 (gnus-range-difference
1319 (gnus-range-difference (list active) (gnus-info-read info))
1322 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1323 gnus-tmp-marked number
1325 "Insert a group line in the group buffer."
1326 (let* ((gnus-tmp-method
1327 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1328 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1330 (gnus-tmp-active (gnus-active gnus-tmp-group))
1331 (gnus-tmp-number-total
1333 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1335 (gnus-tmp-number-of-unread
1336 (if (numberp number) (int-to-string (max 0 number))
1338 (gnus-tmp-number-of-read
1339 (if (numberp number)
1340 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1342 (gnus-tmp-subscribed
1343 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1344 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1345 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1347 (gnus-tmp-qualified-group
1348 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1349 group-name-charset))
1351 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1353 (gnus-tmp-newsgroup-description
1354 (if gnus-description-hashtb
1355 (or (gnus-group-name-decode
1356 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1357 group-name-charset) "")
1360 (if (and gnus-moderated-hashtb
1361 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1363 (gnus-tmp-moderated-string
1364 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1365 (gnus-tmp-group-icon "==&&==")
1366 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1367 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1368 (gnus-tmp-news-method-string
1370 (format "(%s:%s)" (car gnus-tmp-method)
1371 (cadr gnus-tmp-method)) ""))
1372 (gnus-tmp-marked-mark
1373 (if (and (numberp number)
1375 (cdr (assq 'tick gnus-tmp-marked)))
1377 (gnus-tmp-summary-live
1378 (if (and (not gnus-group-is-exiting-p)
1379 (gnus-buffer-live-p (gnus-summary-buffer-name
1382 (gnus-tmp-process-marked
1383 (if (member gnus-tmp-group gnus-group-marked)
1384 gnus-process-mark ? ))
1386 (or (and gnus-use-grouplens
1387 (bbb-grouplens-group-p gnus-tmp-group))
1389 (buffer-read-only nil)
1390 header gnus-tmp-header) ; passed as parameter to user-funcs.
1392 (gnus-add-text-properties
1396 (let ((gnus-tmp-group (gnus-group-name-decode
1397 gnus-tmp-group group-name-charset)))
1398 (eval gnus-group-line-format-spec)))
1399 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1400 gnus-unread ,(if (numberp number)
1401 (string-to-int gnus-tmp-number-of-unread)
1403 gnus-marked ,gnus-tmp-marked-mark
1404 gnus-indentation ,gnus-group-indentation
1405 gnus-level ,gnus-tmp-level))
1407 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1408 (gnus-run-hooks 'gnus-group-update-hook))
1410 ;; Allow XEmacs to remove front-sticky text properties.
1411 (gnus-group-remove-excess-properties)))
1413 (defun gnus-group-highlight-line ()
1414 "Highlight the current line according to `gnus-group-highlight'."
1415 (let* ((list gnus-group-highlight)
1417 (end (progn (end-of-line) (point)))
1418 ;; now find out where the line starts and leave point there.
1419 (beg (progn (beginning-of-line) (point)))
1420 (group (gnus-group-group-name))
1421 (entry (gnus-group-entry group))
1422 (unread (if (numberp (car entry)) (car entry) 0))
1423 (active (gnus-active group))
1424 (total (if active (1+ (- (cdr active) (car active))) 0))
1425 (info (nth 2 entry))
1426 (method (gnus-server-get-method group (gnus-info-method info)))
1427 (marked (gnus-info-marks info))
1428 (mailp (apply 'append
1431 (memq x (assoc (symbol-name
1432 (car (or method gnus-select-method)))
1433 gnus-valid-select-methods)))
1434 '(mail post-mail))))
1435 (level (or (gnus-info-level info) gnus-level-killed))
1436 (score (or (gnus-info-score info) 0))
1437 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1438 (group-age (gnus-group-timestamp-delta group))
1439 (inhibit-read-only t))
1440 ;; Eval the cars of the lists until we find a match.
1442 (not (eval (caar list))))
1443 (setq list (cdr list)))
1444 (let ((face (cdar list)))
1445 (unless (eq face (get-text-property beg 'face))
1446 (gnus-put-text-property-excluding-characters-with-faces
1448 (setq face (if (boundp face) (symbol-value face) face)))
1449 (gnus-extent-start-open beg)))
1452 (defun gnus-group-update-group (group &optional visible-only)
1453 "Update all lines where GROUP appear.
1454 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1456 ;; Can't use `save-excursion' here, so we do it manually.
1457 (let ((buf (current-buffer))
1459 (set-buffer gnus-group-buffer)
1460 (setq mark (point-marker))
1461 ;; The buffer may be narrowed.
1464 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1466 found buffer-read-only)
1467 ;; Enter the current status into the dribble buffer.
1468 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1470 (not (gnus-ephemeral-group-p group)))
1472 (concat "(gnus-group-set-info '"
1473 (gnus-prin1-to-string (nth 2 entry))
1475 ;; Find all group instances. If topics are in use, each group
1476 ;; may be listed in more than once.
1477 (while (setq loc (text-property-any
1478 loc (point-max) 'gnus-group ident))
1481 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1483 (gnus-group-insert-group-line-info group)
1486 (gnus-run-hooks 'gnus-group-update-group-hook)))
1487 (setq loc (1+ loc)))
1488 (unless (or found visible-only)
1489 ;; No such line in the buffer, find out where it's supposed to
1490 ;; go, and insert it there (or at the end of the buffer).
1491 (if gnus-goto-missing-group-function
1492 (funcall gnus-goto-missing-group-function group)
1493 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1494 (while (and entry (car entry)
1498 (point-min) (point-max)
1499 'gnus-group (gnus-intern-safe
1500 (caar entry) gnus-active-hashtb)))))
1501 (setq entry (cdr entry)))
1502 (or entry (goto-char (point-max)))))
1503 ;; Finally insert the line.
1504 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1505 (gnus-group-insert-group-line-info group)
1508 (gnus-run-hooks 'gnus-group-update-group-hook))))
1509 (when gnus-group-update-group-function
1510 (funcall gnus-group-update-group-function group))
1511 (gnus-group-set-mode-line)))
1513 (set-marker mark nil)
1516 (defun gnus-group-set-mode-line ()
1517 "Update the mode line in the group buffer."
1518 (when (memq 'group gnus-updated-mode-lines)
1519 ;; Yes, we want to keep this mode line updated.
1521 (set-buffer gnus-group-buffer)
1522 (let* ((gformat (or gnus-group-mode-line-format-spec
1523 (gnus-set-format 'group-mode)))
1524 (gnus-tmp-news-server (cadr gnus-select-method))
1525 (gnus-tmp-news-method (car gnus-select-method))
1526 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1528 gnus-tmp-header ;Dummy binding for user-defined formats
1529 ;; Get the resulting string.
1531 (and gnus-dribble-buffer
1532 (buffer-name gnus-dribble-buffer)
1533 (buffer-modified-p gnus-dribble-buffer)
1535 (set-buffer gnus-dribble-buffer)
1536 (not (zerop (buffer-size))))))
1537 (mode-string (eval gformat)))
1538 ;; Say whether the dribble buffer has been modified.
1539 (setq mode-line-modified
1540 (if modified (car gnus-mode-line-modified)
1541 (cdr gnus-mode-line-modified)))
1542 ;; If the line is too long, we chop it off.
1543 (when (> (length mode-string) max-len)
1544 (setq mode-string (substring mode-string 0 (- max-len 4))))
1546 (setq mode-line-buffer-identification
1547 (gnus-mode-line-buffer-identification
1548 (list mode-string)))
1549 (set-buffer-modified-p modified))))))
1551 (defun gnus-group-group-name ()
1552 "Get the name of the newsgroup on the current line."
1553 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1555 (symbol-name group))))
1557 (defun gnus-group-group-level ()
1558 "Get the level of the newsgroup on the current line."
1559 (get-text-property (gnus-point-at-bol) 'gnus-level))
1561 (defun gnus-group-group-indentation ()
1562 "Get the indentation of the newsgroup on the current line."
1563 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1564 (and gnus-group-indentation-function
1565 (funcall gnus-group-indentation-function))
1568 (defun gnus-group-group-unread ()
1569 "Get the number of unread articles of the newsgroup on the current line."
1570 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1572 (defun gnus-group-new-mail (group)
1573 (if (nnmail-new-mail-p (gnus-group-real-name group))
1577 (defun gnus-group-level (group)
1578 "Return the estimated level of GROUP."
1579 (or (gnus-info-level (gnus-get-info group))
1580 (and (member group gnus-zombie-list) gnus-level-zombie)
1583 (defun gnus-group-search-forward (&optional backward all level first-too)
1584 "Find the next newsgroup with unread articles.
1585 If BACKWARD is non-nil, find the previous newsgroup instead.
1586 If ALL is non-nil, just find any newsgroup.
1587 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1589 If FIRST-TOO, the current line is also eligible as a target."
1590 (let ((way (if backward -1 1))
1591 (low gnus-level-killed)
1594 (if (and backward (progn (beginning-of-line)) (bobp))
1603 (get-text-property (point) 'gnus-group)
1607 (get-text-property (point) 'gnus-unread)))
1608 (and (numberp unread) (> unread 0)))
1609 (setq lev (get-text-property (point)
1611 (<= lev gnus-level-subscribed)))
1613 (and (setq lev (get-text-property (point)
1622 (zerop (forward-line way)))))
1624 (progn (gnus-group-position-point) t)
1625 (goto-char (or pos beg))
1628 ;;; Gnus group mode commands
1632 (defun gnus-group-mark-line-p ()
1635 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1636 (eq (char-after) gnus-process-mark)))
1638 (defun gnus-group-mark-group (n &optional unmark no-advance)
1639 "Mark the current group."
1641 (let ((buffer-read-only nil)
1645 (when (setq group (gnus-group-group-name))
1646 ;; Go to the mark position.
1648 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1649 (subst-char-in-region
1650 (point) (1+ (point)) (char-after)
1653 (setq gnus-group-marked (delete group gnus-group-marked))
1655 (setq gnus-group-marked
1656 (cons group (delete group gnus-group-marked)))
1657 gnus-process-mark)))
1659 (gnus-group-next-group 1))
1661 (gnus-summary-position-point)
1664 (defun gnus-group-unmark-group (n)
1665 "Remove the mark from the current group."
1667 (gnus-group-mark-group n 'unmark)
1668 (gnus-group-position-point))
1670 (defun gnus-group-unmark-all-groups ()
1671 "Unmark all groups."
1673 (let ((groups gnus-group-marked))
1676 (gnus-group-remove-mark (pop groups)))))
1677 (gnus-group-position-point))
1679 (defun gnus-group-mark-region (unmark beg end)
1680 "Mark all groups between point and mark.
1681 If UNMARK, remove the mark instead."
1682 (interactive "P\nr")
1683 (let ((num (count-lines beg end)))
1686 (- num (gnus-group-mark-group num unmark)))))
1688 (defun gnus-group-mark-buffer (&optional unmark)
1689 "Mark all groups in the buffer.
1690 If UNMARK, remove the mark instead."
1692 (gnus-group-mark-region unmark (point-min) (point-max)))
1694 (defun gnus-group-mark-regexp (regexp)
1695 "Mark all groups that match some regexp."
1696 (interactive "sMark (regexp): ")
1697 (let ((alist (cdr gnus-newsrc-alist))
1700 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1701 (gnus-group-set-mark group))))
1702 (gnus-group-position-point))
1704 (defun gnus-group-remove-mark (group &optional test-marked)
1705 "Remove the process mark from GROUP and move point there.
1706 Return nil if the group isn't displayed."
1707 (if (gnus-group-goto-group group nil test-marked)
1709 (gnus-group-mark-group 1 'unmark t)
1711 (setq gnus-group-marked
1712 (delete group gnus-group-marked))
1715 (defun gnus-group-set-mark (group)
1716 "Set the process mark on GROUP."
1717 (if (gnus-group-goto-group group)
1719 (gnus-group-mark-group 1 nil t))
1720 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1722 (defun gnus-group-universal-argument (arg &optional groups func)
1723 "Perform any command on all groups according to the process/prefix convention."
1725 (if (eq (setq func (or func
1728 (substitute-command-keys
1729 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1731 (gnus-error 1 "Undefined key")
1732 (gnus-group-iterate arg
1734 (command-execute func))))
1735 (gnus-group-position-point))
1737 (defun gnus-group-process-prefix (n)
1738 "Return a list of groups to work on.
1739 Take into consideration N (the prefix) and the list of marked groups."
1742 (setq n (prefix-numeric-value n))
1743 ;; There is a prefix, so we return a list of the N next
1745 (let ((way (if (< n 0) -1 1))
1750 (if (setq group (gnus-group-group-name))
1751 (push group groups))
1753 (gnus-group-next-group way)))
1755 ((and (gnus-region-active-p) (mark))
1756 ;; Work on the region between point and mark.
1757 (let ((max (max (point) (mark)))
1760 (goto-char (min (point) (mark)))
1763 (push (gnus-group-group-name) groups)
1764 (zerop (gnus-group-next-group 1))
1766 (nreverse groups))))
1768 ;; No prefix, but a list of marked articles.
1769 (reverse gnus-group-marked))
1771 ;; Neither marked articles or a prefix, so we return the
1773 (let ((group (gnus-group-group-name)))
1774 (and group (list group))))))
1776 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1777 ;;; imagine why I went through these contortions...
1779 (let ((function (make-symbol "gnus-group-iterate-function"))
1780 (window (make-symbol "gnus-group-iterate-window"))
1781 (groups (make-symbol "gnus-group-iterate-groups"))
1782 (group (make-symbol "gnus-group-iterate-group")))
1784 `(defun gnus-group-iterate (arg ,function)
1785 "Iterate FUNCTION over all process/prefixed groups.
1786 FUNCTION will be called with the group name as the parameter
1787 and with point over the group in question."
1788 (let ((,groups (gnus-group-process-prefix arg))
1789 (,window (selected-window))
1792 (setq ,group (car ,groups)
1793 ,groups (cdr ,groups))
1794 (select-window ,window)
1795 (gnus-group-remove-mark ,group)
1796 (save-selected-window
1798 (funcall ,function ,group)))))))))
1800 (put 'gnus-group-iterate 'lisp-indent-function 1)
1802 ;; Selecting groups.
1804 (defun gnus-group-read-group (&optional all no-article group select-articles)
1805 "Read news in this newsgroup.
1806 If the prefix argument ALL is non-nil, already read articles become
1807 readable. IF ALL is a number, fetch this number of articles. If the
1808 optional argument NO-ARTICLE is non-nil, no article will be
1809 auto-selected upon group entry. If GROUP is non-nil, fetch that
1812 (let ((no-display (eq all 0))
1813 (group (or group (gnus-group-group-name)))
1814 number active marked entry)
1818 (error "No group on current line"))
1819 (setq marked (gnus-info-marks
1820 (nth 2 (setq entry (gnus-gethash
1821 group gnus-newsrc-hashtb)))))
1822 ;; This group might be a dead group. In that case we have to get
1823 ;; the number of unread articles from `gnus-active-hashtb'.
1825 (cond ((numberp all) all)
1827 ((setq active (gnus-active group))
1828 (- (1+ (cdr active)) (car active)))))
1829 (gnus-summary-read-group
1830 group (or all (and (numberp number)
1831 (zerop (+ number (gnus-range-length
1832 (cdr (assq 'tick marked)))
1834 (cdr (assq 'dormant marked)))))))
1835 no-article nil no-display nil select-articles)))
1837 (defun gnus-group-select-group (&optional all)
1838 "Select this newsgroup.
1839 No article is selected automatically.
1840 If the group is opened, just switch the summary buffer.
1841 If ALL is non-nil, already read articles become readable.
1842 If ALL is a number, fetch this number of articles."
1844 (gnus-group-read-group all t))
1846 (defun gnus-group-quick-select-group (&optional all)
1847 "Select the current group \"quickly\".
1848 This means that no highlighting or scoring will be performed.
1849 If ALL (the prefix argument) is 0, don't even generate the summary
1852 This might be useful if you want to toggle threading
1853 before entering the group."
1855 (require 'gnus-score)
1857 gnus-score-find-score-files-function
1858 gnus-home-score-file
1859 gnus-apply-kill-hook
1860 gnus-summary-expunge-below)
1861 (gnus-group-read-group all t)))
1863 (defun gnus-group-visible-select-group (&optional all)
1864 "Select the current group without hiding any articles."
1866 (let ((gnus-inhibit-limiting t))
1867 (gnus-group-read-group all t)))
1869 (defun gnus-group-select-group-ephemerally ()
1870 "Select the current group without doing any processing whatsoever.
1871 You will actually be entered into a group that's a copy of
1872 the current group; no changes you make while in this group will
1875 (require 'gnus-score)
1877 gnus-score-find-score-files-function gnus-apply-kill-hook
1878 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1879 gnus-summary-mode-hook gnus-select-group-hook
1880 (group (gnus-group-group-name))
1881 (method (gnus-find-method-for-group group)))
1882 (gnus-group-read-ephemeral-group
1883 (gnus-group-prefixed-name group method) method)))
1886 (defun gnus-fetch-group (group &optional articles)
1887 "Start Gnus if necessary and enter GROUP.
1888 Returns whether the fetching was successful or not."
1889 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1890 (unless (get-buffer gnus-group-buffer)
1892 (gnus-group-read-group articles nil group))
1895 (defun gnus-fetch-group-other-frame (group)
1896 "Pop up a frame and enter GROUP."
1898 (let ((window (get-buffer-window gnus-group-buffer)))
1900 (select-frame (window-frame window)))
1901 ((= (length (frame-list)) 1)
1902 (select-frame (make-frame)))
1905 (gnus-fetch-group group))
1907 (defvar gnus-ephemeral-group-server 0)
1909 ;; Enter a group that is not in the group buffer. Non-nil is returned
1910 ;; if selection was successful.
1911 (defun gnus-group-read-ephemeral-group (group method &optional activate
1912 quit-config request-only
1915 "Read GROUP from METHOD as an ephemeral group.
1916 If ACTIVATE, request the group first.
1917 If QUIT-CONFIG, use that window configuration when exiting from the
1919 If REQUEST-ONLY, don't actually read the group; just request it.
1920 If SELECT-ARTICLES, only select those articles.
1921 If PARAMETERS, use those as the group parameters.
1923 Return the name of the group if selection was successful."
1924 ;; Transform the select method into a unique server.
1925 (when (stringp method)
1926 (setq method (gnus-server-to-method method)))
1928 `(,(car method) ,(concat (cadr method) "-ephemeral")
1929 (,(intern (format "%s-address" (car method))) ,(cadr method))
1931 (let ((group (if (gnus-group-foreign-p group) group
1932 (gnus-group-prefixed-name (gnus-group-real-name group)
1937 ,gnus-level-default-subscribed nil nil ,method
1940 (cons 'quit-config quit-config)
1942 (cons gnus-summary-buffer
1943 gnus-current-window-configuration)))
1946 (push method gnus-ephemeral-servers)
1947 (set-buffer gnus-group-buffer)
1948 (unless (gnus-check-server method)
1949 (error "Unable to contact server: %s" (gnus-status-message method)))
1951 (gnus-activate-group group 'scan)
1952 (unless (gnus-request-group group)
1953 (error "Couldn't request group: %s"
1954 (nnheader-get-report (car method)))))
1958 (when (gnus-group-read-group t t group select-articles)
1962 (message "Quit reading the ephemeral group")
1965 (defun gnus-group-jump-to-group (group)
1966 "Jump to newsgroup GROUP."
1968 (list (mm-string-make-unibyte
1970 "Group: " gnus-active-hashtb nil
1971 (gnus-read-active-file-p)
1972 gnus-group-jump-to-group-prompt
1973 'gnus-group-history))))
1975 (when (equal group "")
1976 (error "Empty group name"))
1978 (unless (gnus-ephemeral-group-p group)
1979 ;; Either go to the line in the group buffer...
1980 (unless (gnus-group-goto-group group)
1981 ;; ... or insert the line.
1982 (gnus-group-update-group group)
1983 (gnus-group-goto-group group)))
1984 ;; Adjust cursor point.
1985 (gnus-group-position-point))
1987 (defun gnus-group-goto-group (group &optional far test-marked)
1988 "Goto to newsgroup GROUP.
1989 If FAR, it is likely that the group is not on the current line.
1990 If TEST-MARKED, the line must be marked."
1994 ;; It's quite likely that we are on the right line, so
1995 ;; we check the current line first.
1997 (eq (get-text-property (point) 'gnus-group)
1998 (gnus-intern-safe group gnus-active-hashtb))
1999 (or (not test-marked) (gnus-group-mark-line-p)))
2001 ;; Previous and next line are also likely, so we check them as well.
2005 (and (eq (get-text-property (point) 'gnus-group)
2006 (gnus-intern-safe group gnus-active-hashtb))
2007 (or (not test-marked) (gnus-group-mark-line-p)))))
2013 (and (eq (get-text-property (point) 'gnus-group)
2014 (gnus-intern-safe group gnus-active-hashtb))
2015 (or (not test-marked) (gnus-group-mark-line-p)))))
2019 (goto-char (point-min))
2021 (while (and (not found)
2026 (gnus-intern-safe group gnus-active-hashtb))))
2027 (if (gnus-group-mark-line-p)
2032 ;; Search through the entire buffer.
2035 (point-min) (point-max)
2036 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2038 (defun gnus-group-next-group (n &optional silent)
2039 "Go to next N'th newsgroup.
2040 If N is negative, search backward instead.
2041 Returns the difference between N and the number of skips actually
2044 (gnus-group-next-unread-group n t nil silent))
2046 (defun gnus-group-next-unread-group (n &optional all level silent)
2047 "Go to next N'th unread newsgroup.
2048 If N is negative, search backward instead.
2049 If ALL is non-nil, choose any newsgroup, unread or not.
2050 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2051 such group can be found, the next group with a level higher than
2053 Returns the difference between N and the number of skips actually
2056 (let ((backward (< n 0))
2059 (gnus-group-search-forward
2060 backward (or (not gnus-group-goto-unread) all) level))
2064 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2065 (if level " on this level or higher" "")))
2068 (defun gnus-group-prev-group (n)
2069 "Go to previous N'th newsgroup.
2070 Returns the difference between N and the number of skips actually
2073 (gnus-group-next-unread-group (- n) t))
2075 (defun gnus-group-prev-unread-group (n)
2076 "Go to previous N'th unread newsgroup.
2077 Returns the difference between N and the number of skips actually
2080 (gnus-group-next-unread-group (- n)))
2082 (defun gnus-group-next-unread-group-same-level (n)
2083 "Go to next N'th unread newsgroup on the same level.
2084 If N is negative, search backward instead.
2085 Returns the difference between N and the number of skips actually
2088 (gnus-group-next-unread-group n t (gnus-group-group-level))
2089 (gnus-group-position-point))
2091 (defun gnus-group-prev-unread-group-same-level (n)
2092 "Go to next N'th unread newsgroup on the same level.
2093 Returns the difference between N and the number of skips actually
2096 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2097 (gnus-group-position-point))
2099 (defun gnus-group-best-unread-group (&optional exclude-group)
2100 "Go to the group with the highest level.
2101 If EXCLUDE-GROUP, do not go to that group."
2103 (goto-char (point-min))
2107 (setq unread (get-text-property (point) 'gnus-unread))
2108 (when (and (numberp unread) (> unread 0))
2109 (when (and (get-text-property (point) 'gnus-level)
2110 (< (get-text-property (point) 'gnus-level) best)
2111 (or (not exclude-group)
2112 (not (equal exclude-group (gnus-group-group-name)))))
2113 (setq best (get-text-property (point) 'gnus-level))
2114 (setq best-point (point))))
2117 (goto-char best-point))
2118 (gnus-group-position-point)
2119 (and best-point (gnus-group-group-name))))
2121 (defun gnus-group-first-unread-group ()
2122 "Go to the first group with unread articles."
2125 (let ((opoint (point))
2127 (goto-char (point-min))
2128 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2129 (and (numberp unread) ; Not a topic.
2130 (not (zerop unread))) ; Has unread articles.
2131 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2134 nil)) ; Not success.
2135 (gnus-group-position-point)))
2137 (defun gnus-group-enter-server-mode ()
2138 "Jump to the server buffer."
2140 (gnus-enter-server-buffer))
2142 (defun gnus-group-make-group (name &optional method address args)
2143 "Add a new newsgroup.
2144 The user will be prompted for a NAME, for a select METHOD, and an
2148 (gnus-read-group "Group name: ")
2149 (gnus-read-method "From method: ")))
2151 (when (stringp method)
2152 (setq method (or (gnus-server-to-method method) method)))
2153 (let* ((meth (gnus-method-simplify
2155 (not (gnus-server-equal method gnus-select-method)))
2156 (if address (list (intern method) address)
2158 (nname (if method (gnus-group-prefixed-name name meth) name))
2160 (when (gnus-gethash nname gnus-newsrc-hashtb)
2161 (error "Group %s already exists" nname))
2162 ;; Subscribe to the new group.
2163 (gnus-group-change-level
2164 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2165 gnus-level-default-subscribed gnus-level-killed
2166 (and (gnus-group-group-name)
2167 (gnus-gethash (gnus-group-group-name)
2168 gnus-newsrc-hashtb))
2171 (gnus-set-active nname (cons 1 0))
2172 (unless (gnus-ephemeral-group-p name)
2174 (concat "(gnus-group-set-info '"
2175 (gnus-prin1-to-string (cdr info)) ")")))
2177 (gnus-group-insert-group-line-info nname)
2179 (gnus-group-position-point)
2181 ;; Load the backend and try to make the backend create
2182 ;; the group as well.
2183 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2185 gnus-valid-select-methods)
2187 (gnus-check-server meth)
2188 (when (gnus-check-backend-function 'request-create-group nname)
2189 (gnus-request-create-group nname nil args))
2192 (defun gnus-group-delete-groups (&optional arg)
2193 "Delete the current group. Only meaningful with editable groups."
2195 (let ((n (length (gnus-group-process-prefix arg))))
2196 (when (gnus-yes-or-no-p
2198 "Delete this 1 group? "
2199 (format "Delete these %d groups? " n)))
2200 (gnus-group-iterate arg
2202 (gnus-group-delete-group group nil t))))))
2204 (defun gnus-group-delete-group (group &optional force no-prompt)
2205 "Delete the current group. Only meaningful with editable groups.
2206 If FORCE (the prefix) is non-nil, all the articles in the group will
2207 be deleted. This is \"deleted\" as in \"removed forever from the face
2208 of the Earth\". There is no undo. The user will be prompted before
2209 doing the deletion."
2211 (list (gnus-group-group-name)
2212 current-prefix-arg))
2214 (error "No group to delete"))
2215 (unless (gnus-check-backend-function 'request-delete-group group)
2216 (error "This backend does not support group deletion"))
2218 (if (and (not no-prompt)
2219 (not (gnus-yes-or-no-p
2221 "Do you really want to delete %s%s? "
2222 group (if force " and all its contents" "")))))
2224 (gnus-message 6 "Deleting group %s..." group)
2225 (if (not (gnus-request-delete-group group force))
2226 (gnus-error 3 "Couldn't delete group %s" group)
2227 (gnus-message 6 "Deleting group %s...done" group)
2228 (gnus-group-goto-group group)
2229 (gnus-group-kill-group 1 t)
2230 (gnus-sethash group nil gnus-active-hashtb)
2231 (when (and (boundp 'gnus-cache-active-hashtb)
2232 gnus-cache-active-hashtb)
2233 (gnus-sethash group nil gnus-cache-active-hashtb)
2234 (setq gnus-cache-active-altered t))
2236 (gnus-group-position-point)))
2238 (defun gnus-group-rename-group (group new-name)
2239 "Rename group from GROUP to NEW-NAME.
2240 When used interactively, GROUP is the group under point
2241 and NEW-NAME will be prompted for."
2244 (gnus-group-group-name)
2246 (unless (gnus-check-backend-function
2247 'request-rename-group (gnus-group-group-name))
2248 (error "This backend does not support renaming groups"))
2249 (gnus-read-group "Rename group to: "
2250 (gnus-group-real-name (gnus-group-group-name))))))
2252 (unless (gnus-check-backend-function 'request-rename-group group)
2253 (error "This backend does not support renaming groups"))
2255 (error "No group to rename"))
2256 (when (equal (gnus-group-real-name group) new-name)
2257 (error "Can't rename to the same name"))
2259 ;; We find the proper prefixed name.
2261 (if (gnus-group-native-p group)
2265 (gnus-group-prefixed-name
2266 (gnus-group-real-name new-name)
2267 (gnus-info-method (gnus-get-info group)))))
2269 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2272 (gnus-group-goto-group group)
2273 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2274 (gnus-request-rename-group group new-name))))
2275 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2276 ;; We rename the group internally by killing it...
2277 (gnus-group-kill-group)
2278 ;; ... changing its name ...
2279 (setcar (cdar gnus-list-of-killed-groups) new-name)
2280 ;; ... and then yanking it. Magic!
2281 (gnus-group-yank-group)
2282 (gnus-set-active new-name (gnus-active group))
2283 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2285 (setq gnus-killed-list (delete group gnus-killed-list))
2286 (gnus-set-active group nil)
2287 (gnus-dribble-touch)
2288 (gnus-group-position-point)))
2290 (defun gnus-group-edit-group (group &optional part)
2291 "Edit the group on the current line."
2292 (interactive (list (gnus-group-group-name)))
2293 (let ((part (or part 'info))
2296 (error "No group on current line"))
2297 (unless (setq info (gnus-get-info group))
2298 (error "Killed group; can't be edited"))
2300 (gnus-close-group group))
2302 ;; Find the proper form to edit.
2303 (cond ((eq part 'method)
2304 (or (gnus-info-method info) "native"))
2306 (gnus-info-params info))
2308 ;; The proper documentation.
2310 "Editing the %s for `%s'."
2312 ((eq part 'method) "select method")
2313 ((eq part 'params) "group parameters")
2315 (gnus-group-decoded-name group))
2317 (gnus-group-edit-group-done ',part ,group form)))
2320 (gnus-create-info-command
2323 "(gnus)Select Methods")
2325 "(gnus)Group Parameters")
2327 "(gnus)Group Info"))))))
2329 (defun gnus-group-edit-group-method (group)
2330 "Edit the select method of GROUP."
2331 (interactive (list (gnus-group-group-name)))
2332 (gnus-group-edit-group group 'method))
2334 (defun gnus-group-edit-group-parameters (group)
2335 "Edit the group parameters of GROUP."
2336 (interactive (list (gnus-group-group-name)))
2337 (gnus-group-edit-group group 'params))
2339 (defun gnus-group-edit-group-done (part group form)
2341 (let* ((method (cond ((eq part 'info) (nth 4 form))
2342 ((eq part 'method) form)
2344 (info (cond ((eq part 'info) form)
2345 ((eq part 'method) (gnus-get-info group))
2348 (if (or (not method)
2350 gnus-select-method method))
2351 (gnus-group-real-name (car info))
2352 (gnus-group-prefixed-name
2353 (gnus-group-real-name (car info)) method))
2355 (when (and new-group
2356 (not (equal new-group group)))
2357 (when (gnus-group-goto-group group)
2358 (gnus-group-kill-group 1))
2359 (gnus-activate-group new-group))
2361 (if (not (and info new-group))
2362 (gnus-group-set-info form (or new-group group) part)
2363 (setq info (gnus-copy-sequence info))
2364 (setcar info new-group)
2365 (unless (gnus-server-equal method "native")
2366 (unless (nthcdr 3 info)
2367 (nconc info (list nil nil)))
2368 (unless (nthcdr 4 info)
2369 (nconc info (list nil)))
2370 (gnus-info-set-method info method))
2371 (gnus-group-set-info info))
2372 (gnus-group-update-group (or new-group group))
2373 (gnus-group-position-point)))
2375 (defun gnus-group-make-useful-group (group method)
2376 "Create one of the groups described in `gnus-useful-groups'."
2378 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2380 gnus-useful-groups)))
2381 (list (cadr entry) (caddr entry))))
2382 (setq method (gnus-copy-sequence method))
2384 (while (setq entry (memq (assq 'eval method) method))
2385 (setcar entry (eval (cadar entry)))))
2386 (gnus-group-make-group group method))
2388 (defun gnus-group-make-help-group (&optional noerror)
2389 "Create the Gnus documentation group.
2390 Optional argument NOERROR modifies the behavior of this function when the
2391 group already exists:
2392 - if not given, and error is signaled,
2393 - if t, stay silent,
2394 - if anything else, just print a message."
2396 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2397 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2398 (if (gnus-gethash name gnus-newsrc-hashtb)
2399 (cond ((eq noerror nil)
2400 (error "Documentation group already exists"))
2405 (gnus-message 1 "Documentation group already exists")))
2408 (gnus-message 1 "Couldn't find doc group")
2409 (gnus-group-make-group
2410 (gnus-group-real-name name)
2411 (list 'nndoc "gnus-help"
2412 (list 'nndoc-address file)
2413 (list 'nndoc-article-type 'mbox))))
2415 (gnus-group-position-point))
2417 (defun gnus-group-make-doc-group (file type)
2418 "Create a group that uses a single file as the source."
2420 (list (read-file-name "File name: ")
2421 (and current-prefix-arg 'ask)))
2422 (when (eq type 'ask)
2427 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2429 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2430 ((= char ?b) 'babyl)
2431 ((= char ?d) 'digest)
2432 ((= char ?f) 'forward)
2434 ((= char ?g) 'guess)
2435 (t (setq err (format "%c unknown. " char))
2438 (let* ((file (expand-file-name file))
2439 (name (gnus-generate-new-group-name
2440 (gnus-group-prefixed-name
2441 (file-name-nondirectory file) '(nndoc "")))))
2442 (gnus-group-make-group
2443 (gnus-group-real-name name)
2445 (list 'nndoc-address file)
2446 (list 'nndoc-article-type (or type 'guess))))))
2448 (defvar nnweb-type-definition)
2449 (defvar gnus-group-web-type-history nil)
2450 (defvar gnus-group-web-search-history nil)
2451 (defun gnus-group-make-web-group (&optional solid)
2452 "Create an ephemeral nnweb group.
2453 If SOLID (the prefix), create a solid group."
2457 (if solid (gnus-read-group "Group name: ")
2458 (message-unique-id)))
2459 (default-type (or (car gnus-group-web-type-history)
2460 (symbol-name (caar nnweb-type-definition))))
2464 (format "Search engine type (default %s): " default-type)
2465 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2466 nnweb-type-definition)
2467 nil t nil 'gnus-group-web-type-history)
2472 (cons (or (car gnus-group-web-search-history) "") 0)
2473 'gnus-group-web-search-history))
2475 `(nnweb ,group (nnweb-search ,search)
2476 (nnweb-type ,(intern type))
2477 (nnweb-ephemeral-p t))))
2479 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2480 (gnus-group-read-ephemeral-group
2482 (cons (current-buffer)
2483 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2485 (defvar nnwarchive-type-definition)
2486 (defvar gnus-group-warchive-type-history nil)
2487 (defvar gnus-group-warchive-login-history nil)
2488 (defvar gnus-group-warchive-address-history nil)
2490 (defun gnus-group-make-warchive-group ()
2491 "Create a nnwarchive group."
2493 (require 'nnwarchive)
2494 (let* ((group (gnus-read-group "Group name: "))
2495 (default-type (or (car gnus-group-warchive-type-history)
2496 (symbol-name (caar nnwarchive-type-definition))))
2500 (format "Warchive type (default %s): " default-type)
2501 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2502 nnwarchive-type-definition)
2503 nil t nil 'gnus-group-warchive-type-history)
2505 (address (read-string "Warchive address: "
2506 nil 'gnus-group-warchive-address-history))
2507 (default-login (or (car gnus-group-warchive-login-history)
2512 (format "Warchive login (default %s): " user-mail-address)
2513 default-login 'gnus-group-warchive-login-history)
2516 `(nnwarchive ,address
2517 (nnwarchive-type ,(intern type))
2518 (nnwarchive-login ,login))))
2519 (gnus-group-make-group group method)))
2521 (defun gnus-group-make-archive-group (&optional all)
2522 "Create the (ding) Gnus archive group of the most recent articles.
2523 Given a prefix, create a full group."
2525 (let ((group (gnus-group-prefixed-name
2526 (if all "ding.archives" "ding.recent") '(nndir ""))))
2527 (when (gnus-gethash group gnus-newsrc-hashtb)
2528 (error "Archive group already exists"))
2529 (gnus-group-make-group
2530 (gnus-group-real-name group)
2531 (list 'nndir (if all "hpc" "edu")
2532 (list 'nndir-directory
2533 (if all gnus-group-archive-directory
2534 gnus-group-recent-archive-directory))))
2535 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2537 (defun gnus-group-make-directory-group (dir)
2538 "Create an nndir group.
2539 The user will be prompted for a directory. The contents of this
2540 directory will be used as a newsgroup. The directory should contain
2541 mail messages or news articles in files that have numeric names."
2543 (list (read-file-name "Create group from directory: ")))
2544 (unless (file-exists-p dir)
2545 (error "No such directory"))
2546 (unless (file-directory-p dir)
2547 (error "Not a directory"))
2551 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2553 (gnus-group-prefixed-name
2554 (expand-file-name ext dir)
2556 (setq ext (format "<%d>" (setq i (1+ i)))))
2557 (gnus-group-make-group
2558 (gnus-group-real-name group)
2559 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2561 (eval-when-compile (defvar nnkiboze-score-file))
2562 (defun gnus-group-make-kiboze-group (group address scores)
2563 "Create an nnkiboze group.
2564 The user will be prompted for a name, a regexp to match groups, and
2565 score file entries for articles to include in the group."
2568 (read-string "nnkiboze group name: ")
2569 (read-string "Source groups (regexp): ")
2570 (let ((headers (mapcar (lambda (group) (list group))
2571 '("subject" "from" "number" "date" "message-id"
2572 "references" "chars" "lines" "xref"
2573 "followup" "all" "body" "head")))
2574 scores header regexp regexps)
2575 (while (not (equal "" (setq header (completing-read
2576 "Match on header: " headers nil t))))
2578 (while (not (equal "" (setq regexp (read-string
2579 (format "Match on %s (regexp): "
2581 (push (list regexp nil nil 'r) regexps))
2582 (push (cons header regexps) scores))
2584 (gnus-group-make-group group "nnkiboze" address)
2585 (let* ((nnkiboze-current-group group)
2586 (score-file (car (nnkiboze-score-file "")))
2587 (score-dir (file-name-directory score-file)))
2588 (unless (file-exists-p score-dir)
2589 (make-directory score-dir))
2590 (with-temp-file score-file
2591 (let (emacs-lisp-mode-hook)
2592 (pp scores (current-buffer))))))
2594 (defun gnus-group-add-to-virtual (n vgroup)
2595 "Add the current group to a virtual group."
2597 (list current-prefix-arg
2598 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2600 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2601 (error "%s is not an nnvirtual group" vgroup))
2602 (gnus-close-group vgroup)
2603 (let* ((groups (gnus-group-process-prefix n))
2604 (method (gnus-info-method (gnus-get-info vgroup))))
2605 (setcar (cdr method)
2607 (nth 1 method) "\\|"
2610 (gnus-group-remove-mark s)
2611 (concat "\\(^" (regexp-quote s) "$\\)"))
2613 (gnus-group-position-point))
2615 (defun gnus-group-make-empty-virtual (group)
2616 "Create a new, fresh, empty virtual group."
2617 (interactive "sCreate new, empty virtual group: ")
2618 (let* ((method (list 'nnvirtual "^$"))
2619 (pgroup (gnus-group-prefixed-name group method)))
2620 ;; Check whether it exists already.
2621 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2622 (error "Group %s already exists" pgroup))
2623 ;; Subscribe the new group after the group on the current line.
2624 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2625 (gnus-group-update-group pgroup)
2627 (gnus-group-position-point)))
2629 (defun gnus-group-enter-directory (dir)
2630 "Enter an ephemeral nneething group."
2631 (interactive "DDirectory to read: ")
2632 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2633 (leaf (gnus-group-prefixed-name
2634 (file-name-nondirectory (directory-file-name dir))
2636 (name (gnus-generate-new-group-name leaf)))
2637 (unless (gnus-group-read-ephemeral-group
2639 (cons (current-buffer)
2640 (if (eq major-mode 'gnus-summary-mode)
2642 (error "Couldn't enter %s" dir))))
2645 (autoload 'nnimap-expunge "nnimap")
2646 (autoload 'nnimap-acl-get "nnimap")
2647 (autoload 'nnimap-acl-edit "nnimap"))
2649 (defun gnus-group-nnimap-expunge (group)
2650 "Expunge deleted articles in current nnimap GROUP."
2651 (interactive (list (gnus-group-group-name)))
2652 (let ((mailbox (gnus-group-real-name group)) method)
2654 (error "No group on current line"))
2655 (unless (gnus-get-info group)
2656 (error "Killed group; can't be edited"))
2657 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2658 (error "%s is not an nnimap group" group))
2659 (nnimap-expunge mailbox (cadr method))))
2661 (defun gnus-group-nnimap-edit-acl (group)
2662 "Edit the Access Control List of current nnimap GROUP."
2663 (interactive (list (gnus-group-group-name)))
2664 (let ((mailbox (gnus-group-real-name group)) method acl)
2666 (error "No group on current line"))
2667 (unless (gnus-get-info group)
2668 (error "Killed group; can't be edited"))
2669 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2670 (error "%s is not an nnimap group" group))
2671 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2672 (error "Server does not support ACL's"))
2673 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2675 An access control list is a list of (identifier . rights) elements.
2677 The identifier string specifies the corresponding user. The
2678 identifier \"anyone\" is reserved to refer to the universal identity.
2680 Rights is a string listing a (possibly empty) set of alphanumeric
2681 characters, each character listing a set of operations which is being
2682 controlled. Letters are reserved for ``standard'' rights, listed
2683 below. Digits are reserved for implementation or site defined rights.
2685 l - lookup (mailbox is visible to LIST/LSUB commands)
2686 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2687 SEARCH, COPY from mailbox)
2688 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2689 w - write (STORE flags other than \\SEEN and \\DELETED)
2690 i - insert (perform APPEND, COPY into mailbox)
2691 p - post (send mail to submission address for mailbox,
2692 not enforced by IMAP4 itself)
2693 c - create and delete mailbox (CREATE new sub-mailboxes in any
2694 implementation-defined hierarchy, RENAME or DELETE mailbox)
2695 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2696 a - administer (perform SETACL)" group)
2699 ,mailbox ',method ',acl form)))))
2701 ;; Group sorting commands
2702 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2704 (defun gnus-group-sort-groups (func &optional reverse)
2705 "Sort the group buffer according to FUNC.
2706 When used interactively, the sorting function used will be
2707 determined by the `gnus-group-sort-function' variable.
2708 If REVERSE (the prefix), reverse the sorting order."
2709 (interactive (list gnus-group-sort-function current-prefix-arg))
2710 (funcall gnus-group-sort-alist-function
2711 (gnus-make-sort-function func) reverse)
2712 (gnus-group-unmark-all-groups)
2713 (gnus-group-list-groups)
2714 (gnus-dribble-touch))
2716 (defun gnus-group-sort-flat (func reverse)
2717 ;; We peel off the dummy group from the alist.
2719 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2720 (pop gnus-newsrc-alist))
2722 (setq gnus-newsrc-alist
2723 (sort gnus-newsrc-alist func))
2725 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2726 ;; Regenerate the hash table.
2727 (gnus-make-hashtable-from-newsrc-alist)))
2729 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2730 "Sort the group buffer alphabetically by group name.
2731 If REVERSE, sort in reverse order."
2733 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2735 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2736 "Sort the group buffer alphabetically by real (unprefixed) group name.
2737 If REVERSE, sort in reverse order."
2739 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2741 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2742 "Sort the group buffer by number of unread articles.
2743 If REVERSE, sort in reverse order."
2745 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2747 (defun gnus-group-sort-groups-by-level (&optional reverse)
2748 "Sort the group buffer by group level.
2749 If REVERSE, sort in reverse order."
2751 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2753 (defun gnus-group-sort-groups-by-score (&optional reverse)
2754 "Sort the group buffer by group score.
2755 If REVERSE, sort in reverse order."
2757 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2759 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2760 "Sort the group buffer by group rank.
2761 If REVERSE, sort in reverse order."
2763 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2765 (defun gnus-group-sort-groups-by-method (&optional reverse)
2766 "Sort the group buffer alphabetically by backend name.
2767 If REVERSE, sort in reverse order."
2769 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2771 (defun gnus-group-sort-groups-by-server (&optional reverse)
2772 "Sort the group buffer alphabetically by server name.
2773 If REVERSE, sort in reverse order."
2775 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2777 ;;; Selected group sorting.
2779 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2780 "Sort the process/prefixed groups."
2781 (interactive (list current-prefix-arg gnus-group-sort-function))
2782 (let ((groups (gnus-group-process-prefix n)))
2783 (funcall gnus-group-sort-selected-function
2784 groups (gnus-make-sort-function func) reverse)
2785 (gnus-group-unmark-all-groups)
2786 (gnus-group-list-groups)
2787 (gnus-dribble-touch)))
2789 (defun gnus-group-sort-selected-flat (groups func reverse)
2790 (let (entries infos)
2791 ;; First find all the group entries for these groups.
2793 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2795 ;; Then sort the infos.
2799 (lambda (entry) (car entry))
2800 (setq entries (nreverse entries)))
2803 (setq infos (nreverse infos)))
2804 ;; Go through all the infos and replace the old entries
2805 ;; with the new infos.
2807 (setcar (car entries) (pop infos))
2809 ;; Update the hashtable.
2810 (gnus-make-hashtable-from-newsrc-alist)))
2812 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2813 "Sort the group buffer alphabetically by group name.
2814 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2815 sort in reverse order."
2816 (interactive (gnus-interactive "P\ny"))
2817 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2819 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2820 "Sort the group buffer alphabetically by real group name.
2821 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2822 sort in reverse order."
2823 (interactive (gnus-interactive "P\ny"))
2824 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2826 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2827 "Sort the group buffer by number of unread articles.
2828 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2829 sort in reverse order."
2830 (interactive (gnus-interactive "P\ny"))
2831 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2833 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2834 "Sort the group buffer by group level.
2835 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2836 sort in reverse order."
2837 (interactive (gnus-interactive "P\ny"))
2838 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2840 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2841 "Sort the group buffer by group score.
2842 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2843 sort in reverse order."
2844 (interactive (gnus-interactive "P\ny"))
2845 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2847 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2848 "Sort the group buffer by group rank.
2849 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2850 sort in reverse order."
2851 (interactive (gnus-interactive "P\ny"))
2852 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2854 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2855 "Sort the group buffer alphabetically by backend name.
2856 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2857 sort in reverse order."
2858 (interactive (gnus-interactive "P\ny"))
2859 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2861 ;;; Sorting predicates.
2863 (defun gnus-group-sort-by-alphabet (info1 info2)
2864 "Sort alphabetically."
2865 (string< (gnus-info-group info1) (gnus-info-group info2)))
2867 (defun gnus-group-sort-by-real-name (info1 info2)
2868 "Sort alphabetically on real (unprefixed) names."
2869 (string< (gnus-group-real-name (gnus-info-group info1))
2870 (gnus-group-real-name (gnus-info-group info2))))
2872 (defun gnus-group-sort-by-unread (info1 info2)
2873 "Sort by number of unread articles."
2874 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2875 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2876 (< (or (and (numberp n1) n1) 0)
2877 (or (and (numberp n2) n2) 0))))
2879 (defun gnus-group-sort-by-level (info1 info2)
2881 (< (gnus-info-level info1) (gnus-info-level info2)))
2883 (defun gnus-group-sort-by-method (info1 info2)
2884 "Sort alphabetically by backend name."
2885 (string< (car (gnus-find-method-for-group
2886 (gnus-info-group info1) info1))
2887 (car (gnus-find-method-for-group
2888 (gnus-info-group info2) info2))))
2890 (defun gnus-group-sort-by-server (info1 info2)
2891 "Sort alphabetically by server name."
2892 (string< (gnus-method-to-full-server-name
2893 (gnus-find-method-for-group
2894 (gnus-info-group info1) info1))
2895 (gnus-method-to-full-server-name
2896 (gnus-find-method-for-group
2897 (gnus-info-group info2) info2))))
2899 (defun gnus-group-sort-by-score (info1 info2)
2900 "Sort by group score."
2901 (> (gnus-info-score info1) (gnus-info-score info2)))
2903 (defun gnus-group-sort-by-rank (info1 info2)
2904 "Sort by level and score."
2905 (let ((level1 (gnus-info-level info1))
2906 (level2 (gnus-info-level info2)))
2907 (or (< level1 level2)
2908 (and (= level1 level2)
2909 (> (gnus-info-score info1) (gnus-info-score info2))))))
2913 (defun gnus-group-clear-data (&optional arg)
2914 "Clear all marks and read ranges from the current group."
2916 (gnus-group-iterate arg
2919 (gnus-info-clear-data (setq info (gnus-get-info group)))
2920 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2921 (when (gnus-group-goto-group group)
2922 (gnus-group-update-group-line))))))
2924 (defun gnus-group-clear-data-on-native-groups ()
2925 "Clear all marks and read ranges from all native groups."
2927 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2928 (let ((alist (cdr gnus-newsrc-alist))
2930 (while (setq info (pop alist))
2931 (when (gnus-group-native-p (gnus-info-group info))
2932 (gnus-info-clear-data info)))
2933 (gnus-get-unread-articles)
2934 (gnus-dribble-touch)
2935 (when (gnus-y-or-n-p
2936 "Move the cache away to avoid problems in the future? ")
2937 (call-interactively 'gnus-cache-move-cache)))))
2939 (defun gnus-info-clear-data (info)
2940 "Clear all marks and read ranges from INFO."
2941 (let ((group (gnus-info-group info))
2943 (dolist (el (gnus-info-marks info))
2944 (push `(,(cdr el) add (,(car el))) action))
2945 (push `(,(gnus-info-read info) add (read)) action)
2948 (gnus-request-set-mark ,group ',action)
2949 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2950 (gnus-info-set-read ',info ',(gnus-info-read info))
2951 (when (gnus-group-goto-group ,group)
2952 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
2953 (gnus-group-update-group-line))))
2954 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
2956 (gnus-request-set-mark group action)
2957 (gnus-info-set-read info nil)
2958 (when (gnus-info-marks info)
2959 (gnus-info-set-marks info nil))))
2961 ;; Group catching up.
2963 (defun gnus-group-catchup-current (&optional n all)
2964 "Mark all unread articles in the current newsgroup as read.
2965 If prefix argument N is numeric, the next N newsgroups will be
2966 caught up. If ALL is non-nil, marked articles will also be marked as
2967 read. Cross references (Xref: header) of articles are ignored.
2968 The number of newsgroups that this function was unable to catch
2971 (let ((groups (gnus-group-process-prefix n))
2974 (unless groups (error "No groups selected"))
2976 (or (not gnus-interactive-catchup) ;Without confirmation?
2981 "Do you really want to mark all articles in %s as read? "
2982 "Mark all unread articles in %s as read? ")
2983 (if (= (length groups) 1)
2985 (format "these %d groups" (length groups)))))))
2987 (while (setq group (pop groups))
2988 (gnus-group-remove-mark group)
2989 ;; Virtual groups have to be given special treatment.
2990 (let ((method (gnus-find-method-for-group group)))
2991 (when (eq 'nnvirtual (car method))
2992 (nnvirtual-catchup-group
2993 (gnus-group-real-name group) (nth 1 method) all)))
2994 (if (>= (gnus-group-level group) gnus-level-zombie)
2995 (gnus-message 2 "Dead groups can't be caught up")
2997 (gnus-group-goto-group group)
2998 (gnus-group-catchup group all))
2999 (gnus-group-update-group-line)
3000 (setq ret (1+ ret)))))
3001 (gnus-group-next-unread-group 1)
3004 (defun gnus-group-catchup-current-all (&optional n)
3005 "Mark all articles in current newsgroup as read.
3006 Cross references (Xref: header) of articles are ignored."
3008 (gnus-group-catchup-current n 'all))
3010 (defun gnus-group-catchup (group &optional all)
3011 "Mark all articles in GROUP as read.
3012 If ALL is non-nil, all articles are marked as read.
3013 The return value is the number of articles that were marked as read,
3014 or nil if no action could be taken."
3015 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3017 (marks (nth 3 (nth 2 entry)))
3018 (unread (gnus-list-of-unread-articles group)))
3019 ;; Remove entries for this group.
3020 (nnmail-purge-split-history (gnus-group-real-name group))
3021 ;; Do the updating only if the newsgroup isn't killed.
3022 (if (not (numberp (car entry)))
3023 (gnus-message 1 "Can't catch up %s; non-active group" group)
3024 (gnus-update-read-articles group nil)
3026 ;; Nix out the lists of marks and dormants.
3027 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3029 (list (cdr (assq 'dormant marks))
3031 (setq unread (gnus-uncompress-range
3032 (gnus-range-add (gnus-range-add
3033 unread (cdr (assq 'dormant marks)))
3034 (cdr (assq 'tick marks)))))
3035 (gnus-add-marked-articles group 'tick nil nil 'force)
3036 (gnus-add-marked-articles group 'dormant nil nil 'force))
3037 ;; Do auto-expirable marks if that's required.
3038 (when (gnus-group-auto-expirable-p group)
3039 (gnus-add-marked-articles group 'expire unread)
3040 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
3041 (let ((gnus-newsgroup-name group))
3042 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3045 (defun gnus-group-expire-articles (&optional n)
3046 "Expire all expirable articles in the current newsgroup.
3047 Uses the process/prefix convention."
3049 (let ((groups (gnus-group-process-prefix n))
3052 (error "No groups to expire"))
3053 (while (setq group (pop groups))
3054 (gnus-group-remove-mark group)
3055 (gnus-group-expire-articles-1 group)
3056 (gnus-dribble-touch)
3057 (gnus-group-position-point))))
3059 (defun gnus-group-expire-articles-1 (group)
3060 (when (gnus-check-backend-function 'request-expire-articles group)
3061 (gnus-message 6 "Expiring articles in %s..." group)
3062 (let* ((info (gnus-get-info group))
3063 (expirable (if (gnus-group-total-expirable-p group)
3064 (cons nil (gnus-list-of-read-articles group))
3065 (assq 'expire (gnus-info-marks info))))
3066 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3067 (nnmail-expiry-target
3068 (or (gnus-group-find-parameter group 'expiry-target)
3069 nnmail-expiry-target)))
3071 (gnus-check-group group)
3074 (gnus-compress-sequence
3076 ;; We set the expiry variables to the group
3078 (let ((nnmail-expiry-wait-function nil)
3079 (nnmail-expiry-wait expiry-wait))
3080 (gnus-request-expire-articles
3081 (gnus-uncompress-sequence (cdr expirable)) group))
3082 ;; Just expire using the normal expiry values.
3083 (gnus-request-expire-articles
3084 (gnus-uncompress-sequence (cdr expirable)) group))))
3085 (gnus-close-group group))
3086 (gnus-message 6 "Expiring articles in %s...done" group)
3087 ;; Return the list of un-expired articles.
3090 (defun gnus-group-expire-all-groups ()
3091 "Expire all expirable articles in all newsgroups."
3094 (gnus-message 5 "Expiring...")
3095 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3096 (cdr gnus-newsrc-alist))))
3097 (gnus-group-expire-articles nil)))
3098 (gnus-group-position-point)
3099 (gnus-message 5 "Expiring...done"))
3101 (defun gnus-group-set-current-level (n level)
3102 "Set the level of the next N groups to LEVEL."
3107 (let ((s (read-string
3108 (format "Level (default %s): "
3109 (or (gnus-group-group-level)
3110 gnus-level-default-subscribed)))))
3111 (if (string-match "^\\s-*$" s)
3112 (int-to-string (or (gnus-group-group-level)
3113 gnus-level-default-subscribed))
3115 (unless (and (>= level 1) (<= level gnus-level-killed))
3116 (error "Invalid level: %d" level))
3117 (let ((groups (gnus-group-process-prefix n))
3119 (while (setq group (pop groups))
3120 (gnus-group-remove-mark group)
3121 (gnus-message 6 "Changed level of %s from %d to %d"
3122 group (or (gnus-group-group-level) gnus-level-killed)
3124 (gnus-group-change-level
3125 group level (or (gnus-group-group-level) gnus-level-killed))
3126 (gnus-group-update-group-line)))
3127 (gnus-group-position-point))
3129 (defun gnus-group-unsubscribe (&optional n)
3130 "Unsubscribe the current group."
3132 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3134 (defun gnus-group-subscribe (&optional n)
3135 "Subscribe the current group."
3137 (gnus-group-unsubscribe-current-group n 'subscribe))
3139 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3140 "Toggle subscription of the current group.
3141 If given numerical prefix, toggle the N next groups."
3143 (let ((groups (gnus-group-process-prefix n))
3146 (setq group (car groups)
3147 groups (cdr groups))
3148 (gnus-group-remove-mark group)
3149 (gnus-group-unsubscribe-group
3152 ((eq do-sub 'unsubscribe)
3153 gnus-level-default-unsubscribed)
3154 ((eq do-sub 'subscribe)
3155 gnus-level-default-subscribed)
3156 ((<= (gnus-group-group-level) gnus-level-subscribed)
3157 gnus-level-default-unsubscribed)
3159 gnus-level-default-subscribed))
3161 (gnus-group-update-group-line))
3162 (gnus-group-next-group 1)))
3164 (defun gnus-group-unsubscribe-group (group &optional level silent)
3165 "Toggle subscription to GROUP.
3166 Killed newsgroups are subscribed. If SILENT, don't try to update the
3169 (list (completing-read
3170 "Group: " gnus-active-hashtb nil
3171 (gnus-read-active-file-p)
3173 'gnus-group-history)))
3174 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3176 ((string-match "^[ \t]*$" group)
3177 (error "Empty group name"))
3179 ;; Toggle subscription flag.
3180 (gnus-group-change-level
3181 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3182 gnus-level-subscribed)
3183 (1+ gnus-level-subscribed)
3184 gnus-level-default-subscribed)))
3186 (gnus-group-update-group group)))
3187 ((and (stringp group)
3188 (or (not (gnus-read-active-file-p))
3189 (gnus-active group)))
3190 ;; Add new newsgroup.
3191 (gnus-group-change-level
3193 (if level level gnus-level-default-subscribed)
3194 (or (and (member group gnus-zombie-list)
3197 (when (gnus-group-group-name)
3198 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3200 (gnus-group-update-group group)))
3201 (t (error "No such newsgroup: %s" group)))
3202 (gnus-group-position-point)))
3204 (defun gnus-group-transpose-groups (n)
3205 "Move the current newsgroup up N places.
3206 If given a negative prefix, move down instead. The difference between
3207 N and the number of steps taken is returned."
3209 (unless (gnus-group-group-name)
3210 (error "No group on current line"))
3211 (gnus-group-kill-group 1)
3213 (forward-line (- n))
3214 (gnus-group-yank-group)
3215 (gnus-group-position-point)))
3217 (defun gnus-group-kill-all-zombies (&optional dummy)
3218 "Kill all zombie newsgroups.
3219 The optional DUMMY should always be nil."
3220 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3222 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3223 (setq gnus-zombie-list nil)
3224 (gnus-dribble-touch)
3225 (gnus-group-list-groups)))
3227 (defun gnus-group-kill-region (begin end)
3228 "Kill newsgroups in current region (excluding current point).
3229 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3244 (beginning-of-line) ;Important when LINES < 1
3245 (gnus-group-kill-group lines)))
3247 (defun gnus-group-kill-group (&optional n discard)
3248 "Kill the next N groups.
3249 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3250 However, only groups that were alive can be yanked; already killed
3251 groups or zombie groups can't be yanked.
3252 The return value is the name of the group that was killed, or a list
3255 (let ((buffer-read-only nil)
3256 (groups (gnus-group-process-prefix n))
3257 group entry level out)
3258 (if (< (length groups) 10)
3259 ;; This is faster when there are few groups.
3261 (push (setq group (pop groups)) out)
3262 (gnus-group-remove-mark group)
3263 (setq level (gnus-group-group-level))
3265 (when (and (not discard)
3266 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3269 (gnus-group-goto-group ,(gnus-group-group-name))
3270 (gnus-group-yank-group)))
3271 (push (cons (car entry) (nth 2 entry))
3272 gnus-list-of-killed-groups))
3273 (gnus-group-change-level
3274 (if entry entry group) gnus-level-killed (if entry nil level))
3275 (message "Killed group %s" group))
3276 ;; If there are lots and lots of groups to be killed, we use
3277 ;; this thing instead.
3279 (setq groups (nreverse groups))
3281 (gnus-group-remove-mark (setq group (pop groups)))
3283 (push group gnus-killed-list)
3284 (setq gnus-newsrc-alist
3285 (delq (assoc group gnus-newsrc-alist)
3287 (when gnus-group-change-level-function
3288 (funcall gnus-group-change-level-function
3289 group gnus-level-killed 3))
3291 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3292 (push (cons (car entry) (nth 2 entry))
3293 gnus-list-of-killed-groups)
3294 (setcdr (cdr entry) (cdddr entry)))
3295 ((member group gnus-zombie-list)
3296 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3297 ;; There may be more than one instance displayed.
3298 (while (gnus-group-goto-group group)
3299 (gnus-delete-line)))
3300 (gnus-make-hashtable-from-newsrc-alist)))
3302 (gnus-group-position-point)
3303 (if (< (length out) 2) (car out) (nreverse out))))
3305 (defun gnus-group-yank-group (&optional arg)
3306 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3307 The numeric ARG specifies how many newsgroups are to be yanked. The
3308 name of the newsgroup yanked is returned, or (if several groups are
3309 yanked) a list of yanked groups is returned."
3311 (setq arg (or arg 1))
3312 (let (info group prev out)
3313 (while (>= (decf arg) 0)
3314 (when (not (setq info (pop gnus-list-of-killed-groups)))
3315 (error "No more newsgroups to yank"))
3316 (push (setq group (nth 1 info)) out)
3317 ;; Find which newsgroup to insert this one before - search
3318 ;; backward until something suitable is found. If there are no
3319 ;; other newsgroups in this buffer, just make this newsgroup the
3321 (setq prev (gnus-group-group-name))
3322 (gnus-group-change-level
3323 info (gnus-info-level (cdr info)) gnus-level-killed
3324 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3326 (gnus-group-insert-group-line-info group)
3328 `(when (gnus-group-goto-group ,group)
3329 (gnus-group-kill-group 1))))
3331 (gnus-group-position-point)
3332 (if (< (length out) 2) (car out) (nreverse out))))
3334 (defun gnus-group-kill-level (level)
3335 "Kill all groups that is on a certain LEVEL."
3336 (interactive "nKill all groups on level: ")
3338 ((= level gnus-level-zombie)
3339 (setq gnus-killed-list
3340 (nconc gnus-zombie-list gnus-killed-list))
3341 (setq gnus-zombie-list nil))
3342 ((and (< level gnus-level-zombie)
3344 (or gnus-expert-user
3347 "Do you really want to kill all groups on level %d? "
3349 (let* ((prev gnus-newsrc-alist)
3352 (if (= (gnus-info-level (car alist)) level)
3354 (push (gnus-info-group (car alist)) gnus-killed-list)
3355 (setcdr prev (cdr alist)))
3357 (setq alist (cdr alist)))
3358 (gnus-make-hashtable-from-newsrc-alist)
3359 (gnus-group-list-groups)))
3361 (error "Can't kill; invalid level: %d" level))))
3363 (defun gnus-group-list-all-groups (&optional arg)
3364 "List all newsgroups with level ARG or lower.
3365 Default is gnus-level-unsubscribed, which lists all subscribed and most
3366 unsubscribed groups."
3368 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3370 ;; Redefine this to list ALL killed groups if prefix arg used.
3371 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3372 (defun gnus-group-list-killed (&optional arg)
3373 "List all killed newsgroups in the group buffer.
3374 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3375 entail asking the server for the groups."
3377 ;; Find all possible killed newsgroups if arg.
3379 (gnus-get-killed-groups))
3380 (if (not gnus-killed-list)
3381 (gnus-message 6 "No killed groups")
3382 (let (gnus-group-list-mode)
3383 (funcall gnus-group-prepare-function
3384 gnus-level-killed t gnus-level-killed))
3385 (goto-char (point-min)))
3386 (gnus-group-position-point))
3388 (defun gnus-group-list-zombies ()
3389 "List all zombie newsgroups in the group buffer."
3391 (if (not gnus-zombie-list)
3392 (gnus-message 6 "No zombie groups")
3393 (let (gnus-group-list-mode)
3394 (funcall gnus-group-prepare-function
3395 gnus-level-zombie t gnus-level-zombie))
3396 (goto-char (point-min)))
3397 (gnus-group-position-point))
3399 (defun gnus-group-list-active ()
3400 "List all groups that are available from the server(s)."
3402 ;; First we make sure that we have really read the active file.
3403 (unless (gnus-read-active-file-p)
3404 (let ((gnus-read-active-file t)
3405 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3406 (gnus-read-active-file)))
3407 ;; Find all groups and sort them.
3415 (push (symbol-name sym) list)))
3419 (buffer-read-only nil)
3423 (setq group (pop groups))
3424 (gnus-add-text-properties
3425 (point) (prog1 (1+ (point))
3427 (gnus-group-decoded-name group)
3429 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3431 'gnus-level (inline (gnus-group-level group)))))
3432 (goto-char (point-min))))
3434 (defun gnus-activate-all-groups (level)
3435 "Activate absolutely all groups."
3436 (interactive (list gnus-level-unsubscribed))
3437 (let ((gnus-activate-level level)
3438 (gnus-activate-foreign-newsgroups level))
3439 (gnus-group-get-new-news)))
3441 (defun gnus-group-get-new-news (&optional arg)
3442 "Get newly arrived articles.
3443 If ARG is a number, it specifies which levels you are interested in
3444 re-scanning. If ARG is non-nil and not a number, this will force
3445 \"hard\" re-reading of the active files from all servers."
3448 (let ((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)
3454 ;; Read any slave files.
3456 (gnus-master-read-slave-newsrc))
3458 ;; We might read in new NoCeM messages here.
3459 (when (and gnus-use-nocem
3461 (gnus-nocem-scan-groups))
3462 ;; If ARG is not a number, then we read the active file.
3463 (when (and arg (not (numberp arg)))
3464 (let ((gnus-read-active-file t))
3465 (gnus-read-active-file))
3468 ;; If the user wants it, we scan for new groups.
3469 (when (eq gnus-check-new-newsgroups 'always)
3470 (gnus-find-new-newsgroups)))
3472 (setq arg (gnus-group-default-level arg t))
3473 (if (and gnus-read-active-file (not arg))
3475 (gnus-read-active-file)
3476 (gnus-get-unread-articles arg))
3477 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3478 (gnus-get-unread-articles arg)))
3479 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3480 (gnus-group-list-groups (and (numberp arg)
3481 (max (car gnus-group-list-mode) arg)))))
3483 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3484 "Check for newly arrived news in the current group (and the N-1 next groups).
3485 The difference between N and the number of newsgroup checked is returned.
3486 If N is negative, this group and the N-1 previous groups will be checked."
3488 (let* ((groups (gnus-group-process-prefix n))
3489 (ret (if (numberp n) (- n (length groups)) 0))
3493 (gnus-inhibit-demon t)
3494 ;; Binding this variable will inhibit multiple fetchings
3495 ;; of the same mail source.
3496 (nnmail-fetched-sources (list t)))
3497 (gnus-run-hooks 'gnus-get-new-news-hook)
3498 (while (setq group (pop groups))
3499 (gnus-group-remove-mark group)
3500 ;; Bypass any previous denials from the server.
3501 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3502 (if (gnus-activate-group group (if dont-scan nil 'scan))
3504 (gnus-get-unread-articles-in-group
3505 (gnus-get-info group) (gnus-active group) t)
3506 (unless (gnus-virtual-group-p group)
3507 (gnus-close-group group))
3509 (gnus-agent-save-group-info
3510 method (gnus-group-real-name group) (gnus-active group)))
3511 (gnus-group-update-group group))
3512 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3514 (gnus-error 3 "Server denied access")
3515 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3518 (when gnus-goto-next-group-when-activating
3519 (gnus-group-next-unread-group 1 t))
3520 (gnus-summary-position-point)
3523 (defun gnus-group-fetch-faq (group &optional faq-dir)
3524 "Fetch the FAQ for the current group.
3525 If given a prefix argument, prompt for the FAQ dir
3529 (gnus-group-group-name)
3530 (when current-prefix-arg
3532 "FAQ dir: " (and (listp gnus-group-faq-directory)
3534 gnus-group-faq-directory))))))
3536 (error "No group name given"))
3537 (let ((dirs (or faq-dir gnus-group-faq-directory))
3539 (unless (listp dirs)
3540 (setq dirs (list dirs)))
3541 (while (and (not found)
3542 (setq dir (pop dirs)))
3543 (let ((name (gnus-group-real-name group)))
3544 (setq file (expand-file-name name dir)))
3545 (if (not (file-exists-p file))
3546 (gnus-message 1 "No such file: %s" file)
3547 (let ((enable-local-variables nil))
3551 (defun gnus-group-fetch-charter (group)
3552 "Fetch the charter for the current group.
3553 If given a prefix argument, prompt for a group."
3555 (list (or (when current-prefix-arg
3556 (completing-read "Group: " gnus-active-hashtb))
3557 (gnus-group-group-name)
3558 gnus-newsgroup-name)))
3560 (error "No group name given"))
3562 (condition-case nil (require 'url-http) (error nil))
3563 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3565 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3566 (setq hierarchy (match-string 1 name))
3567 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3568 (if (fboundp 'url-http-file-exists-p)
3569 (url-http-file-exists-p (eval url))
3571 (browse-url (eval url))
3572 (setq url (concat "http://" hierarchy
3573 ".news-admin.org/charters/" name))
3574 (if (and (fboundp 'url-http-file-exists-p)
3575 (url-http-file-exists-p url))
3577 (gnus-group-fetch-control group))))))
3579 (defun gnus-group-fetch-control (group)
3580 "Fetch the archived control messages for the current group.
3581 If given a prefix argument, prompt for a group."
3583 (list (or (when current-prefix-arg
3584 (completing-read "Group: " gnus-active-hashtb))
3585 (gnus-group-group-name)
3586 gnus-newsgroup-name)))
3588 (error "No group name given"))
3589 (let ((name (gnus-group-real-name group))
3591 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3592 (setq hierarchy (match-string 1 name))
3593 (if gnus-group-fetch-control-use-browse-url
3594 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3595 hierarchy "/" name ".Z"))
3596 (let ((enable-local-variables nil))
3597 (gnus-group-read-ephemeral-group
3599 `(nndoc ,group (nndoc-address
3600 ,(find-file-noselect
3601 (concat "/ftp@ftp.isc.org:/usenet/control/"
3602 hierarchy "/" name ".Z")))
3603 (nndoc-article-type mbox)) t nil nil))))))
3605 (defun gnus-group-describe-group (force &optional group)
3606 "Display a description of the current newsgroup."
3607 (interactive (list current-prefix-arg (gnus-group-group-name)))
3608 (let* ((method (gnus-find-method-for-group group))
3609 (mname (gnus-group-prefixed-name "" method))
3612 gnus-description-hashtb)
3613 (gnus-sethash mname nil gnus-description-hashtb))
3615 (error "No group name given"))
3616 (when (or (and gnus-description-hashtb
3617 ;; We check whether this group's method has been
3618 ;; queried for a description file.
3619 (gnus-gethash mname gnus-description-hashtb))
3620 (setq desc (gnus-group-get-description group))
3621 (gnus-read-descriptions-file method))
3623 (or desc (gnus-gethash group gnus-description-hashtb)
3624 "No description available")))))
3626 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3627 (defun gnus-group-describe-all-groups (&optional force)
3628 "Pop up a buffer with descriptions of all newsgroups."
3631 (setq gnus-description-hashtb nil))
3632 (when (not (or gnus-description-hashtb
3633 (gnus-read-all-descriptions-files)))
3634 (error "Couldn't request descriptions file"))
3635 (let ((buffer-read-only nil)
3641 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3642 (insert (format " *: %-20s %s\n"
3643 (gnus-group-name-decode
3644 (symbol-name group) charset)
3645 (gnus-group-name-decode
3646 (symbol-value group) charset))))
3647 (gnus-add-text-properties
3648 b (1+ b) (list 'gnus-group group
3649 'gnus-unread t 'gnus-marked nil
3650 'gnus-level (1+ gnus-level-subscribed))))
3651 gnus-description-hashtb)
3652 (goto-char (point-min))
3653 (gnus-group-position-point)))
3655 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3656 (defun gnus-group-apropos (regexp &optional search-description)
3657 "List all newsgroups that have names that match a regexp."
3658 (interactive "sGnus apropos (regexp): ")
3660 (obuf (current-buffer))
3662 ;; Go through all newsgroups that are known to Gnus.
3665 (and (symbol-name group)
3666 (string-match regexp (symbol-name group))
3667 (symbol-value group)
3668 (push (symbol-name group) groups)))
3670 ;; Also go through all descriptions that are known to Gnus.
3671 (when search-description
3674 (and (string-match regexp (symbol-value group))
3675 (push (symbol-name group) groups)))
3676 gnus-description-hashtb))
3678 (gnus-message 3 "No groups matched \"%s\"." regexp)
3679 ;; Print out all the groups.
3681 (pop-to-buffer "*Gnus Help*")
3682 (buffer-disable-undo)
3684 (setq groups (sort groups 'string<))
3686 ;; Groups may be entered twice into the list of groups.
3687 (when (not (string= (car groups) prev))
3688 (setq prev (car groups))
3689 (let ((charset (gnus-group-name-charset nil prev)))
3690 (insert (gnus-group-name-decode prev charset) "\n")
3691 (when (and gnus-description-hashtb
3692 (setq des (gnus-gethash (car groups)
3693 gnus-description-hashtb)))
3694 (insert " " (gnus-group-name-decode des charset) "\n"))))
3695 (setq groups (cdr groups)))
3696 (goto-char (point-min))))
3697 (pop-to-buffer obuf)))
3699 (defun gnus-group-description-apropos (regexp)
3700 "List all newsgroups that have names or descriptions that match a regexp."
3701 (interactive "sGnus description apropos (regexp): ")
3702 (when (not (or gnus-description-hashtb
3703 (gnus-read-all-descriptions-files)))
3704 (error "Couldn't request descriptions file"))
3705 (gnus-group-apropos regexp t))
3707 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3708 (defun gnus-group-list-matching (level regexp &optional all lowest)
3709 "List all groups with unread articles that match REGEXP.
3710 If the prefix LEVEL is non-nil, it should be a number that says which
3711 level to cut off listing groups.
3712 If ALL, also list groups with no unread articles.
3713 If LOWEST, don't list groups with level lower than LOWEST.
3715 This command may read the active file."
3716 (interactive "P\nsList newsgroups matching: ")
3717 ;; First make sure active file has been read.
3719 (> (prefix-numeric-value level) gnus-level-killed))
3720 (gnus-get-killed-groups))
3721 (funcall gnus-group-prepare-function
3722 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3723 (goto-char (point-min))
3724 (gnus-group-position-point))
3726 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3727 "List all groups that match REGEXP.
3728 If the prefix LEVEL is non-nil, it should be a number that says which
3729 level to cut off listing groups.
3730 If LOWEST, don't list groups with level lower than LOWEST."
3731 (interactive "P\nsList newsgroups matching: ")
3733 (setq level (prefix-numeric-value level)))
3734 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3736 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3737 (defun gnus-group-save-newsrc (&optional force)
3738 "Save the Gnus startup files.
3739 If FORCE, force saving whether it is necessary or not."
3741 (gnus-save-newsrc-file force))
3743 (defun gnus-group-restart (&optional arg)
3744 "Force Gnus to read the .newsrc file."
3746 (when (gnus-yes-or-no-p
3747 (format "Are you sure you want to restart Gnus? "))
3748 (gnus-save-newsrc-file)
3752 (defun gnus-group-read-init-file ()
3753 "Read the Gnus elisp init file."
3755 (gnus-read-init-file)
3756 (gnus-message 5 "Read %s" gnus-init-file))
3758 (defun gnus-group-check-bogus-groups (&optional silent)
3759 "Check bogus newsgroups.
3760 If given a prefix, don't ask for confirmation before removing a bogus
3763 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3764 (gnus-group-list-groups))
3766 (defun gnus-group-find-new-groups (&optional arg)
3767 "Search for new groups and add them.
3768 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3769 With 1 C-u, use the `ask-server' method to query the server for new
3771 With 2 C-u's, use most complete method possible to query the server
3772 for new groups, and subscribe the new groups as zombies."
3774 (gnus-find-new-newsgroups (or arg 1))
3775 (gnus-group-list-groups))
3777 (defun gnus-group-edit-global-kill (&optional article group)
3778 "Edit the global kill file.
3779 If GROUP, edit that local kill file instead."
3781 (setq gnus-current-kill-article article)
3782 (gnus-kill-file-edit-file group)
3785 (substitute-command-keys
3786 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3787 (if group "local" "global")))))
3789 (defun gnus-group-edit-local-kill (article group)
3790 "Edit a local kill file."
3791 (interactive (list nil (gnus-group-group-name)))
3792 (gnus-group-edit-global-kill article group))
3794 (defun gnus-group-force-update ()
3795 "Update `.newsrc' file."
3797 (gnus-save-newsrc-file))
3799 (defun gnus-group-suspend ()
3800 "Suspend the current Gnus session.
3801 In fact, cleanup buffers except for group mode buffer.
3802 The hook gnus-suspend-gnus-hook is called before actually suspending."
3804 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3805 (gnus-offer-save-summaries)
3806 ;; Kill Gnus buffers except for group mode buffer.
3807 (let ((group-buf (get-buffer gnus-group-buffer)))
3808 (mapcar (lambda (buf)
3809 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3813 (eq major-mode 'message-mode))))
3814 (gnus-kill-buffer buf)))
3816 (gnus-kill-gnus-frames)
3818 (bury-buffer group-buf)
3819 (delete-windows-on group-buf t))))
3821 (defun gnus-group-clear-dribble ()
3822 "Clear all information from the dribble buffer."
3824 (gnus-dribble-clear)
3825 (gnus-message 7 "Cleared dribble buffer"))
3827 (defun gnus-group-exit ()
3828 "Quit reading news after updating .newsrc.eld and .newsrc.
3829 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3832 (or noninteractive ;For gnus-batch-kill
3833 (not gnus-interactive-exit) ;Without confirmation
3835 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3836 (gnus-run-hooks 'gnus-exit-gnus-hook)
3837 ;; Offer to save data from non-quitted summary buffers.
3838 (gnus-offer-save-summaries)
3839 ;; Save the newsrc file(s).
3840 (gnus-save-newsrc-file)
3842 (gnus-close-backends)
3843 ;; Reset everything.
3845 ;; Allow the user to do things after cleaning up.
3846 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3848 (defun gnus-group-quit ()
3849 "Quit reading news without updating .newsrc.eld or .newsrc.
3850 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3852 (when (or noninteractive ;For gnus-batch-kill
3853 (zerop (buffer-size))
3854 (not (gnus-server-opened gnus-select-method))
3856 (not gnus-current-startup-file)
3858 (format "Quit reading news without saving %s? "
3859 (file-name-nondirectory gnus-current-startup-file))))
3860 (gnus-run-hooks 'gnus-exit-gnus-hook)
3861 (gnus-configure-windows 'group t)
3862 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3863 (not (zerop (save-excursion
3864 (set-buffer gnus-dribble-buffer)
3867 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3869 (gnus-close-backends)
3871 (gnus-kill-buffer gnus-group-buffer)
3872 ;; Allow the user to do things after cleaning up.
3873 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3875 (defun gnus-group-describe-briefly ()
3876 "Give a one line description of the group mode commands."
3878 (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")))
3880 (defun gnus-group-browse-foreign-server (method)
3881 "Browse a foreign news server.
3882 If called interactively, this function will ask for a select method
3883 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3884 If not, METHOD should be a list where the first element is the method
3885 and the second element is the address."
3887 (list (let ((how (completing-read
3889 (append gnus-valid-select-methods gnus-server-alist)
3890 nil t (cons "nntp" 0) 'gnus-method-history)))
3891 ;; We either got a backend name or a virtual server name.
3892 ;; If the first, we also need an address.
3893 (if (assoc how gnus-valid-select-methods)
3895 ;; Suggested by mapjph@bath.ac.uk.
3898 (mapcar (lambda (server) (list server))
3899 gnus-secondary-servers)))
3900 ;; We got a server name.
3902 (gnus-browse-foreign-server method))
3904 (defun gnus-group-set-info (info &optional method-only-group part)
3905 (when (or info part)
3906 (let* ((entry (gnus-gethash
3907 (or method-only-group (gnus-info-group info))
3908 gnus-newsrc-hashtb))
3910 (info (if method-only-group (nth 2 entry) info))
3912 (when method-only-group
3914 (error "Trying to change non-existent group %s" method-only-group))
3915 ;; We have received parts of the actual group info - either the
3916 ;; select method or the group parameters. We first check
3917 ;; whether we have to extend the info, and if so, do that.
3918 (let ((len (length info))
3919 (total (if (eq part 'method) 5 6)))
3921 (setcdr (nthcdr (1- len) info)
3922 (make-list (- total len) nil)))
3923 ;; Then we enter the new info.
3924 (setcar (nthcdr (1- total) info) part-info)))
3926 ;; This is a new group, so we just create it.
3928 (set-buffer gnus-group-buffer)
3929 (setq method (gnus-info-method info))
3930 (when (gnus-server-equal method "native")
3933 (set-buffer gnus-group-buffer)
3935 ;; It's a foreign group...
3936 (gnus-group-make-group
3937 (gnus-group-real-name (gnus-info-group info))
3938 (if (stringp method) method
3939 (prin1-to-string (car method)))
3941 (nth 1 (gnus-info-method info))))
3942 ;; It's a native group.
3943 (gnus-group-make-group (gnus-info-group info))))
3944 (gnus-message 6 "Note: New group created")
3946 (gnus-gethash (gnus-group-prefixed-name
3947 (gnus-group-real-name (gnus-info-group info))
3948 (or (gnus-info-method info) gnus-select-method))
3949 gnus-newsrc-hashtb))))
3950 ;; Whether it was a new group or not, we now have the entry, so we
3951 ;; can do the update.
3954 (setcar (nthcdr 2 entry) info)
3955 (when (and (not (eq (car entry) t))
3956 (gnus-active (gnus-info-group info)))
3957 (setcar entry (length
3958 (gnus-list-of-unread-articles (car info))))))
3959 (error "No such group: %s" (gnus-info-group info))))))
3961 (defun gnus-group-set-method-info (group select-method)
3962 (gnus-group-set-info select-method group 'method))
3964 (defun gnus-group-set-params-info (group params)
3965 (gnus-group-set-info params group 'params))
3967 (defun gnus-add-marked-articles (group type articles &optional info force)
3968 ;; Add ARTICLES of TYPE to the info of GROUP.
3969 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3970 ;; add, but replace marked articles of TYPE with ARTICLES.
3971 (let ((info (or info (gnus-get-info group)))
3974 (and (not (setq marked (nthcdr 3 info)))
3976 (setcdr (nthcdr 2 info)
3977 (list (list (cons type (gnus-compress-sequence
3979 (and (not (setq m (assq type (car marked))))
3982 (cons (cons type (gnus-compress-sequence articles t) )
3986 (setcar (nthcdr 3 info)
3987 (gnus-delete-alist type (car marked)))
3988 (setcdr m (gnus-compress-sequence articles t)))
3989 (setcdr m (gnus-compress-sequence
3990 (sort (nconc (gnus-uncompress-range (cdr m))
3991 (copy-sequence articles)) '<) t))))))
3993 (defun gnus-add-mark (group mark article)
3994 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
3995 (let ((buffer (gnus-summary-buffer-name group)))
3996 (if (gnus-buffer-live-p buffer)
3998 (set-buffer (get-buffer buffer))
3999 (gnus-summary-add-mark article mark))
4000 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4004 ;;; Group timestamps
4007 (defun gnus-group-set-timestamp ()
4008 "Change the timestamp of the current group to the current time.
4009 This function can be used in hooks like `gnus-select-group-hook'
4010 or `gnus-group-catchup-group-hook'."
4011 (when gnus-newsgroup-name
4012 (let ((time (current-time)))
4013 (setcdr (cdr time) nil)
4014 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4016 (defsubst gnus-group-timestamp (group)
4017 "Return the timestamp for GROUP."
4018 (gnus-group-get-parameter group 'timestamp t))
4020 (defun gnus-group-timestamp-delta (group)
4021 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4022 (let* ((time (or (gnus-group-timestamp group)
4024 (delta (subtract-time (current-time) time)))
4025 (+ (* (nth 0 delta) 65536.0)
4028 (defun gnus-group-timestamp-string (group)
4029 "Return a string of the timestamp for GROUP."
4030 (let ((time (gnus-group-timestamp group)))
4033 (gnus-time-iso8601 time))))
4035 (defun gnus-group-list-cached (level &optional lowest)
4036 "List all groups with cached articles.
4037 If the prefix LEVEL is non-nil, it should be a number that says which
4038 level to cut off listing groups.
4039 If LOWEST, don't list groups with level lower than LOWEST.
4041 This command may read the active file."
4044 (setq level (prefix-numeric-value level)))
4045 (when (or (not level) (>= level gnus-level-zombie))
4047 (funcall gnus-group-prepare-function
4048 (or level gnus-level-subscribed)
4050 (let ((marks (gnus-info-marks info)))
4051 (assq 'cache marks)))
4054 (or (gnus-gethash group
4055 gnus-cache-active-hashtb)
4056 ;; Cache active file might use "."
4059 (mapconcat 'identity
4060 (split-string group ":")
4062 gnus-cache-active-hashtb))))
4063 (goto-char (point-min))
4064 (gnus-group-position-point))
4066 (defun gnus-group-list-dormant (level &optional lowest)
4067 "List all groups with dormant articles.
4068 If the prefix LEVEL is non-nil, it should be a number that says which
4069 level to cut off listing groups.
4070 If LOWEST, don't list groups with level lower than LOWEST.
4072 This command may read the active file."
4075 (setq level (prefix-numeric-value level)))
4076 (when (or (not level) (>= level gnus-level-zombie))
4078 (funcall gnus-group-prepare-function
4079 (or level gnus-level-subscribed)
4081 (let ((marks (gnus-info-marks info)))
4082 (assq 'dormant marks)))
4085 (goto-char (point-min))
4086 (gnus-group-position-point))
4088 (defun gnus-group-listed-groups ()
4089 "Return a list of listed groups."
4091 (goto-char (point-min))
4092 (while (setq point (text-property-not-all (point) (point-max)
4095 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4099 (defun gnus-group-list-plus (&optional args)
4100 "List groups plus the current selection."
4102 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4103 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4105 (push last-command-event unread-command-events)
4106 (if (featurep 'xemacs)
4107 (push (make-event 'key-press '(key ?A)) unread-command-events)
4108 (push ?A unread-command-events))
4109 (let (gnus-pick-mode keys)
4110 (setq keys (if (featurep 'xemacs)
4111 (events-to-keys (read-key-sequence nil))
4112 (read-key-sequence nil)))
4113 (setq func (lookup-key (current-local-map) keys)))
4117 (call-interactively func))))
4119 (defun gnus-group-list-flush (&optional args)
4120 "Flush groups from the current selection."
4122 (let ((gnus-group-list-option 'flush))
4123 (gnus-group-list-plus args)))
4125 (defun gnus-group-list-limit (&optional args)
4126 "List groups limited within the current selection."
4128 (let ((gnus-group-list-option 'limit))
4129 (gnus-group-list-plus args)))
4131 (defun gnus-group-mark-article-read (group article)
4132 "Mark ARTICLE read."
4133 (let ((buffer (gnus-summary-buffer-name group))
4134 (mark gnus-read-mark)
4136 (if (get-buffer buffer)
4137 (with-current-buffer buffer
4138 (setq active gnus-newsgroup-active)
4139 (gnus-activate-group group)
4140 (when gnus-newsgroup-prepared
4141 (when (and gnus-newsgroup-auto-expire
4142 (memq mark gnus-auto-expirable-marks))
4143 (setq mark gnus-expirable-mark))
4144 (setq mark (gnus-request-update-mark
4145 group article mark))
4146 (gnus-mark-article-as-read article mark)
4147 (setq gnus-newsgroup-active (gnus-active group))
4149 (setq n (1+ (cdr active)))
4150 (while (<= n (cdr gnus-newsgroup-active))
4151 (unless (eq n article)
4152 (push n gnus-newsgroup-unselected))
4154 (setq gnus-newsgroup-unselected
4155 (nreverse gnus-newsgroup-unselected)))))
4156 (gnus-activate-group group)
4157 (gnus-group-make-articles-read group (list article))
4158 (when (gnus-group-auto-expirable-p group)
4159 (gnus-add-marked-articles
4160 group 'expire (list article))))))
4162 (provide 'gnus-group)
4164 ;;; gnus-group.el ends here