1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
42 (eval-when-compile (require 'mm-url))
44 (defcustom gnus-group-archive-directory
45 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
46 "*The address of the (ding) archives."
47 :group 'gnus-group-foreign
50 (defcustom gnus-group-recent-archive-directory
51 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
52 "*The address of the most recent (ding) articles."
53 :group 'gnus-group-foreign
56 (defcustom gnus-no-groups-message "No gnus is bad news"
57 "*Message displayed by Gnus when no groups are available."
61 (defcustom gnus-keep-same-level nil
62 "*Non-nil means that the next newsgroup after the current will be on the same level.
63 When you type, for instance, `n' after reading the last article in the
64 current newsgroup, you will go to the next newsgroup. If this variable
65 is nil, the next newsgroup will be the next from the group
67 If this variable is non-nil, Gnus will either put you in the
68 next newsgroup with the same level, or, if no such newsgroup is
69 available, the next newsgroup with the lowest possible level higher
70 than the current level.
71 If this variable is `best', Gnus will make the next newsgroup the one
73 :group 'gnus-group-levels
74 :type '(choice (const nil)
76 (sexp :tag "other" t)))
78 (defcustom gnus-group-goto-unread t
79 "*If non-nil, movement commands will go to the next unread and subscribed group."
80 :link '(custom-manual "(gnus)Group Maneuvering")
81 :group 'gnus-group-various
84 (defcustom gnus-goto-next-group-when-activating t
85 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
86 :link '(custom-manual "(gnus)Scanning New Messages")
87 :group 'gnus-group-various
90 (defcustom gnus-permanently-visible-groups nil
91 "*Regexp to match groups that should always be listed in the group buffer.
92 This means that they will still be listed even when there are no
93 unread articles in the groups.
95 If nil, no groups are permanently visible."
96 :group 'gnus-group-listing
97 :type '(choice regexp (const nil)))
99 (defcustom gnus-list-groups-with-ticked-articles t
100 "*If non-nil, list groups that have only ticked articles.
101 If nil, only list groups that have unread articles."
102 :group 'gnus-group-listing
105 (defcustom gnus-group-default-list-level gnus-level-subscribed
106 "*Default listing level.
107 Ignored if `gnus-group-use-permanent-levels' is non-nil."
108 :group 'gnus-group-listing
111 (defcustom gnus-group-list-inactive-groups t
112 "*If non-nil, inactive groups will be listed."
113 :group 'gnus-group-listing
114 :group 'gnus-group-levels
117 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
118 "*Function used for sorting the group buffer.
119 This function will be called with group info entries as the arguments
120 for the groups to be sorted. Pre-made functions include
121 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
122 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
123 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
124 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
126 This variable can also be a list of sorting functions. In that case,
127 the most significant sort function should be the last function in the
129 :group 'gnus-group-listing
130 :link '(custom-manual "(gnus)Sorting Groups")
131 :type '(repeat :value-to-internal (lambda (widget value)
132 (if (listp value) value (list value)))
133 :match (lambda (widget value)
135 (widget-editable-list-match widget value)))
136 (choice (function-item gnus-group-sort-by-alphabet)
137 (function-item gnus-group-sort-by-real-name)
138 (function-item gnus-group-sort-by-unread)
139 (function-item gnus-group-sort-by-level)
140 (function-item gnus-group-sort-by-score)
141 (function-item gnus-group-sort-by-method)
142 (function-item gnus-group-sort-by-server)
143 (function-item gnus-group-sort-by-rank)
144 (function :tag "other" nil))))
146 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l %O\n"
147 "*Format of group lines.
148 It works along the same lines as a normal formatting string,
149 with some simple extensions.
151 %M Only marked articles (character, \"*\" or \" \")
152 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
153 %L Level of subscribedness (integer)
154 %N Number of unread articles (integer)
155 %I Number of dormant articles (integer)
156 %i Number of ticked and dormant (integer)
157 %T Number of ticked articles (integer)
158 %R Number of read articles (integer)
159 %t Estimated total number of articles (integer)
160 %y Number of unread, unticked articles (integer)
161 %G Group name (string)
162 %g Qualified group name (string)
163 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
164 %C Group comment (string)
165 %D Group description (string)
166 %s Select method (string)
167 %o Moderated group (char, \"m\")
168 %p Process mark (char)
169 %O Moderated group (string, \"(m)\" or \"\")
170 %P Topic indentation (string)
171 %m Whether there is new(ish) mail in the group (char, \"%\")
172 %l Whether there are GroupLens predictions for this group (string)
173 %n Select from where (string)
174 %z A string that look like `<%s:%n>' if a foreign select method is used
175 %d The date the group was last entered.
176 %E Icon as defined by `gnus-group-icon-list'.
177 %u User defined specifier. The next character in the format string should
178 be a letter. Gnus will call the function gnus-user-format-function-X,
179 where X is the letter following %u. The function will be passed a
180 single dummy parameter as argument.. The function should return a
181 string, which will be inserted into the buffer just like information
182 from any other group specifier.
184 Note that this format specification is not always respected. For
185 reasons of efficiency, when listing killed groups, this specification
186 is ignored altogether. If the spec is changed considerably, your
187 output may end up looking strange when listing both alive and killed
190 If you use %o or %O, reading the active file will be slower and quite
191 a bit of extra memory will be used. %D will also worsen performance.
192 Also note that if you change the format specification to include any
193 of these specs, you must probably re-start Gnus to see them go into
196 General format specifiers can also be used.
197 See Info node `(gnus)Formatting Variables'."
198 :link '(custom-manual "(gnus)Formatting Variables")
199 :group 'gnus-group-visual
202 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
203 "*The format specification for the group mode line.
204 It works along the same lines as a normal formatting string,
205 with some simple extensions:
207 %S The native news server.
208 %M The native select method.
209 %: \":\" if %S isn't \"\"."
210 :group 'gnus-group-visual
213 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
214 (when (featurep 'xemacs)
215 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
216 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
218 (defcustom gnus-group-menu-hook nil
219 "Hook run after the creation of the group mode menu."
220 :group 'gnus-group-various
223 (defcustom gnus-group-catchup-group-hook nil
224 "Hook run when catching up a group from the group buffer."
225 :group 'gnus-group-various
226 :link '(custom-manual "(gnus)Group Data")
229 (defcustom gnus-group-update-group-hook nil
230 "Hook called when updating group lines."
231 :group 'gnus-group-visual
234 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
235 "*A function that is called to generate the group buffer.
236 The function is called with three arguments: The first is a number;
237 all group with a level less or equal to that number should be listed,
238 if the second is non-nil, empty groups should also be displayed. If
239 the third is non-nil, it is a number. No groups with a level lower
240 than this number should be displayed.
242 The only current function implemented is `gnus-group-prepare-flat'."
243 :group 'gnus-group-listing
246 (defcustom gnus-group-prepare-hook nil
247 "Hook called after the group buffer has been generated.
248 If you want to modify the group buffer, you can use this hook."
249 :group 'gnus-group-listing
252 (defcustom gnus-suspend-gnus-hook nil
253 "Hook called when suspending (not exiting) Gnus."
257 (defcustom gnus-exit-gnus-hook nil
258 "Hook called when exiting Gnus."
262 (defcustom gnus-after-exiting-gnus-hook nil
263 "Hook called after exiting Gnus."
267 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
268 "Hook called when a group line is changed.
269 The hook will not be called if `gnus-visual' is nil.
271 The default function `gnus-group-highlight-line' will
272 highlight the line according to the `gnus-group-highlight'
274 :group 'gnus-group-visual
277 (defcustom gnus-useful-groups
278 '(("(ding) mailing list mirrored at sunsite.auc.dk"
280 (nntp "sunsite.auc.dk"
281 (nntp-address "sunsite.auc.dk")))
284 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
288 (nndoc-article-type mbox)
289 (eval `(nndoc-address
290 ,(let ((file (nnheader-find-etc-directory
293 (error "Couldn't find doc group"))
295 "*Alist of useful group-server pairs."
296 :group 'gnus-group-listing
297 :type '(repeat (list (string :tag "Description")
299 (sexp :tag "Method"))))
301 (defcustom gnus-group-highlight
303 ((and mailp (= unread 0) (eq level 1)) .
304 gnus-group-mail-1-empty-face)
305 ((and mailp (eq level 1)) .
306 gnus-group-mail-1-face)
307 ((and mailp (= unread 0) (eq level 2)) .
308 gnus-group-mail-2-empty-face)
309 ((and mailp (eq level 2)) .
310 gnus-group-mail-2-face)
311 ((and mailp (= unread 0) (eq level 3)) .
312 gnus-group-mail-3-empty-face)
313 ((and mailp (eq level 3)) .
314 gnus-group-mail-3-face)
315 ((and mailp (= unread 0)) .
316 gnus-group-mail-low-empty-face)
318 gnus-group-mail-low-face)
320 ((and (= unread 0) (eq level 1)) .
321 gnus-group-news-1-empty-face)
322 ((and (eq level 1)) .
323 gnus-group-news-1-face)
324 ((and (= unread 0) (eq level 2)) .
325 gnus-group-news-2-empty-face)
326 ((and (eq level 2)) .
327 gnus-group-news-2-face)
328 ((and (= unread 0) (eq level 3)) .
329 gnus-group-news-3-empty-face)
330 ((and (eq level 3)) .
331 gnus-group-news-3-face)
332 ((and (= unread 0) (eq level 4)) .
333 gnus-group-news-4-empty-face)
334 ((and (eq level 4)) .
335 gnus-group-news-4-face)
336 ((and (= unread 0) (eq level 5)) .
337 gnus-group-news-5-empty-face)
338 ((and (eq level 5)) .
339 gnus-group-news-5-face)
340 ((and (= unread 0) (eq level 6)) .
341 gnus-group-news-6-empty-face)
342 ((and (eq level 6)) .
343 gnus-group-news-6-face)
344 ((and (= unread 0)) .
345 gnus-group-news-low-empty-face)
347 gnus-group-news-low-face))
348 "*Controls the highlighting of group buffer lines.
350 Below is a list of `Form'/`Face' pairs. When deciding how a a
351 particular group line should be displayed, each form is
352 evaluated. The content of the face field after the first true form is
353 used. You can change how those group lines are displayed by
354 editing the face field.
356 It is also possible to change and add form fields, but currently that
357 requires an understanding of Lisp expressions. Hopefully this will
358 change in a future release. For now, you can use the following
359 variables in the Lisp expression:
361 group: The name of the group.
362 unread: The number of unread articles in the group.
363 method: The select method used.
364 mailp: Whether it's a mail group or not.
365 level: The level of the group.
366 score: The score of the group.
367 ticked: The number of ticked articles."
368 :group 'gnus-group-visual
369 :type '(repeat (cons (sexp :tag "Form") face)))
371 (defcustom gnus-new-mail-mark ?%
372 "Mark used for groups with new mail."
373 :group 'gnus-group-visual
376 (defgroup gnus-group-icons nil
377 "Add Icons to your group buffer. "
378 :group 'gnus-group-visual)
380 (defcustom gnus-group-icon-list
382 "*Controls the insertion of icons into group buffer lines.
384 Below is a list of `Form'/`File' pairs. When deciding how a
385 particular group line should be displayed, each form is evaluated.
386 The icon from the file field after the first true form is used. You
387 can change how those group lines are displayed by editing the file
388 field. The File will either be found in the
389 `gnus-group-glyph-directory' or by designating absolute path to the
392 It is also possible to change and add form fields, but currently that
393 requires an understanding of Lisp expressions. Hopefully this will
394 change in a future release. For now, you can use the following
395 variables in the Lisp expression:
397 group: The name of the group.
398 unread: The number of unread articles in the group.
399 method: The select method used.
400 mailp: Whether it's a mail group or not.
401 newsp: Whether it's a news group or not
402 level: The level of the group.
403 score: The score of the group.
404 ticked: The number of ticked articles."
405 :group 'gnus-group-icons
406 :type '(repeat (cons (sexp :tag "Form") file)))
408 (defcustom gnus-group-name-charset-method-alist nil
409 "Alist of method and the charset for group names.
412 (((nntp \"news.com.cn\") . cn-gb-2312))"
415 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
417 (defcustom gnus-group-name-charset-group-alist
418 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
419 (and (fboundp 'coding-system-p) (coding-system-p 'utf-8)))
422 "Alist of group regexp and the charset for group names.
425 ((\"\\.com\\.cn:\" . cn-gb-2312))"
427 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
429 (defcustom gnus-group-jump-to-group-prompt nil
430 "Default prompt for `gnus-group-jump-to-group'.
431 If non-nil, the value should be a string, e.g. \"nnml:\",
432 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
433 in the minibuffer prompt."
434 :group 'gnus-group-various
435 :type '(choice (string :tag "Prompt string")
436 (const :tag "Empty" nil)))
438 (defvar gnus-group-listing-limit 1000
439 "*A limit of the number of groups when listing.
440 If the number of groups is larger than the limit, list them in a
443 ;;; Internal variables
445 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
446 "Function for sorting the group buffer.")
448 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
449 "Function for sorting the selected groups in the group buffer.")
451 (defvar gnus-group-indentation-function nil)
452 (defvar gnus-goto-missing-group-function nil)
453 (defvar gnus-group-update-group-function nil)
454 (defvar gnus-group-goto-next-group-function nil
455 "Function to override finding the next group after listing groups.")
457 (defvar gnus-group-edit-buffer nil)
459 (defvar gnus-group-line-format-alist
460 `((?M gnus-tmp-marked-mark ?c)
461 (?S gnus-tmp-subscribed ?c)
462 (?L gnus-tmp-level ?d)
463 (?N (cond ((eq number t) "*" )
467 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
468 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
470 (?R gnus-tmp-number-of-read ?s)
471 (?t gnus-tmp-number-total ?d)
472 (?y gnus-tmp-number-of-unread ?s)
473 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
474 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
475 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
476 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
477 (?g gnus-tmp-group ?s)
478 (?G gnus-tmp-qualified-group ?s)
479 (?c (gnus-short-group-name gnus-tmp-group) ?s)
480 (?C gnus-tmp-comment ?s)
481 (?D gnus-tmp-newsgroup-description ?s)
482 (?o gnus-tmp-moderated ?c)
483 (?O gnus-tmp-moderated-string ?s)
484 (?p gnus-tmp-process-marked ?c)
485 (?s gnus-tmp-news-server ?s)
486 (?n gnus-tmp-news-method ?s)
487 (?P gnus-group-indentation ?s)
488 (?E gnus-tmp-group-icon ?s)
489 (?l gnus-tmp-grouplens ?s)
490 (?z gnus-tmp-news-method-string ?s)
491 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
492 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
493 (?u gnus-tmp-user-defined ?s)))
495 (defvar gnus-group-mode-line-format-alist
496 `((?S gnus-tmp-news-server ?s)
497 (?M gnus-tmp-news-method ?s)
498 (?u gnus-tmp-user-defined ?s)
499 (?: gnus-tmp-colon ?s)))
501 (defvar gnus-topic-topology nil
502 "The complete topic hierarchy.")
504 (defvar gnus-topic-alist nil
505 "The complete topic-group alist.")
507 (defvar gnus-group-marked nil)
509 (defvar gnus-group-list-mode nil)
512 (defvar gnus-group-icon-cache nil)
514 (defvar gnus-group-listed-groups nil)
515 (defvar gnus-group-list-option nil)
521 (put 'gnus-group-mode 'mode-class 'special)
524 (gnus-define-keys gnus-group-mode-map
525 " " gnus-group-read-group
526 "=" gnus-group-select-group
527 "\r" gnus-group-select-group
528 "\M-\r" gnus-group-quick-select-group
529 "\M- " gnus-group-visible-select-group
530 [(meta control return)] gnus-group-select-group-ephemerally
531 "j" gnus-group-jump-to-group
532 "n" gnus-group-next-unread-group
533 "p" gnus-group-prev-unread-group
534 "\177" gnus-group-prev-unread-group
535 [delete] gnus-group-prev-unread-group
536 [backspace] gnus-group-prev-unread-group
537 "N" gnus-group-next-group
538 "P" gnus-group-prev-group
539 "\M-n" gnus-group-next-unread-group-same-level
540 "\M-p" gnus-group-prev-unread-group-same-level
541 "," gnus-group-best-unread-group
542 "." gnus-group-first-unread-group
543 "u" gnus-group-unsubscribe-current-group
544 "U" gnus-group-unsubscribe-group
545 "c" gnus-group-catchup-current
546 "C" gnus-group-catchup-current-all
547 "\M-c" gnus-group-clear-data
548 "l" gnus-group-list-groups
549 "L" gnus-group-list-all-groups
552 "g" gnus-group-get-new-news
553 "\M-g" gnus-group-get-new-news-this-group
554 "R" gnus-group-restart
555 "r" gnus-group-read-init-file
556 "B" gnus-group-browse-foreign-server
557 "b" gnus-group-check-bogus-groups
558 "F" gnus-group-find-new-groups
559 "\C-c\C-d" gnus-group-describe-group
560 "\M-d" gnus-group-describe-all-groups
561 "\C-c\C-a" gnus-group-apropos
562 "\C-c\M-\C-a" gnus-group-description-apropos
563 "a" gnus-group-post-news
564 "\ek" gnus-group-edit-local-kill
565 "\eK" gnus-group-edit-global-kill
566 "\C-k" gnus-group-kill-group
567 "\C-y" gnus-group-yank-group
568 "\C-w" gnus-group-kill-region
569 "\C-x\C-t" gnus-group-transpose-groups
570 "\C-c\C-l" gnus-group-list-killed
571 "\C-c\C-x" gnus-group-expire-articles
572 "\C-c\M-\C-x" gnus-group-expire-all-groups
574 "s" gnus-group-save-newsrc
575 "z" gnus-group-suspend
578 "?" gnus-group-describe-briefly
579 "\C-c\C-i" gnus-info-find-node
580 "\M-e" gnus-group-edit-group-method
581 "^" gnus-group-enter-server-mode
582 gnus-mouse-2 gnus-mouse-pick-group
583 "<" beginning-of-buffer
586 "\C-c\C-s" gnus-group-sort-groups
588 "\C-c\M-g" gnus-activate-all-groups
589 "\M-&" gnus-group-universal-argument
590 "#" gnus-group-mark-group
591 "\M-#" gnus-group-unmark-group)
593 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
594 "m" gnus-group-mark-group
595 "u" gnus-group-unmark-group
596 "w" gnus-group-mark-region
597 "b" gnus-group-mark-buffer
598 "r" gnus-group-mark-regexp
599 "U" gnus-group-unmark-all-groups)
601 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
602 "u" gnus-sieve-update
603 "g" gnus-sieve-generate)
605 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
606 "d" gnus-group-make-directory-group
607 "h" gnus-group-make-help-group
608 "u" gnus-group-make-useful-group
609 "a" gnus-group-make-archive-group
610 "k" gnus-group-make-kiboze-group
611 "l" gnus-group-nnimap-edit-acl
612 "m" gnus-group-make-group
613 "E" gnus-group-edit-group
614 "e" gnus-group-edit-group-method
615 "p" gnus-group-edit-group-parameters
616 "v" gnus-group-add-to-virtual
617 "V" gnus-group-make-empty-virtual
618 "D" gnus-group-enter-directory
619 "f" gnus-group-make-doc-group
620 "w" gnus-group-make-web-group
621 "r" gnus-group-rename-group
622 "c" gnus-group-customize
623 "x" gnus-group-nnimap-expunge
624 "\177" gnus-group-delete-group
625 [delete] gnus-group-delete-group)
627 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
628 "b" gnus-group-brew-soup
629 "w" gnus-soup-save-areas
630 "s" gnus-soup-send-replies
631 "p" gnus-soup-pack-packet
632 "r" nnsoup-pack-replies)
634 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
635 "s" gnus-group-sort-groups
636 "a" gnus-group-sort-groups-by-alphabet
637 "u" gnus-group-sort-groups-by-unread
638 "l" gnus-group-sort-groups-by-level
639 "v" gnus-group-sort-groups-by-score
640 "r" gnus-group-sort-groups-by-rank
641 "m" gnus-group-sort-groups-by-method)
643 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
644 "s" gnus-group-sort-selected-groups
645 "a" gnus-group-sort-selected-groups-by-alphabet
646 "u" gnus-group-sort-selected-groups-by-unread
647 "l" gnus-group-sort-selected-groups-by-level
648 "v" gnus-group-sort-selected-groups-by-score
649 "r" gnus-group-sort-selected-groups-by-rank
650 "m" gnus-group-sort-selected-groups-by-method)
652 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
653 "k" gnus-group-list-killed
654 "z" gnus-group-list-zombies
655 "s" gnus-group-list-groups
656 "u" gnus-group-list-all-groups
657 "A" gnus-group-list-active
658 "a" gnus-group-apropos
659 "d" gnus-group-description-apropos
660 "m" gnus-group-list-matching
661 "M" gnus-group-list-all-matching
662 "l" gnus-group-list-level
663 "c" gnus-group-list-cached
664 "?" gnus-group-list-dormant)
666 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
667 "k" gnus-group-list-limit
668 "z" gnus-group-list-limit
669 "s" gnus-group-list-limit
670 "u" gnus-group-list-limit
671 "A" gnus-group-list-limit
672 "m" gnus-group-list-limit
673 "M" gnus-group-list-limit
674 "l" gnus-group-list-limit
675 "c" gnus-group-list-limit
676 "?" gnus-group-list-limit)
678 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
679 "k" gnus-group-list-flush
680 "z" gnus-group-list-flush
681 "s" gnus-group-list-flush
682 "u" gnus-group-list-flush
683 "A" gnus-group-list-flush
684 "m" gnus-group-list-flush
685 "M" gnus-group-list-flush
686 "l" gnus-group-list-flush
687 "c" gnus-group-list-flush
688 "?" gnus-group-list-flush)
690 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
691 "k" gnus-group-list-plus
692 "z" gnus-group-list-plus
693 "s" gnus-group-list-plus
694 "u" gnus-group-list-plus
695 "A" gnus-group-list-plus
696 "m" gnus-group-list-plus
697 "M" gnus-group-list-plus
698 "l" gnus-group-list-plus
699 "c" gnus-group-list-plus
700 "?" gnus-group-list-plus)
702 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
703 "f" gnus-score-flush-cache)
705 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
706 "c" gnus-group-fetch-charter
707 "C" gnus-group-fetch-control
708 "d" gnus-group-describe-group
709 "f" gnus-group-fetch-faq
712 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
713 "l" gnus-group-set-current-level
714 "t" gnus-group-unsubscribe-current-group
715 "s" gnus-group-unsubscribe-group
716 "k" gnus-group-kill-group
717 "y" gnus-group-yank-group
718 "w" gnus-group-kill-region
719 "\C-k" gnus-group-kill-level
720 "z" gnus-group-kill-all-zombies))
722 (defun gnus-group-make-menu-bar ()
723 (gnus-turn-off-edit-menu 'group)
724 (unless (boundp 'gnus-group-reading-menu)
727 gnus-group-reading-menu gnus-group-mode-map ""
729 ["Read" gnus-group-read-group (gnus-group-group-name)]
730 ["Select" gnus-group-select-group (gnus-group-group-name)]
731 ["See old articles" (gnus-group-select-group 'all)
732 :keys "C-u SPC" :active (gnus-group-group-name)]
733 ["Catch up" gnus-group-catchup-current :active (gnus-group-group-name)
734 ,@(if (featurep 'xemacs) nil
735 '(:help "Mark unread articles in the current group as read"))]
736 ["Catch up all articles" gnus-group-catchup-current-all
737 (gnus-group-group-name)]
738 ["Check for new articles" gnus-group-get-new-news-this-group
739 :active (gnus-group-group-name)
740 ,@(if (featurep 'xemacs) nil
741 '(:help "Check for new messages in current group"))]
742 ["Toggle subscription" gnus-group-unsubscribe-current-group
743 (gnus-group-group-name)]
744 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
745 ,@(if (featurep 'xemacs) nil
746 '(:help "Kill (remove) current group"))]
747 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
748 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
749 ,@(if (featurep 'xemacs) nil
750 '(:help "Display description of the current group"))]
751 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
752 ["Fetch charter" gnus-group-fetch-charter :active (gnus-group-group-name)
753 ,@(if (featurep 'xemacs) nil
754 '(:help "Display the charter of the current group"))]
755 ["Fetch control message" gnus-group-fetch-control :active (gnus-group-group-name)
756 ,@(if (featurep 'xemacs) nil
757 '(:help "Display the archived control message for the current group"))]
758 ;; Actually one should check, if any of the marked groups gives t for
759 ;; (gnus-check-backend-function 'request-expire-articles ...)
760 ["Expire articles" gnus-group-expire-articles
761 (or (and (gnus-group-group-name)
762 (gnus-check-backend-function
763 'request-expire-articles
764 (gnus-group-group-name))) gnus-group-marked)]
765 ["Set group level..." gnus-group-set-current-level
766 (gnus-group-group-name)]
767 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
768 ["Customize" gnus-group-customize (gnus-group-group-name)]
770 ["Parameters" gnus-group-edit-group-parameters
771 (gnus-group-group-name)]
772 ["Select method" gnus-group-edit-group-method
773 (gnus-group-group-name)]
774 ["Info" gnus-group-edit-group (gnus-group-group-name)]
775 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
776 ["Global kill file" gnus-group-edit-global-kill t])))
779 gnus-group-group-menu gnus-group-mode-map ""
782 ["List unread subscribed groups" gnus-group-list-groups t]
783 ["List (un)subscribed groups" gnus-group-list-all-groups t]
784 ["List killed groups" gnus-group-list-killed gnus-killed-list]
785 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
786 ["List level..." gnus-group-list-level t]
787 ["Describe all groups" gnus-group-describe-all-groups t]
788 ["Group apropos..." gnus-group-apropos t]
789 ["Group and description apropos..." gnus-group-description-apropos t]
790 ["List groups matching..." gnus-group-list-matching t]
791 ["List all groups matching..." gnus-group-list-all-matching t]
792 ["List active file" gnus-group-list-active t]
793 ["List groups with cached" gnus-group-list-cached t]
794 ["List groups with dormant" gnus-group-list-dormant t])
796 ["Default sort" gnus-group-sort-groups t]
797 ["Sort by method" gnus-group-sort-groups-by-method t]
798 ["Sort by rank" gnus-group-sort-groups-by-rank t]
799 ["Sort by score" gnus-group-sort-groups-by-score t]
800 ["Sort by level" gnus-group-sort-groups-by-level t]
801 ["Sort by unread" gnus-group-sort-groups-by-unread t]
802 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
803 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
804 ("Sort process/prefixed"
805 ["Default sort" gnus-group-sort-selected-groups
806 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
807 ["Sort by method" gnus-group-sort-selected-groups-by-method
808 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
809 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
810 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
811 ["Sort by score" gnus-group-sort-selected-groups-by-score
812 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
813 ["Sort by level" gnus-group-sort-selected-groups-by-level
814 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
815 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
816 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
817 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
818 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
819 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
820 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
822 ["Mark group" gnus-group-mark-group
823 (and (gnus-group-group-name)
824 (not (memq (gnus-group-group-name) gnus-group-marked)))]
825 ["Unmark group" gnus-group-unmark-group
826 (and (gnus-group-group-name)
827 (memq (gnus-group-group-name) gnus-group-marked))]
828 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
829 ["Mark regexp..." gnus-group-mark-regexp t]
830 ["Mark region" gnus-group-mark-region t]
831 ["Mark buffer" gnus-group-mark-buffer t]
832 ["Execute command" gnus-group-universal-argument
833 (or gnus-group-marked (gnus-group-group-name))])
835 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
836 ["Kill all newsgroups in region" gnus-group-kill-region t]
837 ["Kill all zombie groups" gnus-group-kill-all-zombies
839 ["Kill all groups on level..." gnus-group-kill-level t])
841 ["Make a foreign group..." gnus-group-make-group t]
842 ["Add a directory group..." gnus-group-make-directory-group t]
843 ["Add the help group" gnus-group-make-help-group t]
844 ["Add the archive group" gnus-group-make-archive-group t]
845 ["Make a doc group..." gnus-group-make-doc-group t]
846 ["Make a web group..." gnus-group-make-web-group t]
847 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
848 ["Make a virtual group..." gnus-group-make-empty-virtual t]
849 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
850 ["Rename group..." gnus-group-rename-group
851 (gnus-check-backend-function
852 'request-rename-group (gnus-group-group-name))]
853 ["Delete group" gnus-group-delete-group
854 (gnus-check-backend-function
855 'request-delete-group (gnus-group-group-name))])
857 ["Next" gnus-group-next-group t]
858 ["Previous" gnus-group-prev-group t]
859 ["Next unread" gnus-group-next-unread-group t]
860 ["Previous unread" gnus-group-prev-unread-group t]
861 ["Next unread same level" gnus-group-next-unread-group-same-level t]
862 ["Previous unread same level"
863 gnus-group-prev-unread-group-same-level t]
864 ["Jump to group..." gnus-group-jump-to-group t]
865 ["First unread group" gnus-group-first-unread-group t]
866 ["Best unread group" gnus-group-best-unread-group t])
868 ["Generate" gnus-sieve-generate t]
869 ["Generate and update" gnus-sieve-update t])
870 ["Delete bogus groups" gnus-group-check-bogus-groups t]
871 ["Find new newsgroups" gnus-group-find-new-groups t]
872 ["Transpose" gnus-group-transpose-groups
873 (gnus-group-group-name)]
874 ["Read a directory as a group..." gnus-group-enter-directory t]))
877 gnus-group-misc-menu gnus-group-mode-map ""
880 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
881 ["Send replies" gnus-soup-send-replies
882 (fboundp 'gnus-soup-pack-packet)]
883 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
884 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
885 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
886 ["Send a mail" gnus-group-mail t]
887 ["Send a message (mail or news)" gnus-group-post-news t]
888 ["Create a local message" gnus-group-news t]
889 ["Check for new news" gnus-group-get-new-news
890 ,@(if (featurep 'xemacs) '(t)
891 '(:help "Get newly arrived articles"))
893 ["Send queued messages" gnus-delay-send-queue
894 ,@(if (featurep 'xemacs) '(t)
895 '(:help "Send all messages that are scheduled to be sent now"))
897 ["Activate all groups" gnus-activate-all-groups t]
898 ["Restart Gnus" gnus-group-restart t]
899 ["Read init file" gnus-group-read-init-file t]
900 ["Browse foreign server..." gnus-group-browse-foreign-server t]
901 ["Enter server buffer" gnus-group-enter-server-mode t]
902 ["Expire all expirable articles" gnus-group-expire-all-groups t]
903 ["Generate any kiboze groups" nnkiboze-generate-groups t]
904 ["Gnus version" gnus-version t]
905 ["Save .newsrc files" gnus-group-save-newsrc t]
906 ["Suspend Gnus" gnus-group-suspend t]
907 ["Clear dribble buffer" gnus-group-clear-dribble t]
908 ["Read manual" gnus-info-find-node t]
909 ["Flush score cache" gnus-score-flush-cache t]
910 ["Toggle topics" gnus-topic-mode t]
911 ["Send a bug report" gnus-bug t]
912 ["Exit from Gnus" gnus-group-exit
913 ,@(if (featurep 'xemacs) '(t)
914 '(:help "Quit reading news"))]
915 ["Exit without saving" gnus-group-quit t]))
917 (gnus-run-hooks 'gnus-group-menu-hook)))
919 (defvar gnus-group-toolbar-map nil)
921 ;; Emacs 21 tool bar. Should be no-op otherwise.
922 (defun gnus-group-make-tool-bar ()
924 (condition-case nil (require 'tool-bar) (error nil))
925 (fboundp 'tool-bar-add-item-from-menu)
926 (default-value 'tool-bar-mode)
927 (not gnus-group-toolbar-map))
928 (setq gnus-group-toolbar-map
929 (let ((tool-bar-map (make-sparse-keymap))
930 (load-path (mm-image-load-path)))
931 (tool-bar-add-item-from-menu
932 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
933 (tool-bar-add-item-from-menu
934 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
935 (tool-bar-add-item-from-menu
936 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
937 (tool-bar-add-item-from-menu
938 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
939 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
940 :help "Subscribe to the current group")
941 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
943 :help "Unsubscribe from the current group")
944 (tool-bar-add-item-from-menu
945 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
947 (if gnus-group-toolbar-map
948 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
950 (defun gnus-group-mode ()
951 "Major mode for reading news.
953 All normal editing commands are switched off.
954 \\<gnus-group-mode-map>
955 The group buffer lists (some of) the groups available. For instance,
956 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
957 lists all zombie groups.
959 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
960 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
962 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
964 The following commands are available:
966 \\{gnus-group-mode-map}"
968 (kill-all-local-variables)
969 (when (gnus-visual-p 'group-menu 'menu)
970 (gnus-group-make-menu-bar)
971 (gnus-group-make-tool-bar))
972 (gnus-simplify-mode-line)
973 (setq major-mode 'gnus-group-mode)
974 (setq mode-name "Group")
975 (gnus-group-set-mode-line)
976 (setq mode-line-process nil)
977 (use-local-map gnus-group-mode-map)
978 (buffer-disable-undo)
979 (setq truncate-lines t)
980 (setq buffer-read-only t)
981 (gnus-set-default-directory)
982 (gnus-update-format-specifications nil 'group 'group-mode)
983 (gnus-update-group-mark-positions)
988 (gnus-run-hooks 'gnus-group-mode-hook))
990 (defun gnus-update-group-mark-positions ()
992 (let ((gnus-process-mark ?\200)
993 (gnus-group-update-hook nil)
994 (gnus-group-marked '("dummy.group"))
995 (gnus-active-hashtb (make-vector 10 0))
997 (gnus-set-active "dummy.group" '(0 . 0))
998 (gnus-set-work-buffer)
999 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1000 (goto-char (point-min))
1001 (setq gnus-group-mark-positions
1002 (list (cons 'process (and (search-forward "\200" nil t)
1003 (- (point) 2))))))))
1005 (defun gnus-mouse-pick-group (e)
1006 "Enter the group under the mouse pointer."
1009 (gnus-group-read-group nil))
1011 ;; Look at LEVEL and find out what the level is really supposed to be.
1012 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1013 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1014 (defun gnus-group-default-level (&optional level number-or-nil)
1016 (gnus-group-use-permanent-levels
1017 (or (setq gnus-group-use-permanent-levels
1018 (or level (if (numberp gnus-group-use-permanent-levels)
1019 gnus-group-use-permanent-levels
1020 (or gnus-group-default-list-level
1021 gnus-level-subscribed))))
1022 gnus-group-default-list-level gnus-level-subscribed))
1026 (or level gnus-group-default-list-level gnus-level-subscribed))))
1028 (defun gnus-group-setup-buffer ()
1029 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1030 (unless (eq major-mode 'gnus-group-mode)
1033 (gnus-carpal-setup-buffer 'group))))
1035 (defun gnus-group-name-charset (method group)
1037 (setq method (gnus-find-method-for-group group)))
1038 (let ((item (assoc method gnus-group-name-charset-method-alist))
1039 (alist gnus-group-name-charset-group-alist)
1043 (while (setq item (pop alist))
1044 (if (string-match (car item) group)
1046 result (cdr item))))
1049 (defun gnus-group-name-decode (string charset)
1050 (if (and string charset (featurep 'mule))
1051 (mm-decode-coding-string string charset)
1054 (defun gnus-group-decoded-name (string)
1055 (let ((charset (gnus-group-name-charset nil string)))
1056 (gnus-group-name-decode string charset)))
1058 (defun gnus-group-list-groups (&optional level unread lowest)
1059 "List newsgroups with level LEVEL or lower that have unread articles.
1060 Default is all subscribed groups.
1061 If argument UNREAD is non-nil, groups with no unread articles are also
1064 Also see the `gnus-group-use-permanent-levels' variable."
1066 (list (if current-prefix-arg
1067 (prefix-numeric-value current-prefix-arg)
1069 (gnus-group-default-level nil t)
1070 gnus-group-default-list-level
1071 gnus-level-subscribed))))
1073 (setq level (car gnus-group-list-mode)
1074 unread (cdr gnus-group-list-mode)))
1075 (setq level (gnus-group-default-level level))
1076 (gnus-group-setup-buffer)
1077 (gnus-update-format-specifications nil 'group 'group-mode)
1078 (let ((case-fold-search nil)
1079 (props (text-properties-at (gnus-point-at-bol)))
1080 (empty (= (point-min) (point-max)))
1081 (group (gnus-group-group-name))
1083 (set-buffer gnus-group-buffer)
1084 (setq number (funcall gnus-group-prepare-function level unread lowest))
1085 (when (or (and (numberp number)
1087 (zerop (buffer-size)))
1088 ;; No groups in the buffer.
1089 (gnus-message 5 gnus-no-groups-message))
1090 ;; We have some groups displayed.
1091 (goto-char (point-max))
1092 (when (or (not gnus-group-goto-next-group-function)
1093 (not (funcall gnus-group-goto-next-group-function
1097 (goto-char (point-min)))
1099 ;; Go to the first group with unread articles.
1100 (gnus-group-search-forward t))
1102 ;; Find the right group to put point on. If the current group
1103 ;; has disappeared in the new listing, try to find the next
1104 ;; one. If no next one can be found, just leave point at the
1105 ;; first newsgroup in the buffer.
1106 (when (not (gnus-goto-char
1108 (point-min) (point-max)
1109 'gnus-group (gnus-intern-safe
1110 group gnus-active-hashtb))))
1111 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1113 (not (gnus-goto-char
1115 (point-min) (point-max) 'gnus-group
1117 (caar newsrc) gnus-active-hashtb)))))
1118 (setq newsrc (cdr newsrc)))
1120 (goto-char (point-max))
1121 (forward-line -1)))))))
1122 ;; Adjust cursor point.
1123 (gnus-group-position-point)))
1125 (defun gnus-group-list-level (level &optional all)
1126 "List groups on LEVEL.
1127 If ALL (the prefix), also list groups that have no unread articles."
1128 (interactive "nList groups on level: \nP")
1129 (gnus-group-list-groups level all level))
1131 (defun gnus-group-prepare-logic (group test)
1132 (or (and gnus-group-listed-groups
1133 (null gnus-group-list-option)
1134 (member group gnus-group-listed-groups))
1136 ((null gnus-group-listed-groups) test)
1137 ((null gnus-group-list-option) test)
1138 (t (and (member group gnus-group-listed-groups)
1139 (if (eq gnus-group-list-option 'flush)
1143 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1144 "List all newsgroups with unread articles of level LEVEL or lower.
1145 If PREDICATE is a function, list groups that the function returns non-nil;
1146 if it is t, list groups that have no unread articles.
1147 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1148 If REGEXP is a function, list dead groups that the function returns non-nil;
1149 if it is a string, only list groups matching REGEXP."
1150 (set-buffer gnus-group-buffer)
1151 (let ((buffer-read-only nil)
1152 (newsrc (cdr gnus-newsrc-alist))
1153 (lowest (or lowest 1))
1154 (not-in-list (and gnus-group-listed-groups
1155 (copy-sequence gnus-group-listed-groups)))
1156 info clevel unread group params)
1158 (when (or (< lowest gnus-level-zombie)
1159 gnus-group-listed-groups)
1160 ;; List living groups.
1162 (setq info (car newsrc)
1163 group (gnus-info-group info)
1164 params (gnus-info-params info)
1166 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1168 (setq not-in-list (delete group not-in-list)))
1170 (gnus-group-prepare-logic
1172 (and unread ; This group might be unchecked
1173 (or (not (stringp regexp))
1174 (string-match regexp group))
1175 (<= (setq clevel (gnus-info-level info)) level)
1178 ((functionp predicate)
1179 (funcall predicate info))
1180 (predicate t) ; We list all groups?
1183 (if (eq unread t) ; Unactivated?
1184 gnus-group-list-inactive-groups
1185 ; We list unactivated
1187 ; We list groups with unread articles
1188 (and gnus-list-groups-with-ticked-articles
1189 (cdr (assq 'tick (gnus-info-marks info))))
1190 ; And groups with tickeds
1191 ;; Check for permanent visibility.
1192 (and gnus-permanently-visible-groups
1193 (string-match gnus-permanently-visible-groups group))
1194 (memq 'visible params)
1195 (cdr (assq 'visible params)))))))
1196 (gnus-group-insert-group-line
1197 group (gnus-info-level info)
1198 (gnus-info-marks info) unread (gnus-info-method info)))))
1200 ;; List dead groups.
1201 (if (or gnus-group-listed-groups
1202 (and (>= level gnus-level-zombie)
1203 (<= lowest gnus-level-zombie)))
1204 (gnus-group-prepare-flat-list-dead
1205 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1206 gnus-level-zombie ?Z
1209 (dolist (group gnus-zombie-list)
1210 (setq not-in-list (delete group not-in-list))))
1211 (if (or gnus-group-listed-groups
1212 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1213 (gnus-group-prepare-flat-list-dead
1216 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1217 gnus-level-killed ?K regexp))
1219 (gnus-group-set-mode-line)
1220 (setq gnus-group-list-mode (cons level predicate))
1221 (gnus-run-hooks 'gnus-group-prepare-hook)
1224 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1225 ;; List zombies and killed lists somewhat faster, which was
1226 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1227 ;; this by ignoring the group format specification altogether.
1229 (if (> (length groups) gnus-group-listing-limit)
1231 (setq group (pop groups))
1232 (when (gnus-group-prepare-logic
1235 (and (stringp regexp) (string-match regexp group))
1236 (and (functionp regexp) (funcall regexp group))))
1237 (gnus-add-text-properties
1238 (point) (prog1 (1+ (point))
1239 (insert " " mark " *: "
1240 (gnus-group-decoded-name group)
1242 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1244 'gnus-level level))))
1246 (setq group (pop groups))
1247 (when (gnus-group-prepare-logic
1250 (and (stringp regexp) (string-match regexp group))
1251 (and (functionp regexp) (funcall regexp group))))
1252 (gnus-group-insert-group-line
1254 (let ((active (gnus-active group)))
1256 (if (zerop (cdr active))
1258 (- (1+ (cdr active)) (car active)))
1260 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1262 (defun gnus-group-update-group-line ()
1263 "Update the current line in the group buffer."
1264 (let* ((buffer-read-only nil)
1265 (group (gnus-group-group-name))
1266 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1267 gnus-group-indentation)
1270 (not (gnus-ephemeral-group-p group))
1272 (concat "(gnus-group-set-info '"
1273 (gnus-prin1-to-string (nth 2 entry))
1275 (setq gnus-group-indentation (gnus-group-group-indentation))
1277 (gnus-group-insert-group-line-info group)
1279 (gnus-group-position-point))))
1281 (defun gnus-group-insert-group-line-info (group)
1282 "Insert GROUP on the current line."
1283 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1284 (gnus-group-indentation (gnus-group-group-indentation))
1288 ;; (Un)subscribed group.
1289 (setq info (nth 2 entry))
1290 (gnus-group-insert-group-line
1291 group (gnus-info-level info) (gnus-info-marks info)
1292 (or (car entry) t) (gnus-info-method info)))
1293 ;; This group is dead.
1294 (gnus-group-insert-group-line
1296 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1298 (if (setq active (gnus-active group))
1299 (if (zerop (cdr active))
1301 (- (1+ (cdr active)) (car active)))
1303 (gnus-method-simplify (gnus-find-method-for-group group))))))
1305 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1306 gnus-tmp-marked number
1308 "Insert a group line in the group buffer."
1309 (let* ((gnus-tmp-method
1310 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1311 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1313 (gnus-tmp-active (gnus-active gnus-tmp-group))
1314 (gnus-tmp-number-total
1316 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1318 (gnus-tmp-number-of-unread
1319 (if (numberp number) (int-to-string (max 0 number))
1321 (gnus-tmp-number-of-read
1322 (if (numberp number)
1323 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1325 (gnus-tmp-subscribed
1326 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1327 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1328 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1330 (gnus-tmp-qualified-group
1331 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1332 group-name-charset))
1334 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1336 (gnus-tmp-newsgroup-description
1337 (if gnus-description-hashtb
1338 (or (gnus-group-name-decode
1339 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1340 group-name-charset) "")
1343 (if (and gnus-moderated-hashtb
1344 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1346 (gnus-tmp-moderated-string
1347 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1348 (gnus-tmp-group-icon "==&&==")
1349 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1350 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1351 (gnus-tmp-news-method-string
1353 (format "(%s:%s)" (car gnus-tmp-method)
1354 (cadr gnus-tmp-method)) ""))
1355 (gnus-tmp-marked-mark
1356 (if (and (numberp number)
1358 (cdr (assq 'tick gnus-tmp-marked)))
1360 (gnus-tmp-process-marked
1361 (if (member gnus-tmp-group gnus-group-marked)
1362 gnus-process-mark ? ))
1364 (or (and gnus-use-grouplens
1365 (bbb-grouplens-group-p gnus-tmp-group))
1367 (buffer-read-only nil)
1368 header gnus-tmp-header) ; passed as parameter to user-funcs.
1370 (gnus-add-text-properties
1374 (let ((gnus-tmp-group (gnus-group-name-decode
1375 gnus-tmp-group group-name-charset)))
1376 (eval gnus-group-line-format-spec)))
1377 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1378 gnus-unread ,(if (numberp number)
1379 (string-to-int gnus-tmp-number-of-unread)
1381 gnus-marked ,gnus-tmp-marked-mark
1382 gnus-indentation ,gnus-group-indentation
1383 gnus-level ,gnus-tmp-level))
1385 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1386 (gnus-run-hooks 'gnus-group-update-hook))
1388 ;; Allow XEmacs to remove front-sticky text properties.
1389 (gnus-group-remove-excess-properties)))
1391 (defun gnus-group-highlight-line ()
1392 "Highlight the current line according to `gnus-group-highlight'."
1393 (let* ((list gnus-group-highlight)
1395 (end (progn (end-of-line) (point)))
1396 ;; now find out where the line starts and leave point there.
1397 (beg (progn (beginning-of-line) (point)))
1398 (group (gnus-group-group-name))
1399 (entry (gnus-group-entry group))
1400 (unread (if (numberp (car entry)) (car entry) 0))
1401 (active (gnus-active group))
1402 (total (if active (1+ (- (cdr active) (car active))) 0))
1403 (info (nth 2 entry))
1404 (method (gnus-server-get-method group (gnus-info-method info)))
1405 (marked (gnus-info-marks info))
1406 (mailp (apply 'append
1409 (memq x (assoc (symbol-name
1410 (car (or method gnus-select-method)))
1411 gnus-valid-select-methods)))
1412 '(mail post-mail))))
1413 (level (or (gnus-info-level info) gnus-level-killed))
1414 (score (or (gnus-info-score info) 0))
1415 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1416 (group-age (gnus-group-timestamp-delta group))
1417 (inhibit-read-only t))
1418 ;; Eval the cars of the lists until we find a match.
1420 (not (eval (caar list))))
1421 (setq list (cdr list)))
1422 (let ((face (cdar list)))
1423 (unless (eq face (get-text-property beg 'face))
1424 (gnus-put-text-property-excluding-characters-with-faces
1426 (setq face (if (boundp face) (symbol-value face) face)))
1427 (gnus-extent-start-open beg)))
1430 (defun gnus-group-update-group (group &optional visible-only)
1431 "Update all lines where GROUP appear.
1432 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1434 ;; Can't use `save-excursion' here, so we do it manually.
1435 (let ((buf (current-buffer))
1437 (set-buffer gnus-group-buffer)
1438 (setq mark (point-marker))
1439 ;; The buffer may be narrowed.
1442 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1444 found buffer-read-only)
1445 ;; Enter the current status into the dribble buffer.
1446 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1448 (not (gnus-ephemeral-group-p group)))
1450 (concat "(gnus-group-set-info '"
1451 (gnus-prin1-to-string (nth 2 entry))
1453 ;; Find all group instances. If topics are in use, each group
1454 ;; may be listed in more than once.
1455 (while (setq loc (text-property-any
1456 loc (point-max) 'gnus-group ident))
1459 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1461 (gnus-group-insert-group-line-info group)
1464 (gnus-run-hooks 'gnus-group-update-group-hook)))
1465 (setq loc (1+ loc)))
1466 (unless (or found visible-only)
1467 ;; No such line in the buffer, find out where it's supposed to
1468 ;; go, and insert it there (or at the end of the buffer).
1469 (if gnus-goto-missing-group-function
1470 (funcall gnus-goto-missing-group-function group)
1471 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1472 (while (and entry (car entry)
1476 (point-min) (point-max)
1477 'gnus-group (gnus-intern-safe
1478 (caar entry) gnus-active-hashtb)))))
1479 (setq entry (cdr entry)))
1480 (or entry (goto-char (point-max)))))
1481 ;; Finally insert the line.
1482 (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 (when gnus-group-update-group-function
1488 (funcall gnus-group-update-group-function group))
1489 (gnus-group-set-mode-line)))
1491 (set-marker mark nil)
1494 (defun gnus-group-set-mode-line ()
1495 "Update the mode line in the group buffer."
1496 (when (memq 'group gnus-updated-mode-lines)
1497 ;; Yes, we want to keep this mode line updated.
1499 (set-buffer gnus-group-buffer)
1500 (let* ((gformat (or gnus-group-mode-line-format-spec
1501 (gnus-set-format 'group-mode)))
1502 (gnus-tmp-news-server (cadr gnus-select-method))
1503 (gnus-tmp-news-method (car gnus-select-method))
1504 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1506 gnus-tmp-header ;Dummy binding for user-defined formats
1507 ;; Get the resulting string.
1509 (and gnus-dribble-buffer
1510 (buffer-name gnus-dribble-buffer)
1511 (buffer-modified-p gnus-dribble-buffer)
1513 (set-buffer gnus-dribble-buffer)
1514 (not (zerop (buffer-size))))))
1515 (mode-string (eval gformat)))
1516 ;; Say whether the dribble buffer has been modified.
1517 (setq mode-line-modified
1518 (if modified (car gnus-mode-line-modified)
1519 (cdr gnus-mode-line-modified)))
1520 ;; If the line is too long, we chop it off.
1521 (when (> (length mode-string) max-len)
1522 (setq mode-string (substring mode-string 0 (- max-len 4))))
1524 (setq mode-line-buffer-identification
1525 (gnus-mode-line-buffer-identification
1526 (list mode-string)))
1527 (set-buffer-modified-p modified))))))
1529 (defun gnus-group-group-name ()
1530 "Get the name of the newsgroup on the current line."
1531 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1533 (symbol-name group))))
1535 (defun gnus-group-group-level ()
1536 "Get the level of the newsgroup on the current line."
1537 (get-text-property (gnus-point-at-bol) 'gnus-level))
1539 (defun gnus-group-group-indentation ()
1540 "Get the indentation of the newsgroup on the current line."
1541 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1542 (and gnus-group-indentation-function
1543 (funcall gnus-group-indentation-function))
1546 (defun gnus-group-group-unread ()
1547 "Get the number of unread articles of the newsgroup on the current line."
1548 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1550 (defun gnus-group-new-mail (group)
1551 (if (nnmail-new-mail-p (gnus-group-real-name group))
1555 (defun gnus-group-level (group)
1556 "Return the estimated level of GROUP."
1557 (or (gnus-info-level (gnus-get-info group))
1558 (and (member group gnus-zombie-list) gnus-level-zombie)
1561 (defun gnus-group-search-forward (&optional backward all level first-too)
1562 "Find the next newsgroup with unread articles.
1563 If BACKWARD is non-nil, find the previous newsgroup instead.
1564 If ALL is non-nil, just find any newsgroup.
1565 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1567 If FIRST-TOO, the current line is also eligible as a target."
1568 (let ((way (if backward -1 1))
1569 (low gnus-level-killed)
1572 (if (and backward (progn (beginning-of-line)) (bobp))
1581 (get-text-property (point) 'gnus-group)
1585 (get-text-property (point) 'gnus-unread)))
1586 (and (numberp unread) (> unread 0)))
1587 (setq lev (get-text-property (point)
1589 (<= lev gnus-level-subscribed)))
1591 (and (setq lev (get-text-property (point)
1600 (zerop (forward-line way)))))
1602 (progn (gnus-group-position-point) t)
1603 (goto-char (or pos beg))
1606 ;;; Gnus group mode commands
1610 (defun gnus-group-mark-line-p ()
1613 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1614 (eq (char-after) gnus-process-mark)))
1616 (defun gnus-group-mark-group (n &optional unmark no-advance)
1617 "Mark the current group."
1619 (let ((buffer-read-only nil)
1623 (when (setq group (gnus-group-group-name))
1624 ;; Go to the mark position.
1626 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1627 (subst-char-in-region
1628 (point) (1+ (point)) (char-after)
1631 (setq gnus-group-marked (delete group gnus-group-marked))
1633 (setq gnus-group-marked
1634 (cons group (delete group gnus-group-marked)))
1635 gnus-process-mark)))
1637 (gnus-group-next-group 1))
1639 (gnus-summary-position-point)
1642 (defun gnus-group-unmark-group (n)
1643 "Remove the mark from the current group."
1645 (gnus-group-mark-group n 'unmark)
1646 (gnus-group-position-point))
1648 (defun gnus-group-unmark-all-groups ()
1649 "Unmark all groups."
1651 (let ((groups gnus-group-marked))
1654 (gnus-group-remove-mark (pop groups)))))
1655 (gnus-group-position-point))
1657 (defun gnus-group-mark-region (unmark beg end)
1658 "Mark all groups between point and mark.
1659 If UNMARK, remove the mark instead."
1660 (interactive "P\nr")
1661 (let ((num (count-lines beg end)))
1664 (- num (gnus-group-mark-group num unmark)))))
1666 (defun gnus-group-mark-buffer (&optional unmark)
1667 "Mark all groups in the buffer.
1668 If UNMARK, remove the mark instead."
1670 (gnus-group-mark-region unmark (point-min) (point-max)))
1672 (defun gnus-group-mark-regexp (regexp)
1673 "Mark all groups that match some regexp."
1674 (interactive "sMark (regexp): ")
1675 (let ((alist (cdr gnus-newsrc-alist))
1678 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1679 (gnus-group-set-mark group))))
1680 (gnus-group-position-point))
1682 (defun gnus-group-remove-mark (group &optional test-marked)
1683 "Remove the process mark from GROUP and move point there.
1684 Return nil if the group isn't displayed."
1685 (if (gnus-group-goto-group group nil test-marked)
1687 (gnus-group-mark-group 1 'unmark t)
1689 (setq gnus-group-marked
1690 (delete group gnus-group-marked))
1693 (defun gnus-group-set-mark (group)
1694 "Set the process mark on GROUP."
1695 (if (gnus-group-goto-group group)
1697 (gnus-group-mark-group 1 nil t))
1698 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1700 (defun gnus-group-universal-argument (arg &optional groups func)
1701 "Perform any command on all groups according to the process/prefix convention."
1703 (if (eq (setq func (or func
1706 (substitute-command-keys
1707 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1709 (gnus-error 1 "Undefined key")
1710 (gnus-group-iterate arg
1712 (command-execute func))))
1713 (gnus-group-position-point))
1715 (defun gnus-group-process-prefix (n)
1716 "Return a list of groups to work on.
1717 Take into consideration N (the prefix) and the list of marked groups."
1720 (setq n (prefix-numeric-value n))
1721 ;; There is a prefix, so we return a list of the N next
1723 (let ((way (if (< n 0) -1 1))
1728 (if (setq group (gnus-group-group-name))
1729 (push group groups))
1731 (gnus-group-next-group way)))
1733 ((and (gnus-region-active-p) (mark))
1734 ;; Work on the region between point and mark.
1735 (let ((max (max (point) (mark)))
1738 (goto-char (min (point) (mark)))
1741 (push (gnus-group-group-name) groups)
1742 (zerop (gnus-group-next-group 1))
1744 (nreverse groups))))
1746 ;; No prefix, but a list of marked articles.
1747 (reverse gnus-group-marked))
1749 ;; Neither marked articles or a prefix, so we return the
1751 (let ((group (gnus-group-group-name)))
1752 (and group (list group))))))
1754 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1755 ;;; imagine why I went through these contortions...
1757 (let ((function (make-symbol "gnus-group-iterate-function"))
1758 (window (make-symbol "gnus-group-iterate-window"))
1759 (groups (make-symbol "gnus-group-iterate-groups"))
1760 (group (make-symbol "gnus-group-iterate-group")))
1762 `(defun gnus-group-iterate (arg ,function)
1763 "Iterate FUNCTION over all process/prefixed groups.
1764 FUNCTION will be called with the group name as the parameter
1765 and with point over the group in question."
1766 (let ((,groups (gnus-group-process-prefix arg))
1767 (,window (selected-window))
1770 (setq ,group (car ,groups)
1771 ,groups (cdr ,groups))
1772 (select-window ,window)
1773 (gnus-group-remove-mark ,group)
1774 (save-selected-window
1776 (funcall ,function ,group)))))))))
1778 (put 'gnus-group-iterate 'lisp-indent-function 1)
1780 ;; Selecting groups.
1782 (defun gnus-group-read-group (&optional all no-article group select-articles)
1783 "Read news in this newsgroup.
1784 If the prefix argument ALL is non-nil, already read articles become
1785 readable. IF ALL is a number, fetch this number of articles. If the
1786 optional argument NO-ARTICLE is non-nil, no article will be
1787 auto-selected upon group entry. If GROUP is non-nil, fetch that
1790 (let ((no-display (eq all 0))
1791 (group (or group (gnus-group-group-name)))
1792 number active marked entry)
1796 (error "No group on current line"))
1797 (setq marked (gnus-info-marks
1798 (nth 2 (setq entry (gnus-gethash
1799 group gnus-newsrc-hashtb)))))
1800 ;; This group might be a dead group. In that case we have to get
1801 ;; the number of unread articles from `gnus-active-hashtb'.
1803 (cond ((numberp all) all)
1805 ((setq active (gnus-active group))
1806 (- (1+ (cdr active)) (car active)))))
1807 (gnus-summary-read-group
1808 group (or all (and (numberp number)
1809 (zerop (+ number (gnus-range-length
1810 (cdr (assq 'tick marked)))
1812 (cdr (assq 'dormant marked)))))))
1813 no-article nil no-display nil select-articles)))
1815 (defun gnus-group-select-group (&optional all)
1816 "Select this newsgroup.
1817 No article is selected automatically.
1818 If the group is opened, just switch the summary buffer.
1819 If ALL is non-nil, already read articles become readable.
1820 If ALL is a number, fetch this number of articles."
1822 (gnus-group-read-group all t))
1824 (defun gnus-group-quick-select-group (&optional all)
1825 "Select the current group \"quickly\".
1826 This means that no highlighting or scoring will be performed.
1827 If ALL (the prefix argument) is 0, don't even generate the summary
1830 This might be useful if you want to toggle threading
1831 before entering the group."
1833 (require 'gnus-score)
1835 gnus-score-find-score-files-function
1836 gnus-home-score-file
1837 gnus-apply-kill-hook
1838 gnus-summary-expunge-below)
1839 (gnus-group-read-group all t)))
1841 (defun gnus-group-visible-select-group (&optional all)
1842 "Select the current group without hiding any articles."
1844 (let ((gnus-inhibit-limiting t))
1845 (gnus-group-read-group all t)))
1847 (defun gnus-group-select-group-ephemerally ()
1848 "Select the current group without doing any processing whatsoever.
1849 You will actually be entered into a group that's a copy of
1850 the current group; no changes you make while in this group will
1853 (require 'gnus-score)
1855 gnus-score-find-score-files-function gnus-apply-kill-hook
1856 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1857 gnus-summary-mode-hook gnus-select-group-hook
1858 (group (gnus-group-group-name))
1859 (method (gnus-find-method-for-group group)))
1860 (gnus-group-read-ephemeral-group
1861 (gnus-group-prefixed-name group method) method)))
1864 (defun gnus-fetch-group (group &optional articles)
1865 "Start Gnus if necessary and enter GROUP.
1866 Returns whether the fetching was successful or not."
1867 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1868 (unless (get-buffer gnus-group-buffer)
1870 (gnus-group-read-group articles nil group))
1873 (defun gnus-fetch-group-other-frame (group)
1874 "Pop up a frame and enter GROUP."
1876 (let ((window (get-buffer-window gnus-group-buffer)))
1878 (select-frame (window-frame window)))
1879 ((= (length (frame-list)) 1)
1880 (select-frame (make-frame)))
1883 (gnus-fetch-group group))
1885 (defvar gnus-ephemeral-group-server 0)
1887 ;; Enter a group that is not in the group buffer. Non-nil is returned
1888 ;; if selection was successful.
1889 (defun gnus-group-read-ephemeral-group (group method &optional activate
1890 quit-config request-only
1893 "Read GROUP from METHOD as an ephemeral group.
1894 If ACTIVATE, request the group first.
1895 If QUIT-CONFIG, use that window configuration when exiting from the
1897 If REQUEST-ONLY, don't actually read the group; just request it.
1898 If SELECT-ARTICLES, only select those articles.
1899 If PARAMETERS, use those as the group parameters.
1901 Return the name of the group if selection was successful."
1902 ;; Transform the select method into a unique server.
1903 (when (stringp method)
1904 (setq method (gnus-server-to-method method)))
1906 `(,(car method) ,(concat (cadr method) "-ephemeral")
1907 (,(intern (format "%s-address" (car method))) ,(cadr method))
1909 (let ((group (if (gnus-group-foreign-p group) group
1910 (gnus-group-prefixed-name (gnus-group-real-name group)
1915 ,gnus-level-default-subscribed nil nil ,method
1918 (cons 'quit-config quit-config)
1920 (cons gnus-summary-buffer
1921 gnus-current-window-configuration)))
1924 (push method gnus-ephemeral-servers)
1925 (set-buffer gnus-group-buffer)
1926 (unless (gnus-check-server method)
1927 (error "Unable to contact server: %s" (gnus-status-message method)))
1929 (gnus-activate-group group 'scan)
1930 (unless (gnus-request-group group)
1931 (error "Couldn't request group: %s"
1932 (nnheader-get-report (car method)))))
1936 (when (gnus-group-read-group t t group select-articles)
1940 (message "Quit reading the ephemeral group")
1943 (defun gnus-group-jump-to-group (group)
1944 "Jump to newsgroup GROUP."
1946 (list (completing-read
1947 "Group: " gnus-active-hashtb nil
1948 (gnus-read-active-file-p)
1949 gnus-group-jump-to-group-prompt
1950 'gnus-group-history)))
1952 (when (equal group "")
1953 (error "Empty group name"))
1955 (unless (gnus-ephemeral-group-p group)
1956 ;; Either go to the line in the group buffer...
1957 (unless (gnus-group-goto-group group)
1958 ;; ... or insert the line.
1959 (gnus-group-update-group group)
1960 (gnus-group-goto-group group)))
1961 ;; Adjust cursor point.
1962 (gnus-group-position-point))
1964 (defun gnus-group-goto-group (group &optional far test-marked)
1965 "Goto to newsgroup GROUP.
1966 If FAR, it is likely that the group is not on the current line.
1967 If TEST-MARKED, the line must be marked."
1971 ;; It's quite likely that we are on the right line, so
1972 ;; we check the current line first.
1974 (eq (get-text-property (point) 'gnus-group)
1975 (gnus-intern-safe group gnus-active-hashtb))
1976 (or (not test-marked) (gnus-group-mark-line-p)))
1978 ;; Previous and next line are also likely, so we check them as well.
1982 (and (eq (get-text-property (point) 'gnus-group)
1983 (gnus-intern-safe group gnus-active-hashtb))
1984 (or (not test-marked) (gnus-group-mark-line-p)))))
1990 (and (eq (get-text-property (point) 'gnus-group)
1991 (gnus-intern-safe group gnus-active-hashtb))
1992 (or (not test-marked) (gnus-group-mark-line-p)))))
1996 (goto-char (point-min))
1998 (while (and (not found)
2003 (gnus-intern-safe group gnus-active-hashtb))))
2004 (if (gnus-group-mark-line-p)
2009 ;; Search through the entire buffer.
2012 (point-min) (point-max)
2013 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2015 (defun gnus-group-next-group (n &optional silent)
2016 "Go to next N'th newsgroup.
2017 If N is negative, search backward instead.
2018 Returns the difference between N and the number of skips actually
2021 (gnus-group-next-unread-group n t nil silent))
2023 (defun gnus-group-next-unread-group (n &optional all level silent)
2024 "Go to next N'th unread newsgroup.
2025 If N is negative, search backward instead.
2026 If ALL is non-nil, choose any newsgroup, unread or not.
2027 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2028 such group can be found, the next group with a level higher than
2030 Returns the difference between N and the number of skips actually
2033 (let ((backward (< n 0))
2036 (gnus-group-search-forward
2037 backward (or (not gnus-group-goto-unread) all) level))
2041 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2042 (if level " on this level or higher" "")))
2045 (defun gnus-group-prev-group (n)
2046 "Go to previous N'th newsgroup.
2047 Returns the difference between N and the number of skips actually
2050 (gnus-group-next-unread-group (- n) t))
2052 (defun gnus-group-prev-unread-group (n)
2053 "Go to previous N'th unread newsgroup.
2054 Returns the difference between N and the number of skips actually
2057 (gnus-group-next-unread-group (- n)))
2059 (defun gnus-group-next-unread-group-same-level (n)
2060 "Go to next N'th unread newsgroup on the same level.
2061 If N is negative, search backward instead.
2062 Returns the difference between N and the number of skips actually
2065 (gnus-group-next-unread-group n t (gnus-group-group-level))
2066 (gnus-group-position-point))
2068 (defun gnus-group-prev-unread-group-same-level (n)
2069 "Go to next N'th unread newsgroup on the same level.
2070 Returns the difference between N and the number of skips actually
2073 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2074 (gnus-group-position-point))
2076 (defun gnus-group-best-unread-group (&optional exclude-group)
2077 "Go to the group with the highest level.
2078 If EXCLUDE-GROUP, do not go to that group."
2080 (goto-char (point-min))
2084 (setq unread (get-text-property (point) 'gnus-unread))
2085 (when (and (numberp unread) (> unread 0))
2086 (when (and (get-text-property (point) 'gnus-level)
2087 (< (get-text-property (point) 'gnus-level) best)
2088 (or (not exclude-group)
2089 (not (equal exclude-group (gnus-group-group-name)))))
2090 (setq best (get-text-property (point) 'gnus-level))
2091 (setq best-point (point))))
2094 (goto-char best-point))
2095 (gnus-group-position-point)
2096 (and best-point (gnus-group-group-name))))
2098 (defun gnus-group-first-unread-group ()
2099 "Go to the first group with unread articles."
2102 (let ((opoint (point))
2104 (goto-char (point-min))
2105 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2106 (and (numberp unread) ; Not a topic.
2107 (not (zerop unread))) ; Has unread articles.
2108 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2111 nil)) ; Not success.
2112 (gnus-group-position-point)))
2114 (defun gnus-group-enter-server-mode ()
2115 "Jump to the server buffer."
2117 (gnus-enter-server-buffer))
2119 (defun gnus-group-make-group (name &optional method address args)
2120 "Add a new newsgroup.
2121 The user will be prompted for a NAME, for a select METHOD, and an
2125 (gnus-read-group "Group name: ")
2126 (gnus-read-method "From method: ")))
2128 (when (stringp method)
2129 (setq method (or (gnus-server-to-method method) method)))
2130 (let* ((meth (gnus-method-simplify
2132 (not (gnus-server-equal method gnus-select-method)))
2133 (if address (list (intern method) address)
2135 (nname (if method (gnus-group-prefixed-name name meth) name))
2137 (when (gnus-gethash nname gnus-newsrc-hashtb)
2138 (error "Group %s already exists" nname))
2139 ;; Subscribe to the new group.
2140 (gnus-group-change-level
2141 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2142 gnus-level-default-subscribed gnus-level-killed
2143 (and (gnus-group-group-name)
2144 (gnus-gethash (gnus-group-group-name)
2145 gnus-newsrc-hashtb))
2148 (gnus-set-active nname (cons 1 0))
2149 (unless (gnus-ephemeral-group-p name)
2151 (concat "(gnus-group-set-info '"
2152 (gnus-prin1-to-string (cdr info)) ")")))
2154 (gnus-group-insert-group-line-info nname)
2156 (gnus-group-position-point)
2158 ;; Load the backend and try to make the backend create
2159 ;; the group as well.
2160 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2162 gnus-valid-select-methods)
2164 (gnus-check-server meth)
2165 (when (gnus-check-backend-function 'request-create-group nname)
2166 (gnus-request-create-group nname nil args))
2169 (defun gnus-group-delete-groups (&optional arg)
2170 "Delete the current group. Only meaningful with editable groups."
2172 (let ((n (length (gnus-group-process-prefix arg))))
2173 (when (gnus-yes-or-no-p
2175 "Delete this 1 group? "
2176 (format "Delete these %d groups? " n)))
2177 (gnus-group-iterate arg
2179 (gnus-group-delete-group group nil t))))))
2181 (defun gnus-group-delete-group (group &optional force no-prompt)
2182 "Delete the current group. Only meaningful with editable groups.
2183 If FORCE (the prefix) is non-nil, all the articles in the group will
2184 be deleted. This is \"deleted\" as in \"removed forever from the face
2185 of the Earth\". There is no undo. The user will be prompted before
2186 doing the deletion."
2188 (list (gnus-group-group-name)
2189 current-prefix-arg))
2191 (error "No group to delete"))
2192 (unless (gnus-check-backend-function 'request-delete-group group)
2193 (error "This backend does not support group deletion"))
2195 (if (and (not no-prompt)
2196 (not (gnus-yes-or-no-p
2198 "Do you really want to delete %s%s? "
2199 group (if force " and all its contents" "")))))
2201 (gnus-message 6 "Deleting group %s..." group)
2202 (if (not (gnus-request-delete-group group force))
2203 (gnus-error 3 "Couldn't delete group %s" group)
2204 (gnus-message 6 "Deleting group %s...done" group)
2205 (gnus-group-goto-group group)
2206 (gnus-group-kill-group 1 t)
2207 (gnus-sethash group nil gnus-active-hashtb)
2208 (when (and (boundp 'gnus-cache-active-hashtb)
2209 gnus-cache-active-hashtb)
2210 (gnus-sethash group nil gnus-cache-active-hashtb)
2211 (setq gnus-cache-active-altered t))
2213 (gnus-group-position-point)))
2215 (defun gnus-group-rename-group (group new-name)
2216 "Rename group from GROUP to NEW-NAME.
2217 When used interactively, GROUP is the group under point
2218 and NEW-NAME will be prompted for."
2221 (gnus-group-group-name)
2223 (unless (gnus-check-backend-function
2224 'request-rename-group (gnus-group-group-name))
2225 (error "This backend does not support renaming groups"))
2226 (gnus-read-group "Rename group to: "
2227 (gnus-group-real-name (gnus-group-group-name))))))
2229 (unless (gnus-check-backend-function 'request-rename-group group)
2230 (error "This backend does not support renaming groups"))
2232 (error "No group to rename"))
2233 (when (equal (gnus-group-real-name group) new-name)
2234 (error "Can't rename to the same name"))
2236 ;; We find the proper prefixed name.
2238 (if (gnus-group-native-p group)
2242 (gnus-group-prefixed-name
2243 (gnus-group-real-name new-name)
2244 (gnus-info-method (gnus-get-info group)))))
2246 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2249 (gnus-group-goto-group group)
2250 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2251 (gnus-request-rename-group group new-name))))
2252 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2253 ;; We rename the group internally by killing it...
2254 (gnus-group-kill-group)
2255 ;; ... changing its name ...
2256 (setcar (cdar gnus-list-of-killed-groups) new-name)
2257 ;; ... and then yanking it. Magic!
2258 (gnus-group-yank-group)
2259 (gnus-set-active new-name (gnus-active group))
2260 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2262 (setq gnus-killed-list (delete group gnus-killed-list))
2263 (gnus-set-active group nil)
2264 (gnus-dribble-touch)
2265 (gnus-group-position-point)))
2267 (defun gnus-group-edit-group (group &optional part)
2268 "Edit the group on the current line."
2269 (interactive (list (gnus-group-group-name)))
2270 (let ((part (or part 'info))
2273 (error "No group on current line"))
2274 (unless (setq info (gnus-get-info group))
2275 (error "Killed group; can't be edited"))
2277 (gnus-close-group group))
2279 ;; Find the proper form to edit.
2280 (cond ((eq part 'method)
2281 (or (gnus-info-method info) "native"))
2283 (gnus-info-params info))
2285 ;; The proper documentation.
2287 "Editing the %s for `%s'."
2289 ((eq part 'method) "select method")
2290 ((eq part 'params) "group parameters")
2292 (gnus-group-decoded-name group))
2294 (gnus-group-edit-group-done ',part ,group form)))
2297 (gnus-create-info-command
2300 "(gnus)Select Methods")
2302 "(gnus)Group Parameters")
2304 "(gnus)Group Info"))))))
2306 (defun gnus-group-edit-group-method (group)
2307 "Edit the select method of GROUP."
2308 (interactive (list (gnus-group-group-name)))
2309 (gnus-group-edit-group group 'method))
2311 (defun gnus-group-edit-group-parameters (group)
2312 "Edit the group parameters of GROUP."
2313 (interactive (list (gnus-group-group-name)))
2314 (gnus-group-edit-group group 'params))
2316 (defun gnus-group-edit-group-done (part group form)
2318 (let* ((method (cond ((eq part 'info) (nth 4 form))
2319 ((eq part 'method) form)
2321 (info (cond ((eq part 'info) form)
2322 ((eq part 'method) (gnus-get-info group))
2325 (if (or (not method)
2327 gnus-select-method method))
2328 (gnus-group-real-name (car info))
2329 (gnus-group-prefixed-name
2330 (gnus-group-real-name (car info)) method))
2332 (when (and new-group
2333 (not (equal new-group group)))
2334 (when (gnus-group-goto-group group)
2335 (gnus-group-kill-group 1))
2336 (gnus-activate-group new-group))
2338 (if (not (and info new-group))
2339 (gnus-group-set-info form (or new-group group) part)
2340 (setq info (gnus-copy-sequence info))
2341 (setcar info new-group)
2342 (unless (gnus-server-equal method "native")
2343 (unless (nthcdr 3 info)
2344 (nconc info (list nil nil)))
2345 (unless (nthcdr 4 info)
2346 (nconc info (list nil)))
2347 (gnus-info-set-method info method))
2348 (gnus-group-set-info info))
2349 (gnus-group-update-group (or new-group group))
2350 (gnus-group-position-point)))
2352 (defun gnus-group-make-useful-group (group method)
2353 "Create one of the groups described in `gnus-useful-groups'."
2355 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2357 gnus-useful-groups)))
2358 (list (cadr entry) (caddr entry))))
2359 (setq method (gnus-copy-sequence method))
2361 (while (setq entry (memq (assq 'eval method) method))
2362 (setcar entry (eval (cadar entry)))))
2363 (gnus-group-make-group group method))
2365 (defun gnus-group-make-help-group (&optional noerror)
2366 "Create the Gnus documentation group.
2367 Optional argument NOERROR modifies the behavior of this function when the
2368 group already exists:
2369 - if not given, and error is signaled,
2370 - if t, stay silent,
2371 - if anything else, just print a message."
2373 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2374 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2375 (if (gnus-gethash name gnus-newsrc-hashtb)
2376 (cond ((eq noerror nil)
2377 (error "Documentation group already exists"))
2382 (gnus-message 1 "Documentation group already exists")))
2385 (gnus-message 1 "Couldn't find doc group")
2386 (gnus-group-make-group
2387 (gnus-group-real-name name)
2388 (list 'nndoc "gnus-help"
2389 (list 'nndoc-address file)
2390 (list 'nndoc-article-type 'mbox))))
2392 (gnus-group-position-point))
2394 (defun gnus-group-make-doc-group (file type)
2395 "Create a group that uses a single file as the source."
2397 (list (read-file-name "File name: ")
2398 (and current-prefix-arg 'ask)))
2399 (when (eq type 'ask)
2404 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2406 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2407 ((= char ?b) 'babyl)
2408 ((= char ?d) 'digest)
2409 ((= char ?f) 'forward)
2411 ((= char ?g) 'guess)
2412 (t (setq err (format "%c unknown. " char))
2415 (let* ((file (expand-file-name file))
2416 (name (gnus-generate-new-group-name
2417 (gnus-group-prefixed-name
2418 (file-name-nondirectory file) '(nndoc "")))))
2419 (gnus-group-make-group
2420 (gnus-group-real-name name)
2422 (list 'nndoc-address file)
2423 (list 'nndoc-article-type (or type 'guess))))))
2425 (defvar nnweb-type-definition)
2426 (defvar gnus-group-web-type-history nil)
2427 (defvar gnus-group-web-search-history nil)
2428 (defun gnus-group-make-web-group (&optional solid)
2429 "Create an ephemeral nnweb group.
2430 If SOLID (the prefix), create a solid group."
2434 (if solid (gnus-read-group "Group name: ")
2435 (message-unique-id)))
2436 (default-type (or (car gnus-group-web-type-history)
2437 (symbol-name (caar nnweb-type-definition))))
2441 (format "Search engine type (default %s): " default-type)
2442 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2443 nnweb-type-definition)
2444 nil t nil 'gnus-group-web-type-history)
2449 (cons (or (car gnus-group-web-search-history) "") 0)
2450 'gnus-group-web-search-history))
2452 `(nnweb ,group (nnweb-search ,search)
2453 (nnweb-type ,(intern type))
2454 (nnweb-ephemeral-p t))))
2456 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2457 (gnus-group-read-ephemeral-group
2459 (cons (current-buffer)
2460 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2462 (defvar nnwarchive-type-definition)
2463 (defvar gnus-group-warchive-type-history nil)
2464 (defvar gnus-group-warchive-login-history nil)
2465 (defvar gnus-group-warchive-address-history nil)
2467 (defun gnus-group-make-warchive-group ()
2468 "Create a nnwarchive group."
2470 (require 'nnwarchive)
2471 (let* ((group (gnus-read-group "Group name: "))
2472 (default-type (or (car gnus-group-warchive-type-history)
2473 (symbol-name (caar nnwarchive-type-definition))))
2477 (format "Warchive type (default %s): " default-type)
2478 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2479 nnwarchive-type-definition)
2480 nil t nil 'gnus-group-warchive-type-history)
2482 (address (read-string "Warchive address: "
2483 nil 'gnus-group-warchive-address-history))
2484 (default-login (or (car gnus-group-warchive-login-history)
2489 (format "Warchive login (default %s): " user-mail-address)
2490 default-login 'gnus-group-warchive-login-history)
2493 `(nnwarchive ,address
2494 (nnwarchive-type ,(intern type))
2495 (nnwarchive-login ,login))))
2496 (gnus-group-make-group group method)))
2498 (defun gnus-group-make-archive-group (&optional all)
2499 "Create the (ding) Gnus archive group of the most recent articles.
2500 Given a prefix, create a full group."
2502 (let ((group (gnus-group-prefixed-name
2503 (if all "ding.archives" "ding.recent") '(nndir ""))))
2504 (when (gnus-gethash group gnus-newsrc-hashtb)
2505 (error "Archive group already exists"))
2506 (gnus-group-make-group
2507 (gnus-group-real-name group)
2508 (list 'nndir (if all "hpc" "edu")
2509 (list 'nndir-directory
2510 (if all gnus-group-archive-directory
2511 gnus-group-recent-archive-directory))))
2512 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2514 (defun gnus-group-make-directory-group (dir)
2515 "Create an nndir group.
2516 The user will be prompted for a directory. The contents of this
2517 directory will be used as a newsgroup. The directory should contain
2518 mail messages or news articles in files that have numeric names."
2520 (list (read-file-name "Create group from directory: ")))
2521 (unless (file-exists-p dir)
2522 (error "No such directory"))
2523 (unless (file-directory-p dir)
2524 (error "Not a directory"))
2528 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2530 (gnus-group-prefixed-name
2531 (expand-file-name ext dir)
2533 (setq ext (format "<%d>" (setq i (1+ i)))))
2534 (gnus-group-make-group
2535 (gnus-group-real-name group)
2536 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2538 (eval-when-compile (defvar nnkiboze-score-file))
2539 (defun gnus-group-make-kiboze-group (group address scores)
2540 "Create an nnkiboze group.
2541 The user will be prompted for a name, a regexp to match groups, and
2542 score file entries for articles to include in the group."
2545 (read-string "nnkiboze group name: ")
2546 (read-string "Source groups (regexp): ")
2547 (let ((headers (mapcar (lambda (group) (list group))
2548 '("subject" "from" "number" "date" "message-id"
2549 "references" "chars" "lines" "xref"
2550 "followup" "all" "body" "head")))
2551 scores header regexp regexps)
2552 (while (not (equal "" (setq header (completing-read
2553 "Match on header: " headers nil t))))
2555 (while (not (equal "" (setq regexp (read-string
2556 (format "Match on %s (regexp): "
2558 (push (list regexp nil nil 'r) regexps))
2559 (push (cons header regexps) scores))
2561 (gnus-group-make-group group "nnkiboze" address)
2562 (let* ((nnkiboze-current-group group)
2563 (score-file (car (nnkiboze-score-file "")))
2564 (score-dir (file-name-directory score-file)))
2565 (unless (file-exists-p score-dir)
2566 (make-directory score-dir))
2567 (with-temp-file score-file
2568 (let (emacs-lisp-mode-hook)
2569 (pp scores (current-buffer))))))
2571 (defun gnus-group-add-to-virtual (n vgroup)
2572 "Add the current group to a virtual group."
2574 (list current-prefix-arg
2575 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2577 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2578 (error "%s is not an nnvirtual group" vgroup))
2579 (gnus-close-group vgroup)
2580 (let* ((groups (gnus-group-process-prefix n))
2581 (method (gnus-info-method (gnus-get-info vgroup))))
2582 (setcar (cdr method)
2584 (nth 1 method) "\\|"
2587 (gnus-group-remove-mark s)
2588 (concat "\\(^" (regexp-quote s) "$\\)"))
2590 (gnus-group-position-point))
2592 (defun gnus-group-make-empty-virtual (group)
2593 "Create a new, fresh, empty virtual group."
2594 (interactive "sCreate new, empty virtual group: ")
2595 (let* ((method (list 'nnvirtual "^$"))
2596 (pgroup (gnus-group-prefixed-name group method)))
2597 ;; Check whether it exists already.
2598 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2599 (error "Group %s already exists" pgroup))
2600 ;; Subscribe the new group after the group on the current line.
2601 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2602 (gnus-group-update-group pgroup)
2604 (gnus-group-position-point)))
2606 (defun gnus-group-enter-directory (dir)
2607 "Enter an ephemeral nneething group."
2608 (interactive "DDirectory to read: ")
2609 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2610 (leaf (gnus-group-prefixed-name
2611 (file-name-nondirectory (directory-file-name dir))
2613 (name (gnus-generate-new-group-name leaf)))
2614 (unless (gnus-group-read-ephemeral-group
2616 (cons (current-buffer)
2617 (if (eq major-mode 'gnus-summary-mode)
2619 (error "Couldn't enter %s" dir))))
2622 (autoload 'nnimap-expunge "nnimap")
2623 (autoload 'nnimap-acl-get "nnimap")
2624 (autoload 'nnimap-acl-edit "nnimap"))
2626 (defun gnus-group-nnimap-expunge (group)
2627 "Expunge deleted articles in current nnimap GROUP."
2628 (interactive (list (gnus-group-group-name)))
2629 (let ((mailbox (gnus-group-real-name group)) method)
2631 (error "No group on current line"))
2632 (unless (gnus-get-info group)
2633 (error "Killed group; can't be edited"))
2634 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2635 (error "%s is not an nnimap group" group))
2636 (nnimap-expunge mailbox (cadr method))))
2638 (defun gnus-group-nnimap-edit-acl (group)
2639 "Edit the Access Control List of current nnimap GROUP."
2640 (interactive (list (gnus-group-group-name)))
2641 (let ((mailbox (gnus-group-real-name group)) method acl)
2643 (error "No group on current line"))
2644 (unless (gnus-get-info group)
2645 (error "Killed group; can't be edited"))
2646 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2647 (error "%s is not an nnimap group" group))
2648 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2649 (error "Server does not support ACL's"))
2650 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2652 An access control list is a list of (identifier . rights) elements.
2654 The identifier string specifies the corresponding user. The
2655 identifier \"anyone\" is reserved to refer to the universal identity.
2657 Rights is a string listing a (possibly empty) set of alphanumeric
2658 characters, each character listing a set of operations which is being
2659 controlled. Letters are reserved for ``standard'' rights, listed
2660 below. Digits are reserved for implementation or site defined rights.
2662 l - lookup (mailbox is visible to LIST/LSUB commands)
2663 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2664 SEARCH, COPY from mailbox)
2665 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2666 w - write (STORE flags other than \\SEEN and \\DELETED)
2667 i - insert (perform APPEND, COPY into mailbox)
2668 p - post (send mail to submission address for mailbox,
2669 not enforced by IMAP4 itself)
2670 c - create and delete mailbox (CREATE new sub-mailboxes in any
2671 implementation-defined hierarchy, RENAME or DELETE mailbox)
2672 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2673 a - administer (perform SETACL)" group)
2676 ,mailbox ',method ',acl form)))))
2678 ;; Group sorting commands
2679 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2681 (defun gnus-group-sort-groups (func &optional reverse)
2682 "Sort the group buffer according to FUNC.
2683 When used interactively, the sorting function used will be
2684 determined by the `gnus-group-sort-function' variable.
2685 If REVERSE (the prefix), reverse the sorting order."
2686 (interactive (list gnus-group-sort-function current-prefix-arg))
2687 (funcall gnus-group-sort-alist-function
2688 (gnus-make-sort-function func) reverse)
2689 (gnus-group-unmark-all-groups)
2690 (gnus-group-list-groups)
2691 (gnus-dribble-touch))
2693 (defun gnus-group-sort-flat (func reverse)
2694 ;; We peel off the dummy group from the alist.
2696 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2697 (pop gnus-newsrc-alist))
2699 (setq gnus-newsrc-alist
2700 (sort gnus-newsrc-alist func))
2702 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2703 ;; Regenerate the hash table.
2704 (gnus-make-hashtable-from-newsrc-alist)))
2706 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2707 "Sort the group buffer alphabetically by group name.
2708 If REVERSE, sort in reverse order."
2710 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2712 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2713 "Sort the group buffer alphabetically by real (unprefixed) group name.
2714 If REVERSE, sort in reverse order."
2716 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2718 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2719 "Sort the group buffer by number of unread articles.
2720 If REVERSE, sort in reverse order."
2722 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2724 (defun gnus-group-sort-groups-by-level (&optional reverse)
2725 "Sort the group buffer by group level.
2726 If REVERSE, sort in reverse order."
2728 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2730 (defun gnus-group-sort-groups-by-score (&optional reverse)
2731 "Sort the group buffer by group score.
2732 If REVERSE, sort in reverse order."
2734 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2736 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2737 "Sort the group buffer by group rank.
2738 If REVERSE, sort in reverse order."
2740 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2742 (defun gnus-group-sort-groups-by-method (&optional reverse)
2743 "Sort the group buffer alphabetically by backend name.
2744 If REVERSE, sort in reverse order."
2746 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2748 (defun gnus-group-sort-groups-by-server (&optional reverse)
2749 "Sort the group buffer alphabetically by server name.
2750 If REVERSE, sort in reverse order."
2752 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2754 ;;; Selected group sorting.
2756 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2757 "Sort the process/prefixed groups."
2758 (interactive (list current-prefix-arg gnus-group-sort-function))
2759 (let ((groups (gnus-group-process-prefix n)))
2760 (funcall gnus-group-sort-selected-function
2761 groups (gnus-make-sort-function func) reverse)
2762 (gnus-group-unmark-all-groups)
2763 (gnus-group-list-groups)
2764 (gnus-dribble-touch)))
2766 (defun gnus-group-sort-selected-flat (groups func reverse)
2767 (let (entries infos)
2768 ;; First find all the group entries for these groups.
2770 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2772 ;; Then sort the infos.
2776 (lambda (entry) (car entry))
2777 (setq entries (nreverse entries)))
2780 (setq infos (nreverse infos)))
2781 ;; Go through all the infos and replace the old entries
2782 ;; with the new infos.
2784 (setcar (car entries) (pop infos))
2786 ;; Update the hashtable.
2787 (gnus-make-hashtable-from-newsrc-alist)))
2789 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2790 "Sort the group buffer alphabetically by group name.
2791 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2792 sort in reverse order."
2793 (interactive (gnus-interactive "P\ny"))
2794 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2796 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2797 "Sort the group buffer alphabetically by real group name.
2798 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2799 sort in reverse order."
2800 (interactive (gnus-interactive "P\ny"))
2801 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2803 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2804 "Sort the group buffer by number of unread articles.
2805 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2806 sort in reverse order."
2807 (interactive (gnus-interactive "P\ny"))
2808 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2810 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2811 "Sort the group buffer by group level.
2812 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2813 sort in reverse order."
2814 (interactive (gnus-interactive "P\ny"))
2815 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2817 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2818 "Sort the group buffer by group score.
2819 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2820 sort in reverse order."
2821 (interactive (gnus-interactive "P\ny"))
2822 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2824 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2825 "Sort the group buffer by group rank.
2826 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2827 sort in reverse order."
2828 (interactive (gnus-interactive "P\ny"))
2829 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2831 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2832 "Sort the group buffer alphabetically by backend name.
2833 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2834 sort in reverse order."
2835 (interactive (gnus-interactive "P\ny"))
2836 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2838 ;;; Sorting predicates.
2840 (defun gnus-group-sort-by-alphabet (info1 info2)
2841 "Sort alphabetically."
2842 (string< (gnus-info-group info1) (gnus-info-group info2)))
2844 (defun gnus-group-sort-by-real-name (info1 info2)
2845 "Sort alphabetically on real (unprefixed) names."
2846 (string< (gnus-group-real-name (gnus-info-group info1))
2847 (gnus-group-real-name (gnus-info-group info2))))
2849 (defun gnus-group-sort-by-unread (info1 info2)
2850 "Sort by number of unread articles."
2851 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2852 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2853 (< (or (and (numberp n1) n1) 0)
2854 (or (and (numberp n2) n2) 0))))
2856 (defun gnus-group-sort-by-level (info1 info2)
2858 (< (gnus-info-level info1) (gnus-info-level info2)))
2860 (defun gnus-group-sort-by-method (info1 info2)
2861 "Sort alphabetically by backend name."
2862 (string< (car (gnus-find-method-for-group
2863 (gnus-info-group info1) info1))
2864 (car (gnus-find-method-for-group
2865 (gnus-info-group info2) info2))))
2867 (defun gnus-group-sort-by-server (info1 info2)
2868 "Sort alphabetically by server name."
2869 (string< (gnus-method-to-full-server-name
2870 (gnus-find-method-for-group
2871 (gnus-info-group info1) info1))
2872 (gnus-method-to-full-server-name
2873 (gnus-find-method-for-group
2874 (gnus-info-group info2) info2))))
2876 (defun gnus-group-sort-by-score (info1 info2)
2877 "Sort by group score."
2878 (> (gnus-info-score info1) (gnus-info-score info2)))
2880 (defun gnus-group-sort-by-rank (info1 info2)
2881 "Sort by level and score."
2882 (let ((level1 (gnus-info-level info1))
2883 (level2 (gnus-info-level info2)))
2884 (or (< level1 level2)
2885 (and (= level1 level2)
2886 (> (gnus-info-score info1) (gnus-info-score info2))))))
2890 (defun gnus-group-clear-data (&optional arg)
2891 "Clear all marks and read ranges from the current group."
2893 (gnus-group-iterate arg
2896 (gnus-info-clear-data (setq info (gnus-get-info group)))
2897 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2898 (when (gnus-group-goto-group group)
2899 (gnus-group-update-group-line))))))
2901 (defun gnus-group-clear-data-on-native-groups ()
2902 "Clear all marks and read ranges from all native groups."
2904 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2905 (let ((alist (cdr gnus-newsrc-alist))
2907 (while (setq info (pop alist))
2908 (when (gnus-group-native-p (gnus-info-group info))
2909 (gnus-info-clear-data info)))
2910 (gnus-get-unread-articles)
2911 (gnus-dribble-touch)
2912 (when (gnus-y-or-n-p
2913 "Move the cache away to avoid problems in the future? ")
2914 (call-interactively 'gnus-cache-move-cache)))))
2916 (defun gnus-info-clear-data (info)
2917 "Clear all marks and read ranges from INFO."
2918 (let ((group (gnus-info-group info))
2920 (dolist (el (gnus-info-marks info))
2921 (push `(,(cdr el) add (,(car el))) action))
2922 (push `(,(gnus-info-read info) add (read)) action)
2925 (gnus-request-set-mark ,group ',action)
2926 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2927 (gnus-info-set-read ',info ',(gnus-info-read info))
2928 (when (gnus-group-goto-group ,group)
2929 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
2930 (gnus-group-update-group-line))))
2931 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
2933 (gnus-request-set-mark group action)
2934 (gnus-info-set-read info nil)
2935 (when (gnus-info-marks info)
2936 (gnus-info-set-marks info nil))))
2938 ;; Group catching up.
2940 (defun gnus-group-catchup-current (&optional n all)
2941 "Mark all unread articles in the current newsgroup as read.
2942 If prefix argument N is numeric, the next N newsgroups will be
2943 caught up. If ALL is non-nil, marked articles will also be marked as
2944 read. Cross references (Xref: header) of articles are ignored.
2945 The number of newsgroups that this function was unable to catch
2948 (let ((groups (gnus-group-process-prefix n))
2951 (unless groups (error "No groups selected"))
2953 (or (not gnus-interactive-catchup) ;Without confirmation?
2958 "Do you really want to mark all articles in %s as read? "
2959 "Mark all unread articles in %s as read? ")
2960 (if (= (length groups) 1)
2962 (format "these %d groups" (length groups)))))))
2964 (while (setq group (pop groups))
2965 (gnus-group-remove-mark group)
2966 ;; Virtual groups have to be given special treatment.
2967 (let ((method (gnus-find-method-for-group group)))
2968 (when (eq 'nnvirtual (car method))
2969 (nnvirtual-catchup-group
2970 (gnus-group-real-name group) (nth 1 method) all)))
2971 (if (>= (gnus-group-level group) gnus-level-zombie)
2972 (gnus-message 2 "Dead groups can't be caught up")
2974 (gnus-group-goto-group group)
2975 (gnus-group-catchup group all))
2976 (gnus-group-update-group-line)
2977 (setq ret (1+ ret)))))
2978 (gnus-group-next-unread-group 1)
2981 (defun gnus-group-catchup-current-all (&optional n)
2982 "Mark all articles in current newsgroup as read.
2983 Cross references (Xref: header) of articles are ignored."
2985 (gnus-group-catchup-current n 'all))
2987 (defun gnus-group-catchup (group &optional all)
2988 "Mark all articles in GROUP as read.
2989 If ALL is non-nil, all articles are marked as read.
2990 The return value is the number of articles that were marked as read,
2991 or nil if no action could be taken."
2992 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2994 (marks (nth 3 (nth 2 entry)))
2995 (unread (gnus-list-of-unread-articles group)))
2996 ;; Remove entries for this group.
2997 (nnmail-purge-split-history (gnus-group-real-name group))
2998 ;; Do the updating only if the newsgroup isn't killed.
2999 (if (not (numberp (car entry)))
3000 (gnus-message 1 "Can't catch up %s; non-active group" group)
3001 (gnus-update-read-articles group nil)
3003 ;; Nix out the lists of marks and dormants.
3004 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3006 (list (cdr (assq 'dormant marks))
3008 (setq unread (gnus-uncompress-range
3009 (gnus-range-add (gnus-range-add
3010 unread (cdr (assq 'dormant marks)))
3011 (cdr (assq 'tick marks)))))
3012 (gnus-add-marked-articles group 'tick nil nil 'force)
3013 (gnus-add-marked-articles group 'dormant nil nil 'force))
3014 ;; Do auto-expirable marks if that's required.
3015 (when (gnus-group-auto-expirable-p group)
3016 (gnus-add-marked-articles group 'expire unread)
3017 (gnus-request-set-mark group (list (list unread 'add '(expire)))))
3018 (let ((gnus-newsgroup-name group))
3019 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3022 (defun gnus-group-expire-articles (&optional n)
3023 "Expire all expirable articles in the current newsgroup."
3025 (let ((groups (gnus-group-process-prefix n))
3028 (error "No groups to expire"))
3029 (while (setq group (pop groups))
3030 (gnus-group-remove-mark group)
3031 (gnus-group-expire-articles-1 group)
3032 (gnus-dribble-touch)
3033 (gnus-group-position-point))))
3035 (defun gnus-group-expire-articles-1 (group)
3036 (when (gnus-check-backend-function 'request-expire-articles group)
3037 (gnus-message 6 "Expiring articles in %s..." group)
3038 (let* ((info (gnus-get-info group))
3039 (expirable (if (gnus-group-total-expirable-p group)
3040 (cons nil (gnus-list-of-read-articles group))
3041 (assq 'expire (gnus-info-marks info))))
3042 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3043 (nnmail-expiry-target
3044 (or (gnus-group-find-parameter group 'expiry-target)
3045 nnmail-expiry-target)))
3047 (gnus-check-group group)
3050 (gnus-compress-sequence
3052 ;; We set the expiry variables to the group
3054 (let ((nnmail-expiry-wait-function nil)
3055 (nnmail-expiry-wait expiry-wait))
3056 (gnus-request-expire-articles
3057 (gnus-uncompress-sequence (cdr expirable)) group))
3058 ;; Just expire using the normal expiry values.
3059 (gnus-request-expire-articles
3060 (gnus-uncompress-sequence (cdr expirable)) group))))
3061 (gnus-close-group group))
3062 (gnus-message 6 "Expiring articles in %s...done" group)
3063 ;; Return the list of un-expired articles.
3066 (defun gnus-group-expire-all-groups ()
3067 "Expire all expirable articles in all newsgroups."
3070 (gnus-message 5 "Expiring...")
3071 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3072 (cdr gnus-newsrc-alist))))
3073 (gnus-group-expire-articles nil)))
3074 (gnus-group-position-point)
3075 (gnus-message 5 "Expiring...done"))
3077 (defun gnus-group-set-current-level (n level)
3078 "Set the level of the next N groups to LEVEL."
3083 (let ((s (read-string
3084 (format "Level (default %s): "
3085 (or (gnus-group-group-level)
3086 gnus-level-default-subscribed)))))
3087 (if (string-match "^\\s-*$" s)
3088 (int-to-string (or (gnus-group-group-level)
3089 gnus-level-default-subscribed))
3091 (unless (and (>= level 1) (<= level gnus-level-killed))
3092 (error "Invalid level: %d" level))
3093 (let ((groups (gnus-group-process-prefix n))
3095 (while (setq group (pop groups))
3096 (gnus-group-remove-mark group)
3097 (gnus-message 6 "Changed level of %s from %d to %d"
3098 group (or (gnus-group-group-level) gnus-level-killed)
3100 (gnus-group-change-level
3101 group level (or (gnus-group-group-level) gnus-level-killed))
3102 (gnus-group-update-group-line)))
3103 (gnus-group-position-point))
3105 (defun gnus-group-unsubscribe (&optional n)
3106 "Unsubscribe the current group."
3108 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3110 (defun gnus-group-subscribe (&optional n)
3111 "Subscribe the current group."
3113 (gnus-group-unsubscribe-current-group n 'subscribe))
3115 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3116 "Toggle subscription of the current group.
3117 If given numerical prefix, toggle the N next groups."
3119 (let ((groups (gnus-group-process-prefix n))
3122 (setq group (car groups)
3123 groups (cdr groups))
3124 (gnus-group-remove-mark group)
3125 (gnus-group-unsubscribe-group
3128 ((eq do-sub 'unsubscribe)
3129 gnus-level-default-unsubscribed)
3130 ((eq do-sub 'subscribe)
3131 gnus-level-default-subscribed)
3132 ((<= (gnus-group-group-level) gnus-level-subscribed)
3133 gnus-level-default-unsubscribed)
3135 gnus-level-default-subscribed))
3137 (gnus-group-update-group-line))
3138 (gnus-group-next-group 1)))
3140 (defun gnus-group-unsubscribe-group (group &optional level silent)
3141 "Toggle subscription to GROUP.
3142 Killed newsgroups are subscribed. If SILENT, don't try to update the
3145 (list (completing-read
3146 "Group: " gnus-active-hashtb nil
3147 (gnus-read-active-file-p)
3149 'gnus-group-history)))
3150 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3152 ((string-match "^[ \t]*$" group)
3153 (error "Empty group name"))
3155 ;; Toggle subscription flag.
3156 (gnus-group-change-level
3157 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3158 gnus-level-subscribed)
3159 (1+ gnus-level-subscribed)
3160 gnus-level-default-subscribed)))
3162 (gnus-group-update-group group)))
3163 ((and (stringp group)
3164 (or (not (gnus-read-active-file-p))
3165 (gnus-active group)))
3166 ;; Add new newsgroup.
3167 (gnus-group-change-level
3169 (if level level gnus-level-default-subscribed)
3170 (or (and (member group gnus-zombie-list)
3173 (when (gnus-group-group-name)
3174 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3176 (gnus-group-update-group group)))
3177 (t (error "No such newsgroup: %s" group)))
3178 (gnus-group-position-point)))
3180 (defun gnus-group-transpose-groups (n)
3181 "Move the current newsgroup up N places.
3182 If given a negative prefix, move down instead. The difference between
3183 N and the number of steps taken is returned."
3185 (unless (gnus-group-group-name)
3186 (error "No group on current line"))
3187 (gnus-group-kill-group 1)
3189 (forward-line (- n))
3190 (gnus-group-yank-group)
3191 (gnus-group-position-point)))
3193 (defun gnus-group-kill-all-zombies (&optional dummy)
3194 "Kill all zombie newsgroups.
3195 The optional DUMMY should always be nil."
3196 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3198 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3199 (setq gnus-zombie-list nil)
3200 (gnus-dribble-touch)
3201 (gnus-group-list-groups)))
3203 (defun gnus-group-kill-region (begin end)
3204 "Kill newsgroups in current region (excluding current point).
3205 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3220 (beginning-of-line) ;Important when LINES < 1
3221 (gnus-group-kill-group lines)))
3223 (defun gnus-group-kill-group (&optional n discard)
3224 "Kill the next N groups.
3225 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3226 However, only groups that were alive can be yanked; already killed
3227 groups or zombie groups can't be yanked.
3228 The return value is the name of the group that was killed, or a list
3231 (let ((buffer-read-only nil)
3232 (groups (gnus-group-process-prefix n))
3233 group entry level out)
3234 (if (< (length groups) 10)
3235 ;; This is faster when there are few groups.
3237 (push (setq group (pop groups)) out)
3238 (gnus-group-remove-mark group)
3239 (setq level (gnus-group-group-level))
3241 (when (and (not discard)
3242 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3245 (gnus-group-goto-group ,(gnus-group-group-name))
3246 (gnus-group-yank-group)))
3247 (push (cons (car entry) (nth 2 entry))
3248 gnus-list-of-killed-groups))
3249 (gnus-group-change-level
3250 (if entry entry group) gnus-level-killed (if entry nil level))
3251 (message "Killed group %s" group))
3252 ;; If there are lots and lots of groups to be killed, we use
3253 ;; this thing instead.
3255 (setq groups (nreverse groups))
3257 (gnus-group-remove-mark (setq group (pop groups)))
3259 (push group gnus-killed-list)
3260 (setq gnus-newsrc-alist
3261 (delq (assoc group gnus-newsrc-alist)
3263 (when gnus-group-change-level-function
3264 (funcall gnus-group-change-level-function
3265 group gnus-level-killed 3))
3267 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3268 (push (cons (car entry) (nth 2 entry))
3269 gnus-list-of-killed-groups)
3270 (setcdr (cdr entry) (cdddr entry)))
3271 ((member group gnus-zombie-list)
3272 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3273 ;; There may be more than one instance displayed.
3274 (while (gnus-group-goto-group group)
3275 (gnus-delete-line)))
3276 (gnus-make-hashtable-from-newsrc-alist)))
3278 (gnus-group-position-point)
3279 (if (< (length out) 2) (car out) (nreverse out))))
3281 (defun gnus-group-yank-group (&optional arg)
3282 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3283 The numeric ARG specifies how many newsgroups are to be yanked. The
3284 name of the newsgroup yanked is returned, or (if several groups are
3285 yanked) a list of yanked groups is returned."
3287 (setq arg (or arg 1))
3288 (let (info group prev out)
3289 (while (>= (decf arg) 0)
3290 (when (not (setq info (pop gnus-list-of-killed-groups)))
3291 (error "No more newsgroups to yank"))
3292 (push (setq group (nth 1 info)) out)
3293 ;; Find which newsgroup to insert this one before - search
3294 ;; backward until something suitable is found. If there are no
3295 ;; other newsgroups in this buffer, just make this newsgroup the
3297 (setq prev (gnus-group-group-name))
3298 (gnus-group-change-level
3299 info (gnus-info-level (cdr info)) gnus-level-killed
3300 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3302 (gnus-group-insert-group-line-info group)
3304 `(when (gnus-group-goto-group ,group)
3305 (gnus-group-kill-group 1))))
3307 (gnus-group-position-point)
3308 (if (< (length out) 2) (car out) (nreverse out))))
3310 (defun gnus-group-kill-level (level)
3311 "Kill all groups that is on a certain LEVEL."
3312 (interactive "nKill all groups on level: ")
3314 ((= level gnus-level-zombie)
3315 (setq gnus-killed-list
3316 (nconc gnus-zombie-list gnus-killed-list))
3317 (setq gnus-zombie-list nil))
3318 ((and (< level gnus-level-zombie)
3320 (or gnus-expert-user
3323 "Do you really want to kill all groups on level %d? "
3325 (let* ((prev gnus-newsrc-alist)
3328 (if (= (gnus-info-level (car alist)) level)
3330 (push (gnus-info-group (car alist)) gnus-killed-list)
3331 (setcdr prev (cdr alist)))
3333 (setq alist (cdr alist)))
3334 (gnus-make-hashtable-from-newsrc-alist)
3335 (gnus-group-list-groups)))
3337 (error "Can't kill; invalid level: %d" level))))
3339 (defun gnus-group-list-all-groups (&optional arg)
3340 "List all newsgroups with level ARG or lower.
3341 Default is gnus-level-unsubscribed, which lists all subscribed and most
3342 unsubscribed groups."
3344 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3346 ;; Redefine this to list ALL killed groups if prefix arg used.
3347 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3348 (defun gnus-group-list-killed (&optional arg)
3349 "List all killed newsgroups in the group buffer.
3350 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3351 entail asking the server for the groups."
3353 ;; Find all possible killed newsgroups if arg.
3355 (gnus-get-killed-groups))
3356 (if (not gnus-killed-list)
3357 (gnus-message 6 "No killed groups")
3358 (let (gnus-group-list-mode)
3359 (funcall gnus-group-prepare-function
3360 gnus-level-killed t gnus-level-killed))
3361 (goto-char (point-min)))
3362 (gnus-group-position-point))
3364 (defun gnus-group-list-zombies ()
3365 "List all zombie newsgroups in the group buffer."
3367 (if (not gnus-zombie-list)
3368 (gnus-message 6 "No zombie groups")
3369 (let (gnus-group-list-mode)
3370 (funcall gnus-group-prepare-function
3371 gnus-level-zombie t gnus-level-zombie))
3372 (goto-char (point-min)))
3373 (gnus-group-position-point))
3375 (defun gnus-group-list-active ()
3376 "List all groups that are available from the server(s)."
3378 ;; First we make sure that we have really read the active file.
3379 (unless (gnus-read-active-file-p)
3380 (let ((gnus-read-active-file t)
3381 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3382 (gnus-read-active-file)))
3383 ;; Find all groups and sort them.
3391 (push (symbol-name sym) list)))
3395 (buffer-read-only nil)
3399 (setq group (pop groups))
3400 (gnus-add-text-properties
3401 (point) (prog1 (1+ (point))
3403 (gnus-group-decoded-name group)
3405 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3407 'gnus-level (inline (gnus-group-level group)))))
3408 (goto-char (point-min))))
3410 (defun gnus-activate-all-groups (level)
3411 "Activate absolutely all groups."
3412 (interactive (list gnus-level-unsubscribed))
3413 (let ((gnus-activate-level level)
3414 (gnus-activate-foreign-newsgroups level))
3415 (gnus-group-get-new-news)))
3417 (defun gnus-group-get-new-news (&optional arg)
3418 "Get newly arrived articles.
3419 If ARG is a number, it specifies which levels you are interested in
3420 re-scanning. If ARG is non-nil and not a number, this will force
3421 \"hard\" re-reading of the active files from all servers."
3424 (let ((gnus-inhibit-demon t)
3425 ;; Binding this variable will inhibit multiple fetchings
3426 ;; of the same mail source.
3427 (nnmail-fetched-sources (list t)))
3428 (gnus-run-hooks 'gnus-get-new-news-hook)
3430 ;; Read any slave files.
3432 (gnus-master-read-slave-newsrc))
3434 ;; We might read in new NoCeM messages here.
3435 (when (and gnus-use-nocem
3437 (gnus-nocem-scan-groups))
3438 ;; If ARG is not a number, then we read the active file.
3439 (when (and arg (not (numberp arg)))
3440 (let ((gnus-read-active-file t))
3441 (gnus-read-active-file))
3444 ;; If the user wants it, we scan for new groups.
3445 (when (eq gnus-check-new-newsgroups 'always)
3446 (gnus-find-new-newsgroups)))
3448 (setq arg (gnus-group-default-level arg t))
3449 (if (and gnus-read-active-file (not arg))
3451 (gnus-read-active-file)
3452 (gnus-get-unread-articles arg))
3453 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3454 (gnus-get-unread-articles arg)))
3455 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3456 (gnus-group-list-groups (and (numberp arg)
3457 (max (car gnus-group-list-mode) arg)))))
3459 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3460 "Check for newly arrived news in the current group (and the N-1 next groups).
3461 The difference between N and the number of newsgroup checked is returned.
3462 If N is negative, this group and the N-1 previous groups will be checked."
3464 (let* ((groups (gnus-group-process-prefix n))
3465 (ret (if (numberp n) (- n (length groups)) 0))
3469 (gnus-inhibit-demon t)
3470 ;; Binding this variable will inhibit multiple fetchings
3471 ;; of the same mail source.
3472 (nnmail-fetched-sources (list t)))
3473 (gnus-run-hooks 'gnus-get-new-news-hook)
3474 (while (setq group (pop groups))
3475 (gnus-group-remove-mark group)
3476 ;; Bypass any previous denials from the server.
3477 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3478 (if (gnus-activate-group group (if dont-scan nil 'scan))
3480 (gnus-get-unread-articles-in-group
3481 (gnus-get-info group) (gnus-active group) t)
3482 (unless (gnus-virtual-group-p group)
3483 (gnus-close-group group))
3485 (gnus-agent-save-group-info
3486 method (gnus-group-real-name group) (gnus-active group)))
3487 (gnus-group-update-group group))
3488 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3490 (gnus-error 3 "Server denied access")
3491 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3494 (when gnus-goto-next-group-when-activating
3495 (gnus-group-next-unread-group 1 t))
3496 (gnus-summary-position-point)
3499 (defun gnus-group-fetch-faq (group &optional faq-dir)
3500 "Fetch the FAQ for the current group.
3501 If given a prefix argument, prompt for the FAQ dir
3505 (gnus-group-group-name)
3506 (when current-prefix-arg
3508 "FAQ dir: " (and (listp gnus-group-faq-directory)
3510 gnus-group-faq-directory))))))
3512 (error "No group name given"))
3513 (let ((dirs (or faq-dir gnus-group-faq-directory))
3515 (unless (listp dirs)
3516 (setq dirs (list dirs)))
3517 (while (and (not found)
3518 (setq dir (pop dirs)))
3519 (let ((name (gnus-group-real-name group)))
3520 (setq file (expand-file-name name dir)))
3521 (if (not (file-exists-p file))
3522 (gnus-message 1 "No such file: %s" file)
3523 (let ((enable-local-variables nil))
3527 (defun gnus-group-fetch-charter (group)
3528 "Fetch the charter for the current group.
3529 If given a prefix argument, prompt for a group."
3531 (list (or (when current-prefix-arg
3532 (completing-read "Group: " gnus-active-hashtb))
3533 (gnus-group-group-name)
3534 gnus-newsgroup-name)))
3536 (error "No group name given"))
3538 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3540 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3541 (setq hierarchy (match-string 1 name))
3542 (if (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3543 (browse-url (eval url))
3544 (gnus-group-fetch-control group)))))
3546 (defun gnus-group-fetch-control (group)
3547 "Fetch the archived control messages for the current group.
3548 If given a prefix argument, prompt for a group."
3550 (list (or (when current-prefix-arg
3551 (completing-read "Group: " gnus-active-hashtb))
3552 (gnus-group-group-name)
3553 gnus-newsgroup-name)))
3555 (error "No group name given"))
3556 (let ((name (gnus-group-real-name group))
3558 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3559 (setq hierarchy (match-string 1 name))
3560 (if gnus-group-fetch-control-use-browse-url
3561 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3562 hierarchy "/" name ".Z"))
3563 (let ((enable-local-variables nil))
3564 (gnus-group-read-ephemeral-group
3566 `(nndoc ,group (nndoc-address
3567 ,(find-file-noselect
3568 (concat "/ftp@ftp.isc.org:/usenet/control/"
3569 hierarchy "/" name ".Z")))
3570 (nndoc-article-type mbox)) t nil nil))))))
3572 (defun gnus-group-describe-group (force &optional group)
3573 "Display a description of the current newsgroup."
3574 (interactive (list current-prefix-arg (gnus-group-group-name)))
3575 (let* ((method (gnus-find-method-for-group group))
3576 (mname (gnus-group-prefixed-name "" method))
3579 gnus-description-hashtb)
3580 (gnus-sethash mname nil gnus-description-hashtb))
3582 (error "No group name given"))
3583 (when (or (and gnus-description-hashtb
3584 ;; We check whether this group's method has been
3585 ;; queried for a description file.
3586 (gnus-gethash mname gnus-description-hashtb))
3587 (setq desc (gnus-group-get-description group))
3588 (gnus-read-descriptions-file method))
3590 (or desc (gnus-gethash group gnus-description-hashtb)
3591 "No description available")))))
3593 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3594 (defun gnus-group-describe-all-groups (&optional force)
3595 "Pop up a buffer with descriptions of all newsgroups."
3598 (setq gnus-description-hashtb nil))
3599 (when (not (or gnus-description-hashtb
3600 (gnus-read-all-descriptions-files)))
3601 (error "Couldn't request descriptions file"))
3602 (let ((buffer-read-only nil)
3608 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3609 (insert (format " *: %-20s %s\n"
3610 (gnus-group-name-decode
3611 (symbol-name group) charset)
3612 (gnus-group-name-decode
3613 (symbol-value group) charset))))
3614 (gnus-add-text-properties
3615 b (1+ b) (list 'gnus-group group
3616 'gnus-unread t 'gnus-marked nil
3617 'gnus-level (1+ gnus-level-subscribed))))
3618 gnus-description-hashtb)
3619 (goto-char (point-min))
3620 (gnus-group-position-point)))
3622 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3623 (defun gnus-group-apropos (regexp &optional search-description)
3624 "List all newsgroups that have names that match a regexp."
3625 (interactive "sGnus apropos (regexp): ")
3627 (obuf (current-buffer))
3629 ;; Go through all newsgroups that are known to Gnus.
3632 (and (symbol-name group)
3633 (string-match regexp (symbol-name group))
3634 (symbol-value group)
3635 (push (symbol-name group) groups)))
3637 ;; Also go through all descriptions that are known to Gnus.
3638 (when search-description
3641 (and (string-match regexp (symbol-value group))
3642 (push (symbol-name group) groups)))
3643 gnus-description-hashtb))
3645 (gnus-message 3 "No groups matched \"%s\"." regexp)
3646 ;; Print out all the groups.
3648 (pop-to-buffer "*Gnus Help*")
3649 (buffer-disable-undo)
3651 (setq groups (sort groups 'string<))
3653 ;; Groups may be entered twice into the list of groups.
3654 (when (not (string= (car groups) prev))
3655 (setq prev (car groups))
3656 (let ((charset (gnus-group-name-charset nil prev)))
3657 (insert (gnus-group-name-decode prev charset) "\n")
3658 (when (and gnus-description-hashtb
3659 (setq des (gnus-gethash (car groups)
3660 gnus-description-hashtb)))
3661 (insert " " (gnus-group-name-decode des charset) "\n"))))
3662 (setq groups (cdr groups)))
3663 (goto-char (point-min))))
3664 (pop-to-buffer obuf)))
3666 (defun gnus-group-description-apropos (regexp)
3667 "List all newsgroups that have names or descriptions that match a regexp."
3668 (interactive "sGnus description apropos (regexp): ")
3669 (when (not (or gnus-description-hashtb
3670 (gnus-read-all-descriptions-files)))
3671 (error "Couldn't request descriptions file"))
3672 (gnus-group-apropos regexp t))
3674 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3675 (defun gnus-group-list-matching (level regexp &optional all lowest)
3676 "List all groups with unread articles that match REGEXP.
3677 If the prefix LEVEL is non-nil, it should be a number that says which
3678 level to cut off listing groups.
3679 If ALL, also list groups with no unread articles.
3680 If LOWEST, don't list groups with level lower than LOWEST.
3682 This command may read the active file."
3683 (interactive "P\nsList newsgroups matching: ")
3684 ;; First make sure active file has been read.
3686 (> (prefix-numeric-value level) gnus-level-killed))
3687 (gnus-get-killed-groups))
3688 (funcall gnus-group-prepare-function
3689 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3690 (goto-char (point-min))
3691 (gnus-group-position-point))
3693 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3694 "List all groups that match REGEXP.
3695 If the prefix LEVEL is non-nil, it should be a number that says which
3696 level to cut off listing groups.
3697 If LOWEST, don't list groups with level lower than LOWEST."
3698 (interactive "P\nsList newsgroups matching: ")
3700 (setq level (prefix-numeric-value level)))
3701 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3703 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3704 (defun gnus-group-save-newsrc (&optional force)
3705 "Save the Gnus startup files.
3706 If FORCE, force saving whether it is necessary or not."
3708 (gnus-save-newsrc-file force))
3710 (defun gnus-group-restart (&optional arg)
3711 "Force Gnus to read the .newsrc file."
3713 (when (gnus-yes-or-no-p
3714 (format "Are you sure you want to restart Gnus? "))
3715 (gnus-save-newsrc-file)
3719 (defun gnus-group-read-init-file ()
3720 "Read the Gnus elisp init file."
3722 (gnus-read-init-file)
3723 (gnus-message 5 "Read %s" gnus-init-file))
3725 (defun gnus-group-check-bogus-groups (&optional silent)
3726 "Check bogus newsgroups.
3727 If given a prefix, don't ask for confirmation before removing a bogus
3730 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3731 (gnus-group-list-groups))
3733 (defun gnus-group-find-new-groups (&optional arg)
3734 "Search for new groups and add them.
3735 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3736 With 1 C-u, use the `ask-server' method to query the server for new
3738 With 2 C-u's, use most complete method possible to query the server
3739 for new groups, and subscribe the new groups as zombies."
3741 (gnus-find-new-newsgroups (or arg 1))
3742 (gnus-group-list-groups))
3744 (defun gnus-group-edit-global-kill (&optional article group)
3745 "Edit the global kill file.
3746 If GROUP, edit that local kill file instead."
3748 (setq gnus-current-kill-article article)
3749 (gnus-kill-file-edit-file group)
3752 (substitute-command-keys
3753 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3754 (if group "local" "global")))))
3756 (defun gnus-group-edit-local-kill (article group)
3757 "Edit a local kill file."
3758 (interactive (list nil (gnus-group-group-name)))
3759 (gnus-group-edit-global-kill article group))
3761 (defun gnus-group-force-update ()
3762 "Update `.newsrc' file."
3764 (gnus-save-newsrc-file))
3766 (defun gnus-group-suspend ()
3767 "Suspend the current Gnus session.
3768 In fact, cleanup buffers except for group mode buffer.
3769 The hook gnus-suspend-gnus-hook is called before actually suspending."
3771 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3772 (gnus-offer-save-summaries)
3773 ;; Kill Gnus buffers except for group mode buffer.
3774 (let ((group-buf (get-buffer gnus-group-buffer)))
3775 (mapcar (lambda (buf)
3776 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3780 (eq major-mode 'message-mode))))
3781 (gnus-kill-buffer buf)))
3783 (gnus-kill-gnus-frames)
3785 (bury-buffer group-buf)
3786 (delete-windows-on group-buf t))))
3788 (defun gnus-group-clear-dribble ()
3789 "Clear all information from the dribble buffer."
3791 (gnus-dribble-clear)
3792 (gnus-message 7 "Cleared dribble buffer"))
3794 (defun gnus-group-exit ()
3795 "Quit reading news after updating .newsrc.eld and .newsrc.
3796 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3799 (or noninteractive ;For gnus-batch-kill
3800 (not gnus-interactive-exit) ;Without confirmation
3802 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3803 (gnus-run-hooks 'gnus-exit-gnus-hook)
3804 ;; Offer to save data from non-quitted summary buffers.
3805 (gnus-offer-save-summaries)
3806 ;; Save the newsrc file(s).
3807 (gnus-save-newsrc-file)
3809 (gnus-close-backends)
3810 ;; Reset everything.
3812 ;; Allow the user to do things after cleaning up.
3813 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3815 (defun gnus-group-quit ()
3816 "Quit reading news without updating .newsrc.eld or .newsrc.
3817 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3819 (when (or noninteractive ;For gnus-batch-kill
3820 (zerop (buffer-size))
3821 (not (gnus-server-opened gnus-select-method))
3823 (not gnus-current-startup-file)
3825 (format "Quit reading news without saving %s? "
3826 (file-name-nondirectory gnus-current-startup-file))))
3827 (gnus-run-hooks 'gnus-exit-gnus-hook)
3828 (gnus-configure-windows 'group t)
3829 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
3830 (not (zerop (save-excursion
3831 (set-buffer gnus-dribble-buffer)
3834 ";;; Gnus was exited on purpose without saving the .newsrc files."))
3836 (gnus-close-backends)
3838 (gnus-kill-buffer gnus-group-buffer)
3839 ;; Allow the user to do things after cleaning up.
3840 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3842 (defun gnus-group-describe-briefly ()
3843 "Give a one line description of the group mode commands."
3845 (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")))
3847 (defun gnus-group-browse-foreign-server (method)
3848 "Browse a foreign news server.
3849 If called interactively, this function will ask for a select method
3850 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3851 If not, METHOD should be a list where the first element is the method
3852 and the second element is the address."
3854 (list (let ((how (completing-read
3856 (append gnus-valid-select-methods gnus-server-alist)
3857 nil t (cons "nntp" 0) 'gnus-method-history)))
3858 ;; We either got a backend name or a virtual server name.
3859 ;; If the first, we also need an address.
3860 (if (assoc how gnus-valid-select-methods)
3862 ;; Suggested by mapjph@bath.ac.uk.
3865 (mapcar (lambda (server) (list server))
3866 gnus-secondary-servers)))
3867 ;; We got a server name.
3869 (gnus-browse-foreign-server method))
3871 (defun gnus-group-set-info (info &optional method-only-group part)
3872 (when (or info part)
3873 (let* ((entry (gnus-gethash
3874 (or method-only-group (gnus-info-group info))
3875 gnus-newsrc-hashtb))
3877 (info (if method-only-group (nth 2 entry) info))
3879 (when method-only-group
3881 (error "Trying to change non-existent group %s" method-only-group))
3882 ;; We have received parts of the actual group info - either the
3883 ;; select method or the group parameters. We first check
3884 ;; whether we have to extend the info, and if so, do that.
3885 (let ((len (length info))
3886 (total (if (eq part 'method) 5 6)))
3888 (setcdr (nthcdr (1- len) info)
3889 (make-list (- total len) nil)))
3890 ;; Then we enter the new info.
3891 (setcar (nthcdr (1- total) info) part-info)))
3893 ;; This is a new group, so we just create it.
3895 (set-buffer gnus-group-buffer)
3896 (setq method (gnus-info-method info))
3897 (when (gnus-server-equal method "native")
3900 (set-buffer gnus-group-buffer)
3902 ;; It's a foreign group...
3903 (gnus-group-make-group
3904 (gnus-group-real-name (gnus-info-group info))
3905 (if (stringp method) method
3906 (prin1-to-string (car method)))
3908 (nth 1 (gnus-info-method info))))
3909 ;; It's a native group.
3910 (gnus-group-make-group (gnus-info-group info))))
3911 (gnus-message 6 "Note: New group created")
3913 (gnus-gethash (gnus-group-prefixed-name
3914 (gnus-group-real-name (gnus-info-group info))
3915 (or (gnus-info-method info) gnus-select-method))
3916 gnus-newsrc-hashtb))))
3917 ;; Whether it was a new group or not, we now have the entry, so we
3918 ;; can do the update.
3921 (setcar (nthcdr 2 entry) info)
3922 (when (and (not (eq (car entry) t))
3923 (gnus-active (gnus-info-group info)))
3924 (setcar entry (length
3925 (gnus-list-of-unread-articles (car info))))))
3926 (error "No such group: %s" (gnus-info-group info))))))
3928 (defun gnus-group-set-method-info (group select-method)
3929 (gnus-group-set-info select-method group 'method))
3931 (defun gnus-group-set-params-info (group params)
3932 (gnus-group-set-info params group 'params))
3934 (defun gnus-add-marked-articles (group type articles &optional info force)
3935 ;; Add ARTICLES of TYPE to the info of GROUP.
3936 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3937 ;; add, but replace marked articles of TYPE with ARTICLES.
3938 (let ((info (or info (gnus-get-info group)))
3941 (and (not (setq marked (nthcdr 3 info)))
3943 (setcdr (nthcdr 2 info)
3944 (list (list (cons type (gnus-compress-sequence
3946 (and (not (setq m (assq type (car marked))))
3949 (cons (cons type (gnus-compress-sequence articles t) )
3953 (setcar (nthcdr 3 info)
3954 (gnus-delete-alist type (car marked)))
3955 (setcdr m (gnus-compress-sequence articles t)))
3956 (setcdr m (gnus-compress-sequence
3957 (sort (nconc (gnus-uncompress-range (cdr m))
3958 (copy-sequence articles)) '<) t))))))
3960 (defun gnus-add-mark (group mark article)
3961 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
3962 (let ((buffer (gnus-summary-buffer-name group)))
3963 (if (gnus-buffer-live-p buffer)
3965 (set-buffer (get-buffer buffer))
3966 (gnus-summary-add-mark article mark))
3967 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
3971 ;;; Group timestamps
3974 (defun gnus-group-set-timestamp ()
3975 "Change the timestamp of the current group to the current time.
3976 This function can be used in hooks like `gnus-select-group-hook'
3977 or `gnus-group-catchup-group-hook'."
3978 (when gnus-newsgroup-name
3979 (let ((time (current-time)))
3980 (setcdr (cdr time) nil)
3981 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3983 (defsubst gnus-group-timestamp (group)
3984 "Return the timestamp for GROUP."
3985 (gnus-group-get-parameter group 'timestamp t))
3987 (defun gnus-group-timestamp-delta (group)
3988 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3989 (let* ((time (or (gnus-group-timestamp group)
3991 (delta (subtract-time (current-time) time)))
3992 (+ (* (nth 0 delta) 65536.0)
3995 (defun gnus-group-timestamp-string (group)
3996 "Return a string of the timestamp for GROUP."
3997 (let ((time (gnus-group-timestamp group)))
4000 (gnus-time-iso8601 time))))
4002 (defun gnus-group-list-cached (level &optional lowest)
4003 "List all groups with cached articles.
4004 If the prefix LEVEL is non-nil, it should be a number that says which
4005 level to cut off listing groups.
4006 If LOWEST, don't list groups with level lower than LOWEST.
4008 This command may read the active file."
4011 (setq level (prefix-numeric-value level)))
4012 (when (or (not level) (>= level gnus-level-zombie))
4014 (funcall gnus-group-prepare-function
4015 (or level gnus-level-subscribed)
4017 (let ((marks (gnus-info-marks info)))
4018 (assq 'cache marks)))
4021 (or (gnus-gethash group
4022 gnus-cache-active-hashtb)
4023 ;; Cache active file might use "."
4026 (mapconcat 'identity
4027 (split-string group ":")
4029 gnus-cache-active-hashtb))))
4030 (goto-char (point-min))
4031 (gnus-group-position-point))
4033 (defun gnus-group-list-dormant (level &optional lowest)
4034 "List all groups with dormant articles.
4035 If the prefix LEVEL is non-nil, it should be a number that says which
4036 level to cut off listing groups.
4037 If LOWEST, don't list groups with level lower than LOWEST.
4039 This command may read the active file."
4042 (setq level (prefix-numeric-value level)))
4043 (when (or (not level) (>= level gnus-level-zombie))
4045 (funcall gnus-group-prepare-function
4046 (or level gnus-level-subscribed)
4048 (let ((marks (gnus-info-marks info)))
4049 (assq 'dormant marks)))
4052 (goto-char (point-min))
4053 (gnus-group-position-point))
4055 (defun gnus-group-listed-groups ()
4056 "Return a list of listed groups."
4058 (goto-char (point-min))
4059 (while (setq point (text-property-not-all (point) (point-max)
4062 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4066 (defun gnus-group-list-plus (&optional args)
4067 "List groups plus the current selection."
4069 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4070 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4072 (push last-command-event unread-command-events)
4073 (if (featurep 'xemacs)
4074 (push (make-event 'key-press '(key ?A)) unread-command-events)
4075 (push ?A unread-command-events))
4076 (let (gnus-pick-mode keys)
4077 (setq keys (if (featurep 'xemacs)
4078 (events-to-keys (read-key-sequence nil))
4079 (read-key-sequence nil)))
4080 (setq func (lookup-key (current-local-map) keys)))
4084 (call-interactively func))))
4086 (defun gnus-group-list-flush (&optional args)
4087 "Flush groups from the current selection."
4089 (let ((gnus-group-list-option 'flush))
4090 (gnus-group-list-plus args)))
4092 (defun gnus-group-list-limit (&optional args)
4093 "List groups limited within the current selection."
4095 (let ((gnus-group-list-option 'limit))
4096 (gnus-group-list-plus args)))
4098 (defun gnus-group-mark-article-read (group article)
4099 "Mark ARTICLE read."
4100 (let ((buffer (gnus-summary-buffer-name group))
4101 (mark gnus-read-mark)
4103 (if (get-buffer buffer)
4104 (with-current-buffer buffer
4105 (setq active gnus-newsgroup-active)
4106 (gnus-activate-group group)
4107 (when gnus-newsgroup-prepared
4108 (when (and gnus-newsgroup-auto-expire
4109 (memq mark gnus-auto-expirable-marks))
4110 (setq mark gnus-expirable-mark))
4111 (setq mark (gnus-request-update-mark
4112 group article mark))
4113 (gnus-mark-article-as-read article mark)
4114 (setq gnus-newsgroup-active (gnus-active group))
4116 (setq n (1+ (cdr active)))
4117 (while (<= n (cdr gnus-newsgroup-active))
4118 (unless (eq n article)
4119 (push n gnus-newsgroup-unselected))
4121 (setq gnus-newsgroup-unselected
4122 (nreverse gnus-newsgroup-unselected)))))
4123 (gnus-activate-group group)
4124 (gnus-group-make-articles-read group
4126 (when (gnus-group-auto-expirable-p group)
4127 (gnus-add-marked-articles
4128 group 'expire (list article))))))
4130 (provide 'gnus-group)
4132 ;;; gnus-group.el ends here