1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
41 (defcustom gnus-group-archive-directory
42 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
43 "*The address of the (ding) archives."
44 :group 'gnus-group-foreign
47 (defcustom gnus-group-recent-archive-directory
48 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
49 "*The address of the most recent (ding) articles."
50 :group 'gnus-group-foreign
53 (defcustom gnus-no-groups-message "No gnus is bad news"
54 "*Message displayed by Gnus when no groups are available."
58 (defcustom gnus-keep-same-level nil
59 "*Non-nil means that the next newsgroup after the current will be on the same level.
60 When you type, for instance, `n' after reading the last article in the
61 current newsgroup, you will go to the next newsgroup. If this variable
62 is nil, the next newsgroup will be the next from the group
64 If this variable is non-nil, Gnus will either put you in the
65 next newsgroup with the same level, or, if no such newsgroup is
66 available, the next newsgroup with the lowest possible level higher
67 than the current level.
68 If this variable is `best', Gnus will make the next newsgroup the one
70 :group 'gnus-group-levels
71 :type '(choice (const nil)
73 (sexp :tag "other" t)))
75 (defcustom gnus-group-goto-unread t
76 "*If non-nil, movement commands will go to the next unread and subscribed group."
77 :link '(custom-manual "(gnus)Group Maneuvering")
78 :group 'gnus-group-various
81 (defcustom gnus-goto-next-group-when-activating t
82 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
83 :link '(custom-manual "(gnus)Scanning New Messages")
84 :group 'gnus-group-various
87 (defcustom gnus-permanently-visible-groups nil
88 "*Regexp to match groups that should always be listed in the group buffer.
89 This means that they will still be listed even when there are no
90 unread articles in the groups.
92 If nil, no groups are permanently visible."
93 :group 'gnus-group-listing
94 :type '(choice regexp (const nil)))
96 (defcustom gnus-list-groups-with-ticked-articles t
97 "*If non-nil, list groups that have only ticked articles.
98 If nil, only list groups that have unread articles."
99 :group 'gnus-group-listing
102 (defcustom gnus-group-default-list-level gnus-level-subscribed
103 "*Default listing level.
104 Ignored if `gnus-group-use-permanent-levels' is non-nil."
105 :group 'gnus-group-listing
108 (defcustom gnus-group-list-inactive-groups t
109 "*If non-nil, inactive groups will be listed."
110 :group 'gnus-group-listing
111 :group 'gnus-group-levels
114 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
115 "*Function used for sorting the group buffer.
116 This function will be called with group info entries as the arguments
117 for the groups to be sorted. Pre-made functions include
118 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
119 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
120 `gnus-group-sort-by-score', `gnus-group-sort-by-method', and
121 `gnus-group-sort-by-rank'.
123 This variable can also be a list of sorting functions. In that case,
124 the most significant sort function should be the last function in the
126 :group 'gnus-group-listing
127 :link '(custom-manual "(gnus)Sorting Groups")
128 :type '(radio (function-item gnus-group-sort-by-alphabet)
129 (function-item gnus-group-sort-by-real-name)
130 (function-item gnus-group-sort-by-unread)
131 (function-item gnus-group-sort-by-level)
132 (function-item gnus-group-sort-by-score)
133 (function-item gnus-group-sort-by-method)
134 (function-item gnus-group-sort-by-rank)
135 (function :tag "other" nil)))
137 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
138 "*Format of group lines.
139 It works along the same lines as a normal formatting string,
140 with some simple extensions.
142 %M Only marked articles (character, \"*\" or \" \")
143 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
144 %L Level of subscribedness (integer)
145 %N Number of unread articles (integer)
146 %I Number of dormant articles (integer)
147 %i Number of ticked and dormant (integer)
148 %T Number of ticked articles (integer)
149 %R Number of read articles (integer)
150 %t Estimated total number of articles (integer)
151 %y Number of unread, unticked articles (integer)
152 %G Group name (string)
153 %g Qualified group name (string)
154 %D Group description (string)
155 %s Select method (string)
156 %o Moderated group (char, \"m\")
157 %p Process mark (char)
158 %O Moderated group (string, \"(m)\" or \"\")
159 %P Topic indentation (string)
160 %m Whether there is new(ish) mail in the group (char, \"%\")
161 %w Number of new(ish) mails in the group (integer)
162 %l Whether there are GroupLens predictions for this group (string)
163 %n Select from where (string)
164 %z A string that look like `<%s:%n>' if a foreign select method is used
165 %d The date the group was last entered.
166 %E Icon as defined by `gnus-group-icon-list'.
167 %u User defined specifier. The next character in the format string should
168 be a letter. Gnus will call the function gnus-user-format-function-X,
169 where X is the letter following %u. The function will be passed the
170 current header as argument. The function should return a string, which
171 will be inserted into the buffer just like information from any other
174 Text between %( and %) will be highlighted with `gnus-mouse-face' when
175 the mouse point move inside the area. There can only be one such area.
177 Note that this format specification is not always respected. For
178 reasons of efficiency, when listing killed groups, this specification
179 is ignored altogether. If the spec is changed considerably, your
180 output may end up looking strange when listing both alive and killed
183 If you use %o or %O, reading the active file will be slower and quite
184 a bit of extra memory will be used. %D will also worsen performance.
185 Also note that if you change the format specification to include any
186 of these specs, you must probably re-start Gnus to see them go into
188 :group 'gnus-group-visual
191 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
192 "*The format specification for the group mode line.
193 It works along the same lines as a normal formatting string,
194 with some simple extensions:
196 %S The native news server.
197 %M The native select method.
198 %: \":\" if %S isn't \"\"."
199 :group 'gnus-group-visual
202 (defcustom gnus-group-mode-hook nil
203 "Hook for Gnus group mode."
204 :group 'gnus-group-various
205 :options '(gnus-topic-mode)
208 (defcustom gnus-group-menu-hook nil
209 "Hook run after the creation of the group mode menu."
210 :group 'gnus-group-various
213 (defcustom gnus-group-catchup-group-hook nil
214 "Hook run when catching up a group from the group buffer."
215 :group 'gnus-group-various
216 :link '(custom-manual "(gnus)Group Data")
219 (defcustom gnus-group-update-group-hook nil
220 "Hook called when updating group lines."
221 :group 'gnus-group-visual
224 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
225 "*A function that is called to generate the group buffer.
226 The function is called with three arguments: The first is a number;
227 all group with a level less or equal to that number should be listed,
228 if the second is non-nil, empty groups should also be displayed. If
229 the third is non-nil, it is a number. No groups with a level lower
230 than this number should be displayed.
232 The only current function implemented is `gnus-group-prepare-flat'."
233 :group 'gnus-group-listing
236 (defcustom gnus-group-prepare-hook nil
237 "Hook called after the group buffer has been generated.
238 If you want to modify the group buffer, you can use this hook."
239 :group 'gnus-group-listing
242 (defcustom gnus-suspend-gnus-hook nil
243 "Hook called when suspending (not exiting) Gnus."
247 (defcustom gnus-exit-gnus-hook nil
248 "Hook called when exiting Gnus."
252 (defcustom gnus-after-exiting-gnus-hook nil
253 "Hook called after exiting Gnus."
257 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
258 "Hook called when a group line is changed.
259 The hook will not be called if `gnus-visual' is nil.
261 The default function `gnus-group-highlight-line' will
262 highlight the line according to the `gnus-group-highlight'
264 :group 'gnus-group-visual
267 (defcustom gnus-useful-groups
268 '(("(ding) mailing list mirrored at sunsite.auc.dk"
270 (nntp "sunsite.auc.dk"
271 (nntp-address "sunsite.auc.dk")))
274 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
278 (nndoc-article-type mbox)
279 (eval `(nndoc-address
280 ,(let ((file (nnheader-find-etc-directory
283 (error "Couldn't find doc group"))
285 "*Alist of useful group-server pairs."
286 :group 'gnus-group-listing
287 :type '(repeat (list (string :tag "Description")
289 (sexp :tag "Method"))))
291 (defcustom gnus-group-highlight
293 ((and (= unread 0) (not mailp) (eq level 1)) .
294 gnus-group-news-1-empty-face)
295 ((and (not mailp) (eq level 1)) .
296 gnus-group-news-1-face)
297 ((and (= unread 0) (not mailp) (eq level 2)) .
298 gnus-group-news-2-empty-face)
299 ((and (not mailp) (eq level 2)) .
300 gnus-group-news-2-face)
301 ((and (= unread 0) (not mailp) (eq level 3)) .
302 gnus-group-news-3-empty-face)
303 ((and (not mailp) (eq level 3)) .
304 gnus-group-news-3-face)
305 ((and (= unread 0) (not mailp) (eq level 4)) .
306 gnus-group-news-4-empty-face)
307 ((and (not mailp) (eq level 4)) .
308 gnus-group-news-4-face)
309 ((and (= unread 0) (not mailp) (eq level 5)) .
310 gnus-group-news-5-empty-face)
311 ((and (not mailp) (eq level 5)) .
312 gnus-group-news-5-face)
313 ((and (= unread 0) (not mailp) (eq level 6)) .
314 gnus-group-news-6-empty-face)
315 ((and (not mailp) (eq level 6)) .
316 gnus-group-news-6-face)
317 ((and (= unread 0) (not mailp)) .
318 gnus-group-news-low-empty-face)
320 gnus-group-news-low-face)
322 ((and (= unread 0) (eq level 1)) .
323 gnus-group-mail-1-empty-face)
325 gnus-group-mail-1-face)
326 ((and (= unread 0) (eq level 2)) .
327 gnus-group-mail-2-empty-face)
329 gnus-group-mail-2-face)
330 ((and (= unread 0) (eq level 3)) .
331 gnus-group-mail-3-empty-face)
333 gnus-group-mail-3-face)
335 gnus-group-mail-low-empty-face)
337 gnus-group-mail-low-face))
338 "*Controls the highlighting of group buffer lines.
340 Below is a list of `Form'/`Face' pairs. When deciding how a a
341 particular group line should be displayed, each form is
342 evaluated. The content of the face field after the first true form is
343 used. You can change how those group lines are displayed by
344 editing the face field.
346 It is also possible to change and add form fields, but currently that
347 requires an understanding of Lisp expressions. Hopefully this will
348 change in a future release. For now, you can use the following
349 variables in the Lisp expression:
351 group: The name of the group.
352 unread: The number of unread articles in the group.
353 method: The select method used.
354 mailp: Whether it's a mail group or not.
355 level: The level of the group.
356 score: The score of the group.
357 ticked: The number of ticked articles."
358 :group 'gnus-group-visual
359 :type '(repeat (cons (sexp :tag "Form") face)))
361 (defcustom gnus-new-mail-mark ?%
362 "Mark used for groups with new mail."
363 :group 'gnus-group-visual
366 (defgroup gnus-group-icons nil
367 "Add Icons to your group buffer. "
368 :group 'gnus-group-visual)
370 (defcustom gnus-group-icon-list
372 "*Controls the insertion of icons into group buffer lines.
374 Below is a list of `Form'/`File' pairs. When deciding how a
375 particular group line should be displayed, each form is evaluated.
376 The icon from the file field after the first true form is used. You
377 can change how those group lines are displayed by editing the file
378 field. The File will either be found in the
379 `gnus-group-glyph-directory' or by designating absolute path to the
382 It is also possible to change and add form fields, but currently that
383 requires an understanding of Lisp expressions. Hopefully this will
384 change in a future release. For now, you can use the following
385 variables in the Lisp expression:
387 group: The name of the group.
388 unread: The number of unread articles in the group.
389 method: The select method used.
390 mailp: Whether it's a mail group or not.
391 newsp: Whether it's a news group or not
392 level: The level of the group.
393 score: The score of the group.
394 ticked: The number of ticked articles."
395 :group 'gnus-group-icons
396 :type '(repeat (cons (sexp :tag "Form") file)))
398 (defcustom gnus-group-name-charset-method-alist nil
399 "*Alist of method and the charset for group names.
402 (((nntp \"news.com.cn\") . cn-gb-2312))
405 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
407 (defcustom gnus-group-name-charset-group-alist nil
408 "*Alist of group regexp and the charset for group names.
411 ((\"\\.com\\.cn:\" . cn-gb-2312))
414 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
416 ;;; Internal variables
418 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
419 "Function for sorting the group buffer.")
421 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
422 "Function for sorting the selected groups in the group buffer.")
424 (defvar gnus-group-indentation-function nil)
425 (defvar gnus-goto-missing-group-function nil)
426 (defvar gnus-group-update-group-function nil)
427 (defvar gnus-group-goto-next-group-function nil
428 "Function to override finding the next group after listing groups.")
430 (defvar gnus-group-edit-buffer nil)
432 (defvar gnus-group-line-format-alist
433 `((?M gnus-tmp-marked-mark ?c)
434 (?S gnus-tmp-subscribed ?c)
435 (?L gnus-tmp-level ?d)
436 (?N (cond ((eq number t) "*" )
440 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
441 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
443 (?R gnus-tmp-number-of-read ?s)
444 (?t gnus-tmp-number-total ?d)
445 (?y gnus-tmp-number-of-unread ?s)
446 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
447 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
448 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
449 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
450 (?g gnus-tmp-group ?s)
451 (?G gnus-tmp-qualified-group ?s)
452 (?c (gnus-short-group-name gnus-tmp-group) ?s)
453 (?D gnus-tmp-newsgroup-description ?s)
454 (?o gnus-tmp-moderated ?c)
455 (?O gnus-tmp-moderated-string ?s)
456 (?p gnus-tmp-process-marked ?c)
457 (?s gnus-tmp-news-server ?s)
458 (?n gnus-tmp-news-method ?s)
459 (?P gnus-group-indentation ?s)
460 (?E gnus-tmp-group-icon ?s)
461 (?l gnus-tmp-grouplens ?s)
462 (?z gnus-tmp-news-method-string ?s)
463 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
464 (?w (if (gnus-news-group-p gnus-tmp-group)
468 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
471 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
472 (?u gnus-tmp-user-defined ?s)))
474 (defvar gnus-group-mode-line-format-alist
475 `((?S gnus-tmp-news-server ?s)
476 (?M gnus-tmp-news-method ?s)
477 (?u gnus-tmp-user-defined ?s)
478 (?: gnus-tmp-colon ?s)))
480 (defvar gnus-topic-topology nil
481 "The complete topic hierarchy.")
483 (defvar gnus-topic-alist nil
484 "The complete topic-group alist.")
486 (defvar gnus-group-marked nil)
488 (defvar gnus-group-list-mode nil)
491 (defvar gnus-group-icon-cache nil)
493 (defvar gnus-group-listed-groups nil)
494 (defvar gnus-group-list-option nil)
500 (put 'gnus-group-mode 'mode-class 'special)
503 (gnus-define-keys gnus-group-mode-map
504 " " gnus-group-read-group
505 "=" gnus-group-select-group
506 "\r" gnus-group-select-group
507 "\M-\r" gnus-group-quick-select-group
508 "\M- " gnus-group-visible-select-group
509 [(meta control return)] gnus-group-select-group-ephemerally
510 "j" gnus-group-jump-to-group
511 "n" gnus-group-next-unread-group
512 "p" gnus-group-prev-unread-group
513 "\177" gnus-group-prev-unread-group
514 [delete] gnus-group-prev-unread-group
515 [backspace] gnus-group-prev-unread-group
516 "N" gnus-group-next-group
517 "P" gnus-group-prev-group
518 "\M-n" gnus-group-next-unread-group-same-level
519 "\M-p" gnus-group-prev-unread-group-same-level
520 "," gnus-group-best-unread-group
521 "." gnus-group-first-unread-group
522 "u" gnus-group-unsubscribe-current-group
523 "U" gnus-group-unsubscribe-group
524 "c" gnus-group-catchup-current
525 "C" gnus-group-catchup-current-all
526 "\M-c" gnus-group-clear-data
527 "l" gnus-group-list-groups
528 "L" gnus-group-list-all-groups
530 "g" gnus-group-get-new-news
531 "\M-g" gnus-group-get-new-news-this-group
532 "R" gnus-group-restart
533 "r" gnus-group-read-init-file
534 "B" gnus-group-browse-foreign-server
535 "b" gnus-group-check-bogus-groups
536 "F" gnus-group-find-new-groups
537 "\C-c\C-d" gnus-group-describe-group
538 "\M-d" gnus-group-describe-all-groups
539 "\C-c\C-a" gnus-group-apropos
540 "\C-c\M-\C-a" gnus-group-description-apropos
541 "a" gnus-group-post-news
542 "\ek" gnus-group-edit-local-kill
543 "\eK" gnus-group-edit-global-kill
544 "\C-k" gnus-group-kill-group
545 "\C-y" gnus-group-yank-group
546 "\C-w" gnus-group-kill-region
547 "\C-x\C-t" gnus-group-transpose-groups
548 "\C-c\C-l" gnus-group-list-killed
549 "\C-c\C-x" gnus-group-expire-articles
550 "\C-c\M-\C-x" gnus-group-expire-all-groups
552 "s" gnus-group-save-newsrc
553 "z" gnus-group-suspend
556 "?" gnus-group-describe-briefly
557 "\C-c\C-i" gnus-info-find-node
558 "\M-e" gnus-group-edit-group-method
559 "^" gnus-group-enter-server-mode
560 gnus-mouse-2 gnus-mouse-pick-group
561 "<" beginning-of-buffer
564 "\C-c\C-s" gnus-group-sort-groups
566 "\C-c\M-g" gnus-activate-all-groups
567 "\M-&" gnus-group-universal-argument
568 "#" gnus-group-mark-group
569 "\M-#" gnus-group-unmark-group)
571 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
572 "m" gnus-group-mark-group
573 "u" gnus-group-unmark-group
574 "w" gnus-group-mark-region
575 "b" gnus-group-mark-buffer
576 "r" gnus-group-mark-regexp
577 "U" gnus-group-unmark-all-groups)
579 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
580 "d" gnus-group-make-directory-group
581 "h" gnus-group-make-help-group
582 "u" gnus-group-make-useful-group
583 "a" gnus-group-make-archive-group
584 "k" gnus-group-make-kiboze-group
585 "l" gnus-group-nnimap-edit-acl
586 "m" gnus-group-make-group
587 "E" gnus-group-edit-group
588 "e" gnus-group-edit-group-method
589 "p" gnus-group-edit-group-parameters
590 "v" gnus-group-add-to-virtual
591 "V" gnus-group-make-empty-virtual
592 "D" gnus-group-enter-directory
593 "f" gnus-group-make-doc-group
594 "w" gnus-group-make-web-group
595 "r" gnus-group-rename-group
596 "c" gnus-group-customize
597 "x" gnus-group-nnimap-expunge
598 "\177" gnus-group-delete-group
599 [delete] gnus-group-delete-group)
601 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
602 "b" gnus-group-brew-soup
603 "w" gnus-soup-save-areas
604 "s" gnus-soup-send-replies
605 "p" gnus-soup-pack-packet
606 "r" nnsoup-pack-replies)
608 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
609 "s" gnus-group-sort-groups
610 "a" gnus-group-sort-groups-by-alphabet
611 "u" gnus-group-sort-groups-by-unread
612 "l" gnus-group-sort-groups-by-level
613 "v" gnus-group-sort-groups-by-score
614 "r" gnus-group-sort-groups-by-rank
615 "m" gnus-group-sort-groups-by-method)
617 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
618 "s" gnus-group-sort-selected-groups
619 "a" gnus-group-sort-selected-groups-by-alphabet
620 "u" gnus-group-sort-selected-groups-by-unread
621 "l" gnus-group-sort-selected-groups-by-level
622 "v" gnus-group-sort-selected-groups-by-score
623 "r" gnus-group-sort-selected-groups-by-rank
624 "m" gnus-group-sort-selected-groups-by-method)
626 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
627 "k" gnus-group-list-killed
628 "z" gnus-group-list-zombies
629 "s" gnus-group-list-groups
630 "u" gnus-group-list-all-groups
631 "A" gnus-group-list-active
632 "a" gnus-group-apropos
633 "d" gnus-group-description-apropos
634 "m" gnus-group-list-matching
635 "M" gnus-group-list-all-matching
636 "l" gnus-group-list-level
637 "c" gnus-group-list-cached
638 "?" gnus-group-list-dormant)
640 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
641 "k" gnus-group-list-limit
642 "z" gnus-group-list-limit
643 "s" gnus-group-list-limit
644 "u" gnus-group-list-limit
645 "A" gnus-group-list-limit
646 "m" gnus-group-list-limit
647 "M" gnus-group-list-limit
648 "l" gnus-group-list-limit
649 "c" gnus-group-list-limit
650 "?" gnus-group-list-limit)
652 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
653 "k" gnus-group-list-flush
654 "z" gnus-group-list-flush
655 "s" gnus-group-list-flush
656 "u" gnus-group-list-flush
657 "A" gnus-group-list-flush
658 "m" gnus-group-list-flush
659 "M" gnus-group-list-flush
660 "l" gnus-group-list-flush
661 "c" gnus-group-list-flush
662 "?" gnus-group-list-flush)
664 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
665 "k" gnus-group-list-plus
666 "z" gnus-group-list-plus
667 "s" gnus-group-list-plus
668 "u" gnus-group-list-plus
669 "A" gnus-group-list-plus
670 "m" gnus-group-list-plus
671 "M" gnus-group-list-plus
672 "l" gnus-group-list-plus
673 "c" gnus-group-list-plus
674 "?" gnus-group-list-plus)
676 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
677 "f" gnus-score-flush-cache)
679 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
680 "d" gnus-group-describe-group
681 "f" gnus-group-fetch-faq
684 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
685 "l" gnus-group-set-current-level
686 "t" gnus-group-unsubscribe-current-group
687 "s" gnus-group-unsubscribe-group
688 "k" gnus-group-kill-group
689 "y" gnus-group-yank-group
690 "w" gnus-group-kill-region
691 "\C-k" gnus-group-kill-level
692 "z" gnus-group-kill-all-zombies))
694 (defun gnus-group-make-menu-bar ()
695 (gnus-turn-off-edit-menu 'group)
696 (unless (boundp 'gnus-group-reading-menu)
699 gnus-group-reading-menu gnus-group-mode-map ""
701 ["Read" gnus-group-read-group (gnus-group-group-name)]
702 ["Select" gnus-group-select-group (gnus-group-group-name)]
703 ["See old articles" (gnus-group-select-group 'all)
704 :keys "C-u SPC" :active (gnus-group-group-name)]
705 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
706 ["Catch up all articles" gnus-group-catchup-current-all
707 (gnus-group-group-name)]
708 ["Check for new articles" gnus-group-get-new-news-this-group
709 (gnus-group-group-name)]
710 ["Toggle subscription" gnus-group-unsubscribe-current-group
711 (gnus-group-group-name)]
712 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
713 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
714 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
715 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
716 ;; Actually one should check, if any of the marked groups gives t for
717 ;; (gnus-check-backend-function 'request-expire-articles ...)
718 ["Expire articles" gnus-group-expire-articles
719 (or (and (gnus-group-group-name)
720 (gnus-check-backend-function
721 'request-expire-articles
722 (gnus-group-group-name))) gnus-group-marked)]
723 ["Set group level" gnus-group-set-current-level
724 (gnus-group-group-name)]
725 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
726 ["Customize" gnus-group-customize (gnus-group-group-name)]
728 ["Parameters" gnus-group-edit-group-parameters
729 (gnus-group-group-name)]
730 ["Select method" gnus-group-edit-group-method
731 (gnus-group-group-name)]
732 ["Info" gnus-group-edit-group (gnus-group-group-name)]
733 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
734 ["Global kill file" gnus-group-edit-global-kill t])))
737 gnus-group-group-menu gnus-group-mode-map ""
740 ["List unread subscribed groups" gnus-group-list-groups t]
741 ["List (un)subscribed groups" gnus-group-list-all-groups t]
742 ["List killed groups" gnus-group-list-killed gnus-killed-list]
743 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
744 ["List level..." gnus-group-list-level t]
745 ["Describe all groups" gnus-group-describe-all-groups t]
746 ["Group apropos..." gnus-group-apropos t]
747 ["Group and description apropos..." gnus-group-description-apropos t]
748 ["List groups matching..." gnus-group-list-matching t]
749 ["List all groups matching..." gnus-group-list-all-matching t]
750 ["List active file" gnus-group-list-active t]
751 ["List groups with cached" gnus-group-list-cached t]
752 ["List groups with dormant" gnus-group-list-dormant t])
754 ["Default sort" gnus-group-sort-groups t]
755 ["Sort by method" gnus-group-sort-groups-by-method t]
756 ["Sort by rank" gnus-group-sort-groups-by-rank t]
757 ["Sort by score" gnus-group-sort-groups-by-score t]
758 ["Sort by level" gnus-group-sort-groups-by-level t]
759 ["Sort by unread" gnus-group-sort-groups-by-unread t]
760 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
761 ("Sort process/prefixed"
762 ["Default sort" gnus-group-sort-selected-groups
763 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
764 ["Sort by method" gnus-group-sort-selected-groups-by-method
765 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
766 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
767 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
768 ["Sort by score" gnus-group-sort-selected-groups-by-score
769 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
770 ["Sort by level" gnus-group-sort-selected-groups-by-level
771 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
772 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
773 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
774 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
775 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
777 ["Mark group" gnus-group-mark-group
778 (and (gnus-group-group-name)
779 (not (memq (gnus-group-group-name) gnus-group-marked)))]
780 ["Unmark group" gnus-group-unmark-group
781 (and (gnus-group-group-name)
782 (memq (gnus-group-group-name) gnus-group-marked))]
783 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
784 ["Mark regexp..." gnus-group-mark-regexp t]
785 ["Mark region" gnus-group-mark-region t]
786 ["Mark buffer" gnus-group-mark-buffer t]
787 ["Execute command" gnus-group-universal-argument
788 (or gnus-group-marked (gnus-group-group-name))])
790 ["Subscribe to a group" gnus-group-unsubscribe-group t]
791 ["Kill all newsgroups in region" gnus-group-kill-region t]
792 ["Kill all zombie groups" gnus-group-kill-all-zombies
794 ["Kill all groups on level..." gnus-group-kill-level t])
796 ["Make a foreign group" gnus-group-make-group t]
797 ["Add a directory group" gnus-group-make-directory-group t]
798 ["Add the help group" gnus-group-make-help-group t]
799 ["Add the archive group" gnus-group-make-archive-group t]
800 ["Make a doc group" gnus-group-make-doc-group t]
801 ["Make a web group" gnus-group-make-web-group t]
802 ["Make a kiboze group" gnus-group-make-kiboze-group t]
803 ["Make a virtual group" gnus-group-make-empty-virtual t]
804 ["Add a group to a virtual" gnus-group-add-to-virtual t]
805 ["Rename group" gnus-group-rename-group
806 (gnus-check-backend-function
807 'request-rename-group (gnus-group-group-name))]
808 ["Delete group" gnus-group-delete-group
809 (gnus-check-backend-function
810 'request-delete-group (gnus-group-group-name))])
812 ["Next" gnus-group-next-group t]
813 ["Previous" gnus-group-prev-group t]
814 ["Next unread" gnus-group-next-unread-group t]
815 ["Previous unread" gnus-group-prev-unread-group t]
816 ["Next unread same level" gnus-group-next-unread-group-same-level t]
817 ["Previous unread same level"
818 gnus-group-prev-unread-group-same-level t]
819 ["Jump to group" gnus-group-jump-to-group t]
820 ["First unread group" gnus-group-first-unread-group t]
821 ["Best unread group" gnus-group-best-unread-group t])
822 ["Delete bogus groups" gnus-group-check-bogus-groups t]
823 ["Find new newsgroups" gnus-group-find-new-groups t]
824 ["Transpose" gnus-group-transpose-groups
825 (gnus-group-group-name)]
826 ["Read a directory as a group..." gnus-group-enter-directory t]))
829 gnus-group-misc-menu gnus-group-mode-map ""
832 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
833 ["Send replies" gnus-soup-send-replies
834 (fboundp 'gnus-soup-pack-packet)]
835 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
836 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
837 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
838 ["Send a mail" gnus-group-mail t]
839 ["Post an article..." gnus-group-post-news t]
840 ["Check for new news" gnus-group-get-new-news t]
841 ["Activate all groups" gnus-activate-all-groups t]
842 ["Restart Gnus" gnus-group-restart t]
843 ["Read init file" gnus-group-read-init-file t]
844 ["Browse foreign server" gnus-group-browse-foreign-server t]
845 ["Enter server buffer" gnus-group-enter-server-mode t]
846 ["Expire all expirable articles" gnus-group-expire-all-groups t]
847 ["Generate any kiboze groups" nnkiboze-generate-groups t]
848 ["Gnus version" gnus-version t]
849 ["Save .newsrc files" gnus-group-save-newsrc t]
850 ["Suspend Gnus" gnus-group-suspend t]
851 ["Clear dribble buffer" gnus-group-clear-dribble t]
852 ["Read manual" gnus-info-find-node t]
853 ["Flush score cache" gnus-score-flush-cache t]
854 ["Toggle topics" gnus-topic-mode t]
855 ["Send a bug report" gnus-bug t]
856 ["Exit from Gnus" gnus-group-exit t]
857 ["Exit without saving" gnus-group-quit t]))
859 (gnus-run-hooks 'gnus-group-menu-hook)))
861 (defun gnus-group-mode ()
862 "Major mode for reading news.
864 All normal editing commands are switched off.
865 \\<gnus-group-mode-map>
866 The group buffer lists (some of) the groups available. For instance,
867 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
868 lists all zombie groups.
870 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
871 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
873 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
875 The following commands are available:
877 \\{gnus-group-mode-map}"
879 (when (gnus-visual-p 'group-menu 'menu)
880 (gnus-group-make-menu-bar))
881 (kill-all-local-variables)
882 (gnus-simplify-mode-line)
883 (setq major-mode 'gnus-group-mode)
884 (setq mode-name "Group")
885 (gnus-group-set-mode-line)
886 (setq mode-line-process nil)
887 (use-local-map gnus-group-mode-map)
888 (buffer-disable-undo)
889 (setq truncate-lines t)
890 (setq buffer-read-only t)
891 (gnus-set-default-directory)
892 (gnus-update-format-specifications nil 'group 'group-mode)
893 (gnus-update-group-mark-positions)
898 (gnus-run-hooks 'gnus-group-mode-hook))
900 (defun gnus-update-group-mark-positions ()
902 (let ((gnus-process-mark ?\200)
903 (gnus-group-marked '("dummy.group"))
904 (gnus-active-hashtb (make-vector 10 0))
906 (gnus-set-active "dummy.group" '(0 . 0))
907 (gnus-set-work-buffer)
908 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
909 (goto-char (point-min))
910 (setq gnus-group-mark-positions
911 (list (cons 'process (and (search-forward "\200" nil t)
914 (defun gnus-mouse-pick-group (e)
915 "Enter the group under the mouse pointer."
918 (gnus-group-read-group nil))
920 ;; Look at LEVEL and find out what the level is really supposed to be.
921 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
922 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
923 (defun gnus-group-default-level (&optional level number-or-nil)
925 (gnus-group-use-permanent-levels
926 (or (setq gnus-group-use-permanent-levels
927 (or level (if (numberp gnus-group-use-permanent-levels)
928 gnus-group-use-permanent-levels
929 (or gnus-group-default-list-level
930 gnus-level-subscribed))))
931 gnus-group-default-list-level gnus-level-subscribed))
935 (or level gnus-group-default-list-level gnus-level-subscribed))))
937 (defun gnus-group-setup-buffer ()
938 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
939 (unless (eq major-mode 'gnus-group-mode)
942 (gnus-carpal-setup-buffer 'group))))
944 (defsubst gnus-group-name-charset (method group)
946 (setq method (gnus-find-method-for-group group)))
947 (let ((item (assoc method gnus-group-name-charset-method-alist))
948 (alist gnus-group-name-charset-group-alist)
952 (while (setq item (pop alist))
953 (if (string-match (car item) group)
958 (defsubst gnus-group-name-decode (string charset)
959 (if (and string charset (featurep 'mule))
960 (decode-coding-string string charset)
963 (defun gnus-group-decoded-name (string)
964 (let ((charset (gnus-group-name-charset nil string)))
965 (gnus-group-name-decode string charset)))
967 (defun gnus-group-list-groups (&optional level unread lowest)
968 "List newsgroups with level LEVEL or lower that have unread articles.
969 Default is all subscribed groups.
970 If argument UNREAD is non-nil, groups with no unread articles are also
973 Also see the `gnus-group-use-permanent-levels' variable."
975 (list (if current-prefix-arg
976 (prefix-numeric-value current-prefix-arg)
978 (gnus-group-default-level nil t)
979 gnus-group-default-list-level
980 gnus-level-subscribed))))
982 (setq level (car gnus-group-list-mode)
983 unread (cdr gnus-group-list-mode)))
984 (setq level (gnus-group-default-level level))
985 (gnus-group-setup-buffer)
986 (gnus-update-format-specifications nil 'group 'group-mode)
987 (let ((case-fold-search nil)
988 (props (text-properties-at (gnus-point-at-bol)))
989 (empty (= (point-min) (point-max)))
990 (group (gnus-group-group-name))
992 (set-buffer gnus-group-buffer)
993 (setq number (funcall gnus-group-prepare-function level unread lowest))
994 (when (or (and (numberp number)
996 (zerop (buffer-size)))
997 ;; No groups in the buffer.
998 (gnus-message 5 gnus-no-groups-message))
999 ;; We have some groups displayed.
1000 (goto-char (point-max))
1001 (when (or (not gnus-group-goto-next-group-function)
1002 (not (funcall gnus-group-goto-next-group-function
1006 (goto-char (point-min)))
1008 ;; Go to the first group with unread articles.
1009 (gnus-group-search-forward t))
1011 ;; Find the right group to put point on. If the current group
1012 ;; has disappeared in the new listing, try to find the next
1013 ;; one. If no next one can be found, just leave point at the
1014 ;; first newsgroup in the buffer.
1015 (when (not (gnus-goto-char
1017 (point-min) (point-max)
1018 'gnus-group (gnus-intern-safe
1019 group gnus-active-hashtb))))
1020 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1022 (not (gnus-goto-char
1024 (point-min) (point-max) 'gnus-group
1026 (caar newsrc) gnus-active-hashtb)))))
1027 (setq newsrc (cdr newsrc)))
1029 (goto-char (point-max))
1030 (forward-line -1)))))))
1031 ;; Adjust cursor point.
1032 (gnus-group-position-point)))
1034 (defun gnus-group-list-level (level &optional all)
1035 "List groups on LEVEL.
1036 If ALL (the prefix), also list groups that have no unread articles."
1037 (interactive "nList groups on level: \nP")
1038 (gnus-group-list-groups level all level))
1040 (defun gnus-group-prepare-logic (group test)
1041 (or (and gnus-group-listed-groups
1042 (null gnus-group-list-option)
1043 (member group gnus-group-listed-groups))
1045 ((null gnus-group-listed-groups) test)
1046 ((null gnus-group-list-option) test)
1047 (t (and (member group gnus-group-listed-groups)
1048 (if (eq gnus-group-list-option 'flush)
1052 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1053 "List all newsgroups with unread articles of level LEVEL or lower.
1054 If PREDICATE is a function, list groups that the function returns non-nil;
1055 if it is t, list groups that have no unread articles.
1056 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1057 If REGEXP is a function, list dead groups that the function returns non-nil;
1058 if it is a string, only list groups matching REGEXP."
1059 (set-buffer gnus-group-buffer)
1060 (let ((buffer-read-only nil)
1061 (newsrc (cdr gnus-newsrc-alist))
1062 (lowest (or lowest 1))
1063 (not-in-list (and gnus-group-listed-groups
1064 (copy-sequence gnus-group-listed-groups)))
1065 info clevel unread group params)
1067 (when (or (< lowest gnus-level-zombie)
1068 gnus-group-listed-groups)
1069 ;; List living groups.
1071 (setq info (car newsrc)
1072 group (gnus-info-group info)
1073 params (gnus-info-params info)
1075 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1077 (setq not-in-list (delete group not-in-list)))
1079 (gnus-group-prepare-logic
1081 (and unread ; This group might be unchecked
1082 (or (not (stringp regexp))
1083 (string-match regexp group))
1084 (<= (setq clevel (gnus-info-level info)) level)
1087 ((functionp predicate)
1088 (funcall predicate info))
1089 (predicate t) ; We list all groups?
1092 (if (eq unread t) ; Unactivated?
1093 gnus-group-list-inactive-groups
1094 ; We list unactivated
1096 ; We list groups with unread articles
1097 (and gnus-list-groups-with-ticked-articles
1098 (cdr (assq 'tick (gnus-info-marks info))))
1099 ; And groups with tickeds
1100 ;; Check for permanent visibility.
1101 (and gnus-permanently-visible-groups
1102 (string-match gnus-permanently-visible-groups group))
1103 (memq 'visible params)
1104 (cdr (assq 'visible params)))))))
1105 (gnus-group-insert-group-line
1106 group (gnus-info-level info)
1107 (gnus-info-marks info) unread (gnus-info-method info)))))
1109 ;; List dead groups.
1110 (if (or gnus-group-listed-groups
1111 (and (>= level gnus-level-zombie)
1112 (<= lowest gnus-level-zombie)))
1113 (gnus-group-prepare-flat-list-dead
1114 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1115 gnus-level-zombie ?Z
1118 (dolist (group gnus-zombie-list)
1119 (setq not-in-list (delete group not-in-list))))
1120 (if (or gnus-group-listed-groups
1121 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1122 (gnus-group-prepare-flat-list-dead
1125 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1126 gnus-level-killed ?K regexp))
1128 (gnus-group-set-mode-line)
1129 (setq gnus-group-list-mode (cons level predicate))
1130 (gnus-run-hooks 'gnus-group-prepare-hook)
1133 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1134 ;; List zombies and killed lists somewhat faster, which was
1135 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1136 ;; this by ignoring the group format specification altogether.
1139 (setq group (pop groups))
1140 (when (gnus-group-prepare-logic
1143 (and (stringp regexp) (string-match regexp group))
1144 (and (functionp regexp) (funcall regexp group))))
1145 ;;; (gnus-add-text-properties
1146 ;;; (point) (prog1 (1+ (point))
1147 ;;; (insert " " mark " *: "
1148 ;;; (gnus-group-name-decode group
1149 ;;; (gnus-group-name-charset
1152 ;;; (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1154 ;;; 'gnus-level level))
1155 (gnus-group-insert-group-line
1157 (let ((active (gnus-active group)))
1159 (if (zerop (cdr active))
1161 (- (1+ (cdr active)) (car active)))
1163 (gnus-method-simplify (gnus-find-method-for-group group)))))))
1165 (defun gnus-group-update-group-line ()
1166 "Update the current line in the group buffer."
1167 (let* ((buffer-read-only nil)
1168 (group (gnus-group-group-name))
1169 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1170 gnus-group-indentation)
1173 (not (gnus-ephemeral-group-p group))
1175 (concat "(gnus-group-set-info '"
1176 (gnus-prin1-to-string (nth 2 entry))
1178 (setq gnus-group-indentation (gnus-group-group-indentation))
1180 (gnus-group-insert-group-line-info group)
1182 (gnus-group-position-point))))
1184 (defun gnus-group-insert-group-line-info (group)
1185 "Insert GROUP on the current line."
1186 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1187 (gnus-group-indentation (gnus-group-group-indentation))
1191 ;; (Un)subscribed group.
1192 (setq info (nth 2 entry))
1193 (gnus-group-insert-group-line
1194 group (gnus-info-level info) (gnus-info-marks info)
1195 (or (car entry) t) (gnus-info-method info)))
1196 ;; This group is dead.
1197 (gnus-group-insert-group-line
1199 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1201 (if (setq active (gnus-active group))
1202 (if (zerop (cdr active))
1204 (- (1+ (cdr active)) (car active)))
1206 (gnus-method-simplify (gnus-find-method-for-group group))))))
1208 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1209 gnus-tmp-marked number
1211 "Insert a group line in the group buffer."
1212 (let* ((gnus-tmp-method
1213 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1214 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1216 (gnus-tmp-active (gnus-active gnus-tmp-group))
1217 (gnus-tmp-number-total
1219 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1221 (gnus-tmp-number-of-unread
1222 (if (numberp number) (int-to-string (max 0 number))
1224 (gnus-tmp-number-of-read
1225 (if (numberp number)
1226 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1228 (gnus-tmp-subscribed
1229 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1230 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1231 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1233 (gnus-tmp-qualified-group
1234 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1235 group-name-charset))
1236 (gnus-tmp-newsgroup-description
1237 (if gnus-description-hashtb
1238 (or (gnus-group-name-decode
1239 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1240 group-name-charset) "")
1243 (if (and gnus-moderated-hashtb
1244 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1246 (gnus-tmp-moderated-string
1247 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1248 (gnus-tmp-group-icon "==&&==")
1249 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1250 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1251 (gnus-tmp-news-method-string
1253 (format "(%s:%s)" (car gnus-tmp-method)
1254 (cadr gnus-tmp-method)) ""))
1255 (gnus-tmp-marked-mark
1256 (if (and (numberp number)
1258 (cdr (assq 'tick gnus-tmp-marked)))
1260 (gnus-tmp-process-marked
1261 (if (member gnus-tmp-group gnus-group-marked)
1262 gnus-process-mark ? ))
1264 (or (and gnus-use-grouplens
1265 (bbb-grouplens-group-p gnus-tmp-group))
1267 (buffer-read-only nil)
1268 header gnus-tmp-header) ; passed as parameter to user-funcs.
1270 (gnus-add-text-properties
1274 (eval gnus-group-line-format-spec))
1275 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1276 gnus-unread ,(if (numberp number)
1277 (string-to-int gnus-tmp-number-of-unread)
1279 gnus-marked ,gnus-tmp-marked-mark
1280 gnus-indentation ,gnus-group-indentation
1281 gnus-level ,gnus-tmp-level))
1283 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1284 (gnus-run-hooks 'gnus-group-update-hook))
1286 ;; Allow XEmacs to remove front-sticky text properties.
1287 (gnus-group-remove-excess-properties)))
1289 (defun gnus-group-highlight-line ()
1290 "Highlight the current line according to `gnus-group-highlight'."
1291 (let* ((list gnus-group-highlight)
1293 (end (progn (end-of-line) (point)))
1294 ;; now find out where the line starts and leave point there.
1295 (beg (progn (beginning-of-line) (point)))
1296 (group (gnus-group-group-name))
1297 (entry (gnus-group-entry group))
1298 (unread (if (numberp (car entry)) (car entry) 0))
1299 (active (gnus-active group))
1300 (total (if active (1+ (- (cdr active) (car active))) 0))
1301 (info (nth 2 entry))
1302 (method (gnus-server-get-method group (gnus-info-method info)))
1303 (marked (gnus-info-marks info))
1304 (mailp (memq 'mail (assoc (symbol-name
1305 (car (or method gnus-select-method)))
1306 gnus-valid-select-methods)))
1307 (level (or (gnus-info-level info) gnus-level-killed))
1308 (score (or (gnus-info-score info) 0))
1309 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1310 (group-age (gnus-group-timestamp-delta group))
1311 (inhibit-read-only t))
1312 ;; Eval the cars of the lists until we find a match.
1314 (not (eval (caar list))))
1315 (setq list (cdr list)))
1316 (let ((face (cdar list)))
1317 (unless (eq face (get-text-property beg 'face))
1318 (gnus-put-text-property-excluding-characters-with-faces
1320 (setq face (if (boundp face) (symbol-value face) face)))
1321 (gnus-extent-start-open beg)))
1324 (defun gnus-group-update-group (group &optional visible-only)
1325 "Update all lines where GROUP appear.
1326 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1328 ;; Can't use `save-excursion' here, so we do it manually.
1329 (let ((buf (current-buffer))
1331 (set-buffer gnus-group-buffer)
1332 (setq mark (point-marker))
1333 ;; The buffer may be narrowed.
1336 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1338 found buffer-read-only)
1339 ;; Enter the current status into the dribble buffer.
1340 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1342 (not (gnus-ephemeral-group-p group)))
1344 (concat "(gnus-group-set-info '"
1345 (gnus-prin1-to-string (nth 2 entry))
1347 ;; Find all group instances. If topics are in use, each group
1348 ;; may be listed in more than once.
1349 (while (setq loc (text-property-any
1350 loc (point-max) 'gnus-group ident))
1353 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1355 (gnus-group-insert-group-line-info group)
1358 (gnus-run-hooks 'gnus-group-update-group-hook)))
1359 (setq loc (1+ loc)))
1360 (unless (or found visible-only)
1361 ;; No such line in the buffer, find out where it's supposed to
1362 ;; go, and insert it there (or at the end of the buffer).
1363 (if gnus-goto-missing-group-function
1364 (funcall gnus-goto-missing-group-function group)
1365 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1366 (while (and entry (car entry)
1370 (point-min) (point-max)
1371 'gnus-group (gnus-intern-safe
1372 (caar entry) gnus-active-hashtb)))))
1373 (setq entry (cdr entry)))
1374 (or entry (goto-char (point-max)))))
1375 ;; Finally insert the line.
1376 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1377 (gnus-group-insert-group-line-info group)
1380 (gnus-run-hooks 'gnus-group-update-group-hook))))
1381 (when gnus-group-update-group-function
1382 (funcall gnus-group-update-group-function group))
1383 (gnus-group-set-mode-line)))
1385 (set-marker mark nil)
1388 (defun gnus-group-set-mode-line ()
1389 "Update the mode line in the group buffer."
1390 (when (memq 'group gnus-updated-mode-lines)
1391 ;; Yes, we want to keep this mode line updated.
1393 (set-buffer gnus-group-buffer)
1394 (let* ((gformat (or gnus-group-mode-line-format-spec
1395 (gnus-set-format 'group-mode)))
1396 (gnus-tmp-news-server (cadr gnus-select-method))
1397 (gnus-tmp-news-method (car gnus-select-method))
1398 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1400 gnus-tmp-header ;Dummy binding for user-defined formats
1401 ;; Get the resulting string.
1403 (and gnus-dribble-buffer
1404 (buffer-name gnus-dribble-buffer)
1405 (buffer-modified-p gnus-dribble-buffer)
1407 (set-buffer gnus-dribble-buffer)
1408 (not (zerop (buffer-size))))))
1409 (mode-string (eval gformat)))
1410 ;; Say whether the dribble buffer has been modified.
1411 (setq mode-line-modified
1412 (if modified (car gnus-mode-line-modified)
1413 (cdr gnus-mode-line-modified)))
1414 ;; If the line is too long, we chop it off.
1415 (when (> (length mode-string) max-len)
1416 (setq mode-string (substring mode-string 0 (- max-len 4))))
1418 (setq mode-line-buffer-identification
1419 (gnus-mode-line-buffer-identification
1420 (list mode-string)))
1421 (set-buffer-modified-p modified))))))
1423 (defun gnus-group-group-name ()
1424 "Get the name of the newsgroup on the current line."
1425 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1427 (symbol-name group))))
1429 (defun gnus-group-group-level ()
1430 "Get the level of the newsgroup on the current line."
1431 (get-text-property (gnus-point-at-bol) 'gnus-level))
1433 (defun gnus-group-group-indentation ()
1434 "Get the indentation of the newsgroup on the current line."
1435 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1436 (and gnus-group-indentation-function
1437 (funcall gnus-group-indentation-function))
1440 (defun gnus-group-group-unread ()
1441 "Get the number of unread articles of the newsgroup on the current line."
1442 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1444 (defun gnus-group-new-mail (group)
1445 (if (nnmail-new-mail-p (gnus-group-real-name group))
1449 (defun gnus-group-level (group)
1450 "Return the estimated level of GROUP."
1451 (or (gnus-info-level (gnus-get-info group))
1452 (and (member group gnus-zombie-list) gnus-level-zombie)
1455 (defun gnus-group-search-forward (&optional backward all level first-too)
1456 "Find the next newsgroup with unread articles.
1457 If BACKWARD is non-nil, find the previous newsgroup instead.
1458 If ALL is non-nil, just find any newsgroup.
1459 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1461 If FIRST-TOO, the current line is also eligible as a target."
1462 (let ((way (if backward -1 1))
1463 (low gnus-level-killed)
1466 (if (and backward (progn (beginning-of-line)) (bobp))
1475 (get-text-property (point) 'gnus-group)
1479 (get-text-property (point) 'gnus-unread)))
1480 (and (numberp unread) (> unread 0)))
1481 (setq lev (get-text-property (point)
1483 (<= lev gnus-level-subscribed)))
1485 (and (setq lev (get-text-property (point)
1494 (zerop (forward-line way)))))
1496 (progn (gnus-group-position-point) t)
1497 (goto-char (or pos beg))
1500 ;;; Gnus group mode commands
1504 (defun gnus-group-mark-line-p ()
1507 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1508 (eq (char-after) gnus-process-mark)))
1510 (defun gnus-group-mark-group (n &optional unmark no-advance)
1511 "Mark the current group."
1513 (let ((buffer-read-only nil)
1517 (when (setq group (gnus-group-group-name))
1518 ;; Go to the mark position.
1520 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1521 (subst-char-in-region
1522 (point) (1+ (point)) (char-after)
1525 (setq gnus-group-marked (delete group gnus-group-marked))
1527 (setq gnus-group-marked
1528 (cons group (delete group gnus-group-marked)))
1529 gnus-process-mark)))
1531 (gnus-group-next-group 1))
1533 (gnus-summary-position-point)
1536 (defun gnus-group-unmark-group (n)
1537 "Remove the mark from the current group."
1539 (gnus-group-mark-group n 'unmark)
1540 (gnus-group-position-point))
1542 (defun gnus-group-unmark-all-groups ()
1543 "Unmark all groups."
1545 (let ((groups gnus-group-marked))
1548 (gnus-group-remove-mark (pop groups)))))
1549 (gnus-group-position-point))
1551 (defun gnus-group-mark-region (unmark beg end)
1552 "Mark all groups between point and mark.
1553 If UNMARK, remove the mark instead."
1554 (interactive "P\nr")
1555 (let ((num (count-lines beg end)))
1558 (- num (gnus-group-mark-group num unmark)))))
1560 (defun gnus-group-mark-buffer (&optional unmark)
1561 "Mark all groups in the buffer.
1562 If UNMARK, remove the mark instead."
1564 (gnus-group-mark-region unmark (point-min) (point-max)))
1566 (defun gnus-group-mark-regexp (regexp)
1567 "Mark all groups that match some regexp."
1568 (interactive "sMark (regexp): ")
1569 (let ((alist (cdr gnus-newsrc-alist))
1572 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1573 (gnus-group-set-mark group))))
1574 (gnus-group-position-point))
1576 (defun gnus-group-remove-mark (group &optional test-marked)
1577 "Remove the process mark from GROUP and move point there.
1578 Return nil if the group isn't displayed."
1579 (if (gnus-group-goto-group group nil test-marked)
1581 (gnus-group-mark-group 1 'unmark t)
1583 (setq gnus-group-marked
1584 (delete group gnus-group-marked))
1587 (defun gnus-group-set-mark (group)
1588 "Set the process mark on GROUP."
1589 (if (gnus-group-goto-group group)
1591 (gnus-group-mark-group 1 nil t))
1592 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1594 (defun gnus-group-universal-argument (arg &optional groups func)
1595 "Perform any command on all groups according to the process/prefix convention."
1597 (if (eq (setq func (or func
1600 (substitute-command-keys
1601 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1603 (gnus-error 1 "Undefined key")
1604 (gnus-group-iterate arg
1606 (command-execute func))))
1607 (gnus-group-position-point))
1609 (defun gnus-group-process-prefix (n)
1610 "Return a list of groups to work on.
1611 Take into consideration N (the prefix) and the list of marked groups."
1614 (setq n (prefix-numeric-value n))
1615 ;; There is a prefix, so we return a list of the N next
1617 (let ((way (if (< n 0) -1 1))
1622 (if (setq group (gnus-group-group-name))
1623 (push group groups))
1625 (gnus-group-next-group way)))
1627 ((gnus-region-active-p)
1628 ;; Work on the region between point and mark.
1629 (let ((max (max (point) (mark)))
1632 (goto-char (min (point) (mark)))
1635 (push (gnus-group-group-name) groups)
1636 (zerop (gnus-group-next-group 1))
1638 (nreverse groups))))
1640 ;; No prefix, but a list of marked articles.
1641 (reverse gnus-group-marked))
1643 ;; Neither marked articles or a prefix, so we return the
1645 (let ((group (gnus-group-group-name)))
1646 (and group (list group))))))
1648 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1649 ;;; imagine why I went through these contortions...
1651 (let ((function (make-symbol "gnus-group-iterate-function"))
1652 (window (make-symbol "gnus-group-iterate-window"))
1653 (groups (make-symbol "gnus-group-iterate-groups"))
1654 (group (make-symbol "gnus-group-iterate-group")))
1656 `(defun gnus-group-iterate (arg ,function)
1657 "Iterate FUNCTION over all process/prefixed groups.
1658 FUNCTION will be called with the group name as the parameter
1659 and with point over the group in question."
1660 (let ((,groups (gnus-group-process-prefix arg))
1661 (,window (selected-window))
1664 (setq ,group (car ,groups)
1665 ,groups (cdr ,groups))
1666 (select-window ,window)
1667 (gnus-group-remove-mark ,group)
1668 (save-selected-window
1670 (funcall ,function ,group)))))))))
1672 (put 'gnus-group-iterate 'lisp-indent-function 1)
1674 ;; Selecting groups.
1676 (defun gnus-group-read-group (&optional all no-article group select-articles)
1677 "Read news in this newsgroup.
1678 If the prefix argument ALL is non-nil, already read articles become
1679 readable. IF ALL is a number, fetch this number of articles. If the
1680 optional argument NO-ARTICLE is non-nil, no article will be
1681 auto-selected upon group entry. If GROUP is non-nil, fetch that
1684 (let ((no-display (eq all 0))
1685 (group (or group (gnus-group-group-name)))
1686 number active marked entry)
1690 (error "No group on current line"))
1691 (setq marked (gnus-info-marks
1692 (nth 2 (setq entry (gnus-gethash
1693 group gnus-newsrc-hashtb)))))
1694 ;; This group might be a dead group. In that case we have to get
1695 ;; the number of unread articles from `gnus-active-hashtb'.
1697 (cond ((numberp all) all)
1699 ((setq active (gnus-active group))
1700 (- (1+ (cdr active)) (car active)))))
1701 (gnus-summary-read-group
1702 group (or all (and (numberp number)
1703 (zerop (+ number (gnus-range-length
1704 (cdr (assq 'tick marked)))
1706 (cdr (assq 'dormant marked)))))))
1707 no-article nil no-display nil select-articles)))
1709 (defun gnus-group-select-group (&optional all)
1710 "Select this newsgroup.
1711 No article is selected automatically.
1712 If ALL is non-nil, already read articles become readable.
1713 If ALL is a number, fetch this number of articles."
1715 (gnus-group-read-group all t))
1717 (defun gnus-group-quick-select-group (&optional all)
1718 "Select the current group \"quickly\".
1719 This means that no highlighting or scoring will be performed.
1720 If ALL (the prefix argument) is 0, don't even generate the summary
1723 This might be useful if you want to toggle threading
1724 before entering the group."
1726 (require 'gnus-score)
1728 gnus-score-find-score-files-function
1729 gnus-home-score-file
1730 gnus-apply-kill-hook
1731 gnus-summary-expunge-below)
1732 (gnus-group-read-group all t)))
1734 (defun gnus-group-visible-select-group (&optional all)
1735 "Select the current group without hiding any articles."
1737 (let ((gnus-inhibit-limiting t))
1738 (gnus-group-read-group all t)))
1740 (defun gnus-group-select-group-ephemerally ()
1741 "Select the current group without doing any processing whatsoever.
1742 You will actually be entered into a group that's a copy of
1743 the current group; no changes you make while in this group will
1746 (require 'gnus-score)
1748 gnus-score-find-score-files-function gnus-apply-kill-hook
1749 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1750 gnus-summary-mode-hook gnus-select-group-hook
1751 (group (gnus-group-group-name))
1752 (method (gnus-find-method-for-group group)))
1753 (gnus-group-read-ephemeral-group
1754 (gnus-group-prefixed-name group method) method)))
1757 (defun gnus-fetch-group (group)
1758 "Start Gnus if necessary and enter GROUP.
1759 Returns whether the fetching was successful or not."
1760 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1761 (unless (get-buffer gnus-group-buffer)
1763 (gnus-group-read-group nil nil group))
1766 (defun gnus-fetch-group-other-frame (group)
1767 "Pop up a frame and enter GROUP."
1769 (let ((window (get-buffer-window gnus-group-buffer)))
1771 (select-frame (window-frame window)))
1772 ((= (length (frame-list)) 1)
1773 (select-frame (make-frame)))
1776 (gnus-fetch-group group))
1778 (defvar gnus-ephemeral-group-server 0)
1780 ;; Enter a group that is not in the group buffer. Non-nil is returned
1781 ;; if selection was successful.
1782 (defun gnus-group-read-ephemeral-group (group method &optional activate
1783 quit-config request-only
1785 "Read GROUP from METHOD as an ephemeral group.
1786 If ACTIVATE, request the group first.
1787 If QUIT-CONFIG, use that window configuration when exiting from the
1789 If REQUEST-ONLY, don't actually read the group; just request it.
1790 If SELECT-ARTICLES, only select those articles.
1792 Return the name of the group if selection was successful."
1793 ;; Transform the select method into a unique server.
1794 (when (stringp method)
1795 (setq method (gnus-server-to-method method)))
1797 `(,(car method) ,(concat (cadr method) "-ephemeral")
1798 (,(intern (format "%s-address" (car method))) ,(cadr method))
1800 (let ((group (if (gnus-group-foreign-p group) group
1801 (gnus-group-prefixed-name group method))))
1805 ,gnus-level-default-subscribed nil nil ,method
1807 ,(if quit-config quit-config
1808 (cons gnus-summary-buffer
1809 gnus-current-window-configuration))))))
1811 (push method gnus-ephemeral-servers)
1812 (set-buffer gnus-group-buffer)
1813 (unless (gnus-check-server method)
1814 (error "Unable to contact server: %s" (gnus-status-message method)))
1816 (gnus-activate-group group 'scan)
1817 (unless (gnus-request-group group)
1818 (error "Couldn't request group: %s"
1819 (nnheader-get-report (car method)))))
1823 (when (gnus-group-read-group t t group select-articles)
1827 (message "Quit reading the ephemeral group")
1830 (defun gnus-group-jump-to-group (group)
1831 "Jump to newsgroup GROUP."
1833 (list (completing-read
1834 "Group: " gnus-active-hashtb nil
1835 (gnus-read-active-file-p)
1837 'gnus-group-history)))
1839 (when (equal group "")
1840 (error "Empty group name"))
1842 (unless (gnus-ephemeral-group-p group)
1843 ;; Either go to the line in the group buffer...
1844 (unless (gnus-group-goto-group group)
1845 ;; ... or insert the line.
1846 (gnus-group-update-group group)
1847 (gnus-group-goto-group group)))
1848 ;; Adjust cursor point.
1849 (gnus-group-position-point))
1851 (defun gnus-group-goto-group (group &optional far test-marked)
1852 "Goto to newsgroup GROUP.
1853 If FAR, it is likely that the group is not on the current line.
1854 If TEST-MARKED, the line must be marked."
1858 ;; It's quite likely that we are on the right line, so
1859 ;; we check the current line first.
1861 (eq (get-text-property (point) 'gnus-group)
1862 (gnus-intern-safe group gnus-active-hashtb))
1863 (or (not test-marked) (gnus-group-mark-line-p)))
1865 ;; Previous and next line are also likely, so we check them as well.
1869 (and (eq (get-text-property (point) 'gnus-group)
1870 (gnus-intern-safe group gnus-active-hashtb))
1871 (or (not test-marked) (gnus-group-mark-line-p)))))
1877 (and (eq (get-text-property (point) 'gnus-group)
1878 (gnus-intern-safe group gnus-active-hashtb))
1879 (or (not test-marked) (gnus-group-mark-line-p)))))
1883 (goto-char (point-min))
1885 (while (and (not found)
1890 (gnus-intern-safe group gnus-active-hashtb))))
1891 (if (gnus-group-mark-line-p)
1896 ;; Search through the entire buffer.
1899 (point-min) (point-max)
1900 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
1902 (defun gnus-group-next-group (n &optional silent)
1903 "Go to next N'th newsgroup.
1904 If N is negative, search backward instead.
1905 Returns the difference between N and the number of skips actually
1908 (gnus-group-next-unread-group n t nil silent))
1910 (defun gnus-group-next-unread-group (n &optional all level silent)
1911 "Go to next N'th unread newsgroup.
1912 If N is negative, search backward instead.
1913 If ALL is non-nil, choose any newsgroup, unread or not.
1914 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1915 such group can be found, the next group with a level higher than
1917 Returns the difference between N and the number of skips actually
1920 (let ((backward (< n 0))
1923 (gnus-group-search-forward
1924 backward (or (not gnus-group-goto-unread) all) level))
1928 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1929 (if level " on this level or higher" "")))
1932 (defun gnus-group-prev-group (n)
1933 "Go to previous N'th newsgroup.
1934 Returns the difference between N and the number of skips actually
1937 (gnus-group-next-unread-group (- n) t))
1939 (defun gnus-group-prev-unread-group (n)
1940 "Go to previous N'th unread newsgroup.
1941 Returns the difference between N and the number of skips actually
1944 (gnus-group-next-unread-group (- n)))
1946 (defun gnus-group-next-unread-group-same-level (n)
1947 "Go to next N'th unread newsgroup on the same level.
1948 If N is negative, search backward instead.
1949 Returns the difference between N and the number of skips actually
1952 (gnus-group-next-unread-group n t (gnus-group-group-level))
1953 (gnus-group-position-point))
1955 (defun gnus-group-prev-unread-group-same-level (n)
1956 "Go to next N'th unread newsgroup on the same level.
1957 Returns the difference between N and the number of skips actually
1960 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1961 (gnus-group-position-point))
1963 (defun gnus-group-best-unread-group (&optional exclude-group)
1964 "Go to the group with the highest level.
1965 If EXCLUDE-GROUP, do not go to that group."
1967 (goto-char (point-min))
1971 (setq unread (get-text-property (point) 'gnus-unread))
1972 (when (and (numberp unread) (> unread 0))
1973 (when (and (get-text-property (point) 'gnus-level)
1974 (< (get-text-property (point) 'gnus-level) best)
1975 (or (not exclude-group)
1976 (not (equal exclude-group (gnus-group-group-name)))))
1977 (setq best (get-text-property (point) 'gnus-level))
1978 (setq best-point (point))))
1981 (goto-char best-point))
1982 (gnus-summary-position-point)
1983 (and best-point (gnus-group-group-name))))
1985 (defun gnus-group-first-unread-group ()
1986 "Go to the first group with unread articles."
1989 (let ((opoint (point))
1991 (goto-char (point-min))
1992 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1993 (and (numberp unread) ; Not a topic.
1994 (not (zerop unread))) ; Has unread articles.
1995 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1998 nil)) ; Not success.
1999 (gnus-group-position-point)))
2001 (defun gnus-group-enter-server-mode ()
2002 "Jump to the server buffer."
2004 (gnus-enter-server-buffer))
2006 (defun gnus-group-make-group (name &optional method address args)
2007 "Add a new newsgroup.
2008 The user will be prompted for a NAME, for a select METHOD, and an
2012 (gnus-read-group "Group name: ")
2013 (gnus-read-method "From method: ")))
2015 (when (stringp method)
2016 (setq method (or (gnus-server-to-method method) method)))
2017 (let* ((meth (gnus-method-simplify
2019 (not (gnus-server-equal method gnus-select-method)))
2020 (if address (list (intern method) address)
2022 (nname (if method (gnus-group-prefixed-name name meth) name))
2024 (when (gnus-gethash nname gnus-newsrc-hashtb)
2025 (error "Group %s already exists" nname))
2026 ;; Subscribe to the new group.
2027 (gnus-group-change-level
2028 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2029 gnus-level-default-subscribed gnus-level-killed
2030 (and (gnus-group-group-name)
2031 (gnus-gethash (gnus-group-group-name)
2032 gnus-newsrc-hashtb))
2035 (gnus-set-active nname (cons 1 0))
2036 (unless (gnus-ephemeral-group-p name)
2038 (concat "(gnus-group-set-info '"
2039 (gnus-prin1-to-string (cdr info)) ")")))
2041 (gnus-group-insert-group-line-info nname)
2043 (gnus-group-position-point)
2045 ;; Load the backend and try to make the backend create
2046 ;; the group as well.
2047 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2049 gnus-valid-select-methods)
2051 (gnus-check-server meth)
2052 (when (gnus-check-backend-function 'request-create-group nname)
2053 (gnus-request-create-group nname nil args))
2056 (defun gnus-group-delete-groups (&optional arg)
2057 "Delete the current group. Only meaningful with editable groups."
2059 (let ((n (length (gnus-group-process-prefix arg))))
2060 (when (gnus-yes-or-no-p
2062 "Delete this 1 group? "
2063 (format "Delete these %d groups? " n)))
2064 (gnus-group-iterate arg
2066 (gnus-group-delete-group group nil t))))))
2068 (defun gnus-group-delete-group (group &optional force no-prompt)
2069 "Delete the current group. Only meaningful with editable groups.
2070 If FORCE (the prefix) is non-nil, all the articles in the group will
2071 be deleted. This is \"deleted\" as in \"removed forever from the face
2072 of the Earth\". There is no undo. The user will be prompted before
2073 doing the deletion."
2075 (list (gnus-group-group-name)
2076 current-prefix-arg))
2078 (error "No group to rename"))
2079 (unless (gnus-check-backend-function 'request-delete-group group)
2080 (error "This backend does not support group deletion"))
2082 (if (and (not no-prompt)
2083 (not (gnus-yes-or-no-p
2085 "Do you really want to delete %s%s? "
2086 group (if force " and all its contents" "")))))
2088 (gnus-message 6 "Deleting group %s..." group)
2089 (if (not (gnus-request-delete-group group force))
2090 (gnus-error 3 "Couldn't delete group %s" group)
2091 (gnus-message 6 "Deleting group %s...done" group)
2092 (gnus-group-goto-group group)
2093 (gnus-group-kill-group 1 t)
2094 (gnus-sethash group nil gnus-active-hashtb)
2096 (gnus-group-position-point)))
2098 (defun gnus-group-rename-group (group new-name)
2099 "Rename group from GROUP to NEW-NAME.
2100 When used interactively, GROUP is the group under point
2101 and NEW-NAME will be prompted for."
2104 (gnus-group-group-name)
2106 (unless (gnus-check-backend-function
2107 'request-rename-group (gnus-group-group-name))
2108 (error "This backend does not support renaming groups"))
2109 (gnus-read-group "Rename group to: "
2110 (gnus-group-real-name (gnus-group-group-name))))))
2112 (unless (gnus-check-backend-function 'request-rename-group group)
2113 (error "This backend does not support renaming groups"))
2115 (error "No group to rename"))
2116 (when (equal (gnus-group-real-name group) new-name)
2117 (error "Can't rename to the same name"))
2119 ;; We find the proper prefixed name.
2121 (if (gnus-group-native-p group)
2125 (gnus-group-prefixed-name
2126 (gnus-group-real-name new-name)
2127 (gnus-info-method (gnus-get-info group)))))
2129 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2132 (gnus-group-goto-group group)
2133 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2134 (gnus-request-rename-group group new-name))))
2135 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2136 ;; We rename the group internally by killing it...
2137 (gnus-group-kill-group)
2138 ;; ... changing its name ...
2139 (setcar (cdar gnus-list-of-killed-groups) new-name)
2140 ;; ... and then yanking it. Magic!
2141 (gnus-group-yank-group)
2142 (gnus-set-active new-name (gnus-active group))
2143 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2145 (setq gnus-killed-list (delete group gnus-killed-list))
2146 (gnus-set-active group nil)
2147 (gnus-dribble-touch)
2148 (gnus-group-position-point)))
2150 (defun gnus-group-edit-group (group &optional part)
2151 "Edit the group on the current line."
2152 (interactive (list (gnus-group-group-name)))
2153 (let ((part (or part 'info))
2156 (error "No group on current line"))
2157 (unless (setq info (gnus-get-info group))
2158 (error "Killed group; can't be edited"))
2160 (gnus-close-group group))
2162 ;; Find the proper form to edit.
2163 (cond ((eq part 'method)
2164 (or (gnus-info-method info) "native"))
2166 (gnus-info-params info))
2168 ;; The proper documentation.
2170 "Editing the %s for `%s'."
2172 ((eq part 'method) "select method")
2173 ((eq part 'params) "group parameters")
2175 (gnus-group-decoded-name group))
2177 (gnus-group-edit-group-done ',part ,group form)))))
2179 (defun gnus-group-edit-group-method (group)
2180 "Edit the select method of GROUP."
2181 (interactive (list (gnus-group-group-name)))
2182 (gnus-group-edit-group group 'method))
2184 (defun gnus-group-edit-group-parameters (group)
2185 "Edit the group parameters of GROUP."
2186 (interactive (list (gnus-group-group-name)))
2187 (gnus-group-edit-group group 'params))
2189 (defun gnus-group-edit-group-done (part group form)
2191 (let* ((method (cond ((eq part 'info) (nth 4 form))
2192 ((eq part 'method) form)
2194 (info (cond ((eq part 'info) form)
2195 ((eq part 'method) (gnus-get-info group))
2198 (if (or (not method)
2200 gnus-select-method method))
2201 (gnus-group-real-name (car info))
2202 (gnus-group-prefixed-name
2203 (gnus-group-real-name (car info)) method))
2205 (when (and new-group
2206 (not (equal new-group group)))
2207 (when (gnus-group-goto-group group)
2208 (gnus-group-kill-group 1))
2209 (gnus-activate-group new-group))
2211 (if (not (and info new-group))
2212 (gnus-group-set-info form (or new-group group) part)
2213 (setq info (gnus-copy-sequence info))
2214 (setcar info new-group)
2215 (unless (gnus-server-equal method "native")
2216 (unless (nthcdr 3 info)
2217 (nconc info (list nil nil)))
2218 (unless (nthcdr 4 info)
2219 (nconc info (list nil)))
2220 (gnus-info-set-method info method))
2221 (gnus-group-set-info info))
2222 (gnus-group-update-group (or new-group group))
2223 (gnus-group-position-point)))
2225 (defun gnus-group-make-useful-group (group method)
2226 "Create one of the groups described in `gnus-useful-groups'."
2228 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2230 gnus-useful-groups)))
2231 (list (cadr entry) (caddr entry))))
2232 (setq method (gnus-copy-sequence method))
2234 (while (setq entry (memq (assq 'eval method) method))
2235 (setcar entry (eval (cadar entry)))))
2236 (gnus-group-make-group group method))
2238 (defun gnus-group-make-help-group ()
2239 "Create the Gnus documentation group."
2241 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2242 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2243 (when (gnus-gethash name gnus-newsrc-hashtb)
2244 (error "Documentation group already exists"))
2246 (gnus-message 1 "Couldn't find doc group")
2247 (gnus-group-make-group
2248 (gnus-group-real-name name)
2249 (list 'nndoc "gnus-help"
2250 (list 'nndoc-address file)
2251 (list 'nndoc-article-type 'mbox)))))
2252 (gnus-group-position-point))
2254 (defun gnus-group-make-doc-group (file type)
2255 "Create a group that uses a single file as the source."
2257 (list (read-file-name "File name: ")
2258 (and current-prefix-arg 'ask)))
2259 (when (eq type 'ask)
2264 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2266 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2267 ((= char ?b) 'babyl)
2268 ((= char ?d) 'digest)
2269 ((= char ?f) 'forward)
2271 ((= char ?g) 'guess)
2272 (t (setq err (format "%c unknown. " char))
2275 (let* ((file (expand-file-name file))
2276 (name (gnus-generate-new-group-name
2277 (gnus-group-prefixed-name
2278 (file-name-nondirectory file) '(nndoc "")))))
2279 (gnus-group-make-group
2280 (gnus-group-real-name name)
2282 (list 'nndoc-address file)
2283 (list 'nndoc-article-type (or type 'guess))))))
2285 (defvar nnweb-type-definition)
2286 (defvar gnus-group-web-type-history nil)
2287 (defvar gnus-group-web-search-history nil)
2288 (defun gnus-group-make-web-group (&optional solid)
2289 "Create an ephemeral nnweb group.
2290 If SOLID (the prefix), create a solid group."
2294 (if solid (gnus-read-group "Group name: ")
2295 (message-unique-id)))
2296 (default-type (or (car gnus-group-web-type-history)
2297 (symbol-name (caar nnweb-type-definition))))
2301 (format "Search engine type (default %s): " default-type)
2302 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2303 nnweb-type-definition)
2304 nil t nil 'gnus-group-web-type-history)
2309 (cons (or (car gnus-group-web-search-history) "") 0)
2310 'gnus-group-web-search-history))
2312 `(nnweb ,group (nnweb-search ,search)
2313 (nnweb-type ,(intern type))
2314 (nnweb-ephemeral-p t))))
2316 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2317 (gnus-group-read-ephemeral-group
2319 (cons (current-buffer)
2320 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2322 (defvar nnwarchive-type-definition)
2323 (defvar gnus-group-warchive-type-history nil)
2324 (defvar gnus-group-warchive-login-history nil)
2325 (defvar gnus-group-warchive-address-history nil)
2327 (defun gnus-group-make-warchive-group ()
2328 "Create a nnwarchive group."
2330 (require 'nnwarchive)
2331 (let* ((group (gnus-read-group "Group name: "))
2332 (default-type (or (car gnus-group-warchive-type-history)
2333 (symbol-name (caar nnwarchive-type-definition))))
2337 (format "Warchive type (default %s): " default-type)
2338 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2339 nnwarchive-type-definition)
2340 nil t nil 'gnus-group-warchive-type-history)
2342 (address (read-string "Warchive address: "
2343 nil 'gnus-group-warchive-address-history))
2344 (default-login (or (car gnus-group-warchive-login-history)
2349 (format "Warchive login (default %s): " user-mail-address)
2350 default-login 'gnus-group-warchive-login-history)
2353 `(nnwarchive ,address
2354 (nnwarchive-type ,(intern type))
2355 (nnwarchive-login ,login))))
2356 (gnus-group-make-group group method)))
2358 (defvar nnshimbun-type-definition)
2359 (defvar gnus-group-shimbun-server-history nil)
2361 (defun gnus-group-make-shimbun-group ()
2362 "Create a nnshimbun group."
2364 (require 'nnshimbun)
2365 (let* ((minibuffer-setup-hook (append minibuffer-setup-hook
2366 '(beginning-of-line)))
2367 (server (completing-read
2369 (mapcar (lambda (elem) (list (car elem)))
2370 nnshimbun-type-definition)
2372 (or (car gnus-group-shimbun-server-history)
2373 (caar nnshimbun-type-definition))
2374 'gnus-group-shimbun-server-history))
2375 (group (completing-read
2377 (mapcar (lambda (elem) (list elem))
2379 (cdr (assoc server nnshimbun-type-definition)))))
2381 (nnshimbun-pre-fetch-article nil))
2382 (gnus-group-make-group group `(nnshimbun ,server))))
2384 (defun gnus-group-make-archive-group (&optional all)
2385 "Create the (ding) Gnus archive group of the most recent articles.
2386 Given a prefix, create a full group."
2388 (let ((group (gnus-group-prefixed-name
2389 (if all "ding.archives" "ding.recent") '(nndir ""))))
2390 (when (gnus-gethash group gnus-newsrc-hashtb)
2391 (error "Archive group already exists"))
2392 (gnus-group-make-group
2393 (gnus-group-real-name group)
2394 (list 'nndir (if all "hpc" "edu")
2395 (list 'nndir-directory
2396 (if all gnus-group-archive-directory
2397 gnus-group-recent-archive-directory))))
2398 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2400 (defun gnus-group-make-directory-group (dir)
2401 "Create an nndir group.
2402 The user will be prompted for a directory. The contents of this
2403 directory will be used as a newsgroup. The directory should contain
2404 mail messages or news articles in files that have numeric names."
2406 (list (read-file-name "Create group from directory: ")))
2407 (unless (file-exists-p dir)
2408 (error "No such directory"))
2409 (unless (file-directory-p dir)
2410 (error "Not a directory"))
2414 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2416 (gnus-group-prefixed-name
2417 (concat (file-name-as-directory (directory-file-name dir))
2420 (setq ext (format "<%d>" (setq i (1+ i)))))
2421 (gnus-group-make-group
2422 (gnus-group-real-name group)
2423 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2425 (defun gnus-group-make-kiboze-group (group address scores)
2426 "Create an nnkiboze group.
2427 The user will be prompted for a name, a regexp to match groups, and
2428 score file entries for articles to include in the group."
2431 (read-string "nnkiboze group name: ")
2432 (read-string "Source groups (regexp): ")
2433 (let ((headers (mapcar (lambda (group) (list group))
2434 '("subject" "from" "number" "date" "message-id"
2435 "references" "chars" "lines" "xref"
2436 "followup" "all" "body" "head")))
2437 scores header regexp regexps)
2438 (while (not (equal "" (setq header (completing-read
2439 "Match on header: " headers nil t))))
2441 (while (not (equal "" (setq regexp (read-string
2442 (format "Match on %s (regexp): "
2444 (push (list regexp nil nil 'r) regexps))
2445 (push (cons header regexps) scores))
2447 (gnus-group-make-group group "nnkiboze" address)
2448 (let* ((nnkiboze-current-group group)
2449 (score-file (car (nnkiboze-score-file "")))
2450 (score-dir (file-name-directory score-file)))
2451 (unless (file-exists-p score-dir)
2452 (make-directory score-dir))
2453 (with-temp-file score-file
2454 (let (emacs-lisp-mode-hook)
2455 (pp scores (current-buffer))))))
2457 (defun gnus-group-add-to-virtual (n vgroup)
2458 "Add the current group to a virtual group."
2460 (list current-prefix-arg
2461 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2463 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2464 (error "%s is not an nnvirtual group" vgroup))
2465 (gnus-close-group vgroup)
2466 (let* ((groups (gnus-group-process-prefix n))
2467 (method (gnus-info-method (gnus-get-info vgroup))))
2468 (setcar (cdr method)
2470 (nth 1 method) "\\|"
2473 (gnus-group-remove-mark s)
2474 (concat "\\(^" (regexp-quote s) "$\\)"))
2476 (gnus-group-position-point))
2478 (defun gnus-group-make-empty-virtual (group)
2479 "Create a new, fresh, empty virtual group."
2480 (interactive "sCreate new, empty virtual group: ")
2481 (let* ((method (list 'nnvirtual "^$"))
2482 (pgroup (gnus-group-prefixed-name group method)))
2483 ;; Check whether it exists already.
2484 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2485 (error "Group %s already exists" pgroup))
2486 ;; Subscribe the new group after the group on the current line.
2487 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2488 (gnus-group-update-group pgroup)
2490 (gnus-group-position-point)))
2492 (defun gnus-group-enter-directory (dir)
2493 "Enter an ephemeral nneething group."
2494 (interactive "DDirectory to read: ")
2495 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2496 (leaf (gnus-group-prefixed-name
2497 (file-name-nondirectory (directory-file-name dir))
2499 (name (gnus-generate-new-group-name leaf)))
2500 (unless (gnus-group-read-ephemeral-group
2502 (cons (current-buffer)
2503 (if (eq major-mode 'gnus-summary-mode)
2505 (error "Couldn't enter %s" dir))))
2508 (autoload 'nnimap-expunge "nnimap")
2509 (autoload 'nnimap-acl-get "nnimap")
2510 (autoload 'nnimap-acl-edit "nnimap"))
2512 (defun gnus-group-nnimap-expunge (group)
2513 "Expunge deleted articles in current nnimap GROUP."
2514 (interactive (list (gnus-group-group-name)))
2515 (let ((mailbox (gnus-group-real-name group)) method)
2517 (error "No group on current line"))
2518 (unless (gnus-get-info group)
2519 (error "Killed group; can't be edited"))
2520 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2521 (error "%s is not an nnimap group" group))
2522 (nnimap-expunge mailbox (cadr method))))
2524 (defun gnus-group-nnimap-edit-acl (group)
2525 "Edit the Access Control List of current nnimap GROUP."
2526 (interactive (list (gnus-group-group-name)))
2527 (let ((mailbox (gnus-group-real-name group)) method acl)
2529 (error "No group on current line"))
2530 (unless (gnus-get-info group)
2531 (error "Killed group; can't be edited"))
2532 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2533 (error "%s is not an nnimap group" group))
2534 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2535 (error "Server does not support ACL's"))
2536 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2538 An access control list is a list of (identifier . rights) elements.
2540 The identifier string specifies the corresponding user. The
2541 identifier \"anyone\" is reserved to refer to the universal identity.
2543 Rights is a string listing a (possibly empty) set of alphanumeric
2544 characters, each character listing a set of operations which is being
2545 controlled. Letters are reserved for ``standard'' rights, listed
2546 below. Digits are reserved for implementation or site defined rights.
2548 l - lookup (mailbox is visible to LIST/LSUB commands)
2549 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2550 SEARCH, COPY from mailbox)
2551 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2552 w - write (STORE flags other than \\SEEN and \\DELETED)
2553 i - insert (perform APPEND, COPY into mailbox)
2554 p - post (send mail to submission address for mailbox,
2555 not enforced by IMAP4 itself)
2556 c - create and delete mailbox (CREATE new sub-mailboxes in any
2557 implementation-defined hierarchy, RENAME or DELETE mailbox)
2558 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2559 a - administer (perform SETACL)" group)
2562 ,mailbox ',method ',acl form)))))
2564 ;; Group sorting commands
2565 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2567 (defun gnus-group-sort-groups (func &optional reverse)
2568 "Sort the group buffer according to FUNC.
2569 When used interactively, the sorting function used will be
2570 determined by the `gnus-group-sort-function' variable.
2571 If REVERSE (the prefix), reverse the sorting order."
2572 (interactive (list gnus-group-sort-function current-prefix-arg))
2573 (funcall gnus-group-sort-alist-function
2574 (gnus-make-sort-function func) reverse)
2575 (gnus-group-list-groups)
2576 (gnus-dribble-touch))
2578 (defun gnus-group-sort-flat (func reverse)
2579 ;; We peel off the dummy group from the alist.
2581 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2582 (pop gnus-newsrc-alist))
2584 (setq gnus-newsrc-alist
2585 (sort gnus-newsrc-alist func))
2587 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2588 ;; Regenerate the hash table.
2589 (gnus-make-hashtable-from-newsrc-alist)))
2591 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2592 "Sort the group buffer alphabetically by group name.
2593 If REVERSE, sort in reverse order."
2595 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2597 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2598 "Sort the group buffer by number of unread articles.
2599 If REVERSE, sort in reverse order."
2601 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2603 (defun gnus-group-sort-groups-by-level (&optional reverse)
2604 "Sort the group buffer by group level.
2605 If REVERSE, sort in reverse order."
2607 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2609 (defun gnus-group-sort-groups-by-score (&optional reverse)
2610 "Sort the group buffer by group score.
2611 If REVERSE, sort in reverse order."
2613 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2615 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2616 "Sort the group buffer by group rank.
2617 If REVERSE, sort in reverse order."
2619 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2621 (defun gnus-group-sort-groups-by-method (&optional reverse)
2622 "Sort the group buffer alphabetically by backend name.
2623 If REVERSE, sort in reverse order."
2625 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2627 ;;; Selected group sorting.
2629 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2630 "Sort the process/prefixed groups."
2631 (interactive (list current-prefix-arg gnus-group-sort-function))
2632 (let ((groups (gnus-group-process-prefix n)))
2633 (funcall gnus-group-sort-selected-function
2634 groups (gnus-make-sort-function func) reverse)
2635 (gnus-group-list-groups)))
2637 (defun gnus-group-sort-selected-flat (groups func reverse)
2638 (let (entries infos)
2639 ;; First find all the group entries for these groups.
2641 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2643 ;; Then sort the infos.
2647 (lambda (entry) (car entry))
2648 (setq entries (nreverse entries)))
2651 (setq infos (nreverse infos)))
2652 ;; Go through all the infos and replace the old entries
2653 ;; with the new infos.
2655 (setcar (car entries) (pop infos))
2657 ;; Update the hashtable.
2658 (gnus-make-hashtable-from-newsrc-alist)))
2660 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2661 "Sort the group buffer alphabetically by group name.
2662 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2663 sort in reverse order."
2664 (interactive (gnus-interactive "P\ny"))
2665 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2667 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2668 "Sort the group buffer by number of unread articles.
2669 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2670 sort in reverse order."
2671 (interactive (gnus-interactive "P\ny"))
2672 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2674 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2675 "Sort the group buffer by group level.
2676 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2677 sort in reverse order."
2678 (interactive (gnus-interactive "P\ny"))
2679 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2681 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2682 "Sort the group buffer by group score.
2683 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2684 sort in reverse order."
2685 (interactive (gnus-interactive "P\ny"))
2686 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2688 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2689 "Sort the group buffer by group rank.
2690 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2691 sort in reverse order."
2692 (interactive (gnus-interactive "P\ny"))
2693 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2695 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2696 "Sort the group buffer alphabetically by backend name.
2697 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2698 sort in reverse order."
2699 (interactive (gnus-interactive "P\ny"))
2700 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2702 ;;; Sorting predicates.
2704 (defun gnus-group-sort-by-alphabet (info1 info2)
2705 "Sort alphabetically."
2706 (string< (gnus-info-group info1) (gnus-info-group info2)))
2708 (defun gnus-group-sort-by-real-name (info1 info2)
2709 "Sort alphabetically on real (unprefixed) names."
2710 (string< (gnus-group-real-name (gnus-info-group info1))
2711 (gnus-group-real-name (gnus-info-group info2))))
2713 (defun gnus-group-sort-by-unread (info1 info2)
2714 "Sort by number of unread articles."
2715 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2716 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2717 (< (or (and (numberp n1) n1) 0)
2718 (or (and (numberp n2) n2) 0))))
2720 (defun gnus-group-sort-by-level (info1 info2)
2722 (< (gnus-info-level info1) (gnus-info-level info2)))
2724 (defun gnus-group-sort-by-method (info1 info2)
2725 "Sort alphabetically by backend name."
2726 (string< (symbol-name (car (gnus-find-method-for-group
2727 (gnus-info-group info1) info1)))
2728 (symbol-name (car (gnus-find-method-for-group
2729 (gnus-info-group info2) info2)))))
2731 (defun gnus-group-sort-by-score (info1 info2)
2732 "Sort by group score."
2733 (< (gnus-info-score info1) (gnus-info-score info2)))
2735 (defun gnus-group-sort-by-rank (info1 info2)
2736 "Sort by level and score."
2737 (let ((level1 (gnus-info-level info1))
2738 (level2 (gnus-info-level info2)))
2739 (or (< level1 level2)
2740 (and (= level1 level2)
2741 (> (gnus-info-score info1) (gnus-info-score info2))))))
2745 (defun gnus-group-clear-data (&optional arg)
2746 "Clear all marks and read ranges from the current group."
2748 (gnus-group-iterate arg
2751 (gnus-info-clear-data (setq info (gnus-get-info group)))
2752 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2753 (when (gnus-group-goto-group group)
2754 (gnus-group-update-group-line))))))
2756 (defun gnus-group-clear-data-on-native-groups ()
2757 "Clear all marks and read ranges from all native groups."
2759 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2760 (let ((alist (cdr gnus-newsrc-alist))
2762 (while (setq info (pop alist))
2763 (when (gnus-group-native-p (gnus-info-group info))
2764 (gnus-info-clear-data info)))
2765 (gnus-get-unread-articles)
2766 (gnus-dribble-touch)
2767 (when (gnus-y-or-n-p
2768 "Move the cache away to avoid problems in the future? ")
2769 (call-interactively 'gnus-cache-move-cache)))))
2771 (defun gnus-info-clear-data (info)
2772 "Clear all marks and read ranges from INFO."
2773 (let ((group (gnus-info-group info)))
2776 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2777 (gnus-info-set-read ',info ',(gnus-info-read info))
2778 (when (gnus-group-goto-group ,group)
2779 (gnus-group-update-group-line))))
2780 (gnus-info-set-read info nil)
2781 (when (gnus-info-marks info)
2782 (gnus-info-set-marks info nil))))
2784 ;; Group catching up.
2786 (defun gnus-group-catchup-current (&optional n all)
2787 "Mark all unread articles in the current newsgroup as read.
2788 If prefix argument N is numeric, the next N newsgroups will be
2789 caught up. If ALL is non-nil, marked articles will also be marked as
2790 read. Cross references (Xref: header) of articles are ignored.
2791 The number of newsgroups that this function was unable to catch
2794 (let ((groups (gnus-group-process-prefix n))
2797 (unless groups (error "No groups selected"))
2799 (or (not gnus-interactive-catchup) ;Without confirmation?
2804 "Do you really want to mark all articles in %s as read? "
2805 "Mark all unread articles in %s as read? ")
2806 (if (= (length groups) 1)
2808 (format "these %d groups" (length groups)))))))
2810 (while (setq group (pop groups))
2811 (gnus-group-remove-mark group)
2812 ;; Virtual groups have to be given special treatment.
2813 (let ((method (gnus-find-method-for-group group)))
2814 (when (eq 'nnvirtual (car method))
2815 (nnvirtual-catchup-group
2816 (gnus-group-real-name group) (nth 1 method) all)))
2817 (if (>= (gnus-group-level group) gnus-level-zombie)
2818 (gnus-message 2 "Dead groups can't be caught up")
2820 (gnus-group-goto-group group)
2821 (gnus-group-catchup group all))
2822 (gnus-group-update-group-line)
2823 (setq ret (1+ ret)))))
2824 (gnus-group-next-unread-group 1)
2827 (defun gnus-group-catchup-current-all (&optional n)
2828 "Mark all articles in current newsgroup as read.
2829 Cross references (Xref: header) of articles are ignored."
2831 (gnus-group-catchup-current n 'all))
2833 (defun gnus-group-catchup (group &optional all)
2834 "Mark all articles in GROUP as read.
2835 If ALL is non-nil, all articles are marked as read.
2836 The return value is the number of articles that were marked as read,
2837 or nil if no action could be taken."
2838 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2840 ;; Remove entries for this group.
2841 (nnmail-purge-split-history (gnus-group-real-name group))
2842 ;; Do the updating only if the newsgroup isn't killed.
2843 (if (not (numberp (car entry)))
2844 (gnus-message 1 "Can't catch up %s; non-active group" group)
2845 ;; Do auto-expirable marks if that's required.
2846 (when (gnus-group-auto-expirable-p group)
2847 (gnus-add-marked-articles
2848 group 'expire (gnus-list-of-unread-articles group))
2850 (let ((marks (nth 3 (nth 2 entry))))
2851 (gnus-add-marked-articles
2852 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2853 (gnus-add-marked-articles
2854 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2856 (gnus-update-read-articles group nil)
2857 ;; Also nix out the lists of marks and dormants.
2859 (gnus-add-marked-articles group 'tick nil nil 'force)
2860 (gnus-add-marked-articles group 'dormant nil nil 'force))
2861 (let ((gnus-newsgroup-name group))
2862 (gnus-run-hooks 'gnus-group-catchup-group-hook))
2865 (defun gnus-group-expire-articles (&optional n)
2866 "Expire all expirable articles in the current newsgroup."
2868 (let ((groups (gnus-group-process-prefix n))
2871 (error "No groups to expire"))
2872 (while (setq group (pop groups))
2873 (gnus-group-remove-mark group)
2874 (gnus-group-expire-articles-1 group)
2875 (gnus-dribble-touch)
2876 (gnus-group-position-point))))
2878 (defun gnus-group-expire-articles-1 (group)
2879 (when (gnus-check-backend-function 'request-expire-articles group)
2880 (gnus-message 6 "Expiring articles in %s..." group)
2881 (let* ((info (gnus-get-info group))
2882 (expirable (if (gnus-group-total-expirable-p group)
2883 (cons nil (gnus-list-of-read-articles group))
2884 (assq 'expire (gnus-info-marks info))))
2885 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
2886 (nnmail-expiry-target
2887 (or (gnus-group-find-parameter group 'expiry-target)
2888 nnmail-expiry-target)))
2890 (gnus-check-group group)
2893 (gnus-compress-sequence
2895 ;; We set the expiry variables to the group
2897 (let ((nnmail-expiry-wait-function nil)
2898 (nnmail-expiry-wait expiry-wait))
2899 (gnus-request-expire-articles
2900 (gnus-uncompress-sequence (cdr expirable)) group))
2901 ;; Just expire using the normal expiry values.
2902 (gnus-request-expire-articles
2903 (gnus-uncompress-sequence (cdr expirable)) group))))
2904 (gnus-close-group group))
2905 (gnus-message 6 "Expiring articles in %s...done" group)
2906 ;; Return the list of un-expired articles.
2909 (defun gnus-group-expire-all-groups ()
2910 "Expire all expirable articles in all newsgroups."
2913 (gnus-message 5 "Expiring...")
2914 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2915 (cdr gnus-newsrc-alist))))
2916 (gnus-group-expire-articles nil)))
2917 (gnus-group-position-point)
2918 (gnus-message 5 "Expiring...done"))
2920 (defun gnus-group-set-current-level (n level)
2921 "Set the level of the next N groups to LEVEL."
2926 (let ((s (read-string
2927 (format "Level (default %s): "
2928 (or (gnus-group-group-level)
2929 gnus-level-default-subscribed)))))
2930 (if (string-match "^\\s-*$" s)
2931 (int-to-string (or (gnus-group-group-level)
2932 gnus-level-default-subscribed))
2934 (unless (and (>= level 1) (<= level gnus-level-killed))
2935 (error "Invalid level: %d" level))
2936 (let ((groups (gnus-group-process-prefix n))
2938 (while (setq group (pop groups))
2939 (gnus-group-remove-mark group)
2940 (gnus-message 6 "Changed level of %s from %d to %d"
2941 group (or (gnus-group-group-level) gnus-level-killed)
2943 (gnus-group-change-level
2944 group level (or (gnus-group-group-level) gnus-level-killed))
2945 (gnus-group-update-group-line)))
2946 (gnus-group-position-point))
2948 (defun gnus-group-unsubscribe (&optional n)
2949 "Unsubscribe the current group."
2951 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2953 (defun gnus-group-subscribe (&optional n)
2954 "Subscribe the current group."
2956 (gnus-group-unsubscribe-current-group n 'subscribe))
2958 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2959 "Toggle subscription of the current group.
2960 If given numerical prefix, toggle the N next groups."
2962 (let ((groups (gnus-group-process-prefix n))
2965 (setq group (car groups)
2966 groups (cdr groups))
2967 (gnus-group-remove-mark group)
2968 (gnus-group-unsubscribe-group
2971 ((eq do-sub 'unsubscribe)
2972 gnus-level-default-unsubscribed)
2973 ((eq do-sub 'subscribe)
2974 gnus-level-default-subscribed)
2975 ((<= (gnus-group-group-level) gnus-level-subscribed)
2976 gnus-level-default-unsubscribed)
2978 gnus-level-default-subscribed))
2980 (gnus-group-update-group-line))
2981 (gnus-group-next-group 1)))
2983 (defun gnus-group-unsubscribe-group (group &optional level silent)
2984 "Toggle subscription to GROUP.
2985 Killed newsgroups are subscribed. If SILENT, don't try to update the
2988 (list (completing-read
2989 "Group: " gnus-active-hashtb nil
2990 (gnus-read-active-file-p)
2992 'gnus-group-history)))
2993 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2995 ((string-match "^[ \t]*$" group)
2996 (error "Empty group name"))
2998 ;; Toggle subscription flag.
2999 (gnus-group-change-level
3000 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3001 gnus-level-subscribed)
3002 (1+ gnus-level-subscribed)
3003 gnus-level-default-subscribed)))
3005 (gnus-group-update-group group)))
3006 ((and (stringp group)
3007 (or (not (gnus-read-active-file-p))
3008 (gnus-active group)))
3009 ;; Add new newsgroup.
3010 (gnus-group-change-level
3012 (if level level gnus-level-default-subscribed)
3013 (or (and (member group gnus-zombie-list)
3016 (when (gnus-group-group-name)
3017 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3019 (gnus-group-update-group group)))
3020 (t (error "No such newsgroup: %s" group)))
3021 (gnus-group-position-point)))
3023 (defun gnus-group-transpose-groups (n)
3024 "Move the current newsgroup up N places.
3025 If given a negative prefix, move down instead. The difference between
3026 N and the number of steps taken is returned."
3028 (unless (gnus-group-group-name)
3029 (error "No group on current line"))
3030 (gnus-group-kill-group 1)
3032 (forward-line (- n))
3033 (gnus-group-yank-group)
3034 (gnus-group-position-point)))
3036 (defun gnus-group-kill-all-zombies (&optional dummy)
3037 "Kill all zombie newsgroups.
3038 The optional DUMMY should always be nil."
3039 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3041 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3042 (setq gnus-zombie-list nil)
3043 (gnus-dribble-touch)
3044 (gnus-group-list-groups)))
3046 (defun gnus-group-kill-region (begin end)
3047 "Kill newsgroups in current region (excluding current point).
3048 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3063 (beginning-of-line) ;Important when LINES < 1
3064 (gnus-group-kill-group lines)))
3066 (defun gnus-group-kill-group (&optional n discard)
3067 "Kill the next N groups.
3068 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3069 However, only groups that were alive can be yanked; already killed
3070 groups or zombie groups can't be yanked.
3071 The return value is the name of the group that was killed, or a list
3074 (let ((buffer-read-only nil)
3075 (groups (gnus-group-process-prefix n))
3076 group entry level out)
3077 (if (< (length groups) 10)
3078 ;; This is faster when there are few groups.
3080 (push (setq group (pop groups)) out)
3081 (gnus-group-remove-mark group)
3082 (setq level (gnus-group-group-level))
3084 (when (and (not discard)
3085 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3088 (gnus-group-goto-group ,(gnus-group-group-name))
3089 (gnus-group-yank-group)))
3090 (push (cons (car entry) (nth 2 entry))
3091 gnus-list-of-killed-groups))
3092 (gnus-group-change-level
3093 (if entry entry group) gnus-level-killed (if entry nil level))
3094 (message "Killed group %s" group))
3095 ;; If there are lots and lots of groups to be killed, we use
3096 ;; this thing instead.
3098 (setq groups (nreverse groups))
3100 (gnus-group-remove-mark (setq group (pop groups)))
3102 (push group gnus-killed-list)
3103 (setq gnus-newsrc-alist
3104 (delq (assoc group gnus-newsrc-alist)
3106 (when gnus-group-change-level-function
3107 (funcall gnus-group-change-level-function
3108 group gnus-level-killed 3))
3110 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3111 (push (cons (car entry) (nth 2 entry))
3112 gnus-list-of-killed-groups)
3113 (setcdr (cdr entry) (cdddr entry)))
3114 ((member group gnus-zombie-list)
3115 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3116 ;; There may be more than one instance displayed.
3117 (while (gnus-group-goto-group group)
3118 (gnus-delete-line)))
3119 (gnus-make-hashtable-from-newsrc-alist)))
3121 (gnus-group-position-point)
3122 (if (< (length out) 2) (car out) (nreverse out))))
3124 (defun gnus-group-yank-group (&optional arg)
3125 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3126 The numeric ARG specifies how many newsgroups are to be yanked. The
3127 name of the newsgroup yanked is returned, or (if several groups are
3128 yanked) a list of yanked groups is returned."
3130 (setq arg (or arg 1))
3131 (let (info group prev out)
3132 (while (>= (decf arg) 0)
3133 (when (not (setq info (pop gnus-list-of-killed-groups)))
3134 (error "No more newsgroups to yank"))
3135 (push (setq group (nth 1 info)) out)
3136 ;; Find which newsgroup to insert this one before - search
3137 ;; backward until something suitable is found. If there are no
3138 ;; other newsgroups in this buffer, just make this newsgroup the
3140 (setq prev (gnus-group-group-name))
3141 (gnus-group-change-level
3142 info (gnus-info-level (cdr info)) gnus-level-killed
3143 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3145 (gnus-group-insert-group-line-info group)
3147 `(when (gnus-group-goto-group ,group)
3148 (gnus-group-kill-group 1))))
3150 (gnus-group-position-point)
3151 (if (< (length out) 2) (car out) (nreverse out))))
3153 (defun gnus-group-kill-level (level)
3154 "Kill all groups that is on a certain LEVEL."
3155 (interactive "nKill all groups on level: ")
3157 ((= level gnus-level-zombie)
3158 (setq gnus-killed-list
3159 (nconc gnus-zombie-list gnus-killed-list))
3160 (setq gnus-zombie-list nil))
3161 ((and (< level gnus-level-zombie)
3163 (or gnus-expert-user
3166 "Do you really want to kill all groups on level %d? "
3168 (let* ((prev gnus-newsrc-alist)
3171 (if (= (gnus-info-level (car alist)) level)
3173 (push (gnus-info-group (car alist)) gnus-killed-list)
3174 (setcdr prev (cdr alist)))
3176 (setq alist (cdr alist)))
3177 (gnus-make-hashtable-from-newsrc-alist)
3178 (gnus-group-list-groups)))
3180 (error "Can't kill; invalid level: %d" level))))
3182 (defun gnus-group-list-all-groups (&optional arg)
3183 "List all newsgroups with level ARG or lower.
3184 Default is gnus-level-unsubscribed, which lists all subscribed and most
3185 unsubscribed groups."
3187 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3189 ;; Redefine this to list ALL killed groups if prefix arg used.
3190 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3191 (defun gnus-group-list-killed (&optional arg)
3192 "List all killed newsgroups in the group buffer.
3193 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3194 entail asking the server for the groups."
3196 ;; Find all possible killed newsgroups if arg.
3198 (gnus-get-killed-groups))
3199 (if (not gnus-killed-list)
3200 (gnus-message 6 "No killed groups")
3201 (let (gnus-group-list-mode)
3202 (funcall gnus-group-prepare-function
3203 gnus-level-killed t gnus-level-killed))
3204 (goto-char (point-min)))
3205 (gnus-group-position-point))
3207 (defun gnus-group-list-zombies ()
3208 "List all zombie newsgroups in the group buffer."
3210 (if (not gnus-zombie-list)
3211 (gnus-message 6 "No zombie groups")
3212 (let (gnus-group-list-mode)
3213 (funcall gnus-group-prepare-function
3214 gnus-level-zombie t gnus-level-zombie))
3215 (goto-char (point-min)))
3216 (gnus-group-position-point))
3218 (defun gnus-group-list-active ()
3219 "List all groups that are available from the server(s)."
3221 ;; First we make sure that we have really read the active file.
3222 (unless (gnus-read-active-file-p)
3223 (let ((gnus-read-active-file t)
3224 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3225 (gnus-read-active-file)))
3226 ;; Find all groups and sort them.
3234 (push (symbol-name sym) list)))
3238 (buffer-read-only nil)
3242 (setq group (pop groups))
3243 (gnus-add-text-properties
3244 (point) (prog1 (1+ (point))
3246 (gnus-group-name-decode group
3247 (gnus-group-name-charset
3250 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3252 'gnus-level (inline (gnus-group-level group)))))
3253 (goto-char (point-min))))
3255 (defun gnus-activate-all-groups (level)
3256 "Activate absolutely all groups."
3257 (interactive (list gnus-level-unsubscribed))
3258 (let ((gnus-activate-level level)
3259 (gnus-activate-foreign-newsgroups level))
3260 (gnus-group-get-new-news)))
3262 (defun gnus-group-get-new-news (&optional arg)
3263 "Get newly arrived articles.
3264 If ARG is a number, it specifies which levels you are interested in
3265 re-scanning. If ARG is non-nil and not a number, this will force
3266 \"hard\" re-reading of the active files from all servers."
3269 (let ((gnus-inhibit-demon t)
3270 ;; Binding this variable will inhibit multiple fetchings
3271 ;; of the same mail source.
3272 (nnmail-fetched-sources (list t)))
3273 (gnus-run-hooks 'gnus-get-new-news-hook)
3275 ;; Read any slave files.
3277 (gnus-master-read-slave-newsrc))
3279 ;; We might read in new NoCeM messages here.
3280 (when (and gnus-use-nocem
3282 (gnus-nocem-scan-groups))
3283 ;; If ARG is not a number, then we read the active file.
3284 (when (and arg (not (numberp arg)))
3285 (let ((gnus-read-active-file t))
3286 (gnus-read-active-file))
3289 ;; If the user wants it, we scan for new groups.
3290 (when (eq gnus-check-new-newsgroups 'always)
3291 (gnus-find-new-newsgroups)))
3293 (setq arg (gnus-group-default-level arg t))
3294 (if (and gnus-read-active-file (not arg))
3296 (gnus-read-active-file)
3297 (gnus-get-unread-articles arg))
3298 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3299 (gnus-get-unread-articles arg)))
3300 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3301 (gnus-group-list-groups (and (numberp arg)
3302 (max (car gnus-group-list-mode) arg))))
3304 (when (and gnus-agent (not (interactive-p)))
3305 (gnus-agent-toggle-plugged gnus-plugged)))
3307 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3308 "Check for newly arrived news in the current group (and the N-1 next groups).
3309 The difference between N and the number of newsgroup checked is returned.
3310 If N is negative, this group and the N-1 previous groups will be checked."
3312 (let* ((groups (gnus-group-process-prefix n))
3313 (ret (if (numberp n) (- n (length groups)) 0))
3317 (gnus-inhibit-demon t)
3318 ;; Binding this variable will inhibit multiple fetchings
3319 ;; of the same mail source.
3320 (nnmail-fetched-sources (list t)))
3321 (gnus-run-hooks 'gnus-get-new-news-hook)
3322 (while (setq group (pop groups))
3323 (gnus-group-remove-mark group)
3324 ;; Bypass any previous denials from the server.
3325 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3326 (if (gnus-activate-group group (if dont-scan nil 'scan))
3328 (gnus-get-unread-articles-in-group
3329 (gnus-get-info group) (gnus-active group) t)
3330 (unless (gnus-virtual-group-p group)
3331 (gnus-close-group group))
3333 (gnus-agent-save-group-info
3334 method (gnus-group-real-name group) (gnus-active group)))
3335 (gnus-group-update-group group))
3336 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3338 (gnus-error 3 "Server denied access")
3339 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3342 (when gnus-goto-next-group-when-activating
3343 (gnus-group-next-unread-group 1 t))
3344 (gnus-summary-position-point)
3347 (defun gnus-group-fetch-faq (group &optional faq-dir)
3348 "Fetch the FAQ for the current group.
3349 If given a prefix argument, prompt for the FAQ dir
3353 (gnus-group-group-name)
3354 (when current-prefix-arg
3356 "Faq dir: " (and (listp gnus-group-faq-directory)
3357 (mapcar (lambda (file) (list file))
3358 gnus-group-faq-directory))))))
3360 (error "No group name given"))
3361 (let ((dirs (or faq-dir gnus-group-faq-directory))
3363 (unless (listp dirs)
3364 (setq dirs (list dirs)))
3365 (while (and (not found)
3366 (setq dir (pop dirs)))
3367 (let ((name (gnus-group-real-name group)))
3368 (setq file (concat (file-name-as-directory dir) name)))
3369 (if (not (file-exists-p file))
3370 (gnus-message 1 "No such file: %s" file)
3371 (let ((enable-local-variables nil))
3375 (defun gnus-group-describe-group (force &optional group)
3376 "Display a description of the current newsgroup."
3377 (interactive (list current-prefix-arg (gnus-group-group-name)))
3378 (let* ((method (gnus-find-method-for-group group))
3379 (mname (gnus-group-prefixed-name "" method))
3382 gnus-description-hashtb)
3383 (gnus-sethash mname nil gnus-description-hashtb))
3385 (error "No group name given"))
3386 (when (or (and gnus-description-hashtb
3387 ;; We check whether this group's method has been
3388 ;; queried for a description file.
3389 (gnus-gethash mname gnus-description-hashtb))
3390 (setq desc (gnus-group-get-description group))
3391 (gnus-read-descriptions-file method))
3393 (or desc (gnus-gethash group gnus-description-hashtb)
3394 "No description available")))))
3396 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3397 (defun gnus-group-describe-all-groups (&optional force)
3398 "Pop up a buffer with descriptions of all newsgroups."
3401 (setq gnus-description-hashtb nil))
3402 (when (not (or gnus-description-hashtb
3403 (gnus-read-all-descriptions-files)))
3404 (error "Couldn't request descriptions file"))
3405 (let ((buffer-read-only nil)
3411 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3412 (insert (format " *: %-20s %s\n"
3413 (gnus-group-name-decode
3414 (symbol-name group) charset)
3415 (gnus-group-name-decode
3416 (symbol-value group) charset))))
3417 (gnus-add-text-properties
3418 b (1+ b) (list 'gnus-group group
3419 'gnus-unread t 'gnus-marked nil
3420 'gnus-level (1+ gnus-level-subscribed))))
3421 gnus-description-hashtb)
3422 (goto-char (point-min))
3423 (gnus-group-position-point)))
3425 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3426 (defun gnus-group-apropos (regexp &optional search-description)
3427 "List all newsgroups that have names that match a regexp."
3428 (interactive "sGnus apropos (regexp): ")
3430 (obuf (current-buffer))
3432 ;; Go through all newsgroups that are known to Gnus.
3435 (and (symbol-name group)
3436 (string-match regexp (symbol-name group))
3437 (symbol-value group)
3438 (push (symbol-name group) groups)))
3440 ;; Also go through all descriptions that are known to Gnus.
3441 (when search-description
3444 (and (string-match regexp (symbol-value group))
3445 (push (symbol-name group) groups)))
3446 gnus-description-hashtb))
3448 (gnus-message 3 "No groups matched \"%s\"." regexp)
3449 ;; Print out all the groups.
3451 (pop-to-buffer "*Gnus Help*")
3452 (buffer-disable-undo)
3454 (setq groups (sort groups 'string<))
3456 ;; Groups may be entered twice into the list of groups.
3457 (when (not (string= (car groups) prev))
3458 (setq prev (car groups))
3459 (let ((charset (gnus-group-name-charset nil prev)))
3460 (insert (gnus-group-name-decode prev charset) "\n")
3461 (when (and gnus-description-hashtb
3462 (setq des (gnus-gethash (car groups)
3463 gnus-description-hashtb)))
3464 (insert " " (gnus-group-name-decode des charset) "\n"))))
3465 (setq groups (cdr groups)))
3466 (goto-char (point-min))))
3467 (pop-to-buffer obuf)))
3469 (defun gnus-group-description-apropos (regexp)
3470 "List all newsgroups that have names or descriptions that match a regexp."
3471 (interactive "sGnus description apropos (regexp): ")
3472 (when (not (or gnus-description-hashtb
3473 (gnus-read-all-descriptions-files)))
3474 (error "Couldn't request descriptions file"))
3475 (gnus-group-apropos regexp t))
3477 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3478 (defun gnus-group-list-matching (level regexp &optional all lowest)
3479 "List all groups with unread articles that match REGEXP.
3480 If the prefix LEVEL is non-nil, it should be a number that says which
3481 level to cut off listing groups.
3482 If ALL, also list groups with no unread articles.
3483 If LOWEST, don't list groups with level lower than LOWEST.
3485 This command may read the active file."
3486 (interactive "P\nsList newsgroups matching: ")
3487 ;; First make sure active file has been read.
3489 (> (prefix-numeric-value level) gnus-level-killed))
3490 (gnus-get-killed-groups))
3491 (funcall gnus-group-prepare-function
3492 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3493 (goto-char (point-min))
3494 (gnus-group-position-point))
3496 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3497 "List all groups that match REGEXP.
3498 If the prefix LEVEL is non-nil, it should be a number that says which
3499 level to cut off listing groups.
3500 If LOWEST, don't list groups with level lower than LOWEST."
3501 (interactive "P\nsList newsgroups matching: ")
3503 (setq level (prefix-numeric-value level)))
3504 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3506 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3507 (defun gnus-group-save-newsrc (&optional force)
3508 "Save the Gnus startup files.
3509 If FORCE, force saving whether it is necessary or not."
3511 (gnus-save-newsrc-file force))
3513 (defun gnus-group-restart (&optional arg)
3514 "Force Gnus to read the .newsrc file."
3516 (when (gnus-yes-or-no-p
3517 (format "Are you sure you want to restart Gnus? "))
3518 (gnus-save-newsrc-file)
3522 (defun gnus-group-read-init-file ()
3523 "Read the Gnus elisp init file."
3525 (gnus-read-init-file)
3526 (gnus-message 5 "Read %s" gnus-init-file))
3528 (defun gnus-group-check-bogus-groups (&optional silent)
3529 "Check bogus newsgroups.
3530 If given a prefix, don't ask for confirmation before removing a bogus
3533 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3534 (gnus-group-list-groups))
3536 (defun gnus-group-find-new-groups (&optional arg)
3537 "Search for new groups and add them.
3538 Each new group will be treated with `gnus-subscribe-newsgroup-method.'
3539 With 1 C-u, use the `ask-server' method to query the server for new
3541 With 2 C-u's, use most complete method possible to query the server
3542 for new groups, and subscribe the new groups as zombies."
3544 (gnus-find-new-newsgroups (or arg 1))
3545 (gnus-group-list-groups))
3547 (defun gnus-group-edit-global-kill (&optional article group)
3548 "Edit the global kill file.
3549 If GROUP, edit that local kill file instead."
3551 (setq gnus-current-kill-article article)
3552 (gnus-kill-file-edit-file group)
3555 (substitute-command-keys
3556 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3557 (if group "local" "global")))))
3559 (defun gnus-group-edit-local-kill (article group)
3560 "Edit a local kill file."
3561 (interactive (list nil (gnus-group-group-name)))
3562 (gnus-group-edit-global-kill article group))
3564 (defun gnus-group-force-update ()
3565 "Update `.newsrc' file."
3567 (gnus-save-newsrc-file))
3569 (defun gnus-group-suspend ()
3570 "Suspend the current Gnus session.
3571 In fact, cleanup buffers except for group mode buffer.
3572 The hook gnus-suspend-gnus-hook is called before actually suspending."
3574 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3575 ;; Kill Gnus buffers except for group mode buffer.
3576 (let ((group-buf (get-buffer gnus-group-buffer)))
3577 (mapcar (lambda (buf)
3578 (unless (member buf (list group-buf gnus-dribble-buffer))
3581 (gnus-kill-gnus-frames)
3583 (bury-buffer group-buf)
3584 (delete-windows-on group-buf t))))
3586 (defun gnus-group-clear-dribble ()
3587 "Clear all information from the dribble buffer."
3589 (gnus-dribble-clear)
3590 (gnus-message 7 "Cleared dribble buffer"))
3592 (defun gnus-group-exit ()
3593 "Quit reading news after updating .newsrc.eld and .newsrc.
3594 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3597 (or noninteractive ;For gnus-batch-kill
3598 (not gnus-interactive-exit) ;Without confirmation
3600 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3601 (gnus-run-hooks 'gnus-exit-gnus-hook)
3602 ;; Offer to save data from non-quitted summary buffers.
3603 (gnus-offer-save-summaries)
3604 ;; Save the newsrc file(s).
3605 (gnus-save-newsrc-file)
3607 (gnus-close-backends)
3608 ;; Reset everything.
3610 ;; Allow the user to do things after cleaning up.
3611 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3613 (defun gnus-group-quit ()
3614 "Quit reading news without updating .newsrc.eld or .newsrc.
3615 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3617 (when (or noninteractive ;For gnus-batch-kill
3618 (zerop (buffer-size))
3619 (not (gnus-server-opened gnus-select-method))
3621 (not gnus-current-startup-file)
3623 (format "Quit reading news without saving %s? "
3624 (file-name-nondirectory gnus-current-startup-file))))
3625 (gnus-run-hooks 'gnus-exit-gnus-hook)
3626 (gnus-configure-windows 'group t)
3628 (gnus-close-backends)
3630 (gnus-kill-buffer gnus-group-buffer)
3631 ;; Allow the user to do things after cleaning up.
3632 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3634 (defun gnus-group-describe-briefly ()
3635 "Give a one line description of the group mode commands."
3637 (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")))
3639 (defun gnus-group-browse-foreign-server (method)
3640 "Browse a foreign news server.
3641 If called interactively, this function will ask for a select method
3642 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3643 If not, METHOD should be a list where the first element is the method
3644 and the second element is the address."
3646 (list (let ((how (completing-read
3648 (append gnus-valid-select-methods gnus-server-alist)
3649 nil t (cons "nntp" 0) 'gnus-method-history)))
3650 ;; We either got a backend name or a virtual server name.
3651 ;; If the first, we also need an address.
3652 (if (assoc how gnus-valid-select-methods)
3654 ;; Suggested by mapjph@bath.ac.uk.
3657 (mapcar (lambda (server) (list server))
3658 gnus-secondary-servers)))
3659 ;; We got a server name.
3661 (gnus-browse-foreign-server method))
3663 (defun gnus-group-set-info (info &optional method-only-group part)
3664 (when (or info part)
3665 (let* ((entry (gnus-gethash
3666 (or method-only-group (gnus-info-group info))
3667 gnus-newsrc-hashtb))
3669 (info (if method-only-group (nth 2 entry) info))
3671 (when method-only-group
3673 (error "Trying to change non-existent group %s" method-only-group))
3674 ;; We have received parts of the actual group info - either the
3675 ;; select method or the group parameters. We first check
3676 ;; whether we have to extend the info, and if so, do that.
3677 (let ((len (length info))
3678 (total (if (eq part 'method) 5 6)))
3680 (setcdr (nthcdr (1- len) info)
3681 (make-list (- total len) nil)))
3682 ;; Then we enter the new info.
3683 (setcar (nthcdr (1- total) info) part-info)))
3685 ;; This is a new group, so we just create it.
3687 (set-buffer gnus-group-buffer)
3688 (setq method (gnus-info-method info))
3689 (when (gnus-server-equal method "native")
3692 (set-buffer gnus-group-buffer)
3694 ;; It's a foreign group...
3695 (gnus-group-make-group
3696 (gnus-group-real-name (gnus-info-group info))
3697 (if (stringp method) method
3698 (prin1-to-string (car method)))
3700 (nth 1 (gnus-info-method info))))
3701 ;; It's a native group.
3702 (gnus-group-make-group (gnus-info-group info))))
3703 (gnus-message 6 "Note: New group created")
3705 (gnus-gethash (gnus-group-prefixed-name
3706 (gnus-group-real-name (gnus-info-group info))
3707 (or (gnus-info-method info) gnus-select-method))
3708 gnus-newsrc-hashtb))))
3709 ;; Whether it was a new group or not, we now have the entry, so we
3710 ;; can do the update.
3713 (setcar (nthcdr 2 entry) info)
3714 (when (and (not (eq (car entry) t))
3715 (gnus-active (gnus-info-group info)))
3716 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3717 (error "No such group: %s" (gnus-info-group info))))))
3719 (defun gnus-group-set-method-info (group select-method)
3720 (gnus-group-set-info select-method group 'method))
3722 (defun gnus-group-set-params-info (group params)
3723 (gnus-group-set-info params group 'params))
3725 (defun gnus-add-marked-articles (group type articles &optional info force)
3726 ;; Add ARTICLES of TYPE to the info of GROUP.
3727 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3728 ;; add, but replace marked articles of TYPE with ARTICLES.
3729 (let ((info (or info (gnus-get-info group)))
3732 (and (not (setq marked (nthcdr 3 info)))
3734 (setcdr (nthcdr 2 info)
3735 (list (list (cons type (gnus-compress-sequence
3737 (and (not (setq m (assq type (car marked))))
3740 (cons (cons type (gnus-compress-sequence articles t) )
3744 (setcar (nthcdr 3 info)
3745 (gnus-delete-alist type (car marked)))
3746 (setcdr m (gnus-compress-sequence articles t)))
3747 (setcdr m (gnus-compress-sequence
3748 (sort (nconc (gnus-uncompress-range (cdr m))
3749 (copy-sequence articles)) '<) t))))))
3752 ;;; Group timestamps
3755 (defun gnus-group-set-timestamp ()
3756 "Change the timestamp of the current group to the current time.
3757 This function can be used in hooks like `gnus-select-group-hook'
3758 or `gnus-group-catchup-group-hook'."
3759 (when gnus-newsgroup-name
3760 (let ((time (current-time)))
3761 (setcdr (cdr time) nil)
3762 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3764 (defsubst gnus-group-timestamp (group)
3765 "Return the timestamp for GROUP."
3766 (gnus-group-get-parameter group 'timestamp t))
3768 (defun gnus-group-timestamp-delta (group)
3769 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3770 (let* ((time (or (gnus-group-timestamp group)
3772 (delta (subtract-time (current-time) time)))
3773 (+ (* (nth 0 delta) 65536.0)
3776 (defun gnus-group-timestamp-string (group)
3777 "Return a string of the timestamp for GROUP."
3778 (let ((time (gnus-group-timestamp group)))
3781 (gnus-time-iso8601 time))))
3783 (defun gnus-group-list-cached (level &optional lowest)
3784 "List all groups with cached articles.
3785 If the prefix LEVEL is non-nil, it should be a number that says which
3786 level to cut off listing groups.
3787 If LOWEST, don't list groups with level lower than LOWEST.
3789 This command may read the active file."
3792 (setq level (prefix-numeric-value level)))
3793 (when (or (not level) (>= level gnus-level-zombie))
3795 (funcall gnus-group-prepare-function
3796 (or level gnus-level-subscribed)
3798 (let ((marks (gnus-info-marks info)))
3799 (assq 'cache marks)))
3802 (or (gnus-gethash group
3803 gnus-cache-active-hashtb)
3804 ;; Cache active file might use "."
3807 (mapconcat 'identity
3808 (split-string group ":")
3810 gnus-cache-active-hashtb))))
3811 (goto-char (point-min))
3812 (gnus-group-position-point))
3814 (defun gnus-group-list-dormant (level &optional lowest)
3815 "List all groups with dormant articles.
3816 If the prefix LEVEL is non-nil, it should be a number that says which
3817 level to cut off listing groups.
3818 If LOWEST, don't list groups with level lower than LOWEST.
3820 This command may read the active file."
3823 (setq level (prefix-numeric-value level)))
3824 (when (or (not level) (>= level gnus-level-zombie))
3826 (funcall gnus-group-prepare-function
3827 (or level gnus-level-subscribed)
3829 (let ((marks (gnus-info-marks info)))
3830 (assq 'dormant marks)))
3833 (goto-char (point-min))
3834 (gnus-group-position-point))
3836 (defun gnus-group-listed-groups ()
3837 "Return a list of listed groups."
3839 (goto-char (point-min))
3840 (while (setq point (text-property-not-all (point) (point-max)
3843 (push (symbol-name (get-text-property point 'gnus-group)) groups)
3847 (defun gnus-group-list-plus (&optional args)
3848 "List groups plus the current selection."
3850 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
3851 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
3853 (push last-command-event unread-command-events)
3854 (if (featurep 'xemacs)
3855 (push (make-event 'key-press '(key ?A)) unread-command-events)
3856 (push ?A unread-command-events))
3857 (let (gnus-pick-mode keys)
3858 (setq keys (if (featurep 'xemacs)
3859 (events-to-keys (read-key-sequence nil))
3860 (read-key-sequence nil)))
3861 (setq func (lookup-key (current-local-map) keys)))
3865 (call-interactively func))))
3867 (defun gnus-group-list-flush (&optional args)
3868 "Flush groups from the current selection."
3870 (let ((gnus-group-list-option 'flush))
3871 (gnus-group-list-plus args)))
3873 (defun gnus-group-list-limit (&optional args)
3874 "List groups limited within the current selection."
3876 (let ((gnus-group-list-option 'limit))
3877 (gnus-group-list-plus args)))
3879 (provide 'gnus-group)
3881 ;;; gnus-group.el ends here