1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
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.
31 (defvar tool-bar-map))
46 (let ((features (cons 'gnus-group features)))
48 (defvar gnus-cache-active-hashtb))
50 (defcustom gnus-group-archive-directory
51 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
52 "*The address of the (ding) archives."
53 :group 'gnus-group-foreign
56 (defcustom gnus-group-recent-archive-directory
57 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
58 "*The address of the most recent (ding) articles."
59 :group 'gnus-group-foreign
62 (defcustom gnus-no-groups-message "No gnus is bad news"
63 "*Message displayed by Gnus when no groups are available."
67 (defcustom gnus-keep-same-level nil
68 "*Non-nil means that the next newsgroup after the current will be on the same level.
69 When you type, for instance, `n' after reading the last article in the
70 current newsgroup, you will go to the next newsgroup. If this variable
71 is nil, the next newsgroup will be the next from the group
73 If this variable is non-nil, Gnus will either put you in the
74 next newsgroup with the same level, or, if no such newsgroup is
75 available, the next newsgroup with the lowest possible level higher
76 than the current level.
77 If this variable is `best', Gnus will make the next newsgroup the one
79 :group 'gnus-group-levels
80 :type '(choice (const nil)
82 (sexp :tag "other" t)))
84 (defcustom gnus-group-goto-unread t
85 "*If non-nil, movement commands will go to the next unread and subscribed group."
86 :link '(custom-manual "(gnus)Group Maneuvering")
87 :group 'gnus-group-various
90 (defcustom gnus-goto-next-group-when-activating t
91 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
92 :link '(custom-manual "(gnus)Scanning New Messages")
93 :group 'gnus-group-various
96 (defcustom gnus-permanently-visible-groups nil
97 "*Regexp to match groups that should always be listed in the group buffer.
98 This means that they will still be listed even when there are no
99 unread articles in the groups.
101 If nil, no groups are permanently visible."
102 :group 'gnus-group-listing
103 :type '(choice regexp (const nil)))
105 (defcustom gnus-list-groups-with-ticked-articles t
106 "*If non-nil, list groups that have only ticked articles.
107 If nil, only list groups that have unread articles."
108 :group 'gnus-group-listing
111 (defcustom gnus-group-default-list-level gnus-level-subscribed
112 "*Default listing level.
113 Ignored if `gnus-group-use-permanent-levels' is non-nil."
114 :group 'gnus-group-listing
117 (defcustom gnus-group-list-inactive-groups t
118 "*If non-nil, inactive groups will be listed."
119 :group 'gnus-group-listing
120 :group 'gnus-group-levels
123 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
124 "*Function used for sorting the group buffer.
125 This function will be called with group info entries as the arguments
126 for the groups to be sorted. Pre-made functions include
127 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
128 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
129 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
130 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
132 This variable can also be a list of sorting functions. In that case,
133 the most significant sort function should be the last function in the
135 :group 'gnus-group-listing
136 :link '(custom-manual "(gnus)Sorting Groups")
137 :type '(repeat :value-to-internal (lambda (widget value)
138 (if (listp value) value (list value)))
139 :match (lambda (widget value)
141 (widget-editable-list-match widget value)))
142 (choice (function-item gnus-group-sort-by-alphabet)
143 (function-item gnus-group-sort-by-real-name)
144 (function-item gnus-group-sort-by-unread)
145 (function-item gnus-group-sort-by-level)
146 (function-item gnus-group-sort-by-score)
147 (function-item gnus-group-sort-by-method)
148 (function-item gnus-group-sort-by-server)
149 (function-item gnus-group-sort-by-rank)
150 (function :tag "other" nil))))
152 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%l %O\n"
153 "*Format of group lines.
154 It works along the same lines as a normal formatting string,
155 with some simple extensions.
157 %M Only marked articles (character, \"*\" or \" \")
158 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
159 %L Level of subscribedness (integer)
160 %N Number of unread articles (integer)
161 %I Number of dormant articles (integer)
162 %i Number of ticked and dormant (integer)
163 %T Number of ticked articles (integer)
164 %R Number of read articles (integer)
165 %U Number of unseen articles (integer)
166 %t Estimated total number of articles (integer)
167 %y Number of unread, unticked articles (integer)
168 %G Group name (string)
169 %g Qualified group name (string)
170 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
171 %C Group comment (string)
172 %D Group description (string)
173 %s Select method (string)
174 %o Moderated group (char, \"m\")
175 %p Process mark (char)
176 %B Whether a summary buffer for the group is open (char, \"*\")
177 %O Moderated group (string, \"(m)\" or \"\")
178 %P Topic indentation (string)
179 %m Whether there is new(ish) mail in the group (char, \"%\")
180 %l Whether there are GroupLens predictions for this group (string)
181 %n Select from where (string)
182 %z A string that look like `<%s:%n>' if a foreign select method is used
183 %d The date the group was last entered.
184 %E Icon as defined by `gnus-group-icon-list'.
185 %u User defined specifier. The next character in the format string should
186 be a letter. Gnus will call the function gnus-user-format-function-X,
187 where X is the letter following %u. The function will be passed a
188 single dummy parameter as argument. The function should return a
189 string, which will be inserted into the buffer just like information
190 from any other group specifier.
192 Note that this format specification is not always respected. For
193 reasons of efficiency, when listing killed groups, this specification
194 is ignored altogether. If the spec is changed considerably, your
195 output may end up looking strange when listing both alive and killed
198 If you use %o or %O, reading the active file will be slower and quite
199 a bit of extra memory will be used. %D will also worsen performance.
200 Also note that if you change the format specification to include any
201 of these specs, you must probably re-start Gnus to see them go into
204 General format specifiers can also be used.
205 See Info node `(gnus)Formatting Variables'."
206 :link '(custom-manual "(gnus)Formatting Variables")
207 :group 'gnus-group-visual
210 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
211 "*The format specification for the group mode line.
212 It works along the same lines as a normal formatting string,
213 with some simple extensions:
215 %S The native news server.
216 %M The native select method.
217 %: \":\" if %S isn't \"\"."
218 :group 'gnus-group-visual
221 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
222 (when (featurep 'xemacs)
223 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
224 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
226 (defcustom gnus-group-menu-hook nil
227 "Hook run after the creation of the group mode menu."
228 :group 'gnus-group-various
231 (defcustom gnus-group-catchup-group-hook nil
232 "Hook run when catching up a group from the group buffer."
233 :group 'gnus-group-various
234 :link '(custom-manual "(gnus)Group Data")
237 (defcustom gnus-group-update-group-hook nil
238 "Hook called when updating group lines."
239 :group 'gnus-group-visual
242 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
243 "*A function that is called to generate the group buffer.
244 The function is called with three arguments: The first is a number;
245 all group with a level less or equal to that number should be listed,
246 if the second is non-nil, empty groups should also be displayed. If
247 the third is non-nil, it is a number. No groups with a level lower
248 than this number should be displayed.
250 The only current function implemented is `gnus-group-prepare-flat'."
251 :group 'gnus-group-listing
254 (defcustom gnus-group-prepare-hook nil
255 "Hook called after the group buffer has been generated.
256 If you want to modify the group buffer, you can use this hook."
257 :group 'gnus-group-listing
260 (defcustom gnus-suspend-gnus-hook nil
261 "Hook called when suspending (not exiting) Gnus."
265 (defcustom gnus-exit-gnus-hook nil
266 "Hook called when exiting Gnus."
270 (defcustom gnus-after-exiting-gnus-hook nil
271 "Hook called after exiting Gnus."
275 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
276 "Hook called when a group line is changed.
277 The hook will not be called if `gnus-visual' is nil.
279 The default function `gnus-group-highlight-line' will
280 highlight the line according to the `gnus-group-highlight'
282 :group 'gnus-group-visual
285 (defcustom gnus-useful-groups
286 '(("(ding) mailing list mirrored at sunsite.auc.dk"
288 (nntp "sunsite.auc.dk"
289 (nntp-address "sunsite.auc.dk")))
292 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
296 (nndoc-article-type mbox)
297 (eval `(nndoc-address
298 ,(let ((file (nnheader-find-etc-directory
301 (error "Couldn't find doc group"))
303 "*Alist of useful group-server pairs."
304 :group 'gnus-group-listing
305 :type '(repeat (list (string :tag "Description")
307 (sexp :tag "Method"))))
309 (defcustom gnus-group-highlight
311 ((and mailp (= unread 0) (eq level 1)) .
312 gnus-group-mail-1-empty)
313 ((and mailp (eq level 1)) .
315 ((and mailp (= unread 0) (eq level 2)) .
316 gnus-group-mail-2-empty)
317 ((and mailp (eq level 2)) .
319 ((and mailp (= unread 0) (eq level 3)) .
320 gnus-group-mail-3-empty)
321 ((and mailp (eq level 3)) .
323 ((and mailp (= unread 0)) .
324 gnus-group-mail-low-empty)
328 ((and (= unread 0) (eq level 1)) .
329 gnus-group-news-1-empty)
330 ((and (eq level 1)) .
332 ((and (= unread 0) (eq level 2)) .
333 gnus-group-news-2-empty)
334 ((and (eq level 2)) .
336 ((and (= unread 0) (eq level 3)) .
337 gnus-group-news-3-empty)
338 ((and (eq level 3)) .
340 ((and (= unread 0) (eq level 4)) .
341 gnus-group-news-4-empty)
342 ((and (eq level 4)) .
344 ((and (= unread 0) (eq level 5)) .
345 gnus-group-news-5-empty)
346 ((and (eq level 5)) .
348 ((and (= unread 0) (eq level 6)) .
349 gnus-group-news-6-empty)
350 ((and (eq level 6)) .
352 ((and (= unread 0)) .
353 gnus-group-news-low-empty)
355 gnus-group-news-low))
356 "*Controls the highlighting of group buffer lines.
358 Below is a list of `Form'/`Face' pairs. When deciding how a a
359 particular group line should be displayed, each form is
360 evaluated. The content of the face field after the first true form is
361 used. You can change how those group lines are displayed by
362 editing the face field.
364 It is also possible to change and add form fields, but currently that
365 requires an understanding of Lisp expressions. Hopefully this will
366 change in a future release. For now, you can use the following
367 variables in the Lisp expression:
369 group: The name of the group.
370 unread: The number of unread articles in the group.
371 method: The select method used.
372 mailp: Whether it's a mail group or not.
373 level: The level of the group.
374 score: The score of the group.
375 ticked: The number of ticked articles."
376 :group 'gnus-group-visual
377 :type '(repeat (cons (sexp :tag "Form") face)))
379 (defcustom gnus-new-mail-mark ?%
380 "Mark used for groups with new mail."
381 :group 'gnus-group-visual
384 (defgroup gnus-group-icons nil
385 "Add Icons to your group buffer."
386 :group 'gnus-group-visual)
388 (defcustom gnus-group-icon-list
390 "*Controls the insertion of icons into group buffer lines.
392 Below is a list of `Form'/`File' pairs. When deciding how a
393 particular group line should be displayed, each form is evaluated.
394 The icon from the file field after the first true form is used. You
395 can change how those group lines are displayed by editing the file
396 field. The File will either be found in the
397 `gnus-group-glyph-directory' or by designating absolute name of the
400 It is also possible to change and add form fields, but currently that
401 requires an understanding of Lisp expressions. Hopefully this will
402 change in a future release. For now, you can use the following
403 variables in the Lisp expression:
405 group: The name of the group.
406 unread: The number of unread articles in the group.
407 method: The select method used.
408 mailp: Whether it's a mail group or not.
409 newsp: Whether it's a news group or not
410 level: The level of the group.
411 score: The score of the group.
412 ticked: The number of ticked articles."
413 :group 'gnus-group-icons
414 :type '(repeat (cons (sexp :tag "Form") file)))
416 (defcustom gnus-group-name-charset-method-alist nil
417 "Alist of method and the charset for group names.
420 (((nntp \"news.com.cn\") . cn-gb-2312))"
423 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
425 (defcustom gnus-group-name-charset-group-alist
426 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
427 (mm-coding-system-p 'utf-8))
430 "Alist of group regexp and the charset for group names.
433 ((\"\\.com\\.cn:\" . cn-gb-2312))"
435 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
437 (defcustom gnus-group-jump-to-group-prompt nil
438 "Default prompt for `gnus-group-jump-to-group'.
439 If non-nil, the value should be a string, e.g. \"nnml:\",
440 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
441 in the minibuffer prompt."
443 :group 'gnus-group-various
444 :type '(choice (string :tag "Prompt string")
445 (const :tag "Empty" nil)))
447 (defvar gnus-group-listing-limit 1000
448 "*A limit of the number of groups when listing.
449 If the number of groups is larger than the limit, list them in a
452 ;;; Internal variables
454 (defvar gnus-group-is-exiting-p nil)
455 (defvar gnus-group-is-exiting-without-update-p nil)
456 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
457 "Function for sorting the group buffer.")
459 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
460 "Function for sorting the selected groups in the group buffer.")
462 (defvar gnus-group-indentation-function nil)
463 (defvar gnus-goto-missing-group-function nil)
464 (defvar gnus-group-update-group-function nil)
465 (defvar gnus-group-goto-next-group-function nil
466 "Function to override finding the next group after listing groups.")
468 (defvar gnus-group-edit-buffer nil)
470 (defvar gnus-group-line-format-alist
471 `((?M gnus-tmp-marked-mark ?c)
472 (?S gnus-tmp-subscribed ?c)
473 (?L gnus-tmp-level ?d)
474 (?N (cond ((eq number t) "*" )
478 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
479 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
481 (?R gnus-tmp-number-of-read ?s)
482 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
483 (?t gnus-tmp-number-total ?d)
484 (?y gnus-tmp-number-of-unread ?s)
485 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
486 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
487 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
488 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
489 (?g (if (boundp 'gnus-tmp-decoded-group)
490 gnus-tmp-decoded-group
493 (?G gnus-tmp-qualified-group ?s)
494 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
495 gnus-tmp-decoded-group
498 (?C gnus-tmp-comment ?s)
499 (?D gnus-tmp-newsgroup-description ?s)
500 (?o gnus-tmp-moderated ?c)
501 (?O gnus-tmp-moderated-string ?s)
502 (?p gnus-tmp-process-marked ?c)
503 (?s gnus-tmp-news-server ?s)
504 (?n ,(if (featurep 'xemacs)
505 '(symbol-name gnus-tmp-news-method)
506 'gnus-tmp-news-method)
508 (?P gnus-group-indentation ?s)
509 (?E gnus-tmp-group-icon ?s)
510 (?B gnus-tmp-summary-live ?c)
511 (?l gnus-tmp-grouplens ?s)
512 (?z gnus-tmp-news-method-string ?s)
513 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
514 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
515 (?u gnus-tmp-user-defined ?s)))
517 (defvar gnus-group-mode-line-format-alist
518 `((?S gnus-tmp-news-server ?s)
519 (?M gnus-tmp-news-method ?s)
520 (?u gnus-tmp-user-defined ?s)
521 (?: gnus-tmp-colon ?s)))
523 (defvar gnus-topic-topology nil
524 "The complete topic hierarchy.")
526 (defvar gnus-topic-alist nil
527 "The complete topic-group alist.")
529 (defvar gnus-group-marked nil)
531 (defvar gnus-group-list-mode nil)
534 (defvar gnus-group-icon-cache nil)
536 (defvar gnus-group-listed-groups nil)
537 (defvar gnus-group-list-option nil)
543 (put 'gnus-group-mode 'mode-class 'special)
545 (gnus-define-keys gnus-group-mode-map
546 " " gnus-group-read-group
547 "=" gnus-group-select-group
548 "\r" gnus-group-select-group
549 "\M-\r" gnus-group-quick-select-group
550 "\M- " gnus-group-visible-select-group
551 [(meta control return)] gnus-group-select-group-ephemerally
552 "j" gnus-group-jump-to-group
553 "n" gnus-group-next-unread-group
554 "p" gnus-group-prev-unread-group
555 "\177" gnus-group-prev-unread-group
556 [delete] gnus-group-prev-unread-group
557 [backspace] gnus-group-prev-unread-group
558 "N" gnus-group-next-group
559 "P" gnus-group-prev-group
560 "\M-n" gnus-group-next-unread-group-same-level
561 "\M-p" gnus-group-prev-unread-group-same-level
562 "," gnus-group-best-unread-group
563 "." gnus-group-first-unread-group
564 "u" gnus-group-unsubscribe-current-group
565 "U" gnus-group-unsubscribe-group
566 "c" gnus-group-catchup-current
567 "C" gnus-group-catchup-current-all
568 "\M-c" gnus-group-clear-data
569 "l" gnus-group-list-groups
570 "L" gnus-group-list-all-groups
573 "g" gnus-group-get-new-news
574 "\M-g" gnus-group-get-new-news-this-group
575 "R" gnus-group-restart
576 "r" gnus-group-read-init-file
577 "B" gnus-group-browse-foreign-server
578 "b" gnus-group-check-bogus-groups
579 "F" gnus-group-find-new-groups
580 "\C-c\C-d" gnus-group-describe-group
581 "\M-d" gnus-group-describe-all-groups
582 "\C-c\C-a" gnus-group-apropos
583 "\C-c\M-\C-a" gnus-group-description-apropos
584 "a" gnus-group-post-news
585 "\ek" gnus-group-edit-local-kill
586 "\eK" gnus-group-edit-global-kill
587 "\C-k" gnus-group-kill-group
588 "\C-y" gnus-group-yank-group
589 "\C-w" gnus-group-kill-region
590 "\C-x\C-t" gnus-group-transpose-groups
591 "\C-c\C-l" gnus-group-list-killed
592 "\C-c\C-x" gnus-group-expire-articles
593 "\C-c\M-\C-x" gnus-group-expire-all-groups
595 "s" gnus-group-save-newsrc
596 "z" gnus-group-suspend
599 "?" gnus-group-describe-briefly
600 "\C-c\C-i" gnus-info-find-node
601 "\M-e" gnus-group-edit-group-method
602 "^" gnus-group-enter-server-mode
603 gnus-mouse-2 gnus-mouse-pick-group
604 [follow-link] mouse-face
605 "<" beginning-of-buffer
608 "\C-c\C-s" gnus-group-sort-groups
610 "\C-c\M-g" gnus-activate-all-groups
611 "\M-&" gnus-group-universal-argument
612 "#" gnus-group-mark-group
613 "\M-#" gnus-group-unmark-group)
615 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
616 "m" gnus-group-mark-group
617 "u" gnus-group-unmark-group
618 "w" gnus-group-mark-region
619 "b" gnus-group-mark-buffer
620 "r" gnus-group-mark-regexp
621 "U" gnus-group-unmark-all-groups)
623 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
624 "u" gnus-sieve-update
625 "g" gnus-sieve-generate)
627 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
628 "d" gnus-group-make-directory-group
629 "h" gnus-group-make-help-group
630 "u" gnus-group-make-useful-group
631 "a" gnus-group-make-archive-group
632 "k" gnus-group-make-kiboze-group
633 "l" gnus-group-nnimap-edit-acl
634 "m" gnus-group-make-group
635 "E" gnus-group-edit-group
636 "e" gnus-group-edit-group-method
637 "p" gnus-group-edit-group-parameters
638 "v" gnus-group-add-to-virtual
639 "V" gnus-group-make-empty-virtual
640 "D" gnus-group-enter-directory
641 "f" gnus-group-make-doc-group
642 "w" gnus-group-make-web-group
643 "M" gnus-group-read-ephemeral-group
644 "r" gnus-group-rename-group
645 "R" gnus-group-make-rss-group
646 "c" gnus-group-customize
647 "x" gnus-group-nnimap-expunge
648 "\177" gnus-group-delete-group
649 [delete] gnus-group-delete-group)
651 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
652 "b" gnus-group-brew-soup
653 "w" gnus-soup-save-areas
654 "s" gnus-soup-send-replies
655 "p" gnus-soup-pack-packet
656 "r" nnsoup-pack-replies)
658 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
659 "s" gnus-group-sort-groups
660 "a" gnus-group-sort-groups-by-alphabet
661 "u" gnus-group-sort-groups-by-unread
662 "l" gnus-group-sort-groups-by-level
663 "v" gnus-group-sort-groups-by-score
664 "r" gnus-group-sort-groups-by-rank
665 "m" gnus-group-sort-groups-by-method
666 "n" gnus-group-sort-groups-by-real-name)
668 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
669 "s" gnus-group-sort-selected-groups
670 "a" gnus-group-sort-selected-groups-by-alphabet
671 "u" gnus-group-sort-selected-groups-by-unread
672 "l" gnus-group-sort-selected-groups-by-level
673 "v" gnus-group-sort-selected-groups-by-score
674 "r" gnus-group-sort-selected-groups-by-rank
675 "m" gnus-group-sort-selected-groups-by-method
676 "n" gnus-group-sort-selected-groups-by-real-name)
678 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
679 "k" gnus-group-list-killed
680 "z" gnus-group-list-zombies
681 "s" gnus-group-list-groups
682 "u" gnus-group-list-all-groups
683 "A" gnus-group-list-active
684 "a" gnus-group-apropos
685 "d" gnus-group-description-apropos
686 "m" gnus-group-list-matching
687 "M" gnus-group-list-all-matching
688 "l" gnus-group-list-level
689 "c" gnus-group-list-cached
690 "?" gnus-group-list-dormant)
692 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
693 "k" gnus-group-list-limit
694 "z" gnus-group-list-limit
695 "s" gnus-group-list-limit
696 "u" gnus-group-list-limit
697 "A" gnus-group-list-limit
698 "m" gnus-group-list-limit
699 "M" gnus-group-list-limit
700 "l" gnus-group-list-limit
701 "c" gnus-group-list-limit
702 "?" gnus-group-list-limit)
704 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
705 "k" gnus-group-list-flush
706 "z" gnus-group-list-flush
707 "s" gnus-group-list-flush
708 "u" gnus-group-list-flush
709 "A" gnus-group-list-flush
710 "m" gnus-group-list-flush
711 "M" gnus-group-list-flush
712 "l" gnus-group-list-flush
713 "c" gnus-group-list-flush
714 "?" gnus-group-list-flush)
716 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
717 "k" gnus-group-list-plus
718 "z" gnus-group-list-plus
719 "s" gnus-group-list-plus
720 "u" gnus-group-list-plus
721 "A" gnus-group-list-plus
722 "m" gnus-group-list-plus
723 "M" gnus-group-list-plus
724 "l" gnus-group-list-plus
725 "c" gnus-group-list-plus
726 "?" gnus-group-list-plus)
728 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
729 "f" gnus-score-flush-cache)
731 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
732 "c" gnus-group-fetch-charter
733 "C" gnus-group-fetch-control
734 "d" gnus-group-describe-group
735 "f" gnus-group-fetch-faq
738 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
739 "l" gnus-group-set-current-level
740 "t" gnus-group-unsubscribe-current-group
741 "s" gnus-group-unsubscribe-group
742 "k" gnus-group-kill-group
743 "y" gnus-group-yank-group
744 "w" gnus-group-kill-region
745 "\C-k" gnus-group-kill-level
746 "z" gnus-group-kill-all-zombies)
748 (defun gnus-topic-mode-p ()
749 "Return non-nil in `gnus-topic-mode'."
750 (and (boundp 'gnus-topic-mode)
751 (symbol-value 'gnus-topic-mode)))
753 (defun gnus-group-make-menu-bar ()
754 (gnus-turn-off-edit-menu 'group)
755 (unless (boundp 'gnus-group-reading-menu)
758 gnus-group-reading-menu gnus-group-mode-map ""
760 ["Read" gnus-group-read-group
761 :included (not (gnus-topic-mode-p))
762 :active (gnus-group-group-name)]
763 ["Read " gnus-topic-read-group
764 :included (gnus-topic-mode-p)]
765 ["Select" gnus-group-select-group
766 :included (not (gnus-topic-mode-p))
767 :active (gnus-group-group-name)]
768 ["Select " gnus-topic-select-group
769 :included (gnus-topic-mode-p)]
770 ["See old articles" (gnus-group-select-group 'all)
771 :keys "C-u SPC" :active (gnus-group-group-name)]
772 ["Catch up" gnus-group-catchup-current
773 :included (not (gnus-topic-mode-p))
774 :active (gnus-group-group-name)
775 ,@(if (featurep 'xemacs) nil
776 '(:help "Mark unread articles in the current group as read"))]
777 ["Catch up " gnus-topic-catchup-articles
778 :included (gnus-topic-mode-p)
779 ,@(if (featurep 'xemacs) nil
780 '(:help "Mark unread articles in the current group or topic as read"))]
781 ["Catch up all articles" gnus-group-catchup-current-all
782 (gnus-group-group-name)]
783 ["Check for new articles" gnus-group-get-new-news-this-group
784 :included (not (gnus-topic-mode-p))
785 :active (gnus-group-group-name)
786 ,@(if (featurep 'xemacs) nil
787 '(:help "Check for new messages in current group"))]
788 ["Check for new articles " gnus-topic-get-new-news-this-topic
789 :included (gnus-topic-mode-p)
790 ,@(if (featurep 'xemacs) nil
791 '(:help "Check for new messages in current group or topic"))]
792 ["Toggle subscription" gnus-group-unsubscribe-current-group
793 (gnus-group-group-name)]
794 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
795 ,@(if (featurep 'xemacs) nil
796 '(:help "Kill (remove) current group"))]
797 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
798 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
799 ,@(if (featurep 'xemacs) nil
800 '(:help "Display description of the current group"))]
801 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
802 ["Fetch charter" gnus-group-fetch-charter
803 :active (gnus-group-group-name)
804 ,@(if (featurep 'xemacs) nil
805 '(:help "Display the charter of the current group"))]
806 ["Fetch control message" gnus-group-fetch-control
807 :active (gnus-group-group-name)
808 ,@(if (featurep 'xemacs) nil
809 '(:help "Display the archived control message for the current group"))]
810 ;; Actually one should check, if any of the marked groups gives t for
811 ;; (gnus-check-backend-function 'request-expire-articles ...)
812 ["Expire articles" gnus-group-expire-articles
813 :included (not (gnus-topic-mode-p))
814 :active (or (and (gnus-group-group-name)
815 (gnus-check-backend-function
816 'request-expire-articles
817 (gnus-group-group-name))) gnus-group-marked)]
818 ["Expire articles " gnus-topic-expire-articles
819 :included (gnus-topic-mode-p)]
820 ["Set group level..." gnus-group-set-current-level
821 (gnus-group-group-name)]
822 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
823 ["Customize" gnus-group-customize (gnus-group-group-name)]
825 ["Parameters" gnus-group-edit-group-parameters
826 :included (not (gnus-topic-mode-p))
827 :active (gnus-group-group-name)]
828 ["Parameters " gnus-topic-edit-parameters
829 :included (gnus-topic-mode-p)]
830 ["Select method" gnus-group-edit-group-method
831 (gnus-group-group-name)]
832 ["Info" gnus-group-edit-group (gnus-group-group-name)]
833 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
834 ["Global kill file" gnus-group-edit-global-kill t])))
837 gnus-group-group-menu gnus-group-mode-map ""
840 ["List unread subscribed groups" gnus-group-list-groups t]
841 ["List (un)subscribed groups" gnus-group-list-all-groups t]
842 ["List killed groups" gnus-group-list-killed gnus-killed-list]
843 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
844 ["List level..." gnus-group-list-level t]
845 ["Describe all groups" gnus-group-describe-all-groups t]
846 ["Group apropos..." gnus-group-apropos t]
847 ["Group and description apropos..." gnus-group-description-apropos t]
848 ["List groups matching..." gnus-group-list-matching t]
849 ["List all groups matching..." gnus-group-list-all-matching t]
850 ["List active file" gnus-group-list-active t]
851 ["List groups with cached" gnus-group-list-cached t]
852 ["List groups with dormant" gnus-group-list-dormant t])
854 ["Default sort" gnus-group-sort-groups t]
855 ["Sort by method" gnus-group-sort-groups-by-method t]
856 ["Sort by rank" gnus-group-sort-groups-by-rank t]
857 ["Sort by score" gnus-group-sort-groups-by-score t]
858 ["Sort by level" gnus-group-sort-groups-by-level t]
859 ["Sort by unread" gnus-group-sort-groups-by-unread t]
860 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
861 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
862 ("Sort process/prefixed"
863 ["Default sort" gnus-group-sort-selected-groups
864 (not (gnus-topic-mode-p))]
865 ["Sort by method" gnus-group-sort-selected-groups-by-method
866 (not (gnus-topic-mode-p))]
867 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
868 (not (gnus-topic-mode-p))]
869 ["Sort by score" gnus-group-sort-selected-groups-by-score
870 (not (gnus-topic-mode-p))]
871 ["Sort by level" gnus-group-sort-selected-groups-by-level
872 (not (gnus-topic-mode-p))]
873 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
874 (not (gnus-topic-mode-p))]
875 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
876 (not (gnus-topic-mode-p))]
877 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
878 (not (gnus-topic-mode-p))])
880 ["Mark group" gnus-group-mark-group
881 (and (gnus-group-group-name)
882 (not (memq (gnus-group-group-name) gnus-group-marked)))]
883 ["Unmark group" gnus-group-unmark-group
884 (and (gnus-group-group-name)
885 (memq (gnus-group-group-name) gnus-group-marked))]
886 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
887 ["Mark regexp..." gnus-group-mark-regexp t]
888 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
889 ["Mark buffer" gnus-group-mark-buffer t]
890 ["Execute command" gnus-group-universal-argument
891 (or gnus-group-marked (gnus-group-group-name))])
893 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
894 ["Kill all newsgroups in region" gnus-group-kill-region
895 :active (gnus-mark-active-p)]
896 ["Kill all zombie groups" gnus-group-kill-all-zombies
898 ["Kill all groups on level..." gnus-group-kill-level t])
900 ["Make a foreign group..." gnus-group-make-group t]
901 ["Add a directory group..." gnus-group-make-directory-group t]
902 ["Add the help group" gnus-group-make-help-group t]
903 ["Add the archive group" gnus-group-make-archive-group t]
904 ["Make a doc group..." gnus-group-make-doc-group t]
905 ["Make a web group..." gnus-group-make-web-group t]
906 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
907 ["Make a virtual group..." gnus-group-make-empty-virtual t]
908 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
909 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
910 ["Make an RSS group..." gnus-group-make-rss-group t]
911 ["Rename group..." gnus-group-rename-group
912 (gnus-check-backend-function
913 'request-rename-group (gnus-group-group-name))]
914 ["Delete group" gnus-group-delete-group
915 (gnus-check-backend-function
916 'request-delete-group (gnus-group-group-name))])
918 ["Next" gnus-group-next-group t]
919 ["Previous" gnus-group-prev-group t]
920 ["Next unread" gnus-group-next-unread-group t]
921 ["Previous unread" gnus-group-prev-unread-group t]
922 ["Next unread same level" gnus-group-next-unread-group-same-level t]
923 ["Previous unread same level"
924 gnus-group-prev-unread-group-same-level t]
925 ["Jump to group..." gnus-group-jump-to-group t]
926 ["First unread group" gnus-group-first-unread-group t]
927 ["Best unread group" gnus-group-best-unread-group t])
929 ["Generate" gnus-sieve-generate t]
930 ["Generate and update" gnus-sieve-update t])
931 ["Delete bogus groups" gnus-group-check-bogus-groups t]
932 ["Find new newsgroups" gnus-group-find-new-groups t]
933 ["Transpose" gnus-group-transpose-groups
934 (gnus-group-group-name)]
935 ["Read a directory as a group..." gnus-group-enter-directory t]))
938 gnus-group-misc-menu gnus-group-mode-map ""
941 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
942 ["Send replies" gnus-soup-send-replies
943 (fboundp 'gnus-soup-pack-packet)]
944 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
945 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
946 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
947 ["Send a mail" gnus-group-mail t]
948 ["Send a message (mail or news)" gnus-group-post-news t]
949 ["Create a local message" gnus-group-news t]
950 ["Check for new news" gnus-group-get-new-news
951 ,@(if (featurep 'xemacs) '(t)
952 '(:help "Get newly arrived articles"))
954 ["Send queued messages" gnus-delay-send-queue
955 ,@(if (featurep 'xemacs) '(t)
956 '(:help "Send all messages that are scheduled to be sent now"))
958 ["Activate all groups" gnus-activate-all-groups t]
959 ["Restart Gnus" gnus-group-restart t]
960 ["Read init file" gnus-group-read-init-file t]
961 ["Browse foreign server..." gnus-group-browse-foreign-server t]
962 ["Enter server buffer" gnus-group-enter-server-mode t]
963 ["Expire all expirable articles" gnus-group-expire-all-groups t]
964 ["Generate any kiboze groups" nnkiboze-generate-groups t]
965 ["Gnus version" gnus-version t]
966 ["Save .newsrc files" gnus-group-save-newsrc t]
967 ["Suspend Gnus" gnus-group-suspend t]
968 ["Clear dribble buffer" gnus-group-clear-dribble t]
969 ["Read manual" gnus-info-find-node t]
970 ["Flush score cache" gnus-score-flush-cache t]
971 ["Toggle topics" gnus-topic-mode t]
972 ["Send a bug report" gnus-bug t]
973 ["Exit from Gnus" gnus-group-exit
974 ,@(if (featurep 'xemacs) '(t)
975 '(:help "Quit reading news"))]
976 ["Exit without saving" gnus-group-quit t]))
978 (gnus-run-hooks 'gnus-group-menu-hook)))
980 (defvar gnus-group-toolbar-map nil)
982 ;; Emacs 21 tool bar. Should be no-op otherwise.
983 (defun gnus-group-make-tool-bar ()
985 (condition-case nil (require 'tool-bar) (error nil))
986 (fboundp 'tool-bar-add-item-from-menu)
987 (default-value 'tool-bar-mode)
988 (not gnus-group-toolbar-map))
989 (setq gnus-group-toolbar-map
990 (let ((tool-bar-map (make-sparse-keymap))
991 (load-path (mm-image-load-path)))
992 (tool-bar-add-item-from-menu
993 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
994 (tool-bar-add-item-from-menu
995 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
996 (tool-bar-add-item-from-menu
997 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
998 (tool-bar-add-item-from-menu
999 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
1000 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
1001 :help "Subscribe to the current group")
1002 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
1004 :help "Unsubscribe from the current group")
1005 (tool-bar-add-item-from-menu
1006 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
1008 (if gnus-group-toolbar-map
1009 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
1011 (defun gnus-group-mode ()
1012 "Major mode for reading news.
1014 All normal editing commands are switched off.
1015 \\<gnus-group-mode-map>
1016 The group buffer lists (some of) the groups available. For instance,
1017 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1018 lists all zombie groups.
1020 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1021 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1023 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1025 The following commands are available:
1027 \\{gnus-group-mode-map}"
1029 (kill-all-local-variables)
1030 (when (gnus-visual-p 'group-menu 'menu)
1031 (gnus-group-make-menu-bar)
1032 (gnus-group-make-tool-bar))
1033 (gnus-simplify-mode-line)
1034 (setq major-mode 'gnus-group-mode)
1035 (setq mode-name "Group")
1036 (gnus-group-set-mode-line)
1037 (setq mode-line-process nil)
1038 (use-local-map gnus-group-mode-map)
1039 (buffer-disable-undo)
1040 (setq truncate-lines t)
1041 (setq buffer-read-only t)
1042 (gnus-set-default-directory)
1043 (gnus-update-format-specifications nil 'group 'group-mode)
1044 (gnus-update-group-mark-positions)
1049 (gnus-run-mode-hooks 'gnus-group-mode-hook))
1051 (defun gnus-update-group-mark-positions ()
1053 (let ((gnus-process-mark ?\200)
1054 (gnus-group-update-hook nil)
1055 (gnus-group-marked '("dummy.group"))
1056 (gnus-active-hashtb (make-vector 10 0))
1058 (gnus-set-active "dummy.group" '(0 . 0))
1059 (gnus-set-work-buffer)
1060 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1061 (goto-char (point-min))
1062 (setq gnus-group-mark-positions
1063 (list (cons 'process (and (search-forward
1064 (mm-string-as-multibyte "\200") nil t)
1065 (- (point) 2))))))))
1067 (defun gnus-mouse-pick-group (e)
1068 "Enter the group under the mouse pointer."
1071 (gnus-group-read-group nil))
1073 ;; Look at LEVEL and find out what the level is really supposed to be.
1074 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1075 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1076 (defun gnus-group-default-level (&optional level number-or-nil)
1078 (gnus-group-use-permanent-levels
1079 (or (setq gnus-group-use-permanent-levels
1080 (or level (if (numberp gnus-group-use-permanent-levels)
1081 gnus-group-use-permanent-levels
1082 (or gnus-group-default-list-level
1083 gnus-level-subscribed))))
1084 gnus-group-default-list-level gnus-level-subscribed))
1088 (or level gnus-group-default-list-level gnus-level-subscribed))))
1090 (defun gnus-group-setup-buffer ()
1091 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1092 (unless (eq major-mode 'gnus-group-mode)
1095 (gnus-carpal-setup-buffer 'group))))
1097 (defun gnus-group-name-charset (method group)
1099 (setq method (gnus-find-method-for-group group)))
1100 (let ((item (assoc method gnus-group-name-charset-method-alist))
1101 (alist gnus-group-name-charset-group-alist)
1105 (while (setq item (pop alist))
1106 (if (string-match (car item) group)
1108 result (cdr item))))
1111 (defun gnus-group-name-decode (string charset)
1112 ;; Fixme: Don't decode in unibyte mode.
1113 (if (and string charset (featurep 'mule))
1114 (mm-decode-coding-string string charset)
1117 (defun gnus-group-decoded-name (string)
1118 (let ((charset (gnus-group-name-charset nil string)))
1119 (gnus-group-name-decode string charset)))
1121 (defun gnus-group-list-groups (&optional level unread lowest)
1122 "List newsgroups with level LEVEL or lower that have unread articles.
1123 Default is all subscribed groups.
1124 If argument UNREAD is non-nil, groups with no unread articles are also
1127 Also see the `gnus-group-use-permanent-levels' variable."
1129 (list (if current-prefix-arg
1130 (prefix-numeric-value current-prefix-arg)
1132 (gnus-group-default-level nil t)
1133 gnus-group-default-list-level
1134 gnus-level-subscribed))))
1136 (setq level (car gnus-group-list-mode)
1137 unread (cdr gnus-group-list-mode)))
1138 (setq level (gnus-group-default-level level))
1139 (gnus-group-setup-buffer)
1140 (gnus-update-format-specifications nil 'group 'group-mode)
1141 (let ((case-fold-search nil)
1142 (props (text-properties-at (gnus-point-at-bol)))
1143 (empty (= (point-min) (point-max)))
1144 (group (gnus-group-group-name))
1146 (set-buffer gnus-group-buffer)
1147 (setq number (funcall gnus-group-prepare-function level unread lowest))
1148 (when (or (and (numberp number)
1150 (zerop (buffer-size)))
1151 ;; No groups in the buffer.
1152 (gnus-message 5 gnus-no-groups-message))
1153 ;; We have some groups displayed.
1154 (goto-char (point-max))
1155 (when (or (not gnus-group-goto-next-group-function)
1156 (not (funcall gnus-group-goto-next-group-function
1160 (goto-char (point-min)))
1162 ;; Go to the first group with unread articles.
1163 (gnus-group-search-forward t))
1165 ;; Find the right group to put point on. If the current group
1166 ;; has disappeared in the new listing, try to find the next
1167 ;; one. If no next one can be found, just leave point at the
1168 ;; first newsgroup in the buffer.
1169 (when (not (gnus-goto-char
1171 (point-min) (point-max)
1172 'gnus-group (gnus-intern-safe
1173 group gnus-active-hashtb))))
1174 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1176 (not (gnus-goto-char
1178 (point-min) (point-max) 'gnus-group
1180 (caar newsrc) gnus-active-hashtb)))))
1181 (setq newsrc (cdr newsrc)))
1183 (goto-char (point-max))
1184 (forward-line -1)))))))
1185 ;; Adjust cursor point.
1186 (gnus-group-position-point)))
1188 (defun gnus-group-list-level (level &optional all)
1189 "List groups on LEVEL.
1190 If ALL (the prefix), also list groups that have no unread articles."
1191 (interactive "nList groups on level: \nP")
1192 (gnus-group-list-groups level all level))
1194 (defun gnus-group-prepare-logic (group test)
1195 (or (and gnus-group-listed-groups
1196 (null gnus-group-list-option)
1197 (member group gnus-group-listed-groups))
1199 ((null gnus-group-listed-groups) test)
1200 ((null gnus-group-list-option) test)
1201 (t (and (member group gnus-group-listed-groups)
1202 (if (eq gnus-group-list-option 'flush)
1206 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1207 "List all newsgroups with unread articles of level LEVEL or lower.
1208 If PREDICATE is a function, list groups that the function returns non-nil;
1209 if it is t, list groups that have no unread articles.
1210 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1211 If REGEXP is a function, list dead groups that the function returns non-nil;
1212 if it is a string, only list groups matching REGEXP."
1213 (set-buffer gnus-group-buffer)
1214 (let ((buffer-read-only nil)
1215 (newsrc (cdr gnus-newsrc-alist))
1216 (lowest (or lowest 1))
1217 (not-in-list (and gnus-group-listed-groups
1218 (copy-sequence gnus-group-listed-groups)))
1219 info clevel unread group params)
1221 (when (or (< lowest gnus-level-zombie)
1222 gnus-group-listed-groups)
1223 ;; List living groups.
1225 (setq info (car newsrc)
1226 group (gnus-info-group info)
1227 params (gnus-info-params info)
1229 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1231 (setq not-in-list (delete group not-in-list)))
1232 (when (gnus-group-prepare-logic
1234 (and unread ; This group might be unchecked
1235 (or (not (stringp regexp))
1236 (string-match regexp group))
1237 (<= (setq clevel (gnus-info-level info)) level)
1240 ((functionp predicate)
1241 (funcall predicate info))
1242 (predicate t) ; We list all groups?
1245 (if (eq unread t) ; Unactivated?
1246 gnus-group-list-inactive-groups
1247 ; We list unactivated
1249 ; We list groups with unread articles
1250 (and gnus-list-groups-with-ticked-articles
1251 (cdr (assq 'tick (gnus-info-marks info))))
1252 ; And groups with tickeds
1253 ;; Check for permanent visibility.
1254 (and gnus-permanently-visible-groups
1255 (string-match gnus-permanently-visible-groups
1257 (memq 'visible params)
1258 (cdr (assq 'visible params)))))))
1259 (gnus-group-insert-group-line
1260 group (gnus-info-level info)
1261 (gnus-info-marks info) unread (gnus-info-method info)))))
1263 ;; List dead groups.
1264 (when (or gnus-group-listed-groups
1265 (and (>= level gnus-level-zombie)
1266 (<= lowest gnus-level-zombie)))
1267 (gnus-group-prepare-flat-list-dead
1268 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1269 gnus-level-zombie ?Z
1272 (dolist (group gnus-zombie-list)
1273 (setq not-in-list (delete group not-in-list))))
1274 (when (or gnus-group-listed-groups
1275 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1276 (gnus-group-prepare-flat-list-dead
1279 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1280 gnus-level-killed ?K regexp))
1282 (gnus-group-set-mode-line)
1283 (setq gnus-group-list-mode (cons level predicate))
1284 (gnus-run-hooks 'gnus-group-prepare-hook)
1287 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1288 ;; List zombies and killed lists somewhat faster, which was
1289 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1290 ;; this by ignoring the group format specification altogether.
1292 (if (> (length groups) gnus-group-listing-limit)
1294 (setq group (pop groups))
1295 (when (gnus-group-prepare-logic
1298 (and (stringp regexp) (string-match regexp group))
1299 (and (functionp regexp) (funcall regexp group))))
1300 (gnus-add-text-properties
1301 (point) (prog1 (1+ (point))
1302 (insert " " mark " *: "
1303 (gnus-group-decoded-name group)
1305 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1307 'gnus-level level))))
1309 (setq group (pop groups))
1310 (when (gnus-group-prepare-logic
1313 (and (stringp regexp) (string-match regexp group))
1314 (and (functionp regexp) (funcall regexp group))))
1315 (gnus-group-insert-group-line
1317 (let ((active (gnus-active group)))
1319 (if (zerop (cdr active))
1321 (- (1+ (cdr active)) (car active)))
1323 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1325 (defun gnus-group-update-group-line ()
1326 "Update the current line in the group buffer."
1327 (let* ((buffer-read-only nil)
1328 (group (gnus-group-group-name))
1329 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1330 gnus-group-indentation)
1333 (not (gnus-ephemeral-group-p group))
1335 (concat "(gnus-group-set-info '"
1336 (gnus-prin1-to-string (nth 2 entry))
1338 (setq gnus-group-indentation (gnus-group-group-indentation))
1340 (gnus-group-insert-group-line-info group)
1342 (gnus-group-position-point))))
1344 (defun gnus-group-insert-group-line-info (group)
1345 "Insert GROUP on the current line."
1346 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1347 (gnus-group-indentation (gnus-group-group-indentation))
1351 ;; (Un)subscribed group.
1352 (setq info (nth 2 entry))
1353 (gnus-group-insert-group-line
1354 group (gnus-info-level info) (gnus-info-marks info)
1355 (or (car entry) t) (gnus-info-method info)))
1356 ;; This group is dead.
1357 (gnus-group-insert-group-line
1359 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1361 (if (setq active (gnus-active group))
1362 (if (zerop (cdr active))
1364 (- (1+ (cdr active)) (car active)))
1366 (gnus-method-simplify (gnus-find-method-for-group group))))))
1368 (defun gnus-number-of-unseen-articles-in-group (group)
1369 (let* ((info (nth 2 (gnus-group-entry group)))
1370 (marked (gnus-info-marks info))
1371 (seen (cdr (assq 'seen marked)))
1372 (active (gnus-active group)))
1375 (length (gnus-uncompress-range
1376 (gnus-range-difference
1377 (gnus-range-difference (list active) (gnus-info-read info))
1380 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1381 gnus-tmp-marked number
1383 "Insert a group line in the group buffer."
1384 (let* ((gnus-tmp-method
1385 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1386 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1388 (gnus-tmp-active (gnus-active gnus-tmp-group))
1389 (gnus-tmp-number-total
1391 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1393 (gnus-tmp-number-of-unread
1394 (if (numberp number) (int-to-string (max 0 number))
1396 (gnus-tmp-number-of-read
1397 (if (numberp number)
1398 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1400 (gnus-tmp-subscribed
1401 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1402 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1403 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1405 (gnus-tmp-qualified-group
1406 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1407 group-name-charset))
1409 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1411 (gnus-tmp-newsgroup-description
1412 (if gnus-description-hashtb
1413 (or (gnus-group-name-decode
1414 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1415 group-name-charset) "")
1418 (if (and gnus-moderated-hashtb
1419 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1421 (gnus-tmp-moderated-string
1422 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1423 (gnus-tmp-group-icon "==&&==")
1424 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1425 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1426 (gnus-tmp-news-method-string
1428 (format "(%s:%s)" (car gnus-tmp-method)
1429 (cadr gnus-tmp-method)) ""))
1430 (gnus-tmp-marked-mark
1431 (if (and (numberp number)
1433 (cdr (assq 'tick gnus-tmp-marked)))
1435 (gnus-tmp-summary-live
1436 (if (and (not gnus-group-is-exiting-p)
1437 (gnus-buffer-live-p (gnus-summary-buffer-name
1440 (gnus-tmp-process-marked
1441 (if (member gnus-tmp-group gnus-group-marked)
1442 gnus-process-mark ? ))
1444 (or (and gnus-use-grouplens
1445 (bbb-grouplens-group-p gnus-tmp-group))
1447 (buffer-read-only nil)
1448 header gnus-tmp-header) ; passed as parameter to user-funcs.
1450 (gnus-add-text-properties
1454 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1455 gnus-tmp-group group-name-charset)))
1456 (eval gnus-group-line-format-spec)))
1457 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1458 gnus-unread ,(if (numberp number)
1459 (string-to-number gnus-tmp-number-of-unread)
1461 gnus-marked ,gnus-tmp-marked-mark
1462 gnus-indentation ,gnus-group-indentation
1463 gnus-level ,gnus-tmp-level))
1465 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1466 (gnus-run-hooks 'gnus-group-update-hook))
1468 ;; Allow XEmacs to remove front-sticky text properties.
1469 (gnus-group-remove-excess-properties)))
1471 (defun gnus-group-highlight-line ()
1472 "Highlight the current line according to `gnus-group-highlight'."
1473 (let* ((list gnus-group-highlight)
1475 (end (gnus-point-at-eol))
1476 ;; now find out where the line starts and leave point there.
1477 (beg (progn (beginning-of-line) (point)))
1478 (group (gnus-group-group-name))
1479 (entry (gnus-group-entry group))
1480 (unread (if (numberp (car entry)) (car entry) 0))
1481 (active (gnus-active group))
1482 (total (if active (1+ (- (cdr active) (car active))) 0))
1483 (info (nth 2 entry))
1484 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1485 (marked (gnus-info-marks info))
1486 (mailp (apply 'append
1489 (memq x (assoc (symbol-name
1490 (car (or method gnus-select-method)))
1491 gnus-valid-select-methods)))
1492 '(mail post-mail))))
1493 (level (or (gnus-info-level info) gnus-level-killed))
1494 (score (or (gnus-info-score info) 0))
1495 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1496 (group-age (gnus-group-timestamp-delta group))
1497 (inhibit-read-only t))
1498 ;; Eval the cars of the lists until we find a match.
1500 (not (eval (caar list))))
1501 (setq list (cdr list)))
1502 (let ((face (cdar list)))
1503 (unless (eq face (get-text-property beg 'face))
1504 (gnus-put-text-property-excluding-characters-with-faces
1506 (setq face (if (boundp face) (symbol-value face) face)))
1507 (gnus-extent-start-open beg)))
1510 (defun gnus-group-update-group (group &optional visible-only)
1511 "Update all lines where GROUP appear.
1512 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1514 ;; Can't use `save-excursion' here, so we do it manually.
1515 (let ((buf (current-buffer))
1517 (set-buffer gnus-group-buffer)
1518 (setq mark (point-marker))
1519 ;; The buffer may be narrowed.
1522 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1524 found buffer-read-only)
1525 ;; Enter the current status into the dribble buffer.
1526 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1528 (not (gnus-ephemeral-group-p group)))
1530 (concat "(gnus-group-set-info '"
1531 (gnus-prin1-to-string (nth 2 entry))
1533 ;; Find all group instances. If topics are in use, each group
1534 ;; may be listed in more than once.
1535 (while (setq loc (text-property-any
1536 loc (point-max) 'gnus-group ident))
1539 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1541 (gnus-group-insert-group-line-info group)
1544 (gnus-run-hooks 'gnus-group-update-group-hook)))
1545 (setq loc (1+ loc)))
1546 (unless (or found visible-only)
1547 ;; No such line in the buffer, find out where it's supposed to
1548 ;; go, and insert it there (or at the end of the buffer).
1549 (if gnus-goto-missing-group-function
1550 (funcall gnus-goto-missing-group-function group)
1551 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1552 (while (and entry (car entry)
1556 (point-min) (point-max)
1557 'gnus-group (gnus-intern-safe
1558 (caar entry) gnus-active-hashtb)))))
1559 (setq entry (cdr entry)))
1560 (or entry (goto-char (point-max)))))
1561 ;; Finally insert the line.
1562 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1563 (gnus-group-insert-group-line-info group)
1566 (gnus-run-hooks 'gnus-group-update-group-hook))))
1567 (when gnus-group-update-group-function
1568 (funcall gnus-group-update-group-function group))
1569 (gnus-group-set-mode-line)))
1571 (set-marker mark nil)
1574 (defun gnus-group-set-mode-line ()
1575 "Update the mode line in the group buffer."
1576 (when (memq 'group gnus-updated-mode-lines)
1577 ;; Yes, we want to keep this mode line updated.
1579 (set-buffer gnus-group-buffer)
1580 (let* ((gformat (or gnus-group-mode-line-format-spec
1581 (gnus-set-format 'group-mode)))
1582 (gnus-tmp-news-server (cadr gnus-select-method))
1583 (gnus-tmp-news-method (car gnus-select-method))
1584 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1586 gnus-tmp-header ;Dummy binding for user-defined formats
1587 ;; Get the resulting string.
1589 (and gnus-dribble-buffer
1590 (buffer-name gnus-dribble-buffer)
1591 (buffer-modified-p gnus-dribble-buffer)
1593 (set-buffer gnus-dribble-buffer)
1594 (not (zerop (buffer-size))))))
1595 (mode-string (eval gformat)))
1596 ;; Say whether the dribble buffer has been modified.
1597 (setq mode-line-modified
1598 (if modified (car gnus-mode-line-modified)
1599 (cdr gnus-mode-line-modified)))
1600 ;; If the line is too long, we chop it off.
1601 (when (> (length mode-string) max-len)
1602 (setq mode-string (substring mode-string 0 (- max-len 4))))
1604 (setq mode-line-buffer-identification
1605 (gnus-mode-line-buffer-identification
1606 (list mode-string)))
1607 (set-buffer-modified-p modified))))))
1609 (defun gnus-group-group-name ()
1610 "Get the name of the newsgroup on the current line."
1611 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1613 (symbol-name group))))
1615 (defun gnus-group-group-level ()
1616 "Get the level of the newsgroup on the current line."
1617 (get-text-property (gnus-point-at-bol) 'gnus-level))
1619 (defun gnus-group-group-indentation ()
1620 "Get the indentation of the newsgroup on the current line."
1621 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1622 (and gnus-group-indentation-function
1623 (funcall gnus-group-indentation-function))
1626 (defun gnus-group-group-unread ()
1627 "Get the number of unread articles of the newsgroup on the current line."
1628 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1630 (defun gnus-group-new-mail (group)
1631 (if (nnmail-new-mail-p (gnus-group-real-name group))
1635 (defun gnus-group-level (group)
1636 "Return the estimated level of GROUP."
1637 (or (gnus-info-level (gnus-get-info group))
1638 (and (member group gnus-zombie-list) gnus-level-zombie)
1641 (defun gnus-group-search-forward (&optional backward all level first-too)
1642 "Find the next newsgroup with unread articles.
1643 If BACKWARD is non-nil, find the previous newsgroup instead.
1644 If ALL is non-nil, just find any newsgroup.
1645 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1647 If FIRST-TOO, the current line is also eligible as a target."
1648 (let ((way (if backward -1 1))
1649 (low gnus-level-killed)
1652 (if (and backward (progn (beginning-of-line)) (bobp))
1661 (get-text-property (point) 'gnus-group)
1665 (get-text-property (point) 'gnus-unread)))
1666 (and (numberp unread) (> unread 0)))
1667 (setq lev (get-text-property (point)
1669 (<= lev gnus-level-subscribed)))
1671 (and (setq lev (get-text-property (point)
1680 (zerop (forward-line way)))))
1682 (progn (gnus-group-position-point) t)
1683 (goto-char (or pos beg))
1686 ;;; Gnus group mode commands
1690 (defun gnus-group-mark-line-p ()
1693 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1694 (eq (char-after) gnus-process-mark)))
1696 (defun gnus-group-mark-group (n &optional unmark no-advance)
1697 "Mark the current group."
1699 (let ((buffer-read-only nil)
1703 (when (setq group (gnus-group-group-name))
1704 ;; Go to the mark position.
1706 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1707 (subst-char-in-region
1708 (point) (1+ (point)) (char-after)
1711 (setq gnus-group-marked (delete group gnus-group-marked))
1713 (setq gnus-group-marked
1714 (cons group (delete group gnus-group-marked)))
1715 gnus-process-mark)))
1717 (gnus-group-next-group 1))
1719 (gnus-summary-position-point)
1722 (defun gnus-group-unmark-group (n)
1723 "Remove the mark from the current group."
1725 (gnus-group-mark-group n 'unmark)
1726 (gnus-group-position-point))
1728 (defun gnus-group-unmark-all-groups ()
1729 "Unmark all groups."
1731 (let ((groups gnus-group-marked))
1734 (gnus-group-remove-mark (pop groups)))))
1735 (gnus-group-position-point))
1737 (defun gnus-group-mark-region (unmark beg end)
1738 "Mark all groups between point and mark.
1739 If UNMARK, remove the mark instead."
1740 (interactive "P\nr")
1741 (let ((num (count-lines beg end)))
1744 (- num (gnus-group-mark-group num unmark)))))
1746 (defun gnus-group-mark-buffer (&optional unmark)
1747 "Mark all groups in the buffer.
1748 If UNMARK, remove the mark instead."
1750 (gnus-group-mark-region unmark (point-min) (point-max)))
1752 (defun gnus-group-mark-regexp (regexp)
1753 "Mark all groups that match some regexp."
1754 (interactive "sMark (regexp): ")
1755 (let ((alist (cdr gnus-newsrc-alist))
1759 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1760 (gnus-group-jump-to-group group)
1761 (gnus-group-set-mark group)))))
1762 (gnus-group-position-point))
1764 (defun gnus-group-remove-mark (group &optional test-marked)
1765 "Remove the process mark from GROUP and move point there.
1766 Return nil if the group isn't displayed."
1767 (if (gnus-group-goto-group group nil test-marked)
1769 (gnus-group-mark-group 1 'unmark t)
1771 (setq gnus-group-marked
1772 (delete group gnus-group-marked))
1775 (defun gnus-group-set-mark (group)
1776 "Set the process mark on GROUP."
1777 (if (gnus-group-goto-group group)
1779 (gnus-group-mark-group 1 nil t))
1780 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1782 (defun gnus-group-universal-argument (arg &optional groups func)
1783 "Perform any command on all groups according to the process/prefix convention."
1785 (if (eq (setq func (or func
1788 (substitute-command-keys
1789 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1791 (gnus-error 1 "Undefined key")
1792 (gnus-group-iterate arg
1794 (command-execute func))))
1795 (gnus-group-position-point))
1797 (defun gnus-group-process-prefix (n)
1798 "Return a list of groups to work on.
1799 Take into consideration N (the prefix) and the list of marked groups."
1802 (setq n (prefix-numeric-value n))
1803 ;; There is a prefix, so we return a list of the N next
1805 (let ((way (if (< n 0) -1 1))
1810 (if (setq group (gnus-group-group-name))
1811 (push group groups))
1813 (gnus-group-next-group way)))
1815 ((and (gnus-region-active-p) (mark))
1816 ;; Work on the region between point and mark.
1817 (let ((max (max (point) (mark)))
1820 (goto-char (min (point) (mark)))
1823 (push (gnus-group-group-name) groups)
1824 (zerop (gnus-group-next-group 1))
1826 (nreverse groups))))
1828 ;; No prefix, but a list of marked articles.
1829 (reverse gnus-group-marked))
1831 ;; Neither marked articles or a prefix, so we return the
1833 (let ((group (gnus-group-group-name)))
1834 (and group (list group))))))
1836 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1837 ;;; imagine why I went through these contortions...
1839 (let ((function (make-symbol "gnus-group-iterate-function"))
1840 (window (make-symbol "gnus-group-iterate-window"))
1841 (groups (make-symbol "gnus-group-iterate-groups"))
1842 (group (make-symbol "gnus-group-iterate-group")))
1844 `(defun gnus-group-iterate (arg ,function)
1845 "Iterate FUNCTION over all process/prefixed groups.
1846 FUNCTION will be called with the group name as the parameter
1847 and with point over the group in question."
1848 (let ((,groups (gnus-group-process-prefix arg))
1849 (,window (selected-window))
1852 (setq ,group (car ,groups)
1853 ,groups (cdr ,groups))
1854 (select-window ,window)
1855 (gnus-group-remove-mark ,group)
1856 (save-selected-window
1858 (funcall ,function ,group)))))))))
1860 (put 'gnus-group-iterate 'lisp-indent-function 1)
1862 ;; Selecting groups.
1864 (defun gnus-group-read-group (&optional all no-article group select-articles)
1865 "Read news in this newsgroup.
1866 If the prefix argument ALL is non-nil, already read articles become
1867 readable. IF ALL is a number, fetch this number of articles. If the
1868 optional argument NO-ARTICLE is non-nil, no article will be
1869 auto-selected upon group entry. If GROUP is non-nil, fetch that
1872 (let ((no-display (eq all 0))
1873 (group (or group (gnus-group-group-name)))
1874 number active marked entry)
1878 (error "No group on current line"))
1879 (setq marked (gnus-info-marks
1880 (nth 2 (setq entry (gnus-gethash
1881 group gnus-newsrc-hashtb)))))
1882 ;; This group might be a dead group. In that case we have to get
1883 ;; the number of unread articles from `gnus-active-hashtb'.
1885 (cond ((numberp all) all)
1887 ((setq active (gnus-active group))
1888 (- (1+ (cdr active)) (car active)))))
1889 (gnus-summary-read-group
1890 group (or all (and (numberp number)
1891 (zerop (+ number (gnus-range-length
1892 (cdr (assq 'tick marked)))
1894 (cdr (assq 'dormant marked)))))))
1895 no-article nil no-display nil select-articles)))
1897 (defun gnus-group-select-group (&optional all)
1898 "Select this newsgroup.
1899 No article is selected automatically.
1900 If the group is opened, just switch the summary buffer.
1901 If ALL is non-nil, already read articles become readable.
1902 If ALL is a number, fetch this number of articles."
1904 (when (and (eobp) (not (gnus-group-group-name)))
1906 (gnus-group-read-group all t))
1908 (defun gnus-group-quick-select-group (&optional all)
1909 "Select the current group \"quickly\".
1910 This means that no highlighting or scoring will be performed.
1911 If ALL (the prefix argument) is 0, don't even generate the summary
1914 This might be useful if you want to toggle threading
1915 before entering the group."
1917 (require 'gnus-score)
1919 gnus-score-find-score-files-function
1920 gnus-home-score-file
1921 gnus-apply-kill-hook
1922 gnus-summary-expunge-below)
1923 (gnus-group-read-group all t)))
1925 (defun gnus-group-visible-select-group (&optional all)
1926 "Select the current group without hiding any articles."
1928 (let ((gnus-inhibit-limiting t))
1929 (gnus-group-read-group all t)))
1931 (defun gnus-group-select-group-ephemerally ()
1932 "Select the current group without doing any processing whatsoever.
1933 You will actually be entered into a group that's a copy of
1934 the current group; no changes you make while in this group will
1937 (require 'gnus-score)
1939 gnus-score-find-score-files-function gnus-apply-kill-hook
1940 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1941 gnus-summary-mode-hook gnus-select-group-hook
1942 (group (gnus-group-group-name))
1943 (method (gnus-find-method-for-group group)))
1944 (gnus-group-read-ephemeral-group
1945 (gnus-group-prefixed-name group method) method)))
1948 (defun gnus-fetch-group (group &optional articles)
1949 "Start Gnus if necessary and enter GROUP.
1950 Returns whether the fetching was successful or not."
1951 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1952 (unless (get-buffer gnus-group-buffer)
1954 (gnus-group-read-group articles nil group))
1957 (defun gnus-fetch-group-other-frame (group)
1958 "Pop up a frame and enter GROUP."
1960 (let ((window (get-buffer-window gnus-group-buffer)))
1962 (select-frame (window-frame window)))
1963 ((= (length (frame-list)) 1)
1964 (select-frame (make-frame)))
1967 (gnus-fetch-group group))
1969 (defvar gnus-ephemeral-group-server 0)
1971 (defcustom gnus-large-ephemeral-newsgroup 200
1972 "The number of articles which indicates a large ephemeral newsgroup.
1973 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
1975 If the number of articles in a newsgroup is greater than this value,
1976 confirmation is required for selecting the newsgroup. If it is nil, no
1977 confirmation is required."
1979 :group 'gnus-group-select
1980 :type '(choice (const :tag "No limit" nil)
1983 (defcustom gnus-fetch-old-ephemeral-headers nil
1984 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
1987 :type '(choice (const :tag "off" nil)
1990 (sexp :menu-tag "other" t)))
1992 ;; Enter a group that is not in the group buffer. Non-nil is returned
1993 ;; if selection was successful.
1994 (defun gnus-group-read-ephemeral-group (group method &optional activate
1995 quit-config request-only
1999 "Read GROUP from METHOD as an ephemeral group.
2000 If ACTIVATE, request the group first.
2001 If QUIT-CONFIG, use that window configuration when exiting from the
2003 If REQUEST-ONLY, don't actually read the group; just request it.
2004 If SELECT-ARTICLES, only select those articles.
2005 If PARAMETERS, use those as the group parameters.
2006 If NUMBER, fetch this number of articles.
2008 Return the name of the group if selection was successful."
2011 ;; (gnus-read-group "Group name: ")
2013 "Group: " gnus-active-hashtb
2015 'gnus-group-history)
2016 (gnus-read-method "From method: ")))
2017 ;; Transform the select method into a unique server.
2018 (when (stringp method)
2019 (setq method (gnus-server-to-method method)))
2021 `(,(car method) ,(concat (cadr method) "-ephemeral")
2022 (,(intern (format "%s-address" (car method))) ,(cadr method))
2024 (let ((group (if (gnus-group-foreign-p group) group
2025 (gnus-group-prefixed-name (gnus-group-real-name group)
2030 ,gnus-level-default-subscribed nil nil ,method
2033 (cons 'quit-config quit-config)
2035 (cons gnus-summary-buffer
2036 gnus-current-window-configuration)))
2039 (push method gnus-ephemeral-servers)
2040 (set-buffer gnus-group-buffer)
2041 (unless (gnus-check-server method)
2042 (error "Unable to contact server: %s" (gnus-status-message method)))
2044 (gnus-activate-group group 'scan)
2045 (unless (gnus-request-group group)
2046 (error "Couldn't request group: %s"
2047 (nnheader-get-report (car method)))))
2051 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2052 (gnus-fetch-old-headers
2053 gnus-fetch-old-ephemeral-headers))
2054 (gnus-group-read-group (or number t) t group select-articles))
2058 (message "Quit reading the ephemeral group")
2061 (defun gnus-group-jump-to-group (group)
2062 "Jump to newsgroup GROUP."
2064 (list (mm-string-make-unibyte
2066 "Group: " gnus-active-hashtb nil
2067 (gnus-read-active-file-p)
2068 gnus-group-jump-to-group-prompt
2069 'gnus-group-history))))
2071 (when (equal group "")
2072 (error "Empty group name"))
2074 (unless (gnus-ephemeral-group-p group)
2075 ;; Either go to the line in the group buffer...
2076 (unless (gnus-group-goto-group group)
2077 ;; ... or insert the line.
2078 (gnus-group-update-group group)
2079 (gnus-group-goto-group group)))
2080 ;; Adjust cursor point.
2081 (gnus-group-position-point))
2083 (defun gnus-group-goto-group (group &optional far test-marked)
2084 "Goto to newsgroup GROUP.
2085 If FAR, it is likely that the group is not on the current line.
2086 If TEST-MARKED, the line must be marked."
2090 ;; It's quite likely that we are on the right line, so
2091 ;; we check the current line first.
2093 (eq (get-text-property (point) 'gnus-group)
2094 (gnus-intern-safe group gnus-active-hashtb))
2095 (or (not test-marked) (gnus-group-mark-line-p)))
2097 ;; Previous and next line are also likely, so we check them as well.
2101 (and (eq (get-text-property (point) 'gnus-group)
2102 (gnus-intern-safe group gnus-active-hashtb))
2103 (or (not test-marked) (gnus-group-mark-line-p)))))
2109 (and (eq (get-text-property (point) 'gnus-group)
2110 (gnus-intern-safe group gnus-active-hashtb))
2111 (or (not test-marked) (gnus-group-mark-line-p)))))
2115 (goto-char (point-min))
2117 (while (and (not found)
2122 (gnus-intern-safe group gnus-active-hashtb))))
2123 (if (gnus-group-mark-line-p)
2128 ;; Search through the entire buffer.
2131 (point-min) (point-max)
2132 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2134 (defun gnus-group-next-group (n &optional silent)
2135 "Go to next N'th newsgroup.
2136 If N is negative, search backward instead.
2137 Returns the difference between N and the number of skips actually
2140 (gnus-group-next-unread-group n t nil silent))
2142 (defun gnus-group-next-unread-group (n &optional all level silent)
2143 "Go to next N'th unread newsgroup.
2144 If N is negative, search backward instead.
2145 If ALL is non-nil, choose any newsgroup, unread or not.
2146 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2147 such group can be found, the next group with a level higher than
2149 Returns the difference between N and the number of skips actually
2152 (let ((backward (< n 0))
2155 (gnus-group-search-forward
2156 backward (or (not gnus-group-goto-unread) all) level))
2160 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2161 (if level " on this level or higher" "")))
2164 (defun gnus-group-prev-group (n)
2165 "Go to previous N'th newsgroup.
2166 Returns the difference between N and the number of skips actually
2169 (gnus-group-next-unread-group (- n) t))
2171 (defun gnus-group-prev-unread-group (n)
2172 "Go to previous N'th unread newsgroup.
2173 Returns the difference between N and the number of skips actually
2176 (gnus-group-next-unread-group (- n)))
2178 (defun gnus-group-next-unread-group-same-level (n)
2179 "Go to next N'th unread newsgroup on the same level.
2180 If N is negative, search backward instead.
2181 Returns the difference between N and the number of skips actually
2184 (gnus-group-next-unread-group n t (gnus-group-group-level))
2185 (gnus-group-position-point))
2187 (defun gnus-group-prev-unread-group-same-level (n)
2188 "Go to next N'th unread newsgroup on the same level.
2189 Returns the difference between N and the number of skips actually
2192 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2193 (gnus-group-position-point))
2195 (defun gnus-group-best-unread-group (&optional exclude-group)
2196 "Go to the group with the highest level.
2197 If EXCLUDE-GROUP, do not go to that group."
2199 (goto-char (point-min))
2203 (setq unread (get-text-property (point) 'gnus-unread))
2204 (when (and (numberp unread) (> unread 0))
2205 (when (and (get-text-property (point) 'gnus-level)
2206 (< (get-text-property (point) 'gnus-level) best)
2207 (or (not exclude-group)
2208 (not (equal exclude-group (gnus-group-group-name)))))
2209 (setq best (get-text-property (point) 'gnus-level))
2210 (setq best-point (point))))
2213 (goto-char best-point))
2214 (gnus-group-position-point)
2215 (and best-point (gnus-group-group-name))))
2217 (defun gnus-group-first-unread-group ()
2218 "Go to the first group with unread articles."
2221 (let ((opoint (point))
2223 (goto-char (point-min))
2224 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2225 (and (numberp unread) ; Not a topic.
2226 (not (zerop unread))) ; Has unread articles.
2227 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2230 nil)) ; Not success.
2231 (gnus-group-position-point)))
2233 (defun gnus-group-enter-server-mode ()
2234 "Jump to the server buffer."
2236 (gnus-enter-server-buffer))
2238 (defun gnus-group-make-group (name &optional method address args)
2239 "Add a new newsgroup.
2240 The user will be prompted for a NAME, for a select METHOD, and an
2244 (gnus-read-group "Group name: ")
2245 (gnus-read-method "From method: ")))
2247 (when (stringp method)
2248 (setq method (or (gnus-server-to-method method) method)))
2249 (let* ((meth (gnus-method-simplify
2251 (not (gnus-server-equal method gnus-select-method)))
2252 (if address (list (intern method) address)
2254 (nname (if method (gnus-group-prefixed-name name meth) name))
2256 (when (gnus-gethash nname gnus-newsrc-hashtb)
2257 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2258 ;; Subscribe to the new group.
2259 (gnus-group-change-level
2260 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2261 gnus-level-default-subscribed gnus-level-killed
2262 (and (gnus-group-group-name)
2263 (gnus-gethash (gnus-group-group-name)
2264 gnus-newsrc-hashtb))
2267 (gnus-set-active nname (cons 1 0))
2268 (unless (gnus-ephemeral-group-p name)
2270 (concat "(gnus-group-set-info '"
2271 (gnus-prin1-to-string (cdr info)) ")")))
2273 (gnus-group-insert-group-line-info nname)
2275 (gnus-group-position-point)
2277 ;; Load the back end and try to make the back end create
2278 ;; the group as well.
2279 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2281 gnus-valid-select-methods)
2283 (gnus-check-server meth)
2284 (when (gnus-check-backend-function 'request-create-group nname)
2285 (unless (gnus-request-create-group nname nil args)
2286 (error "Could not create group on server: %s"
2287 (nnheader-get-report backend))))
2290 (defun gnus-group-delete-groups (&optional arg)
2291 "Delete the current group. Only meaningful with editable groups."
2293 (let ((n (length (gnus-group-process-prefix arg))))
2294 (when (gnus-yes-or-no-p
2296 "Delete this 1 group? "
2297 (format "Delete these %d groups? " n)))
2298 (gnus-group-iterate arg
2300 (gnus-group-delete-group group nil t))))))
2302 (defun gnus-group-delete-group (group &optional force no-prompt)
2303 "Delete the current group. Only meaningful with editable groups.
2304 If FORCE (the prefix) is non-nil, all the articles in the group will
2305 be deleted. This is \"deleted\" as in \"removed forever from the face
2306 of the Earth\". There is no undo. The user will be prompted before
2308 Note that you also have to specify FORCE if you want the group to
2309 be removed from the server, even when it's empty."
2311 (list (gnus-group-group-name)
2312 current-prefix-arg))
2314 (error "No group to delete"))
2315 (unless (gnus-check-backend-function 'request-delete-group group)
2316 (error "This back end does not support group deletion"))
2318 (let ((group-decoded (gnus-group-decoded-name group)))
2319 (if (and (not no-prompt)
2320 (not (gnus-yes-or-no-p
2322 "Do you really want to delete %s%s? "
2323 group-decoded (if force " and all its contents" "")))))
2325 (gnus-message 6 "Deleting group %s..." group-decoded)
2326 (if (not (gnus-request-delete-group group force))
2327 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2328 (gnus-message 6 "Deleting group %s...done" group-decoded)
2329 (gnus-group-goto-group group)
2330 (gnus-group-kill-group 1 t)
2331 (gnus-sethash group nil gnus-active-hashtb)
2333 (gnus-group-position-point)))
2335 (defun gnus-group-rename-group (group new-name)
2336 "Rename group from GROUP to NEW-NAME.
2337 When used interactively, GROUP is the group under point
2338 and NEW-NAME will be prompted for."
2341 (gnus-group-group-name)
2343 (unless (gnus-check-backend-function
2344 'request-rename-group (gnus-group-group-name))
2345 (error "This back end does not support renaming groups"))
2346 (gnus-read-group "Rename group to: "
2347 (gnus-group-real-name (gnus-group-group-name))))))
2349 (unless (gnus-check-backend-function 'request-rename-group group)
2350 (error "This back end does not support renaming groups"))
2352 (error "No group to rename"))
2353 (when (equal (gnus-group-real-name group) new-name)
2354 (error "Can't rename to the same name"))
2356 ;; We find the proper prefixed name.
2358 (if (gnus-group-native-p group)
2362 (gnus-group-prefixed-name
2363 (gnus-group-real-name new-name)
2364 (gnus-info-method (gnus-get-info group)))))
2366 (when (gnus-active new-name)
2367 (error "The group %s already exists" new-name))
2369 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2372 (gnus-group-goto-group group)
2373 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2374 (gnus-request-rename-group group new-name))))
2375 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2376 ;; We rename the group internally by killing it...
2377 (gnus-group-kill-group)
2378 ;; ... changing its name ...
2379 (setcar (cdar gnus-list-of-killed-groups) new-name)
2380 ;; ... and then yanking it. Magic!
2381 (gnus-group-yank-group)
2382 (gnus-set-active new-name (gnus-active group))
2383 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2385 (setq gnus-killed-list (delete group gnus-killed-list))
2386 (gnus-set-active group nil)
2387 (gnus-dribble-touch)
2388 (gnus-group-position-point)))
2390 (defun gnus-group-edit-group (group &optional part)
2391 "Edit the group on the current line."
2392 (interactive (list (gnus-group-group-name)))
2393 (let ((part (or part 'info))
2396 (error "No group on current line"))
2397 (unless (setq info (gnus-get-info group))
2398 (error "Killed group; can't be edited"))
2400 (gnus-close-group group))
2402 ;; Find the proper form to edit.
2403 (cond ((eq part 'method)
2404 (or (gnus-info-method info) "native"))
2406 (gnus-info-params info))
2408 ;; The proper documentation.
2410 "Editing the %s for `%s'."
2412 ((eq part 'method) "select method")
2413 ((eq part 'params) "group parameters")
2415 (gnus-group-decoded-name group))
2417 (gnus-group-edit-group-done ',part ,group form)))
2420 (gnus-create-info-command
2423 "(gnus)Select Methods")
2425 "(gnus)Group Parameters")
2427 "(gnus)Group Info"))))))
2429 (defun gnus-group-edit-group-method (group)
2430 "Edit the select method of GROUP."
2431 (interactive (list (gnus-group-group-name)))
2432 (gnus-group-edit-group group 'method))
2434 (defun gnus-group-edit-group-parameters (group)
2435 "Edit the group parameters of GROUP."
2436 (interactive (list (gnus-group-group-name)))
2437 (gnus-group-edit-group group 'params))
2439 (defun gnus-group-edit-group-done (part group form)
2441 (let* ((method (cond ((eq part 'info) (nth 4 form))
2442 ((eq part 'method) form)
2444 (info (cond ((eq part 'info) form)
2445 ((eq part 'method) (gnus-get-info group))
2448 (if (or (not method)
2450 gnus-select-method method))
2451 (gnus-group-real-name (car info))
2452 (gnus-group-prefixed-name
2453 (gnus-group-real-name (car info)) method))
2455 (when (and new-group
2456 (not (equal new-group group)))
2457 (when (gnus-group-goto-group group)
2458 (gnus-group-kill-group 1))
2459 (gnus-activate-group new-group))
2461 (if (not (and info new-group))
2462 (gnus-group-set-info form (or new-group group) part)
2463 (setq info (gnus-copy-sequence info))
2464 (setcar info new-group)
2465 (unless (gnus-server-equal method "native")
2466 (unless (nthcdr 3 info)
2467 (nconc info (list nil nil)))
2468 (unless (nthcdr 4 info)
2469 (nconc info (list nil)))
2470 (gnus-info-set-method info method))
2471 (gnus-group-set-info info))
2472 (gnus-group-update-group (or new-group group))
2473 (gnus-group-position-point)))
2475 (defun gnus-group-make-useful-group (group method)
2476 "Create one of the groups described in `gnus-useful-groups'."
2478 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2480 gnus-useful-groups)))
2481 (list (cadr entry) (caddr entry))))
2482 (setq method (gnus-copy-sequence method))
2484 (while (setq entry (memq (assq 'eval method) method))
2485 (setcar entry (eval (cadar entry)))))
2486 (gnus-group-make-group group method))
2488 (defun gnus-group-make-help-group (&optional noerror)
2489 "Create the Gnus documentation group.
2490 Optional argument NOERROR modifies the behavior of this function when the
2491 group already exists:
2492 - if not given, and error is signaled,
2493 - if t, stay silent,
2494 - if anything else, just print a message."
2496 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2497 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2498 (if (gnus-gethash name gnus-newsrc-hashtb)
2499 (cond ((eq noerror nil)
2500 (error "Documentation group already exists"))
2505 (gnus-message 1 "Documentation group already exists")))
2508 (gnus-message 1 "Couldn't find doc group")
2509 (gnus-group-make-group
2510 (gnus-group-real-name name)
2511 (list 'nndoc "gnus-help"
2512 (list 'nndoc-address file)
2513 (list 'nndoc-article-type 'mbox))))
2515 (gnus-group-position-point))
2517 (defun gnus-group-make-doc-group (file type)
2518 "Create a group that uses a single file as the source.
2520 If called with a prefix argument, ask for the file type."
2522 (list (read-file-name "File name: ")
2523 (and current-prefix-arg 'ask)))
2524 (when (eq type 'ask)
2529 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
2531 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2532 ((= char ?b) 'babyl)
2533 ((= char ?d) 'digest)
2534 ((= char ?f) 'forward)
2536 ((= char ?g) 'guess)
2537 (t (setq err (format "%c unknown. " char))
2540 (let* ((file (expand-file-name file))
2541 (name (gnus-generate-new-group-name
2542 (gnus-group-prefixed-name
2543 (file-name-nondirectory file) '(nndoc "")))))
2544 (gnus-group-make-group
2545 (gnus-group-real-name name)
2547 (list 'nndoc-address file)
2548 (list 'nndoc-article-type (or type 'guess))))))
2550 (defvar nnweb-type-definition)
2551 (defvar gnus-group-web-type-history nil)
2552 (defvar gnus-group-web-search-history nil)
2553 (defun gnus-group-make-web-group (&optional solid)
2554 "Create an ephemeral nnweb group.
2555 If SOLID (the prefix), create a solid group."
2559 (if solid (gnus-read-group "Group name: ")
2560 (message-unique-id)))
2561 (default-type (or (car gnus-group-web-type-history)
2562 (symbol-name (caar nnweb-type-definition))))
2566 (format "Search engine type (default %s): " default-type)
2567 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2568 nnweb-type-definition)
2569 nil t nil 'gnus-group-web-type-history)
2574 (cons (or (car gnus-group-web-search-history) "") 0)
2575 'gnus-group-web-search-history))
2577 `(nnweb ,group (nnweb-search ,search)
2578 (nnweb-type ,(intern type))
2579 (nnweb-ephemeral-p t))))
2582 (gnus-pull 'nnweb-ephemeral-p method)
2583 (gnus-group-make-group group method))
2584 (gnus-group-read-ephemeral-group
2586 (cons (current-buffer)
2587 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2590 (defvar nnrss-group-alist)
2591 (defun nnrss-discover-feed (arg))
2592 (defun nnrss-save-server-data (arg)))
2593 (defun gnus-group-make-rss-group (&optional url)
2594 "Given a URL, discover if there is an RSS feed.
2595 If there is, use Gnus to create an nnrss group"
2599 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2600 (let ((feedinfo (nnrss-discover-feed url)))
2602 (let ((title (gnus-newsgroup-savable-name
2603 (read-from-minibuffer "Title: "
2604 (gnus-newsgroup-savable-name
2605 (or (cdr (assoc 'title
2608 (desc (read-from-minibuffer "Description: "
2609 (cdr (assoc 'description
2611 (href (cdr (assoc 'href feedinfo)))
2612 (encodable (mm-coding-system-p 'utf-8)))
2614 ;; Unify non-ASCII text.
2615 (setq title (mm-decode-coding-string
2616 (mm-encode-coding-string title 'utf-8) 'utf-8)))
2617 (gnus-group-make-group (if encodable
2618 (mm-encode-coding-string title 'utf-8)
2621 (push (list title href desc) nnrss-group-alist)
2622 (nnrss-save-server-data nil))
2623 (error "No feeds found for %s" url))))
2625 (defvar nnwarchive-type-definition)
2626 (defvar gnus-group-warchive-type-history nil)
2627 (defvar gnus-group-warchive-login-history nil)
2628 (defvar gnus-group-warchive-address-history nil)
2630 (defun gnus-group-make-warchive-group ()
2631 "Create a nnwarchive group."
2633 (require 'nnwarchive)
2634 (let* ((group (gnus-read-group "Group name: "))
2635 (default-type (or (car gnus-group-warchive-type-history)
2636 (symbol-name (caar nnwarchive-type-definition))))
2640 (format "Warchive type (default %s): " default-type)
2641 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2642 nnwarchive-type-definition)
2643 nil t nil 'gnus-group-warchive-type-history)
2645 (address (read-string "Warchive address: "
2646 nil 'gnus-group-warchive-address-history))
2647 (default-login (or (car gnus-group-warchive-login-history)
2652 (format "Warchive login (default %s): " user-mail-address)
2653 default-login 'gnus-group-warchive-login-history)
2656 `(nnwarchive ,address
2657 (nnwarchive-type ,(intern type))
2658 (nnwarchive-login ,login))))
2659 (gnus-group-make-group group method)))
2661 (defun gnus-group-make-archive-group (&optional all)
2662 "Create the (ding) Gnus archive group of the most recent articles.
2663 Given a prefix, create a full group."
2665 (let ((group (gnus-group-prefixed-name
2666 (if all "ding.archives" "ding.recent") '(nndir ""))))
2667 (when (gnus-gethash group gnus-newsrc-hashtb)
2668 (error "Archive group already exists"))
2669 (gnus-group-make-group
2670 (gnus-group-real-name group)
2671 (list 'nndir (if all "hpc" "edu")
2672 (list 'nndir-directory
2673 (if all gnus-group-archive-directory
2674 gnus-group-recent-archive-directory))))
2675 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2677 (defun gnus-group-make-directory-group (dir)
2678 "Create an nndir group.
2679 The user will be prompted for a directory. The contents of this
2680 directory will be used as a newsgroup. The directory should contain
2681 mail messages or news articles in files that have numeric names."
2683 (list (read-file-name "Create group from directory: ")))
2684 (unless (file-exists-p dir)
2685 (error "No such directory"))
2686 (unless (file-directory-p dir)
2687 (error "Not a directory"))
2691 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2693 (gnus-group-prefixed-name
2694 (expand-file-name ext dir)
2696 (setq ext (format "<%d>" (setq i (1+ i)))))
2697 (gnus-group-make-group
2698 (gnus-group-real-name group)
2699 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2701 (defvar nnkiboze-score-file)
2702 (defun gnus-group-make-kiboze-group (group address scores)
2703 "Create an nnkiboze group.
2704 The user will be prompted for a name, a regexp to match groups, and
2705 score file entries for articles to include in the group."
2708 (read-string "nnkiboze group name: ")
2709 (read-string "Source groups (regexp): ")
2710 (let ((headers (mapcar (lambda (group) (list group))
2711 '("subject" "from" "number" "date" "message-id"
2712 "references" "chars" "lines" "xref"
2713 "followup" "all" "body" "head")))
2714 scores header regexp regexps)
2715 (while (not (equal "" (setq header (completing-read
2716 "Match on header: " headers nil t))))
2718 (while (not (equal "" (setq regexp (read-string
2719 (format "Match on %s (regexp): "
2721 (push (list regexp nil nil 'r) regexps))
2722 (push (cons header regexps) scores))
2724 (gnus-group-make-group group "nnkiboze" address)
2725 (let* ((nnkiboze-current-group group)
2726 (score-file (car (nnkiboze-score-file "")))
2727 (score-dir (file-name-directory score-file)))
2728 (unless (file-exists-p score-dir)
2729 (make-directory score-dir))
2730 (with-temp-file score-file
2731 (let (emacs-lisp-mode-hook)
2732 (gnus-pp scores)))))
2734 (defun gnus-group-add-to-virtual (n vgroup)
2735 "Add the current group to a virtual group."
2737 (list current-prefix-arg
2738 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2740 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2741 (error "%s is not an nnvirtual group" vgroup))
2742 (gnus-close-group vgroup)
2743 (let* ((groups (gnus-group-process-prefix n))
2744 (method (gnus-info-method (gnus-get-info vgroup))))
2745 (setcar (cdr method)
2747 (nth 1 method) "\\|"
2750 (gnus-group-remove-mark s)
2751 (concat "\\(^" (regexp-quote s) "$\\)"))
2753 (gnus-group-position-point))
2755 (defun gnus-group-make-empty-virtual (group)
2756 "Create a new, fresh, empty virtual group."
2757 (interactive "sCreate new, empty virtual group: ")
2758 (let* ((method (list 'nnvirtual "^$"))
2759 (pgroup (gnus-group-prefixed-name group method)))
2760 ;; Check whether it exists already.
2761 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2762 (error "Group %s already exists" pgroup))
2763 ;; Subscribe the new group after the group on the current line.
2764 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2765 (gnus-group-update-group pgroup)
2767 (gnus-group-position-point)))
2769 (defun gnus-group-enter-directory (dir)
2770 "Enter an ephemeral nneething group."
2771 (interactive "DDirectory to read: ")
2772 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2773 (leaf (gnus-group-prefixed-name
2774 (file-name-nondirectory (directory-file-name dir))
2776 (name (gnus-generate-new-group-name leaf)))
2777 (unless (gnus-group-read-ephemeral-group
2779 (cons (current-buffer)
2780 (if (eq major-mode 'gnus-summary-mode)
2782 (error "Couldn't enter %s" dir))))
2785 (autoload 'nnimap-expunge "nnimap")
2786 (autoload 'nnimap-acl-get "nnimap")
2787 (autoload 'nnimap-acl-edit "nnimap"))
2789 (defun gnus-group-nnimap-expunge (group)
2790 "Expunge deleted articles in current nnimap GROUP."
2791 (interactive (list (gnus-group-group-name)))
2792 (let ((mailbox (gnus-group-real-name group)) method)
2794 (error "No group on current line"))
2795 (unless (gnus-get-info group)
2796 (error "Killed group; can't be edited"))
2797 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2798 (error "%s is not an nnimap group" group))
2799 (nnimap-expunge mailbox (cadr method))))
2801 (defun gnus-group-nnimap-edit-acl (group)
2802 "Edit the Access Control List of current nnimap GROUP."
2803 (interactive (list (gnus-group-group-name)))
2804 (let ((mailbox (gnus-group-real-name group)) method acl)
2806 (error "No group on current line"))
2807 (unless (gnus-get-info group)
2808 (error "Killed group; can't be edited"))
2809 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2810 (error "%s is not an nnimap group" group))
2811 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2812 (error "Server does not support ACL's"))
2813 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2815 An access control list is a list of (identifier . rights) elements.
2817 The identifier string specifies the corresponding user. The
2818 identifier \"anyone\" is reserved to refer to the universal identity.
2820 Rights is a string listing a (possibly empty) set of alphanumeric
2821 characters, each character listing a set of operations which is being
2822 controlled. Letters are reserved for ``standard'' rights, listed
2823 below. Digits are reserved for implementation or site defined rights.
2825 l - lookup (mailbox is visible to LIST/LSUB commands)
2826 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2827 SEARCH, COPY from mailbox)
2828 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2829 w - write (STORE flags other than \\SEEN and \\DELETED)
2830 i - insert (perform APPEND, COPY into mailbox)
2831 p - post (send mail to submission address for mailbox,
2832 not enforced by IMAP4 itself)
2833 c - create and delete mailbox (CREATE new sub-mailboxes in any
2834 implementation-defined hierarchy, RENAME or DELETE mailbox)
2835 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2836 a - administer (perform SETACL)" group)
2839 ,mailbox ',method ',acl form)))))
2841 ;; Group sorting commands
2842 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2844 (defun gnus-group-sort-groups (func &optional reverse)
2845 "Sort the group buffer according to FUNC.
2846 When used interactively, the sorting function used will be
2847 determined by the `gnus-group-sort-function' variable.
2848 If REVERSE (the prefix), reverse the sorting order."
2849 (interactive (list gnus-group-sort-function current-prefix-arg))
2850 (funcall gnus-group-sort-alist-function
2851 (gnus-make-sort-function func) reverse)
2852 (gnus-group-unmark-all-groups)
2853 (gnus-group-list-groups)
2854 (gnus-dribble-touch))
2856 (defun gnus-group-sort-flat (func reverse)
2857 ;; We peel off the dummy group from the alist.
2859 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2860 (pop gnus-newsrc-alist))
2862 (setq gnus-newsrc-alist
2863 (sort gnus-newsrc-alist func))
2865 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2866 ;; Regenerate the hash table.
2867 (gnus-make-hashtable-from-newsrc-alist)))
2869 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2870 "Sort the group buffer alphabetically by group name.
2871 If REVERSE, sort in reverse order."
2873 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2875 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2876 "Sort the group buffer alphabetically by real (unprefixed) group name.
2877 If REVERSE, sort in reverse order."
2879 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2881 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2882 "Sort the group buffer by number of unread articles.
2883 If REVERSE, sort in reverse order."
2885 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2887 (defun gnus-group-sort-groups-by-level (&optional reverse)
2888 "Sort the group buffer by group level.
2889 If REVERSE, sort in reverse order."
2891 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2893 (defun gnus-group-sort-groups-by-score (&optional reverse)
2894 "Sort the group buffer by group score.
2895 If REVERSE, sort in reverse order."
2897 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2899 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2900 "Sort the group buffer by group rank.
2901 If REVERSE, sort in reverse order."
2903 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2905 (defun gnus-group-sort-groups-by-method (&optional reverse)
2906 "Sort the group buffer alphabetically by back end name.
2907 If REVERSE, sort in reverse order."
2909 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2911 (defun gnus-group-sort-groups-by-server (&optional reverse)
2912 "Sort the group buffer alphabetically by server name.
2913 If REVERSE, sort in reverse order."
2915 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2917 ;;; Selected group sorting.
2919 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2920 "Sort the process/prefixed groups."
2921 (interactive (list current-prefix-arg gnus-group-sort-function))
2922 (let ((groups (gnus-group-process-prefix n)))
2923 (funcall gnus-group-sort-selected-function
2924 groups (gnus-make-sort-function func) reverse)
2925 (gnus-group-unmark-all-groups)
2926 (gnus-group-list-groups)
2927 (gnus-dribble-touch)))
2929 (defun gnus-group-sort-selected-flat (groups func reverse)
2930 (let (entries infos)
2931 ;; First find all the group entries for these groups.
2933 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2935 ;; Then sort the infos.
2939 (lambda (entry) (car entry))
2940 (setq entries (nreverse entries)))
2943 (setq infos (nreverse infos)))
2944 ;; Go through all the infos and replace the old entries
2945 ;; with the new infos.
2947 (setcar (car entries) (pop infos))
2949 ;; Update the hashtable.
2950 (gnus-make-hashtable-from-newsrc-alist)))
2952 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2953 "Sort the group buffer alphabetically by group name.
2954 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2955 sort in reverse order."
2956 (interactive (gnus-interactive "P\ny"))
2957 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2959 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2960 "Sort the group buffer alphabetically by real group name.
2961 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2962 sort in reverse order."
2963 (interactive (gnus-interactive "P\ny"))
2964 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
2966 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2967 "Sort the group buffer by number of unread articles.
2968 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2969 sort in reverse order."
2970 (interactive (gnus-interactive "P\ny"))
2971 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2973 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2974 "Sort the group buffer by group level.
2975 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2976 sort in reverse order."
2977 (interactive (gnus-interactive "P\ny"))
2978 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2980 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2981 "Sort the group buffer by group score.
2982 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2983 sort in reverse order."
2984 (interactive (gnus-interactive "P\ny"))
2985 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2987 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2988 "Sort the group buffer by group rank.
2989 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2990 sort in reverse order."
2991 (interactive (gnus-interactive "P\ny"))
2992 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2994 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2995 "Sort the group buffer alphabetically by back end name.
2996 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2997 sort in reverse order."
2998 (interactive (gnus-interactive "P\ny"))
2999 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3001 ;;; Sorting predicates.
3003 (defun gnus-group-sort-by-alphabet (info1 info2)
3004 "Sort alphabetically."
3005 (string< (gnus-info-group info1) (gnus-info-group info2)))
3007 (defun gnus-group-sort-by-real-name (info1 info2)
3008 "Sort alphabetically on real (unprefixed) names."
3009 (string< (gnus-group-real-name (gnus-info-group info1))
3010 (gnus-group-real-name (gnus-info-group info2))))
3012 (defun gnus-group-sort-by-unread (info1 info2)
3013 "Sort by number of unread articles."
3014 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
3015 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
3016 (< (or (and (numberp n1) n1) 0)
3017 (or (and (numberp n2) n2) 0))))
3019 (defun gnus-group-sort-by-level (info1 info2)
3021 (< (gnus-info-level info1) (gnus-info-level info2)))
3023 (defun gnus-group-sort-by-method (info1 info2)
3024 "Sort alphabetically by back end name."
3025 (string< (car (gnus-find-method-for-group
3026 (gnus-info-group info1) info1))
3027 (car (gnus-find-method-for-group
3028 (gnus-info-group info2) info2))))
3030 (defun gnus-group-sort-by-server (info1 info2)
3031 "Sort alphabetically by server name."
3032 (string< (gnus-method-to-full-server-name
3033 (gnus-find-method-for-group
3034 (gnus-info-group info1) info1))
3035 (gnus-method-to-full-server-name
3036 (gnus-find-method-for-group
3037 (gnus-info-group info2) info2))))
3039 (defun gnus-group-sort-by-score (info1 info2)
3040 "Sort by group score."
3041 (> (gnus-info-score info1) (gnus-info-score info2)))
3043 (defun gnus-group-sort-by-rank (info1 info2)
3044 "Sort by level and score."
3045 (let ((level1 (gnus-info-level info1))
3046 (level2 (gnus-info-level info2)))
3047 (or (< level1 level2)
3048 (and (= level1 level2)
3049 (> (gnus-info-score info1) (gnus-info-score info2))))))
3053 (defun gnus-group-clear-data (&optional arg)
3054 "Clear all marks and read ranges from the current group.
3055 Obeys the process/prefix convention."
3057 (gnus-group-iterate arg
3060 (gnus-info-clear-data (setq info (gnus-get-info group)))
3061 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3062 (when (gnus-group-goto-group group)
3063 (gnus-group-update-group-line))))))
3065 (defun gnus-group-clear-data-on-native-groups ()
3066 "Clear all marks and read ranges from all native groups."
3068 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3069 (let ((alist (cdr gnus-newsrc-alist))
3071 (while (setq info (pop alist))
3072 (when (gnus-group-native-p (gnus-info-group info))
3073 (gnus-info-clear-data info)))
3074 (gnus-get-unread-articles)
3075 (gnus-dribble-touch)
3076 (when (gnus-y-or-n-p
3077 "Move the cache away to avoid problems in the future? ")
3078 (call-interactively 'gnus-cache-move-cache)))))
3080 (defun gnus-info-clear-data (info)
3081 "Clear all marks and read ranges from INFO."
3082 (let ((group (gnus-info-group info))
3084 (dolist (el (gnus-info-marks info))
3085 (push `(,(cdr el) add (,(car el))) action))
3086 (push `(,(gnus-info-read info) add (read)) action)
3089 (gnus-request-set-mark ,group ',action)
3090 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3091 (gnus-info-set-read ',info ',(gnus-info-read info))
3092 (when (gnus-group-goto-group ,group)
3093 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3094 (gnus-group-update-group-line))))
3095 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3097 (gnus-request-set-mark group action)
3098 (gnus-info-set-read info nil)
3099 (when (gnus-info-marks info)
3100 (gnus-info-set-marks info nil))))
3102 ;; Group catching up.
3104 (defun gnus-group-catchup-current (&optional n all)
3105 "Mark all unread articles in the current newsgroup as read.
3106 If prefix argument N is numeric, the next N newsgroups will be
3107 caught up. If ALL is non-nil, marked articles will also be marked as
3108 read. Cross references (Xref: header) of articles are ignored.
3109 The number of newsgroups that this function was unable to catch
3112 (let ((groups (gnus-group-process-prefix n))
3115 (unless groups (error "No groups selected"))
3117 (or (not gnus-interactive-catchup) ;Without confirmation?
3122 "Do you really want to mark all articles in %s as read? "
3123 "Mark all unread articles in %s as read? ")
3124 (if (= (length groups) 1)
3125 (gnus-group-decoded-name (car groups))
3126 (format "these %d groups" (length groups)))))))
3128 (while (setq group (pop groups))
3129 (gnus-group-remove-mark group)
3130 ;; Virtual groups have to be given special treatment.
3131 (let ((method (gnus-find-method-for-group group)))
3132 (when (eq 'nnvirtual (car method))
3133 (nnvirtual-catchup-group
3134 (gnus-group-real-name group) (nth 1 method) all)))
3135 (if (>= (gnus-group-level group) gnus-level-zombie)
3136 (gnus-message 2 "Dead groups can't be caught up")
3138 (gnus-group-goto-group group)
3139 (gnus-group-catchup group all))
3140 (gnus-group-update-group-line)
3141 (setq ret (1+ ret)))))
3142 (gnus-group-next-unread-group 1)
3145 (defun gnus-group-catchup-current-all (&optional n)
3146 "Mark all articles in current newsgroup as read.
3147 Cross references (Xref: header) of articles are ignored."
3149 (gnus-group-catchup-current n 'all))
3151 (defun gnus-group-catchup (group &optional all)
3152 "Mark all articles in GROUP as read.
3153 If ALL is non-nil, all articles are marked as read.
3154 The return value is the number of articles that were marked as read,
3155 or nil if no action could be taken."
3156 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3158 (marks (nth 3 (nth 2 entry)))
3159 (unread (gnus-sequence-of-unread-articles group)))
3160 ;; Remove entries for this group.
3161 (nnmail-purge-split-history (gnus-group-real-name group))
3162 ;; Do the updating only if the newsgroup isn't killed.
3163 (if (not (numberp (car entry)))
3164 (gnus-message 1 "Can't catch up %s; non-active group" group)
3165 (gnus-update-read-articles group nil)
3167 ;; Nix out the lists of marks and dormants.
3168 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3170 (list (cdr (assq 'dormant marks))
3172 (setq unread (gnus-range-add (gnus-range-add
3173 unread (cdr (assq 'dormant marks)))
3174 (cdr (assq 'tick marks))))
3175 (gnus-add-marked-articles group 'tick nil nil 'force)
3176 (gnus-add-marked-articles group 'dormant nil nil 'force))
3177 ;; Do auto-expirable marks if that's required.
3178 (when (gnus-group-auto-expirable-p group)
3179 (gnus-range-map (lambda (article)
3180 (gnus-add-marked-articles group 'expire (list article))
3181 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3183 (let ((gnus-newsgroup-name group))
3184 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3187 (defun gnus-group-expire-articles (&optional n)
3188 "Expire all expirable articles in the current newsgroup.
3189 Uses the process/prefix convention."
3191 (let ((groups (gnus-group-process-prefix n))
3194 (error "No groups to expire"))
3195 (while (setq group (pop groups))
3196 (gnus-group-remove-mark group)
3197 (gnus-group-expire-articles-1 group)
3198 (gnus-dribble-touch)
3199 (gnus-group-position-point))))
3201 (defun gnus-group-expire-articles-1 (group)
3202 (when (gnus-check-backend-function 'request-expire-articles group)
3203 (gnus-message 6 "Expiring articles in %s..."
3204 (gnus-group-decoded-name group))
3205 (let* ((info (gnus-get-info group))
3206 (expirable (if (gnus-group-total-expirable-p group)
3207 (cons nil (gnus-list-of-read-articles group))
3208 (assq 'expire (gnus-info-marks info))))
3209 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3210 (nnmail-expiry-target
3211 (or (gnus-group-find-parameter group 'expiry-target)
3212 nnmail-expiry-target)))
3214 (gnus-check-group group)
3217 (gnus-compress-sequence
3219 ;; We set the expiry variables to the group
3221 (let ((nnmail-expiry-wait-function nil)
3222 (nnmail-expiry-wait expiry-wait))
3223 (gnus-request-expire-articles
3224 (gnus-uncompress-sequence (cdr expirable)) group))
3225 ;; Just expire using the normal expiry values.
3226 (gnus-request-expire-articles
3227 (gnus-uncompress-sequence (cdr expirable)) group))))
3228 (gnus-close-group group))
3229 (gnus-message 6 "Expiring articles in %s...done"
3230 (gnus-group-decoded-name group))
3231 ;; Return the list of un-expired articles.
3234 (defun gnus-group-expire-all-groups ()
3235 "Expire all expirable articles in all newsgroups."
3238 (gnus-message 5 "Expiring...")
3239 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3240 (cdr gnus-newsrc-alist))))
3241 (gnus-group-expire-articles nil)))
3242 (gnus-group-position-point)
3243 (gnus-message 5 "Expiring...done"))
3245 (defun gnus-group-set-current-level (n level)
3246 "Set the level of the next N groups to LEVEL."
3251 (unless (gnus-group-process-prefix current-prefix-arg)
3252 (error "No group on the current line"))
3254 (let ((s (read-string
3255 (format "Level (default %s): "
3256 (or (gnus-group-group-level)
3257 gnus-level-default-subscribed)))))
3258 (if (string-match "^\\s-*$" s)
3259 (int-to-string (or (gnus-group-group-level)
3260 gnus-level-default-subscribed))
3262 (unless (and (>= level 1) (<= level gnus-level-killed))
3263 (error "Invalid level: %d" level))
3264 (let ((groups (gnus-group-process-prefix n))
3266 (while (setq group (pop groups))
3267 (gnus-group-remove-mark group)
3268 (gnus-message 6 "Changed level of %s from %d to %d"
3269 (gnus-group-decoded-name group)
3270 (or (gnus-group-group-level) gnus-level-killed)
3272 (gnus-group-change-level
3273 group level (or (gnus-group-group-level) gnus-level-killed))
3274 (gnus-group-update-group-line)))
3275 (gnus-group-position-point))
3277 (defun gnus-group-unsubscribe (&optional n)
3278 "Unsubscribe the current group."
3280 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3282 (defun gnus-group-subscribe (&optional n)
3283 "Subscribe the current group."
3285 (gnus-group-unsubscribe-current-group n 'subscribe))
3287 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3288 "Toggle subscription of the current group.
3289 If given numerical prefix, toggle the N next groups."
3291 (dolist (group (gnus-group-process-prefix n))
3292 (gnus-group-remove-mark group)
3293 (gnus-group-unsubscribe-group
3296 ((eq do-sub 'unsubscribe)
3297 gnus-level-default-unsubscribed)
3298 ((eq do-sub 'subscribe)
3299 gnus-level-default-subscribed)
3300 ((<= (gnus-group-group-level) gnus-level-subscribed)
3301 gnus-level-default-unsubscribed)
3303 gnus-level-default-subscribed))
3305 (gnus-group-update-group-line))
3306 (gnus-group-next-group 1))
3308 (defun gnus-group-unsubscribe-group (group &optional level silent)
3309 "Toggle subscription to GROUP.
3310 Killed newsgroups are subscribed. If SILENT, don't try to update the
3313 (list (completing-read
3314 "Group: " gnus-active-hashtb nil
3315 (gnus-read-active-file-p)
3317 'gnus-group-history)))
3318 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3320 ((string-match "^[ \t]*$" group)
3321 (error "Empty group name"))
3323 ;; Toggle subscription flag.
3324 (gnus-group-change-level
3325 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3326 gnus-level-subscribed)
3327 (1+ gnus-level-subscribed)
3328 gnus-level-default-subscribed)))
3330 (gnus-group-update-group group)))
3331 ((and (stringp group)
3332 (or (not (gnus-read-active-file-p))
3333 (gnus-active group)))
3334 ;; Add new newsgroup.
3335 (gnus-group-change-level
3337 (if level level gnus-level-default-subscribed)
3338 (or (and (member group gnus-zombie-list)
3341 (when (gnus-group-group-name)
3342 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3344 (gnus-group-update-group group)))
3345 (t (error "No such newsgroup: %s" group)))
3346 (gnus-group-position-point)))
3348 (defun gnus-group-transpose-groups (n)
3349 "Move the current newsgroup up N places.
3350 If given a negative prefix, move down instead. The difference between
3351 N and the number of steps taken is returned."
3353 (unless (gnus-group-group-name)
3354 (error "No group on current line"))
3355 (gnus-group-kill-group 1)
3357 (forward-line (- n))
3358 (gnus-group-yank-group)
3359 (gnus-group-position-point)))
3361 (defun gnus-group-kill-all-zombies (&optional dummy)
3362 "Kill all zombie newsgroups.
3363 The optional DUMMY should always be nil."
3364 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3366 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3367 (setq gnus-zombie-list nil)
3368 (gnus-dribble-touch)
3369 (gnus-group-list-groups)))
3371 (defun gnus-group-kill-region (begin end)
3372 "Kill newsgroups in current region (excluding current point).
3373 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3388 (beginning-of-line) ;Important when LINES < 1
3389 (gnus-group-kill-group lines)))
3391 (defun gnus-group-kill-group (&optional n discard)
3392 "Kill the next N groups.
3393 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3394 However, only groups that were alive can be yanked; already killed
3395 groups or zombie groups can't be yanked.
3396 The return value is the name of the group that was killed, or a list
3399 (let ((buffer-read-only nil)
3400 (groups (gnus-group-process-prefix n))
3401 group entry level out)
3402 (if (< (length groups) 10)
3403 ;; This is faster when there are few groups.
3405 (push (setq group (pop groups)) out)
3406 (gnus-group-remove-mark group)
3407 (setq level (gnus-group-group-level))
3409 (when (and (not discard)
3410 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3413 (gnus-group-goto-group ,(gnus-group-group-name))
3414 (gnus-group-yank-group)))
3415 (push (cons (car entry) (nth 2 entry))
3416 gnus-list-of-killed-groups))
3417 (gnus-group-change-level
3418 (if entry entry group) gnus-level-killed (if entry nil level))
3419 (message "Killed group %s" (gnus-group-decoded-name group)))
3420 ;; If there are lots and lots of groups to be killed, we use
3421 ;; this thing instead.
3422 (dolist (group (nreverse groups))
3423 (gnus-group-remove-mark group)
3425 (push group gnus-killed-list)
3426 (setq gnus-newsrc-alist
3427 (delq (assoc group gnus-newsrc-alist)
3429 (when gnus-group-change-level-function
3430 (funcall gnus-group-change-level-function
3431 group gnus-level-killed 3))
3433 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3434 (push (cons (car entry) (nth 2 entry))
3435 gnus-list-of-killed-groups)
3436 (setcdr (cdr entry) (cdddr entry)))
3437 ((member group gnus-zombie-list)
3438 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3439 ;; There may be more than one instance displayed.
3440 (while (gnus-group-goto-group group)
3441 (gnus-delete-line)))
3442 (gnus-make-hashtable-from-newsrc-alist))
3444 (gnus-group-position-point)
3445 (if (< (length out) 2) (car out) (nreverse out))))
3447 (defun gnus-group-yank-group (&optional arg)
3448 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3449 The numeric ARG specifies how many newsgroups are to be yanked. The
3450 name of the newsgroup yanked is returned, or (if several groups are
3451 yanked) a list of yanked groups is returned."
3453 (setq arg (or arg 1))
3454 (let (info group prev out)
3455 (while (>= (decf arg) 0)
3456 (when (not (setq info (pop gnus-list-of-killed-groups)))
3457 (error "No more newsgroups to yank"))
3458 (push (setq group (nth 1 info)) out)
3459 ;; Find which newsgroup to insert this one before - search
3460 ;; backward until something suitable is found. If there are no
3461 ;; other newsgroups in this buffer, just make this newsgroup the
3463 (setq prev (gnus-group-group-name))
3464 (gnus-group-change-level
3465 info (gnus-info-level (cdr info)) gnus-level-killed
3466 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3468 (gnus-group-insert-group-line-info group)
3470 `(when (gnus-group-goto-group ,group)
3471 (gnus-group-kill-group 1))))
3473 (gnus-group-position-point)
3474 (if (< (length out) 2) (car out) (nreverse out))))
3476 (defun gnus-group-kill-level (level)
3477 "Kill all groups that is on a certain LEVEL."
3478 (interactive "nKill all groups on level: ")
3480 ((= level gnus-level-zombie)
3481 (setq gnus-killed-list
3482 (nconc gnus-zombie-list gnus-killed-list))
3483 (setq gnus-zombie-list nil))
3484 ((and (< level gnus-level-zombie)
3486 (or gnus-expert-user
3489 "Do you really want to kill all groups on level %d? "
3491 (let* ((prev gnus-newsrc-alist)
3494 (if (= (gnus-info-level (car alist)) level)
3496 (push (gnus-info-group (car alist)) gnus-killed-list)
3497 (setcdr prev (cdr alist)))
3499 (setq alist (cdr alist)))
3500 (gnus-make-hashtable-from-newsrc-alist)
3501 (gnus-group-list-groups)))
3503 (error "Can't kill; invalid level: %d" level))))
3505 (defun gnus-group-list-all-groups (&optional arg)
3506 "List all newsgroups with level ARG or lower.
3507 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3508 unsubscribed groups."
3510 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3512 ;; Redefine this to list ALL killed groups if prefix arg used.
3513 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3514 (defun gnus-group-list-killed (&optional arg)
3515 "List all killed newsgroups in the group buffer.
3516 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3517 entail asking the server for the groups."
3519 ;; Find all possible killed newsgroups if arg.
3521 (gnus-get-killed-groups))
3522 (if (not gnus-killed-list)
3523 (gnus-message 6 "No killed groups")
3524 (let (gnus-group-list-mode)
3525 (funcall gnus-group-prepare-function
3526 gnus-level-killed t gnus-level-killed))
3527 (goto-char (point-min)))
3528 (gnus-group-position-point))
3530 (defun gnus-group-list-zombies ()
3531 "List all zombie newsgroups in the group buffer."
3533 (if (not gnus-zombie-list)
3534 (gnus-message 6 "No zombie groups")
3535 (let (gnus-group-list-mode)
3536 (funcall gnus-group-prepare-function
3537 gnus-level-zombie t gnus-level-zombie))
3538 (goto-char (point-min)))
3539 (gnus-group-position-point))
3541 (defun gnus-group-list-active ()
3542 "List all groups that are available from the server(s)."
3544 ;; First we make sure that we have really read the active file.
3545 (unless (gnus-read-active-file-p)
3546 (let ((gnus-read-active-file t)
3547 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3548 (gnus-read-active-file)))
3549 ;; Find all groups and sort them.
3557 (push (symbol-name sym) list)))
3561 (buffer-read-only nil)
3565 (setq group (pop groups))
3566 (gnus-add-text-properties
3567 (point) (prog1 (1+ (point))
3569 (gnus-group-decoded-name group)
3571 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3573 'gnus-level (inline (gnus-group-level group)))))
3574 (goto-char (point-min))))
3576 (defun gnus-activate-all-groups (level)
3577 "Activate absolutely all groups."
3578 (interactive (list gnus-level-unsubscribed))
3579 (let ((gnus-activate-level level)
3580 (gnus-activate-foreign-newsgroups level))
3581 (gnus-group-get-new-news)))
3583 (defun gnus-group-get-new-news (&optional arg)
3584 "Get newly arrived articles.
3585 If ARG is a number, it specifies which levels you are interested in
3586 re-scanning. If ARG is non-nil and not a number, this will force
3587 \"hard\" re-reading of the active files from all servers."
3590 (let ((gnus-inhibit-demon t)
3591 ;; Binding this variable will inhibit multiple fetchings
3592 ;; of the same mail source.
3593 (nnmail-fetched-sources (list t)))
3594 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3595 (gnus-run-hooks 'gnus-get-new-news-hook)
3597 ;; Read any slave files.
3599 (gnus-master-read-slave-newsrc))
3601 ;; We might read in new NoCeM messages here.
3602 (when (and gnus-use-nocem
3604 (gnus-nocem-scan-groups))
3605 ;; If ARG is not a number, then we read the active file.
3606 (when (and arg (not (numberp arg)))
3607 (let ((gnus-read-active-file t))
3608 (gnus-read-active-file))
3611 ;; If the user wants it, we scan for new groups.
3612 (when (eq gnus-check-new-newsgroups 'always)
3613 (gnus-find-new-newsgroups)))
3615 (setq arg (gnus-group-default-level arg t))
3616 (if (and gnus-read-active-file (not arg))
3618 (gnus-read-active-file)
3619 (gnus-get-unread-articles arg))
3620 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3621 (gnus-get-unread-articles arg)))
3622 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3623 (gnus-group-list-groups (and (numberp arg)
3624 (max (car gnus-group-list-mode) arg)))))
3626 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3627 "Check for newly arrived news in the current group (and the N-1 next groups).
3628 The difference between N and the number of newsgroup checked is returned.
3629 If N is negative, this group and the N-1 previous groups will be checked.
3630 If DONT-SCAN is non-nil, scan non-activated groups as well."
3632 (let* ((groups (gnus-group-process-prefix n))
3633 (ret (if (numberp n) (- n (length groups)) 0))
3637 (gnus-inhibit-demon t)
3638 ;; Binding this variable will inhibit multiple fetchings
3639 ;; of the same mail source.
3640 (nnmail-fetched-sources (list t)))
3641 (gnus-run-hooks 'gnus-get-new-news-hook)
3642 (while (setq group (pop groups))
3643 (gnus-group-remove-mark group)
3644 ;; Bypass any previous denials from the server.
3645 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3646 (if (gnus-activate-group group (if dont-scan nil 'scan))
3648 (gnus-get-unread-articles-in-group
3649 (gnus-get-info group) (gnus-active group) t)
3650 (unless (gnus-virtual-group-p group)
3651 (gnus-close-group group))
3653 (gnus-agent-save-group-info
3654 method (gnus-group-real-name group) (gnus-active group)))
3655 (gnus-group-update-group group))
3656 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3658 (gnus-error 3 "Server denied access")
3659 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3662 (when gnus-goto-next-group-when-activating
3663 (gnus-group-next-unread-group 1 t))
3664 (gnus-summary-position-point)
3667 (defun gnus-group-fetch-faq (group &optional faq-dir)
3668 "Fetch the FAQ for the current group.
3669 If given a prefix argument, prompt for the FAQ dir
3673 (gnus-group-group-name)
3674 (when current-prefix-arg
3676 "FAQ dir: " (and (listp gnus-group-faq-directory)
3678 gnus-group-faq-directory))))))
3680 (error "No group name given"))
3681 (let ((dirs (or faq-dir gnus-group-faq-directory))
3683 (unless (listp dirs)
3684 (setq dirs (list dirs)))
3685 (while (and (not found)
3686 (setq dir (pop dirs)))
3687 (let ((name (gnus-group-real-name group)))
3688 (setq file (expand-file-name name dir)))
3689 (if (not (file-exists-p file))
3690 (gnus-message 1 "No such file: %s" file)
3691 (let ((enable-local-variables nil))
3695 (defun gnus-group-fetch-charter (group)
3696 "Fetch the charter for the current group.
3697 If given a prefix argument, prompt for a group."
3699 (list (or (when current-prefix-arg
3700 (completing-read "Group: " gnus-active-hashtb))
3701 (gnus-group-group-name)
3702 gnus-newsgroup-name)))
3704 (error "No group name given"))
3706 (condition-case nil (require 'url-http) (error nil))
3707 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3709 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3710 (setq hierarchy (match-string 1 name))
3711 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3712 (if (fboundp 'url-http-file-exists-p)
3713 (url-http-file-exists-p (eval url))
3715 (browse-url (eval url))
3716 (setq url (concat "http://" hierarchy
3717 ".news-admin.org/charters/" name))
3718 (if (and (fboundp 'url-http-file-exists-p)
3719 (url-http-file-exists-p url))
3721 (gnus-group-fetch-control group))))))
3723 (defun gnus-group-fetch-control (group)
3724 "Fetch the archived control messages for the current group.
3725 If given a prefix argument, prompt for a group."
3727 (list (or (when current-prefix-arg
3728 (completing-read "Group: " gnus-active-hashtb))
3729 (gnus-group-group-name)
3730 gnus-newsgroup-name)))
3732 (error "No group name given"))
3733 (let ((name (gnus-group-real-name group))
3735 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3736 (setq hierarchy (match-string 1 name))
3737 (if gnus-group-fetch-control-use-browse-url
3738 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3739 hierarchy "/" name ".gz"))
3740 (let ((enable-local-variables nil))
3741 (gnus-group-read-ephemeral-group
3743 `(nndoc ,group (nndoc-address
3744 ,(find-file-noselect
3745 (concat "/ftp@ftp.isc.org:/usenet/control/"
3746 hierarchy "/" name ".gz")))
3747 (nndoc-article-type mbox)) t nil nil))))))
3749 (defun gnus-group-describe-group (force &optional group)
3750 "Display a description of the current newsgroup."
3751 (interactive (list current-prefix-arg (gnus-group-group-name)))
3752 (let* ((method (gnus-find-method-for-group group))
3753 (mname (gnus-group-prefixed-name "" method))
3756 gnus-description-hashtb)
3757 (gnus-sethash mname nil gnus-description-hashtb))
3759 (error "No group name given"))
3760 (when (or (and gnus-description-hashtb
3761 ;; We check whether this group's method has been
3762 ;; queried for a description file.
3763 (gnus-gethash mname gnus-description-hashtb))
3764 (setq desc (gnus-group-get-description group))
3765 (gnus-read-descriptions-file method))
3767 (or desc (gnus-gethash group gnus-description-hashtb)
3768 "No description available")))))
3770 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3771 (defun gnus-group-describe-all-groups (&optional force)
3772 "Pop up a buffer with descriptions of all newsgroups."
3775 (setq gnus-description-hashtb nil))
3776 (when (not (or gnus-description-hashtb
3777 (gnus-read-all-descriptions-files)))
3778 (error "Couldn't request descriptions file"))
3779 (let ((buffer-read-only nil)
3785 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3786 (insert (format " *: %-20s %s\n"
3787 (gnus-group-name-decode
3788 (symbol-name group) charset)
3789 (gnus-group-name-decode
3790 (symbol-value group) charset))))
3791 (gnus-add-text-properties
3792 b (1+ b) (list 'gnus-group group
3793 'gnus-unread t 'gnus-marked nil
3794 'gnus-level (1+ gnus-level-subscribed))))
3795 gnus-description-hashtb)
3796 (goto-char (point-min))
3797 (gnus-group-position-point)))
3799 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3800 (defun gnus-group-apropos (regexp &optional search-description)
3801 "List all newsgroups that have names that match a regexp."
3802 (interactive "sGnus apropos (regexp): ")
3804 (obuf (current-buffer))
3806 ;; Go through all newsgroups that are known to Gnus.
3809 (and (symbol-name group)
3810 (string-match regexp (symbol-name group))
3811 (symbol-value group)
3812 (push (symbol-name group) groups)))
3814 ;; Also go through all descriptions that are known to Gnus.
3815 (when search-description
3818 (and (string-match regexp (symbol-value group))
3819 (push (symbol-name group) groups)))
3820 gnus-description-hashtb))
3822 (gnus-message 3 "No groups matched \"%s\"." regexp)
3823 ;; Print out all the groups.
3825 (pop-to-buffer "*Gnus Help*")
3826 (buffer-disable-undo)
3828 (setq groups (sort groups 'string<))
3830 ;; Groups may be entered twice into the list of groups.
3831 (when (not (string= (car groups) prev))
3832 (setq prev (car groups))
3833 (let ((charset (gnus-group-name-charset nil prev)))
3834 (insert (gnus-group-name-decode prev charset) "\n")
3835 (when (and gnus-description-hashtb
3836 (setq des (gnus-gethash (car groups)
3837 gnus-description-hashtb)))
3838 (insert " " (gnus-group-name-decode des charset) "\n"))))
3839 (setq groups (cdr groups)))
3840 (goto-char (point-min))))
3841 (pop-to-buffer obuf)))
3843 (defun gnus-group-description-apropos (regexp)
3844 "List all newsgroups that have names or descriptions that match REGEXP."
3845 (interactive "sGnus description apropos (regexp): ")
3846 (when (not (or gnus-description-hashtb
3847 (gnus-read-all-descriptions-files)))
3848 (error "Couldn't request descriptions file"))
3849 (gnus-group-apropos regexp t))
3851 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3852 (defun gnus-group-list-matching (level regexp &optional all lowest)
3853 "List all groups with unread articles that match REGEXP.
3854 If the prefix LEVEL is non-nil, it should be a number that says which
3855 level to cut off listing groups.
3856 If ALL, also list groups with no unread articles.
3857 If LOWEST, don't list groups with level lower than LOWEST.
3859 This command may read the active file."
3860 (interactive "P\nsList newsgroups matching: ")
3861 ;; First make sure active file has been read.
3863 (> (prefix-numeric-value level) gnus-level-killed))
3864 (gnus-get-killed-groups))
3865 (funcall gnus-group-prepare-function
3866 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3867 (goto-char (point-min))
3868 (gnus-group-position-point))
3870 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3871 "List all groups that match REGEXP.
3872 If the prefix LEVEL is non-nil, it should be a number that says which
3873 level to cut off listing groups.
3874 If LOWEST, don't list groups with level lower than LOWEST."
3875 (interactive "P\nsList newsgroups matching: ")
3877 (setq level (prefix-numeric-value level)))
3878 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3880 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3881 (defun gnus-group-save-newsrc (&optional force)
3882 "Save the Gnus startup files.
3883 If FORCE, force saving whether it is necessary or not."
3885 (gnus-save-newsrc-file force))
3887 (defun gnus-group-restart (&optional arg)
3888 "Force Gnus to read the .newsrc file."
3890 (when (gnus-yes-or-no-p
3891 (format "Are you sure you want to restart Gnus? "))
3892 (gnus-save-newsrc-file)
3896 (defun gnus-group-read-init-file ()
3897 "Read the Gnus elisp init file."
3899 (gnus-read-init-file)
3900 (gnus-message 5 "Read %s" gnus-init-file))
3902 (defun gnus-group-check-bogus-groups (&optional silent)
3903 "Check bogus newsgroups.
3904 If given a prefix, don't ask for confirmation before removing a bogus
3907 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3908 (gnus-group-list-groups))
3910 (defun gnus-group-find-new-groups (&optional arg)
3911 "Search for new groups and add them.
3912 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3913 With 1 C-u, use the `ask-server' method to query the server for new
3915 With 2 C-u's, use most complete method possible to query the server
3916 for new groups, and subscribe the new groups as zombies."
3918 (gnus-find-new-newsgroups (or arg 1))
3919 (gnus-group-list-groups))
3921 (defun gnus-group-edit-global-kill (&optional article group)
3922 "Edit the global kill file.
3923 If GROUP, edit that local kill file instead."
3925 (setq gnus-current-kill-article article)
3926 (gnus-kill-file-edit-file group)
3929 (substitute-command-keys
3930 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3931 (if group "local" "global")))))
3933 (defun gnus-group-edit-local-kill (article group)
3934 "Edit a local kill file."
3935 (interactive (list nil (gnus-group-group-name)))
3936 (gnus-group-edit-global-kill article group))
3938 (defun gnus-group-force-update ()
3939 "Update `.newsrc' file."
3941 (gnus-save-newsrc-file))
3943 (defvar gnus-backlog-articles)
3945 (defun gnus-group-suspend ()
3946 "Suspend the current Gnus session.
3947 In fact, cleanup buffers except for group mode buffer.
3948 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
3950 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3951 (gnus-offer-save-summaries)
3952 ;; Kill Gnus buffers except for group mode buffer.
3953 (let ((group-buf (get-buffer gnus-group-buffer)))
3954 (mapcar (lambda (buf)
3955 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3959 (eq major-mode 'message-mode))))
3960 (gnus-kill-buffer buf)))
3962 (setq gnus-backlog-articles nil)
3963 (gnus-kill-gnus-frames)
3965 (bury-buffer group-buf)
3966 (delete-windows-on group-buf t))))
3968 (defun gnus-group-clear-dribble ()
3969 "Clear all information from the dribble buffer."
3971 (gnus-dribble-clear)
3972 (gnus-message 7 "Cleared dribble buffer"))
3974 (defun gnus-group-exit ()
3975 "Quit reading news after updating .newsrc.eld and .newsrc.
3976 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3979 (or noninteractive ;For gnus-batch-kill
3980 (not gnus-interactive-exit) ;Without confirmation
3982 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3983 (gnus-run-hooks 'gnus-exit-gnus-hook)
3984 ;; Offer to save data from non-quitted summary buffers.
3985 (gnus-offer-save-summaries)
3986 ;; Save the newsrc file(s).
3987 (gnus-save-newsrc-file)
3989 (gnus-close-backends)
3990 ;; Reset everything.
3992 ;; Allow the user to do things after cleaning up.
3993 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3995 (defun gnus-group-quit ()
3996 "Quit reading news without updating .newsrc.eld or .newsrc.
3997 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3999 (when (or noninteractive ;For gnus-batch-kill
4000 (zerop (buffer-size))
4001 (not (gnus-server-opened gnus-select-method))
4003 (not gnus-current-startup-file)
4005 (format "Quit reading news without saving %s? "
4006 (file-name-nondirectory gnus-current-startup-file))))
4007 (gnus-run-hooks 'gnus-exit-gnus-hook)
4008 (gnus-configure-windows 'group t)
4009 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4010 (not (zerop (save-excursion
4011 (set-buffer gnus-dribble-buffer)
4014 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4016 (gnus-close-backends)
4018 (gnus-kill-buffer gnus-group-buffer)
4019 ;; Allow the user to do things after cleaning up.
4020 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4022 (defun gnus-group-describe-briefly ()
4023 "Give a one line description of the group mode commands."
4025 (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")))
4027 (defun gnus-group-browse-foreign-server (method)
4028 "Browse a foreign news server.
4029 If called interactively, this function will ask for a select method
4030 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4031 If not, METHOD should be a list where the first element is the method
4032 and the second element is the address."
4034 (list (let ((how (completing-read
4036 (append gnus-valid-select-methods gnus-server-alist)
4037 nil t (cons "nntp" 0) 'gnus-method-history)))
4038 ;; We either got a back end name or a virtual server name.
4039 ;; If the first, we also need an address.
4040 (if (assoc how gnus-valid-select-methods)
4042 ;; Suggested by mapjph@bath.ac.uk.
4045 (mapcar (lambda (server) (list server))
4046 gnus-secondary-servers)))
4047 ;; We got a server name.
4049 (gnus-browse-foreign-server method))
4051 (defun gnus-group-set-info (info &optional method-only-group part)
4052 (when (or info part)
4053 (let* ((entry (gnus-gethash
4054 (or method-only-group (gnus-info-group info))
4055 gnus-newsrc-hashtb))
4057 (info (if method-only-group (nth 2 entry) info))
4059 (when method-only-group
4061 (error "Trying to change non-existent group %s" method-only-group))
4062 ;; We have received parts of the actual group info - either the
4063 ;; select method or the group parameters. We first check
4064 ;; whether we have to extend the info, and if so, do that.
4065 (let ((len (length info))
4066 (total (if (eq part 'method) 5 6)))
4068 (setcdr (nthcdr (1- len) info)
4069 (make-list (- total len) nil)))
4070 ;; Then we enter the new info.
4071 (setcar (nthcdr (1- total) info) part-info)))
4073 ;; This is a new group, so we just create it.
4075 (set-buffer gnus-group-buffer)
4076 (setq method (gnus-info-method info))
4077 (when (gnus-server-equal method "native")
4080 (set-buffer gnus-group-buffer)
4082 ;; It's a foreign group...
4083 (gnus-group-make-group
4084 (gnus-group-real-name (gnus-info-group info))
4085 (if (stringp method) method
4086 (prin1-to-string (car method)))
4088 (nth 1 (gnus-info-method info))))
4089 ;; It's a native group.
4090 (gnus-group-make-group (gnus-info-group info))))
4091 (gnus-message 6 "Note: New group created")
4093 (gnus-gethash (gnus-group-prefixed-name
4094 (gnus-group-real-name (gnus-info-group info))
4095 (or (gnus-info-method info) gnus-select-method))
4096 gnus-newsrc-hashtb))))
4097 ;; Whether it was a new group or not, we now have the entry, so we
4098 ;; can do the update.
4101 (setcar (nthcdr 2 entry) info)
4102 (when (and (not (eq (car entry) t))
4103 (gnus-active (gnus-info-group info)))
4104 (setcar entry (length
4105 (gnus-list-of-unread-articles (car info))))))
4106 (error "No such group: %s" (gnus-info-group info))))))
4108 (defun gnus-group-set-method-info (group select-method)
4109 (gnus-group-set-info select-method group 'method))
4111 (defun gnus-group-set-params-info (group params)
4112 (gnus-group-set-info params group 'params))
4114 (defun gnus-add-marked-articles (group type articles &optional info force)
4115 ;; Add ARTICLES of TYPE to the info of GROUP.
4116 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4117 ;; add, but replace marked articles of TYPE with ARTICLES.
4118 (let ((info (or info (gnus-get-info group)))
4121 (and (not (setq marked (nthcdr 3 info)))
4123 (setcdr (nthcdr 2 info)
4124 (list (list (cons type (gnus-compress-sequence
4126 (and (not (setq m (assq type (car marked))))
4129 (cons (cons type (gnus-compress-sequence articles t) )
4133 (setcar (nthcdr 3 info)
4134 (gnus-delete-alist type (car marked)))
4135 (setcdr m (gnus-compress-sequence articles t)))
4136 (setcdr m (gnus-compress-sequence
4137 (sort (nconc (gnus-uncompress-range (cdr m))
4138 (copy-sequence articles)) '<) t))))))
4140 (defun gnus-add-mark (group mark article)
4141 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4142 (let ((buffer (gnus-summary-buffer-name group)))
4143 (if (gnus-buffer-live-p buffer)
4145 (set-buffer (get-buffer buffer))
4146 (gnus-summary-add-mark article mark))
4147 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4151 ;;; Group timestamps
4154 (defun gnus-group-set-timestamp ()
4155 "Change the timestamp of the current group to the current time.
4156 This function can be used in hooks like `gnus-select-group-hook'
4157 or `gnus-group-catchup-group-hook'."
4158 (when gnus-newsgroup-name
4159 (let ((time (current-time)))
4160 (setcdr (cdr time) nil)
4161 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4163 (defsubst gnus-group-timestamp (group)
4164 "Return the timestamp for GROUP."
4165 (gnus-group-get-parameter group 'timestamp t))
4167 (defun gnus-group-timestamp-delta (group)
4168 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4169 (let* ((time (or (gnus-group-timestamp group)
4171 (delta (subtract-time (current-time) time)))
4172 (+ (* (nth 0 delta) 65536.0)
4175 (defun gnus-group-timestamp-string (group)
4176 "Return a string of the timestamp for GROUP."
4177 (let ((time (gnus-group-timestamp group)))
4180 (gnus-time-iso8601 time))))
4182 (defun gnus-group-list-cached (level &optional lowest)
4183 "List all groups with cached articles.
4184 If the prefix LEVEL is non-nil, it should be a number that says which
4185 level to cut off listing groups.
4186 If LOWEST, don't list groups with level lower than LOWEST.
4188 This command may read the active file."
4191 (setq level (prefix-numeric-value level)))
4192 (when (or (not level) (>= level gnus-level-zombie))
4194 (funcall gnus-group-prepare-function
4195 (or level gnus-level-subscribed)
4197 (let ((marks (gnus-info-marks info)))
4198 (assq 'cache marks)))
4201 (or (gnus-gethash group
4202 gnus-cache-active-hashtb)
4203 ;; Cache active file might use "."
4206 (mapconcat 'identity
4207 (split-string group ":")
4209 gnus-cache-active-hashtb))))
4210 (goto-char (point-min))
4211 (gnus-group-position-point))
4213 (defun gnus-group-list-dormant (level &optional lowest)
4214 "List all groups with dormant articles.
4215 If the prefix LEVEL is non-nil, it should be a number that says which
4216 level to cut off listing groups.
4217 If LOWEST, don't list groups with level lower than LOWEST.
4219 This command may read the active file."
4222 (setq level (prefix-numeric-value level)))
4223 (when (or (not level) (>= level gnus-level-zombie))
4225 (funcall gnus-group-prepare-function
4226 (or level gnus-level-subscribed)
4228 (let ((marks (gnus-info-marks info)))
4229 (assq 'dormant marks)))
4232 (goto-char (point-min))
4233 (gnus-group-position-point))
4235 (defun gnus-group-listed-groups ()
4236 "Return a list of listed groups."
4238 (goto-char (point-min))
4239 (while (setq point (text-property-not-all (point) (point-max)
4242 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4246 (defun gnus-group-list-plus (&optional args)
4247 "List groups plus the current selection."
4249 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4250 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4252 (push last-command-event unread-command-events)
4253 (if (featurep 'xemacs)
4254 (push (make-event 'key-press '(key ?A)) unread-command-events)
4255 (push ?A unread-command-events))
4256 (let (gnus-pick-mode keys)
4257 (setq keys (if (featurep 'xemacs)
4258 (events-to-keys (read-key-sequence nil))
4259 (read-key-sequence nil)))
4260 (setq func (lookup-key (current-local-map) keys)))
4264 (call-interactively func))))
4266 (defun gnus-group-list-flush (&optional args)
4267 "Flush groups from the current selection."
4269 (let ((gnus-group-list-option 'flush))
4270 (gnus-group-list-plus args)))
4272 (defun gnus-group-list-limit (&optional args)
4273 "List groups limited within the current selection."
4275 (let ((gnus-group-list-option 'limit))
4276 (gnus-group-list-plus args)))
4278 (defun gnus-group-mark-article-read (group article)
4279 "Mark ARTICLE read."
4280 (let ((buffer (gnus-summary-buffer-name group))
4281 (mark gnus-read-mark)
4283 (if (get-buffer buffer)
4284 (with-current-buffer buffer
4285 (setq active gnus-newsgroup-active)
4286 (gnus-activate-group group)
4287 (when gnus-newsgroup-prepared
4288 (when (and gnus-newsgroup-auto-expire
4289 (memq mark gnus-auto-expirable-marks))
4290 (setq mark gnus-expirable-mark))
4291 (setq mark (gnus-request-update-mark
4292 group article mark))
4293 (gnus-mark-article-as-read article mark)
4294 (setq gnus-newsgroup-active (gnus-active group))
4296 (setq n (1+ (cdr active)))
4297 (while (<= n (cdr gnus-newsgroup-active))
4298 (unless (eq n article)
4299 (push n gnus-newsgroup-unselected))
4301 (setq gnus-newsgroup-unselected
4302 (nreverse gnus-newsgroup-unselected)))))
4303 (gnus-activate-group group)
4304 (gnus-group-make-articles-read group (list article))
4305 (when (gnus-group-auto-expirable-p group)
4306 (gnus-add-marked-articles
4307 group 'expire (list article))))))
4309 (provide 'gnus-group)
4311 ;;; arch-tag: 2eb5440f-0bca-4091-814c-e37817536af6
4312 ;;; gnus-group.el ends here