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))
42 (defcustom gnus-group-archive-directory
43 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
44 "*The address of the (ding) archives."
45 :group 'gnus-group-foreign
48 (defcustom gnus-group-recent-archive-directory
49 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
50 "*The address of the most recent (ding) articles."
51 :group 'gnus-group-foreign
54 (defcustom gnus-no-groups-message "No gnus is bad news"
55 "*Message displayed by Gnus when no groups are available."
59 (defcustom gnus-keep-same-level nil
60 "*Non-nil means that the next newsgroup after the current will be on the same level.
61 When you type, for instance, `n' after reading the last article in the
62 current newsgroup, you will go to the next newsgroup. If this variable
63 is nil, the next newsgroup will be the next from the group
65 If this variable is non-nil, Gnus will either put you in the
66 next newsgroup with the same level, or, if no such newsgroup is
67 available, the next newsgroup with the lowest possible level higher
68 than the current level.
69 If this variable is `best', Gnus will make the next newsgroup the one
71 :group 'gnus-group-levels
72 :type '(choice (const nil)
74 (sexp :tag "other" t)))
76 (defcustom gnus-group-goto-unread t
77 "*If non-nil, movement commands will go to the next unread and subscribed group."
78 :link '(custom-manual "(gnus)Group Maneuvering")
79 :group 'gnus-group-various
82 (defcustom gnus-goto-next-group-when-activating t
83 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
84 :link '(custom-manual "(gnus)Scanning New Messages")
85 :group 'gnus-group-various
88 (defcustom gnus-permanently-visible-groups nil
89 "*Regexp to match groups that should always be listed in the group buffer.
90 This means that they will still be listed even when there are no
91 unread articles in the groups.
93 If nil, no groups are permanently visible."
94 :group 'gnus-group-listing
95 :type '(choice regexp (const nil)))
97 (defcustom gnus-list-groups-with-ticked-articles t
98 "*If non-nil, list groups that have only ticked articles.
99 If nil, only list groups that have unread articles."
100 :group 'gnus-group-listing
103 (defcustom gnus-group-default-list-level gnus-level-subscribed
104 "*Default listing level.
105 Ignored if `gnus-group-use-permanent-levels' is non-nil."
106 :group 'gnus-group-listing
109 (defcustom gnus-group-list-inactive-groups t
110 "*If non-nil, inactive groups will be listed."
111 :group 'gnus-group-listing
112 :group 'gnus-group-levels
115 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
116 "*Function used for sorting the group buffer.
117 This function will be called with group info entries as the arguments
118 for the groups to be sorted. Pre-made functions include
119 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
120 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
121 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
122 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
124 This variable can also be a list of sorting functions. In that case,
125 the most significant sort function should be the last function in the
127 :group 'gnus-group-listing
128 :link '(custom-manual "(gnus)Sorting Groups")
129 :type '(radio (function-item gnus-group-sort-by-alphabet)
130 (function-item gnus-group-sort-by-real-name)
131 (function-item gnus-group-sort-by-unread)
132 (function-item gnus-group-sort-by-level)
133 (function-item gnus-group-sort-by-score)
134 (function-item gnus-group-sort-by-method)
135 (function-item gnus-group-sort-by-server)
136 (function-item gnus-group-sort-by-rank)
137 (function :tag "other" nil)))
139 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
140 "*Format of group lines.
141 It works along the same lines as a normal formatting string,
142 with some simple extensions.
144 %M Only marked articles (character, \"*\" or \" \")
145 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
146 %L Level of subscribedness (integer)
147 %N Number of unread articles (integer)
148 %I Number of dormant articles (integer)
149 %i Number of ticked and dormant (integer)
150 %T Number of ticked articles (integer)
151 %R Number of read articles (integer)
152 %t Estimated total number of articles (integer)
153 %y Number of unread, unticked articles (integer)
154 %G Group name (string)
155 %g Qualified group name (string)
156 %D Group description (string)
157 %s Select method (string)
158 %o Moderated group (char, \"m\")
159 %p Process mark (char)
160 %O Moderated group (string, \"(m)\" or \"\")
161 %P Topic indentation (string)
162 %m Whether there is new(ish) mail in the group (char, \"%\")
163 %l Whether there are GroupLens predictions for this group (string)
164 %n Select from where (string)
165 %z A string that look like `<%s:%n>' if a foreign select method is used
166 %d The date the group was last entered.
167 %E Icon as defined by `gnus-group-icon-list'.
168 %u User defined specifier. The next character in the format string should
169 be a letter. Gnus will call the function gnus-user-format-function-X,
170 where X is the letter following %u. The function will be passed the
171 current header as argument. The function should return a string, which
172 will be inserted into the buffer just like information from any other
175 Text between %( and %) will be highlighted with `gnus-mouse-face' when
176 the mouse point move inside the area. There can only be one such area.
178 Note that this format specification is not always respected. For
179 reasons of efficiency, when listing killed groups, this specification
180 is ignored altogether. If the spec is changed considerably, your
181 output may end up looking strange when listing both alive and killed
184 If you use %o or %O, reading the active file will be slower and quite
185 a bit of extra memory will be used. %D will also worsen performance.
186 Also note that if you change the format specification to include any
187 of these specs, you must probably re-start Gnus to see them go into
189 :group 'gnus-group-visual
192 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
193 "*The format specification for the group mode line.
194 It works along the same lines as a normal formatting string,
195 with some simple extensions:
197 %S The native news server.
198 %M The native select method.
199 %: \":\" if %S isn't \"\"."
200 :group 'gnus-group-visual
203 (defcustom gnus-group-mode-hook nil
204 "Hook for Gnus group mode."
205 :group 'gnus-group-various
206 :options '(gnus-topic-mode)
209 (defcustom gnus-group-menu-hook nil
210 "Hook run after the creation of the group mode menu."
211 :group 'gnus-group-various
214 (defcustom gnus-group-catchup-group-hook nil
215 "Hook run when catching up a group from the group buffer."
216 :group 'gnus-group-various
217 :link '(custom-manual "(gnus)Group Data")
220 (defcustom gnus-group-update-group-hook nil
221 "Hook called when updating group lines."
222 :group 'gnus-group-visual
225 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
226 "*A function that is called to generate the group buffer.
227 The function is called with three arguments: The first is a number;
228 all group with a level less or equal to that number should be listed,
229 if the second is non-nil, empty groups should also be displayed. If
230 the third is non-nil, it is a number. No groups with a level lower
231 than this number should be displayed.
233 The only current function implemented is `gnus-group-prepare-flat'."
234 :group 'gnus-group-listing
237 (defcustom gnus-group-prepare-hook nil
238 "Hook called after the group buffer has been generated.
239 If you want to modify the group buffer, you can use this hook."
240 :group 'gnus-group-listing
243 (defcustom gnus-suspend-gnus-hook nil
244 "Hook called when suspending (not exiting) Gnus."
248 (defcustom gnus-exit-gnus-hook nil
249 "Hook called when exiting Gnus."
253 (defcustom gnus-after-exiting-gnus-hook nil
254 "Hook called after exiting Gnus."
258 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
259 "Hook called when a group line is changed.
260 The hook will not be called if `gnus-visual' is nil.
262 The default function `gnus-group-highlight-line' will
263 highlight the line according to the `gnus-group-highlight'
265 :group 'gnus-group-visual
268 (defcustom gnus-useful-groups
269 '(("(ding) mailing list mirrored at sunsite.auc.dk"
271 (nntp "sunsite.auc.dk"
272 (nntp-address "sunsite.auc.dk")))
275 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
279 (nndoc-article-type mbox)
280 (eval `(nndoc-address
281 ,(let ((file (nnheader-find-etc-directory
284 (error "Couldn't find doc group"))
286 "*Alist of useful group-server pairs."
287 :group 'gnus-group-listing
288 :type '(repeat (list (string :tag "Description")
290 (sexp :tag "Method"))))
292 (defcustom gnus-group-highlight
294 ((and (= unread 0) (not mailp) (eq level 1)) .
295 gnus-group-news-1-empty-face)
296 ((and (not mailp) (eq level 1)) .
297 gnus-group-news-1-face)
298 ((and (= unread 0) (not mailp) (eq level 2)) .
299 gnus-group-news-2-empty-face)
300 ((and (not mailp) (eq level 2)) .
301 gnus-group-news-2-face)
302 ((and (= unread 0) (not mailp) (eq level 3)) .
303 gnus-group-news-3-empty-face)
304 ((and (not mailp) (eq level 3)) .
305 gnus-group-news-3-face)
306 ((and (= unread 0) (not mailp) (eq level 4)) .
307 gnus-group-news-4-empty-face)
308 ((and (not mailp) (eq level 4)) .
309 gnus-group-news-4-face)
310 ((and (= unread 0) (not mailp) (eq level 5)) .
311 gnus-group-news-5-empty-face)
312 ((and (not mailp) (eq level 5)) .
313 gnus-group-news-5-face)
314 ((and (= unread 0) (not mailp) (eq level 6)) .
315 gnus-group-news-6-empty-face)
316 ((and (not mailp) (eq level 6)) .
317 gnus-group-news-6-face)
318 ((and (= unread 0) (not mailp)) .
319 gnus-group-news-low-empty-face)
321 gnus-group-news-low-face)
323 ((and (= unread 0) (eq level 1)) .
324 gnus-group-mail-1-empty-face)
326 gnus-group-mail-1-face)
327 ((and (= unread 0) (eq level 2)) .
328 gnus-group-mail-2-empty-face)
330 gnus-group-mail-2-face)
331 ((and (= unread 0) (eq level 3)) .
332 gnus-group-mail-3-empty-face)
334 gnus-group-mail-3-face)
336 gnus-group-mail-low-empty-face)
338 gnus-group-mail-low-face))
339 "*Controls the highlighting of group buffer lines.
341 Below is a list of `Form'/`Face' pairs. When deciding how a a
342 particular group line should be displayed, each form is
343 evaluated. The content of the face field after the first true form is
344 used. You can change how those group lines are displayed by
345 editing the face field.
347 It is also possible to change and add form fields, but currently that
348 requires an understanding of Lisp expressions. Hopefully this will
349 change in a future release. For now, you can use the following
350 variables in the Lisp expression:
352 group: The name of the group.
353 unread: The number of unread articles in the group.
354 method: The select method used.
355 mailp: Whether it's a mail group or not.
356 level: The level of the group.
357 score: The score of the group.
358 ticked: The number of ticked articles."
359 :group 'gnus-group-visual
360 :type '(repeat (cons (sexp :tag "Form") face)))
362 (defcustom gnus-new-mail-mark ?%
363 "Mark used for groups with new mail."
364 :group 'gnus-group-visual
367 (defgroup gnus-group-icons nil
368 "Add Icons to your group buffer. "
369 :group 'gnus-group-visual)
371 (defcustom gnus-group-icon-list
373 "*Controls the insertion of icons into group buffer lines.
375 Below is a list of `Form'/`File' pairs. When deciding how a
376 particular group line should be displayed, each form is evaluated.
377 The icon from the file field after the first true form is used. You
378 can change how those group lines are displayed by editing the file
379 field. The File will either be found in the
380 `gnus-group-glyph-directory' or by designating absolute path to the
383 It is also possible to change and add form fields, but currently that
384 requires an understanding of Lisp expressions. Hopefully this will
385 change in a future release. For now, you can use the following
386 variables in the Lisp expression:
388 group: The name of the group.
389 unread: The number of unread articles in the group.
390 method: The select method used.
391 mailp: Whether it's a mail group or not.
392 newsp: Whether it's a news group or not
393 level: The level of the group.
394 score: The score of the group.
395 ticked: The number of ticked articles."
396 :group 'gnus-group-icons
397 :type '(repeat (cons (sexp :tag "Form") file)))
399 (defcustom gnus-group-name-charset-method-alist nil
400 "*Alist of method and the charset for group names.
403 (((nntp \"news.com.cn\") . cn-gb-2312))
407 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
409 (defcustom gnus-group-name-charset-group-alist nil
410 "*Alist of group regexp and the charset for group names.
413 ((\"\\.com\\.cn:\" . cn-gb-2312))
416 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
418 (defcustom gnus-group-jump-to-group-prompt nil
419 "Default prompt for `gnus-group-jump-to-group'.
420 If non-nil, the value should be a string, e.g. \"nnml:\",
421 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
422 in the minibuffer prompt."
423 :group 'gnus-group-various
424 :type '(choice (string :tag "Prompt string")
425 (const :tag "Empty" nil)))
427 ;;; Internal variables
429 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
430 "Function for sorting the group buffer.")
432 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
433 "Function for sorting the selected groups in the group buffer.")
435 (defvar gnus-group-indentation-function nil)
436 (defvar gnus-goto-missing-group-function nil)
437 (defvar gnus-group-update-group-function nil)
438 (defvar gnus-group-goto-next-group-function nil
439 "Function to override finding the next group after listing groups.")
441 (defvar gnus-group-edit-buffer nil)
443 (defvar gnus-group-line-format-alist
444 `((?M gnus-tmp-marked-mark ?c)
445 (?S gnus-tmp-subscribed ?c)
446 (?L gnus-tmp-level ?d)
447 (?N (cond ((eq number t) "*" )
451 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
452 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
454 (?R gnus-tmp-number-of-read ?s)
455 (?t gnus-tmp-number-total ?d)
456 (?y gnus-tmp-number-of-unread ?s)
457 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
458 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
459 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
460 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
461 (?g gnus-tmp-group ?s)
462 (?G gnus-tmp-qualified-group ?s)
463 (?c (gnus-short-group-name gnus-tmp-group) ?s)
464 (?D gnus-tmp-newsgroup-description ?s)
465 (?o gnus-tmp-moderated ?c)
466 (?O gnus-tmp-moderated-string ?s)
467 (?p gnus-tmp-process-marked ?c)
468 (?s gnus-tmp-news-server ?s)
469 (?n gnus-tmp-news-method ?s)
470 (?P gnus-group-indentation ?s)
471 (?E gnus-tmp-group-icon ?s)
472 (?l gnus-tmp-grouplens ?s)
473 (?z gnus-tmp-news-method-string ?s)
474 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
475 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
476 (?u gnus-tmp-user-defined ?s)))
478 (defvar gnus-group-mode-line-format-alist
479 `((?S gnus-tmp-news-server ?s)
480 (?M gnus-tmp-news-method ?s)
481 (?u gnus-tmp-user-defined ?s)
482 (?: gnus-tmp-colon ?s)))
484 (defvar gnus-topic-topology nil
485 "The complete topic hierarchy.")
487 (defvar gnus-topic-alist nil
488 "The complete topic-group alist.")
490 (defvar gnus-group-marked nil)
492 (defvar gnus-group-list-mode nil)
495 (defvar gnus-group-icon-cache nil)
497 (defvar gnus-group-listed-groups nil)
498 (defvar gnus-group-list-option nil)
504 (put 'gnus-group-mode 'mode-class 'special)
507 (gnus-define-keys gnus-group-mode-map
508 " " gnus-group-read-group
509 "=" gnus-group-select-group
510 "\r" gnus-group-select-group
511 "\M-\r" gnus-group-quick-select-group
512 "\M- " gnus-group-visible-select-group
513 [(meta control return)] gnus-group-select-group-ephemerally
514 "j" gnus-group-jump-to-group
515 "n" gnus-group-next-unread-group
516 "p" gnus-group-prev-unread-group
517 "\177" gnus-group-prev-unread-group
518 [delete] gnus-group-prev-unread-group
519 [backspace] gnus-group-prev-unread-group
520 "N" gnus-group-next-group
521 "P" gnus-group-prev-group
522 "\M-n" gnus-group-next-unread-group-same-level
523 "\M-p" gnus-group-prev-unread-group-same-level
524 "," gnus-group-best-unread-group
525 "." gnus-group-first-unread-group
526 "u" gnus-group-unsubscribe-current-group
527 "U" gnus-group-unsubscribe-group
528 "c" gnus-group-catchup-current
529 "C" gnus-group-catchup-current-all
530 "\M-c" gnus-group-clear-data
531 "l" gnus-group-list-groups
532 "L" gnus-group-list-all-groups
534 "g" gnus-group-get-new-news
535 "\M-g" gnus-group-get-new-news-this-group
536 "R" gnus-group-restart
537 "r" gnus-group-read-init-file
538 "B" gnus-group-browse-foreign-server
539 "b" gnus-group-check-bogus-groups
540 "F" gnus-group-find-new-groups
541 "\C-c\C-d" gnus-group-describe-group
542 "\M-d" gnus-group-describe-all-groups
543 "\C-c\C-a" gnus-group-apropos
544 "\C-c\M-\C-a" gnus-group-description-apropos
545 "a" gnus-group-post-news
546 "\ek" gnus-group-edit-local-kill
547 "\eK" gnus-group-edit-global-kill
548 "\C-k" gnus-group-kill-group
549 "\C-y" gnus-group-yank-group
550 "\C-w" gnus-group-kill-region
551 "\C-x\C-t" gnus-group-transpose-groups
552 "\C-c\C-l" gnus-group-list-killed
553 "\C-c\C-x" gnus-group-expire-articles
554 "\C-c\M-\C-x" gnus-group-expire-all-groups
556 "s" gnus-group-save-newsrc
557 "z" gnus-group-suspend
560 "?" gnus-group-describe-briefly
561 "\C-c\C-i" gnus-info-find-node
562 "\M-e" gnus-group-edit-group-method
563 "^" gnus-group-enter-server-mode
564 gnus-mouse-2 gnus-mouse-pick-group
565 "<" beginning-of-buffer
568 "\C-c\C-s" gnus-group-sort-groups
570 "\C-c\M-g" gnus-activate-all-groups
571 "\M-&" gnus-group-universal-argument
572 "#" gnus-group-mark-group
573 "\M-#" gnus-group-unmark-group)
575 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
576 "m" gnus-group-mark-group
577 "u" gnus-group-unmark-group
578 "w" gnus-group-mark-region
579 "b" gnus-group-mark-buffer
580 "r" gnus-group-mark-regexp
581 "U" gnus-group-unmark-all-groups)
583 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
584 "d" gnus-group-make-directory-group
585 "h" gnus-group-make-help-group
586 "u" gnus-group-make-useful-group
587 "a" gnus-group-make-archive-group
588 "k" gnus-group-make-kiboze-group
589 "l" gnus-group-nnimap-edit-acl
590 "m" gnus-group-make-group
591 "E" gnus-group-edit-group
592 "e" gnus-group-edit-group-method
593 "p" gnus-group-edit-group-parameters
594 "v" gnus-group-add-to-virtual
595 "V" gnus-group-make-empty-virtual
596 "D" gnus-group-enter-directory
597 "f" gnus-group-make-doc-group
598 "w" gnus-group-make-web-group
599 "r" gnus-group-rename-group
600 "c" gnus-group-customize
601 "x" gnus-group-nnimap-expunge
602 "\177" gnus-group-delete-group
603 [delete] gnus-group-delete-group)
605 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
606 "b" gnus-group-brew-soup
607 "w" gnus-soup-save-areas
608 "s" gnus-soup-send-replies
609 "p" gnus-soup-pack-packet
610 "r" nnsoup-pack-replies)
612 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
613 "s" gnus-group-sort-groups
614 "a" gnus-group-sort-groups-by-alphabet
615 "u" gnus-group-sort-groups-by-unread
616 "l" gnus-group-sort-groups-by-level
617 "v" gnus-group-sort-groups-by-score
618 "r" gnus-group-sort-groups-by-rank
619 "m" gnus-group-sort-groups-by-method)
621 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
622 "s" gnus-group-sort-selected-groups
623 "a" gnus-group-sort-selected-groups-by-alphabet
624 "u" gnus-group-sort-selected-groups-by-unread
625 "l" gnus-group-sort-selected-groups-by-level
626 "v" gnus-group-sort-selected-groups-by-score
627 "r" gnus-group-sort-selected-groups-by-rank
628 "m" gnus-group-sort-selected-groups-by-method)
630 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
631 "k" gnus-group-list-killed
632 "z" gnus-group-list-zombies
633 "s" gnus-group-list-groups
634 "u" gnus-group-list-all-groups
635 "A" gnus-group-list-active
636 "a" gnus-group-apropos
637 "d" gnus-group-description-apropos
638 "m" gnus-group-list-matching
639 "M" gnus-group-list-all-matching
640 "l" gnus-group-list-level
641 "c" gnus-group-list-cached
642 "?" gnus-group-list-dormant)
644 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
645 "k" gnus-group-list-limit
646 "z" gnus-group-list-limit
647 "s" gnus-group-list-limit
648 "u" gnus-group-list-limit
649 "A" gnus-group-list-limit
650 "m" gnus-group-list-limit
651 "M" gnus-group-list-limit
652 "l" gnus-group-list-limit
653 "c" gnus-group-list-limit
654 "?" gnus-group-list-limit)
656 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
657 "k" gnus-group-list-flush
658 "z" gnus-group-list-flush
659 "s" gnus-group-list-flush
660 "u" gnus-group-list-flush
661 "A" gnus-group-list-flush
662 "m" gnus-group-list-flush
663 "M" gnus-group-list-flush
664 "l" gnus-group-list-flush
665 "c" gnus-group-list-flush
666 "?" gnus-group-list-flush)
668 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
669 "k" gnus-group-list-plus
670 "z" gnus-group-list-plus
671 "s" gnus-group-list-plus
672 "u" gnus-group-list-plus
673 "A" gnus-group-list-plus
674 "m" gnus-group-list-plus
675 "M" gnus-group-list-plus
676 "l" gnus-group-list-plus
677 "c" gnus-group-list-plus
678 "?" gnus-group-list-plus)
680 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
681 "f" gnus-score-flush-cache)
683 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
684 "d" gnus-group-describe-group
685 "f" gnus-group-fetch-faq
688 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
689 "l" gnus-group-set-current-level
690 "t" gnus-group-unsubscribe-current-group
691 "s" gnus-group-unsubscribe-group
692 "k" gnus-group-kill-group
693 "y" gnus-group-yank-group
694 "w" gnus-group-kill-region
695 "\C-k" gnus-group-kill-level
696 "z" gnus-group-kill-all-zombies))
698 (defun gnus-group-make-menu-bar ()
699 (gnus-turn-off-edit-menu 'group)
700 (unless (boundp 'gnus-group-reading-menu)
703 gnus-group-reading-menu gnus-group-mode-map ""
705 ["Read" gnus-group-read-group (gnus-group-group-name)]
706 ["Select" gnus-group-select-group (gnus-group-group-name)]
707 ["See old articles" (gnus-group-select-group 'all)
708 :keys "C-u SPC" :active (gnus-group-group-name)]
709 ["Catch up" gnus-group-catchup-current :active (gnus-group-group-name)
710 ,@(if (featurep 'xemacs) nil
711 '(:help "Mark unread articles in the current group as read"))]
712 ["Catch up all articles" gnus-group-catchup-current-all
713 (gnus-group-group-name)]
714 ["Check for new articles" gnus-group-get-new-news-this-group
715 :active (gnus-group-group-name)
716 ,@(if (featurep 'xemacs) nil
717 '(:help "Check for new messages in current group"))]
718 ["Toggle subscription" gnus-group-unsubscribe-current-group
719 (gnus-group-group-name)]
720 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
721 ,@(if (featurep 'xemacs) nil
722 '(:help "Kill (remove) current group"))]
723 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
724 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
725 ,@(if (featurep 'xemacs) nil
726 '(:help "Display description of the current group"))]
727 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
728 ;; Actually one should check, if any of the marked groups gives t for
729 ;; (gnus-check-backend-function 'request-expire-articles ...)
730 ["Expire articles" gnus-group-expire-articles
731 (or (and (gnus-group-group-name)
732 (gnus-check-backend-function
733 'request-expire-articles
734 (gnus-group-group-name))) gnus-group-marked)]
735 ["Set group level" gnus-group-set-current-level
736 (gnus-group-group-name)]
737 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
738 ["Customize" gnus-group-customize (gnus-group-group-name)]
740 ["Parameters" gnus-group-edit-group-parameters
741 (gnus-group-group-name)]
742 ["Select method" gnus-group-edit-group-method
743 (gnus-group-group-name)]
744 ["Info" gnus-group-edit-group (gnus-group-group-name)]
745 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
746 ["Global kill file" gnus-group-edit-global-kill t])))
749 gnus-group-group-menu gnus-group-mode-map ""
752 ["List unread subscribed groups" gnus-group-list-groups t]
753 ["List (un)subscribed groups" gnus-group-list-all-groups t]
754 ["List killed groups" gnus-group-list-killed gnus-killed-list]
755 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
756 ["List level..." gnus-group-list-level t]
757 ["Describe all groups" gnus-group-describe-all-groups t]
758 ["Group apropos..." gnus-group-apropos t]
759 ["Group and description apropos..." gnus-group-description-apropos t]
760 ["List groups matching..." gnus-group-list-matching t]
761 ["List all groups matching..." gnus-group-list-all-matching t]
762 ["List active file" gnus-group-list-active t]
763 ["List groups with cached" gnus-group-list-cached t]
764 ["List groups with dormant" gnus-group-list-dormant t])
766 ["Default sort" gnus-group-sort-groups t]
767 ["Sort by method" gnus-group-sort-groups-by-method t]
768 ["Sort by rank" gnus-group-sort-groups-by-rank t]
769 ["Sort by score" gnus-group-sort-groups-by-score t]
770 ["Sort by level" gnus-group-sort-groups-by-level t]
771 ["Sort by unread" gnus-group-sort-groups-by-unread t]
772 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
773 ("Sort process/prefixed"
774 ["Default sort" gnus-group-sort-selected-groups
775 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
776 ["Sort by method" gnus-group-sort-selected-groups-by-method
777 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
778 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
779 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
780 ["Sort by score" gnus-group-sort-selected-groups-by-score
781 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
782 ["Sort by level" gnus-group-sort-selected-groups-by-level
783 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
784 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
785 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
786 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
787 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
789 ["Mark group" gnus-group-mark-group
790 (and (gnus-group-group-name)
791 (not (memq (gnus-group-group-name) gnus-group-marked)))]
792 ["Unmark group" gnus-group-unmark-group
793 (and (gnus-group-group-name)
794 (memq (gnus-group-group-name) gnus-group-marked))]
795 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
796 ["Mark regexp..." gnus-group-mark-regexp t]
797 ["Mark region" gnus-group-mark-region t]
798 ["Mark buffer" gnus-group-mark-buffer t]
799 ["Execute command" gnus-group-universal-argument
800 (or gnus-group-marked (gnus-group-group-name))])
802 ["Subscribe to a group" gnus-group-unsubscribe-group t]
803 ["Kill all newsgroups in region" gnus-group-kill-region t]
804 ["Kill all zombie groups" gnus-group-kill-all-zombies
806 ["Kill all groups on level..." gnus-group-kill-level t])
808 ["Make a foreign group" gnus-group-make-group t]
809 ["Add a directory group" gnus-group-make-directory-group t]
810 ["Add the help group" gnus-group-make-help-group t]
811 ["Add the archive group" gnus-group-make-archive-group t]
812 ["Make a doc group" gnus-group-make-doc-group t]
813 ["Make a web group" gnus-group-make-web-group t]
814 ["Make a kiboze group" gnus-group-make-kiboze-group t]
815 ["Make a virtual group" gnus-group-make-empty-virtual t]
816 ["Add a group to a virtual" gnus-group-add-to-virtual t]
817 ["Rename group" gnus-group-rename-group
818 (gnus-check-backend-function
819 'request-rename-group (gnus-group-group-name))]
820 ["Delete group" gnus-group-delete-group
821 (gnus-check-backend-function
822 'request-delete-group (gnus-group-group-name))])
824 ["Next" gnus-group-next-group t]
825 ["Previous" gnus-group-prev-group t]
826 ["Next unread" gnus-group-next-unread-group t]
827 ["Previous unread" gnus-group-prev-unread-group t]
828 ["Next unread same level" gnus-group-next-unread-group-same-level t]
829 ["Previous unread same level"
830 gnus-group-prev-unread-group-same-level t]
831 ["Jump to group" gnus-group-jump-to-group t]
832 ["First unread group" gnus-group-first-unread-group t]
833 ["Best unread group" gnus-group-best-unread-group t])
834 ["Delete bogus groups" gnus-group-check-bogus-groups t]
835 ["Find new newsgroups" gnus-group-find-new-groups t]
836 ["Transpose" gnus-group-transpose-groups
837 (gnus-group-group-name)]
838 ["Read a directory as a group..." gnus-group-enter-directory t]))
841 gnus-group-misc-menu gnus-group-mode-map ""
844 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
845 ["Send replies" gnus-soup-send-replies
846 (fboundp 'gnus-soup-pack-packet)]
847 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
848 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
849 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
850 ["Send a mail" gnus-group-mail t]
851 ["Post an article..." gnus-group-post-news t]
852 ["Check for new news" gnus-group-get-new-news
853 ,@(if (featurep 'xemacs) nil
854 '(:help "Get newly arrived articles"))
856 ["Activate all groups" gnus-activate-all-groups t]
857 ["Restart Gnus" gnus-group-restart t]
858 ["Read init file" gnus-group-read-init-file t]
859 ["Browse foreign server" gnus-group-browse-foreign-server t]
860 ["Enter server buffer" gnus-group-enter-server-mode t]
861 ["Expire all expirable articles" gnus-group-expire-all-groups t]
862 ["Generate any kiboze groups" nnkiboze-generate-groups t]
863 ["Gnus version" gnus-version t]
864 ["Save .newsrc files" gnus-group-save-newsrc t]
865 ["Suspend Gnus" gnus-group-suspend t]
866 ["Clear dribble buffer" gnus-group-clear-dribble t]
867 ["Read manual" gnus-info-find-node t]
868 ["Flush score cache" gnus-score-flush-cache t]
869 ["Toggle topics" gnus-topic-mode t]
870 ["Send a bug report" gnus-bug t]
871 ["Exit from Gnus" gnus-group-exit
872 ,@(if (featurep 'xemacs) nil
873 '(:help "Quit reading news"))]
874 ["Exit without saving" gnus-group-quit t]))
876 (gnus-run-hooks 'gnus-group-menu-hook)))
878 (defvar gnus-group-toolbar-map nil)
880 ;; Emacs 21 tool bar. Should be no-op otherwise.
881 (defun gnus-group-make-tool-bar ()
882 (if (and (fboundp 'tool-bar-add-item-from-menu)
883 (default-value 'tool-bar-mode)
884 (not gnus-group-toolbar-map))
885 (setq gnus-group-toolbar-map
886 (let ((tool-bar-map (make-sparse-keymap))
887 (load-path (mm-image-load-path)))
888 (tool-bar-add-item-from-menu
889 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
890 (tool-bar-add-item-from-menu
891 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
892 (tool-bar-add-item-from-menu
893 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
894 (tool-bar-add-item-from-menu
895 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
896 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
897 :help "Subscribe to the current group")
898 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
900 :help "Unsubscribe from the current group")
901 (tool-bar-add-item-from-menu
902 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
904 (if gnus-group-toolbar-map
905 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
907 (defun gnus-group-mode ()
908 "Major mode for reading news.
910 All normal editing commands are switched off.
911 \\<gnus-group-mode-map>
912 The group buffer lists (some of) the groups available. For instance,
913 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
914 lists all zombie groups.
916 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
917 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
919 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
921 The following commands are available:
923 \\{gnus-group-mode-map}"
925 (kill-all-local-variables)
926 (when (gnus-visual-p 'group-menu 'menu)
927 (gnus-group-make-menu-bar)
928 (gnus-group-make-tool-bar))
929 (gnus-simplify-mode-line)
930 (setq major-mode 'gnus-group-mode)
931 (setq mode-name "Group")
932 (gnus-group-set-mode-line)
933 (setq mode-line-process nil)
934 (use-local-map gnus-group-mode-map)
935 (buffer-disable-undo)
936 (setq truncate-lines t)
937 (setq buffer-read-only t)
938 (gnus-set-default-directory)
939 (gnus-update-format-specifications nil 'group 'group-mode)
940 (gnus-update-group-mark-positions)
945 (gnus-run-hooks 'gnus-group-mode-hook))
947 (defun gnus-update-group-mark-positions ()
949 (let ((gnus-process-mark ?\200)
950 (gnus-group-marked '("dummy.group"))
951 (gnus-active-hashtb (make-vector 10 0))
953 (gnus-set-active "dummy.group" '(0 . 0))
954 (gnus-set-work-buffer)
955 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
956 (goto-char (point-min))
957 (setq gnus-group-mark-positions
958 (list (cons 'process (and (search-forward "\200" nil t)
961 (defun gnus-mouse-pick-group (e)
962 "Enter the group under the mouse pointer."
965 (gnus-group-read-group nil))
967 ;; Look at LEVEL and find out what the level is really supposed to be.
968 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
969 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
970 (defun gnus-group-default-level (&optional level number-or-nil)
972 (gnus-group-use-permanent-levels
973 (or (setq gnus-group-use-permanent-levels
974 (or level (if (numberp gnus-group-use-permanent-levels)
975 gnus-group-use-permanent-levels
976 (or gnus-group-default-list-level
977 gnus-level-subscribed))))
978 gnus-group-default-list-level gnus-level-subscribed))
982 (or level gnus-group-default-list-level gnus-level-subscribed))))
984 (defun gnus-group-setup-buffer ()
985 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
986 (unless (eq major-mode 'gnus-group-mode)
989 (gnus-carpal-setup-buffer 'group))))
991 (defsubst gnus-group-name-charset (method group)
993 (setq method (gnus-find-method-for-group group)))
994 (let ((item (assoc method gnus-group-name-charset-method-alist))
995 (alist gnus-group-name-charset-group-alist)
999 (while (setq item (pop alist))
1000 (if (string-match (car item) group)
1002 result (cdr item))))
1005 (defsubst gnus-group-name-decode (string charset)
1006 (if (and string charset (featurep 'mule))
1007 (mm-decode-coding-string string charset)
1010 (defun gnus-group-decoded-name (string)
1011 (let ((charset (gnus-group-name-charset nil string)))
1012 (gnus-group-name-decode string charset)))
1014 (defun gnus-group-list-groups (&optional level unread lowest)
1015 "List newsgroups with level LEVEL or lower that have unread articles.
1016 Default is all subscribed groups.
1017 If argument UNREAD is non-nil, groups with no unread articles are also
1020 Also see the `gnus-group-use-permanent-levels' variable."
1022 (list (if current-prefix-arg
1023 (prefix-numeric-value current-prefix-arg)
1025 (gnus-group-default-level nil t)
1026 gnus-group-default-list-level
1027 gnus-level-subscribed))))
1029 (setq level (car gnus-group-list-mode)
1030 unread (cdr gnus-group-list-mode)))
1031 (setq level (gnus-group-default-level level))
1032 (gnus-group-setup-buffer)
1033 (gnus-update-format-specifications nil 'group 'group-mode)
1034 (let ((case-fold-search nil)
1035 (props (text-properties-at (gnus-point-at-bol)))
1036 (empty (= (point-min) (point-max)))
1037 (group (gnus-group-group-name))
1039 (set-buffer gnus-group-buffer)
1040 (setq number (funcall gnus-group-prepare-function level unread lowest))
1041 (when (or (and (numberp number)
1043 (zerop (buffer-size)))
1044 ;; No groups in the buffer.
1045 (gnus-message 5 gnus-no-groups-message))
1046 ;; We have some groups displayed.
1047 (goto-char (point-max))
1048 (when (or (not gnus-group-goto-next-group-function)
1049 (not (funcall gnus-group-goto-next-group-function
1053 (goto-char (point-min)))
1055 ;; Go to the first group with unread articles.
1056 (gnus-group-search-forward t))
1058 ;; Find the right group to put point on. If the current group
1059 ;; has disappeared in the new listing, try to find the next
1060 ;; one. If no next one can be found, just leave point at the
1061 ;; first newsgroup in the buffer.
1062 (when (not (gnus-goto-char
1064 (point-min) (point-max)
1065 'gnus-group (gnus-intern-safe
1066 group gnus-active-hashtb))))
1067 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1069 (not (gnus-goto-char
1071 (point-min) (point-max) 'gnus-group
1073 (caar newsrc) gnus-active-hashtb)))))
1074 (setq newsrc (cdr newsrc)))
1076 (goto-char (point-max))
1077 (forward-line -1)))))))
1078 ;; Adjust cursor point.
1079 (gnus-group-position-point)))
1081 (defun gnus-group-list-level (level &optional all)
1082 "List groups on LEVEL.
1083 If ALL (the prefix), also list groups that have no unread articles."
1084 (interactive "nList groups on level: \nP")
1085 (gnus-group-list-groups level all level))
1087 (defun gnus-group-prepare-logic (group test)
1088 (or (and gnus-group-listed-groups
1089 (null gnus-group-list-option)
1090 (member group gnus-group-listed-groups))
1092 ((null gnus-group-listed-groups) test)
1093 ((null gnus-group-list-option) test)
1094 (t (and (member group gnus-group-listed-groups)
1095 (if (eq gnus-group-list-option 'flush)
1099 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1100 "List all newsgroups with unread articles of level LEVEL or lower.
1101 If PREDICATE is a function, list groups that the function returns non-nil;
1102 if it is t, list groups that have no unread articles.
1103 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1104 If REGEXP is a function, list dead groups that the function returns non-nil;
1105 if it is a string, only list groups matching REGEXP."
1106 (set-buffer gnus-group-buffer)
1107 (let ((buffer-read-only nil)
1108 (newsrc (cdr gnus-newsrc-alist))
1109 (lowest (or lowest 1))
1110 (not-in-list (and gnus-group-listed-groups
1111 (copy-sequence gnus-group-listed-groups)))
1112 info clevel unread group params)
1114 (when (or (< lowest gnus-level-zombie)
1115 gnus-group-listed-groups)
1116 ;; List living groups.
1118 (setq info (car newsrc)
1119 group (gnus-info-group info)
1120 params (gnus-info-params info)
1122 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1124 (setq not-in-list (delete group not-in-list)))
1126 (gnus-group-prepare-logic
1128 (and unread ; This group might be unchecked
1129 (or (not (stringp regexp))
1130 (string-match regexp group))
1131 (<= (setq clevel (gnus-info-level info)) level)
1134 ((functionp predicate)
1135 (funcall predicate info))
1136 (predicate t) ; We list all groups?
1139 (if (eq unread t) ; Unactivated?
1140 gnus-group-list-inactive-groups
1141 ; We list unactivated
1143 ; We list groups with unread articles
1144 (and gnus-list-groups-with-ticked-articles
1145 (cdr (assq 'tick (gnus-info-marks info))))
1146 ; And groups with tickeds
1147 ;; Check for permanent visibility.
1148 (and gnus-permanently-visible-groups
1149 (string-match gnus-permanently-visible-groups group))
1150 (memq 'visible params)
1151 (cdr (assq 'visible params)))))))
1152 (gnus-group-insert-group-line
1153 group (gnus-info-level info)
1154 (gnus-info-marks info) unread (gnus-info-method info)))))
1156 ;; List dead groups.
1157 (if (or gnus-group-listed-groups
1158 (and (>= level gnus-level-zombie)
1159 (<= lowest gnus-level-zombie)))
1160 (gnus-group-prepare-flat-list-dead
1161 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1162 gnus-level-zombie ?Z
1165 (dolist (group gnus-zombie-list)
1166 (setq not-in-list (delete group not-in-list))))
1167 (if (or gnus-group-listed-groups
1168 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1169 (gnus-group-prepare-flat-list-dead
1172 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1173 gnus-level-killed ?K regexp))
1175 (gnus-group-set-mode-line)
1176 (setq gnus-group-list-mode (cons level predicate))
1177 (gnus-run-hooks 'gnus-group-prepare-hook)
1180 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1181 ;; List zombies and killed lists somewhat faster, which was
1182 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1183 ;; this by ignoring the group format specification altogether.
1186 (setq group (pop groups))
1187 (when (gnus-group-prepare-logic
1190 (and (stringp regexp) (string-match regexp group))
1191 (and (functionp regexp) (funcall regexp group))))
1192 ;;; (gnus-add-text-properties
1193 ;;; (point) (prog1 (1+ (point))
1194 ;;; (insert " " mark " *: "
1195 ;;; (gnus-group-name-decode group
1196 ;;; (gnus-group-name-charset
1199 ;;; (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1201 ;;; 'gnus-level level))
1202 (gnus-group-insert-group-line
1204 (let ((active (gnus-active group)))
1206 (if (zerop (cdr active))
1208 (- (1+ (cdr active)) (car active)))
1210 (gnus-method-simplify (gnus-find-method-for-group group)))))))
1212 (defun gnus-group-update-group-line ()
1213 "Update the current line in the group buffer."
1214 (let* ((buffer-read-only nil)
1215 (group (gnus-group-group-name))
1216 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1217 gnus-group-indentation)
1220 (not (gnus-ephemeral-group-p group))
1222 (concat "(gnus-group-set-info '"
1223 (gnus-prin1-to-string (nth 2 entry))
1225 (setq gnus-group-indentation (gnus-group-group-indentation))
1227 (gnus-group-insert-group-line-info group)
1229 (gnus-group-position-point))))
1231 (defun gnus-group-insert-group-line-info (group)
1232 "Insert GROUP on the current line."
1233 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1234 (gnus-group-indentation (gnus-group-group-indentation))
1238 ;; (Un)subscribed group.
1239 (setq info (nth 2 entry))
1240 (gnus-group-insert-group-line
1241 group (gnus-info-level info) (gnus-info-marks info)
1242 (or (car entry) t) (gnus-info-method info)))
1243 ;; This group is dead.
1244 (gnus-group-insert-group-line
1246 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1248 (if (setq active (gnus-active group))
1249 (if (zerop (cdr active))
1251 (- (1+ (cdr active)) (car active)))
1253 (gnus-method-simplify (gnus-find-method-for-group group))))))
1255 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1256 gnus-tmp-marked number
1258 "Insert a group line in the group buffer."
1259 (let* ((gnus-tmp-method
1260 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1261 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1263 (gnus-tmp-active (gnus-active gnus-tmp-group))
1264 (gnus-tmp-number-total
1266 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1268 (gnus-tmp-number-of-unread
1269 (if (numberp number) (int-to-string (max 0 number))
1271 (gnus-tmp-number-of-read
1272 (if (numberp number)
1273 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1275 (gnus-tmp-subscribed
1276 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1277 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1278 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1280 (gnus-tmp-qualified-group
1281 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1282 group-name-charset))
1283 (gnus-tmp-newsgroup-description
1284 (if gnus-description-hashtb
1285 (or (gnus-group-name-decode
1286 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1287 group-name-charset) "")
1290 (if (and gnus-moderated-hashtb
1291 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1293 (gnus-tmp-moderated-string
1294 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1295 (gnus-tmp-group-icon "==&&==")
1296 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1297 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1298 (gnus-tmp-news-method-string
1300 (format "(%s:%s)" (car gnus-tmp-method)
1301 (cadr gnus-tmp-method)) ""))
1302 (gnus-tmp-marked-mark
1303 (if (and (numberp number)
1305 (cdr (assq 'tick gnus-tmp-marked)))
1307 (gnus-tmp-process-marked
1308 (if (member gnus-tmp-group gnus-group-marked)
1309 gnus-process-mark ? ))
1311 (or (and gnus-use-grouplens
1312 (bbb-grouplens-group-p gnus-tmp-group))
1314 (buffer-read-only nil)
1315 header gnus-tmp-header) ; passed as parameter to user-funcs.
1317 (gnus-add-text-properties
1321 (eval gnus-group-line-format-spec))
1322 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1323 gnus-unread ,(if (numberp number)
1324 (string-to-int gnus-tmp-number-of-unread)
1326 gnus-marked ,gnus-tmp-marked-mark
1327 gnus-indentation ,gnus-group-indentation
1328 gnus-level ,gnus-tmp-level))
1330 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1331 (gnus-run-hooks 'gnus-group-update-hook))
1333 ;; Allow XEmacs to remove front-sticky text properties.
1334 (gnus-group-remove-excess-properties)))
1336 (defun gnus-group-highlight-line ()
1337 "Highlight the current line according to `gnus-group-highlight'."
1338 (let* ((list gnus-group-highlight)
1340 (end (progn (end-of-line) (point)))
1341 ;; now find out where the line starts and leave point there.
1342 (beg (progn (beginning-of-line) (point)))
1343 (group (gnus-group-group-name))
1344 (entry (gnus-group-entry group))
1345 (unread (if (numberp (car entry)) (car entry) 0))
1346 (active (gnus-active group))
1347 (total (if active (1+ (- (cdr active) (car active))) 0))
1348 (info (nth 2 entry))
1349 (method (gnus-server-get-method group (gnus-info-method info)))
1350 (marked (gnus-info-marks info))
1351 (mailp (memq 'mail (assoc (symbol-name
1352 (car (or method gnus-select-method)))
1353 gnus-valid-select-methods)))
1354 (level (or (gnus-info-level info) gnus-level-killed))
1355 (score (or (gnus-info-score info) 0))
1356 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1357 (group-age (gnus-group-timestamp-delta group))
1358 (inhibit-read-only t))
1359 ;; Eval the cars of the lists until we find a match.
1361 (not (eval (caar list))))
1362 (setq list (cdr list)))
1363 (let ((face (cdar list)))
1364 (unless (eq face (get-text-property beg 'face))
1365 (gnus-put-text-property-excluding-characters-with-faces
1367 (setq face (if (boundp face) (symbol-value face) face)))
1368 (gnus-extent-start-open beg)))
1371 (defun gnus-group-update-group (group &optional visible-only)
1372 "Update all lines where GROUP appear.
1373 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1375 ;; Can't use `save-excursion' here, so we do it manually.
1376 (let ((buf (current-buffer))
1378 (set-buffer gnus-group-buffer)
1379 (setq mark (point-marker))
1380 ;; The buffer may be narrowed.
1383 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1385 found buffer-read-only)
1386 ;; Enter the current status into the dribble buffer.
1387 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1389 (not (gnus-ephemeral-group-p group)))
1391 (concat "(gnus-group-set-info '"
1392 (gnus-prin1-to-string (nth 2 entry))
1394 ;; Find all group instances. If topics are in use, each group
1395 ;; may be listed in more than once.
1396 (while (setq loc (text-property-any
1397 loc (point-max) 'gnus-group ident))
1400 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1402 (gnus-group-insert-group-line-info group)
1405 (gnus-run-hooks 'gnus-group-update-group-hook)))
1406 (setq loc (1+ loc)))
1407 (unless (or found visible-only)
1408 ;; No such line in the buffer, find out where it's supposed to
1409 ;; go, and insert it there (or at the end of the buffer).
1410 (if gnus-goto-missing-group-function
1411 (funcall gnus-goto-missing-group-function group)
1412 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1413 (while (and entry (car entry)
1417 (point-min) (point-max)
1418 'gnus-group (gnus-intern-safe
1419 (caar entry) gnus-active-hashtb)))))
1420 (setq entry (cdr entry)))
1421 (or entry (goto-char (point-max)))))
1422 ;; Finally insert the line.
1423 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1424 (gnus-group-insert-group-line-info group)
1427 (gnus-run-hooks 'gnus-group-update-group-hook))))
1428 (when gnus-group-update-group-function
1429 (funcall gnus-group-update-group-function group))
1430 (gnus-group-set-mode-line)))
1432 (set-marker mark nil)
1435 (defun gnus-group-set-mode-line ()
1436 "Update the mode line in the group buffer."
1437 (when (memq 'group gnus-updated-mode-lines)
1438 ;; Yes, we want to keep this mode line updated.
1440 (set-buffer gnus-group-buffer)
1441 (let* ((gformat (or gnus-group-mode-line-format-spec
1442 (gnus-set-format 'group-mode)))
1443 (gnus-tmp-news-server (cadr gnus-select-method))
1444 (gnus-tmp-news-method (car gnus-select-method))
1445 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1447 gnus-tmp-header ;Dummy binding for user-defined formats
1448 ;; Get the resulting string.
1450 (and gnus-dribble-buffer
1451 (buffer-name gnus-dribble-buffer)
1452 (buffer-modified-p gnus-dribble-buffer)
1454 (set-buffer gnus-dribble-buffer)
1455 (not (zerop (buffer-size))))))
1456 (mode-string (eval gformat)))
1457 ;; Say whether the dribble buffer has been modified.
1458 (setq mode-line-modified
1459 (if modified (car gnus-mode-line-modified)
1460 (cdr gnus-mode-line-modified)))
1461 ;; If the line is too long, we chop it off.
1462 (when (> (length mode-string) max-len)
1463 (setq mode-string (substring mode-string 0 (- max-len 4))))
1465 (setq mode-line-buffer-identification
1466 (gnus-mode-line-buffer-identification
1467 (list mode-string)))
1468 (set-buffer-modified-p modified))))))
1470 (defun gnus-group-group-name ()
1471 "Get the name of the newsgroup on the current line."
1472 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1474 (symbol-name group))))
1476 (defun gnus-group-group-level ()
1477 "Get the level of the newsgroup on the current line."
1478 (get-text-property (gnus-point-at-bol) 'gnus-level))
1480 (defun gnus-group-group-indentation ()
1481 "Get the indentation of the newsgroup on the current line."
1482 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1483 (and gnus-group-indentation-function
1484 (funcall gnus-group-indentation-function))
1487 (defun gnus-group-group-unread ()
1488 "Get the number of unread articles of the newsgroup on the current line."
1489 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1491 (defun gnus-group-new-mail (group)
1492 (if (nnmail-new-mail-p (gnus-group-real-name group))
1496 (defun gnus-group-level (group)
1497 "Return the estimated level of GROUP."
1498 (or (gnus-info-level (gnus-get-info group))
1499 (and (member group gnus-zombie-list) gnus-level-zombie)
1502 (defun gnus-group-search-forward (&optional backward all level first-too)
1503 "Find the next newsgroup with unread articles.
1504 If BACKWARD is non-nil, find the previous newsgroup instead.
1505 If ALL is non-nil, just find any newsgroup.
1506 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1508 If FIRST-TOO, the current line is also eligible as a target."
1509 (let ((way (if backward -1 1))
1510 (low gnus-level-killed)
1513 (if (and backward (progn (beginning-of-line)) (bobp))
1522 (get-text-property (point) 'gnus-group)
1526 (get-text-property (point) 'gnus-unread)))
1527 (and (numberp unread) (> unread 0)))
1528 (setq lev (get-text-property (point)
1530 (<= lev gnus-level-subscribed)))
1532 (and (setq lev (get-text-property (point)
1541 (zerop (forward-line way)))))
1543 (progn (gnus-group-position-point) t)
1544 (goto-char (or pos beg))
1547 ;;; Gnus group mode commands
1551 (defun gnus-group-mark-line-p ()
1554 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1555 (eq (char-after) gnus-process-mark)))
1557 (defun gnus-group-mark-group (n &optional unmark no-advance)
1558 "Mark the current group."
1560 (let ((buffer-read-only nil)
1564 (when (setq group (gnus-group-group-name))
1565 ;; Go to the mark position.
1567 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1568 (subst-char-in-region
1569 (point) (1+ (point)) (char-after)
1572 (setq gnus-group-marked (delete group gnus-group-marked))
1574 (setq gnus-group-marked
1575 (cons group (delete group gnus-group-marked)))
1576 gnus-process-mark)))
1578 (gnus-group-next-group 1))
1580 (gnus-summary-position-point)
1583 (defun gnus-group-unmark-group (n)
1584 "Remove the mark from the current group."
1586 (gnus-group-mark-group n 'unmark)
1587 (gnus-group-position-point))
1589 (defun gnus-group-unmark-all-groups ()
1590 "Unmark all groups."
1592 (let ((groups gnus-group-marked))
1595 (gnus-group-remove-mark (pop groups)))))
1596 (gnus-group-position-point))
1598 (defun gnus-group-mark-region (unmark beg end)
1599 "Mark all groups between point and mark.
1600 If UNMARK, remove the mark instead."
1601 (interactive "P\nr")
1602 (let ((num (count-lines beg end)))
1605 (- num (gnus-group-mark-group num unmark)))))
1607 (defun gnus-group-mark-buffer (&optional unmark)
1608 "Mark all groups in the buffer.
1609 If UNMARK, remove the mark instead."
1611 (gnus-group-mark-region unmark (point-min) (point-max)))
1613 (defun gnus-group-mark-regexp (regexp)
1614 "Mark all groups that match some regexp."
1615 (interactive "sMark (regexp): ")
1616 (let ((alist (cdr gnus-newsrc-alist))
1619 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1620 (gnus-group-set-mark group))))
1621 (gnus-group-position-point))
1623 (defun gnus-group-remove-mark (group &optional test-marked)
1624 "Remove the process mark from GROUP and move point there.
1625 Return nil if the group isn't displayed."
1626 (if (gnus-group-goto-group group nil test-marked)
1628 (gnus-group-mark-group 1 'unmark t)
1630 (setq gnus-group-marked
1631 (delete group gnus-group-marked))
1634 (defun gnus-group-set-mark (group)
1635 "Set the process mark on GROUP."
1636 (if (gnus-group-goto-group group)
1638 (gnus-group-mark-group 1 nil t))
1639 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1641 (defun gnus-group-universal-argument (arg &optional groups func)
1642 "Perform any command on all groups according to the process/prefix convention."
1644 (if (eq (setq func (or func
1647 (substitute-command-keys
1648 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1650 (gnus-error 1 "Undefined key")
1651 (gnus-group-iterate arg
1653 (command-execute func))))
1654 (gnus-group-position-point))
1656 (defun gnus-group-process-prefix (n)
1657 "Return a list of groups to work on.
1658 Take into consideration N (the prefix) and the list of marked groups."
1661 (setq n (prefix-numeric-value n))
1662 ;; There is a prefix, so we return a list of the N next
1664 (let ((way (if (< n 0) -1 1))
1669 (if (setq group (gnus-group-group-name))
1670 (push group groups))
1672 (gnus-group-next-group way)))
1674 ((gnus-region-active-p)
1675 ;; Work on the region between point and mark.
1676 (let ((max (max (point) (mark)))
1679 (goto-char (min (point) (mark)))
1682 (push (gnus-group-group-name) groups)
1683 (zerop (gnus-group-next-group 1))
1685 (nreverse groups))))
1687 ;; No prefix, but a list of marked articles.
1688 (reverse gnus-group-marked))
1690 ;; Neither marked articles or a prefix, so we return the
1692 (let ((group (gnus-group-group-name)))
1693 (and group (list group))))))
1695 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1696 ;;; imagine why I went through these contortions...
1698 (let ((function (make-symbol "gnus-group-iterate-function"))
1699 (window (make-symbol "gnus-group-iterate-window"))
1700 (groups (make-symbol "gnus-group-iterate-groups"))
1701 (group (make-symbol "gnus-group-iterate-group")))
1703 `(defun gnus-group-iterate (arg ,function)
1704 "Iterate FUNCTION over all process/prefixed groups.
1705 FUNCTION will be called with the group name as the parameter
1706 and with point over the group in question."
1707 (let ((,groups (gnus-group-process-prefix arg))
1708 (,window (selected-window))
1711 (setq ,group (car ,groups)
1712 ,groups (cdr ,groups))
1713 (select-window ,window)
1714 (gnus-group-remove-mark ,group)
1715 (save-selected-window
1717 (funcall ,function ,group)))))))))
1719 (put 'gnus-group-iterate 'lisp-indent-function 1)
1721 ;; Selecting groups.
1723 (defun gnus-group-read-group (&optional all no-article group select-articles)
1724 "Read news in this newsgroup.
1725 If the prefix argument ALL is non-nil, already read articles become
1726 readable. IF ALL is a number, fetch this number of articles. If the
1727 optional argument NO-ARTICLE is non-nil, no article will be
1728 auto-selected upon group entry. If GROUP is non-nil, fetch that
1731 (let ((no-display (eq all 0))
1732 (group (or group (gnus-group-group-name)))
1733 number active marked entry)
1737 (error "No group on current line"))
1738 (setq marked (gnus-info-marks
1739 (nth 2 (setq entry (gnus-gethash
1740 group gnus-newsrc-hashtb)))))
1741 ;; This group might be a dead group. In that case we have to get
1742 ;; the number of unread articles from `gnus-active-hashtb'.
1744 (cond ((numberp all) all)
1746 ((setq active (gnus-active group))
1747 (- (1+ (cdr active)) (car active)))))
1748 (gnus-summary-read-group
1749 group (or all (and (numberp number)
1750 (zerop (+ number (gnus-range-length
1751 (cdr (assq 'tick marked)))
1753 (cdr (assq 'dormant marked)))))))
1754 no-article nil no-display nil select-articles)))
1756 (defun gnus-group-select-group (&optional all)
1757 "Select this newsgroup.
1758 No article is selected automatically.
1759 If ALL is non-nil, already read articles become readable.
1760 If ALL is a number, fetch this number of articles."
1762 (gnus-group-read-group all t))
1764 (defun gnus-group-quick-select-group (&optional all)
1765 "Select the current group \"quickly\".
1766 This means that no highlighting or scoring will be performed.
1767 If ALL (the prefix argument) is 0, don't even generate the summary
1770 This might be useful if you want to toggle threading
1771 before entering the group."
1773 (require 'gnus-score)
1775 gnus-score-find-score-files-function
1776 gnus-home-score-file
1777 gnus-apply-kill-hook
1778 gnus-summary-expunge-below)
1779 (gnus-group-read-group all t)))
1781 (defun gnus-group-visible-select-group (&optional all)
1782 "Select the current group without hiding any articles."
1784 (let ((gnus-inhibit-limiting t))
1785 (gnus-group-read-group all t)))
1787 (defun gnus-group-select-group-ephemerally ()
1788 "Select the current group without doing any processing whatsoever.
1789 You will actually be entered into a group that's a copy of
1790 the current group; no changes you make while in this group will
1793 (require 'gnus-score)
1795 gnus-score-find-score-files-function gnus-apply-kill-hook
1796 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1797 gnus-summary-mode-hook gnus-select-group-hook
1798 (group (gnus-group-group-name))
1799 (method (gnus-find-method-for-group group)))
1800 (gnus-group-read-ephemeral-group
1801 (gnus-group-prefixed-name group method) method)))
1804 (defun gnus-fetch-group (group)
1805 "Start Gnus if necessary and enter GROUP.
1806 Returns whether the fetching was successful or not."
1807 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1808 (unless (get-buffer gnus-group-buffer)
1810 (gnus-group-read-group nil nil group))
1813 (defun gnus-fetch-group-other-frame (group)
1814 "Pop up a frame and enter GROUP."
1816 (let ((window (get-buffer-window gnus-group-buffer)))
1818 (select-frame (window-frame window)))
1819 ((= (length (frame-list)) 1)
1820 (select-frame (make-frame)))
1823 (gnus-fetch-group group))
1825 (defvar gnus-ephemeral-group-server 0)
1827 ;; Enter a group that is not in the group buffer. Non-nil is returned
1828 ;; if selection was successful.
1829 (defun gnus-group-read-ephemeral-group (group method &optional activate
1830 quit-config request-only
1832 "Read GROUP from METHOD as an ephemeral group.
1833 If ACTIVATE, request the group first.
1834 If QUIT-CONFIG, use that window configuration when exiting from the
1836 If REQUEST-ONLY, don't actually read the group; just request it.
1837 If SELECT-ARTICLES, only select those articles.
1839 Return the name of the group if selection was successful."
1840 ;; Transform the select method into a unique server.
1841 (when (stringp method)
1842 (setq method (gnus-server-to-method method)))
1844 `(,(car method) ,(concat (cadr method) "-ephemeral")
1845 (,(intern (format "%s-address" (car method))) ,(cadr method))
1847 (let ((group (if (gnus-group-foreign-p group) group
1848 (gnus-group-prefixed-name group method))))
1852 ,gnus-level-default-subscribed nil nil ,method
1854 ,(if quit-config quit-config
1855 (cons gnus-summary-buffer
1856 gnus-current-window-configuration))))))
1858 (push method gnus-ephemeral-servers)
1859 (set-buffer gnus-group-buffer)
1860 (unless (gnus-check-server method)
1861 (error "Unable to contact server: %s" (gnus-status-message method)))
1863 (gnus-activate-group group 'scan)
1864 (unless (gnus-request-group group)
1865 (error "Couldn't request group: %s"
1866 (nnheader-get-report (car method)))))
1870 (when (gnus-group-read-group t t group select-articles)
1874 (message "Quit reading the ephemeral group")
1877 (defun gnus-group-jump-to-group (group)
1878 "Jump to newsgroup GROUP."
1880 (list (completing-read
1881 "Group: " gnus-active-hashtb nil
1882 (gnus-read-active-file-p)
1883 gnus-group-jump-to-group-prompt
1884 'gnus-group-history)))
1886 (when (equal group "")
1887 (error "Empty group name"))
1889 (unless (gnus-ephemeral-group-p group)
1890 ;; Either go to the line in the group buffer...
1891 (unless (gnus-group-goto-group group)
1892 ;; ... or insert the line.
1893 (gnus-group-update-group group)
1894 (gnus-group-goto-group group)))
1895 ;; Adjust cursor point.
1896 (gnus-group-position-point))
1898 (defun gnus-group-goto-group (group &optional far test-marked)
1899 "Goto to newsgroup GROUP.
1900 If FAR, it is likely that the group is not on the current line.
1901 If TEST-MARKED, the line must be marked."
1905 ;; It's quite likely that we are on the right line, so
1906 ;; we check the current line first.
1908 (eq (get-text-property (point) 'gnus-group)
1909 (gnus-intern-safe group gnus-active-hashtb))
1910 (or (not test-marked) (gnus-group-mark-line-p)))
1912 ;; Previous and next line are also likely, so we check them as well.
1916 (and (eq (get-text-property (point) 'gnus-group)
1917 (gnus-intern-safe group gnus-active-hashtb))
1918 (or (not test-marked) (gnus-group-mark-line-p)))))
1924 (and (eq (get-text-property (point) 'gnus-group)
1925 (gnus-intern-safe group gnus-active-hashtb))
1926 (or (not test-marked) (gnus-group-mark-line-p)))))
1930 (goto-char (point-min))
1932 (while (and (not found)
1937 (gnus-intern-safe group gnus-active-hashtb))))
1938 (if (gnus-group-mark-line-p)
1943 ;; Search through the entire buffer.
1946 (point-min) (point-max)
1947 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
1949 (defun gnus-group-next-group (n &optional silent)
1950 "Go to next N'th newsgroup.
1951 If N is negative, search backward instead.
1952 Returns the difference between N and the number of skips actually
1955 (gnus-group-next-unread-group n t nil silent))
1957 (defun gnus-group-next-unread-group (n &optional all level silent)
1958 "Go to next N'th unread newsgroup.
1959 If N is negative, search backward instead.
1960 If ALL is non-nil, choose any newsgroup, unread or not.
1961 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1962 such group can be found, the next group with a level higher than
1964 Returns the difference between N and the number of skips actually
1967 (let ((backward (< n 0))
1970 (gnus-group-search-forward
1971 backward (or (not gnus-group-goto-unread) all) level))
1975 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1976 (if level " on this level or higher" "")))
1979 (defun gnus-group-prev-group (n)
1980 "Go to previous N'th newsgroup.
1981 Returns the difference between N and the number of skips actually
1984 (gnus-group-next-unread-group (- n) t))
1986 (defun gnus-group-prev-unread-group (n)
1987 "Go to previous N'th unread newsgroup.
1988 Returns the difference between N and the number of skips actually
1991 (gnus-group-next-unread-group (- n)))
1993 (defun gnus-group-next-unread-group-same-level (n)
1994 "Go to next N'th unread newsgroup on the same level.
1995 If N is negative, search backward instead.
1996 Returns the difference between N and the number of skips actually
1999 (gnus-group-next-unread-group n t (gnus-group-group-level))
2000 (gnus-group-position-point))
2002 (defun gnus-group-prev-unread-group-same-level (n)
2003 "Go to next N'th unread newsgroup on the same level.
2004 Returns the difference between N and the number of skips actually
2007 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2008 (gnus-group-position-point))
2010 (defun gnus-group-best-unread-group (&optional exclude-group)
2011 "Go to the group with the highest level.
2012 If EXCLUDE-GROUP, do not go to that group."
2014 (goto-char (point-min))
2018 (setq unread (get-text-property (point) 'gnus-unread))
2019 (when (and (numberp unread) (> unread 0))
2020 (when (and (get-text-property (point) 'gnus-level)
2021 (< (get-text-property (point) 'gnus-level) best)
2022 (or (not exclude-group)
2023 (not (equal exclude-group (gnus-group-group-name)))))
2024 (setq best (get-text-property (point) 'gnus-level))
2025 (setq best-point (point))))
2028 (goto-char best-point))
2029 (gnus-summary-position-point)
2030 (and best-point (gnus-group-group-name))))
2032 (defun gnus-group-first-unread-group ()
2033 "Go to the first group with unread articles."
2036 (let ((opoint (point))
2038 (goto-char (point-min))
2039 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2040 (and (numberp unread) ; Not a topic.
2041 (not (zerop unread))) ; Has unread articles.
2042 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2045 nil)) ; Not success.
2046 (gnus-group-position-point)))
2048 (defun gnus-group-enter-server-mode ()
2049 "Jump to the server buffer."
2051 (gnus-enter-server-buffer))
2053 (defun gnus-group-make-group (name &optional method address args)
2054 "Add a new newsgroup.
2055 The user will be prompted for a NAME, for a select METHOD, and an
2059 (gnus-read-group "Group name: ")
2060 (gnus-read-method "From method: ")))
2062 (when (stringp method)
2063 (setq method (or (gnus-server-to-method method) method)))
2064 (let* ((meth (gnus-method-simplify
2066 (not (gnus-server-equal method gnus-select-method)))
2067 (if address (list (intern method) address)
2069 (nname (if method (gnus-group-prefixed-name name meth) name))
2071 (when (gnus-gethash nname gnus-newsrc-hashtb)
2072 (error "Group %s already exists" nname))
2073 ;; Subscribe to the new group.
2074 (gnus-group-change-level
2075 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2076 gnus-level-default-subscribed gnus-level-killed
2077 (and (gnus-group-group-name)
2078 (gnus-gethash (gnus-group-group-name)
2079 gnus-newsrc-hashtb))
2082 (gnus-set-active nname (cons 1 0))
2083 (unless (gnus-ephemeral-group-p name)
2085 (concat "(gnus-group-set-info '"
2086 (gnus-prin1-to-string (cdr info)) ")")))
2088 (gnus-group-insert-group-line-info nname)
2090 (gnus-group-position-point)
2092 ;; Load the backend and try to make the backend create
2093 ;; the group as well.
2094 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2096 gnus-valid-select-methods)
2098 (gnus-check-server meth)
2099 (when (gnus-check-backend-function 'request-create-group nname)
2100 (gnus-request-create-group nname nil args))
2103 (defun gnus-group-delete-groups (&optional arg)
2104 "Delete the current group. Only meaningful with editable groups."
2106 (let ((n (length (gnus-group-process-prefix arg))))
2107 (when (gnus-yes-or-no-p
2109 "Delete this 1 group? "
2110 (format "Delete these %d groups? " n)))
2111 (gnus-group-iterate arg
2113 (gnus-group-delete-group group nil t))))))
2115 (defun gnus-group-delete-group (group &optional force no-prompt)
2116 "Delete the current group. Only meaningful with editable groups.
2117 If FORCE (the prefix) is non-nil, all the articles in the group will
2118 be deleted. This is \"deleted\" as in \"removed forever from the face
2119 of the Earth\". There is no undo. The user will be prompted before
2120 doing the deletion."
2122 (list (gnus-group-group-name)
2123 current-prefix-arg))
2125 (error "No group to rename"))
2126 (unless (gnus-check-backend-function 'request-delete-group group)
2127 (error "This backend does not support group deletion"))
2129 (if (and (not no-prompt)
2130 (not (gnus-yes-or-no-p
2132 "Do you really want to delete %s%s? "
2133 group (if force " and all its contents" "")))))
2135 (gnus-message 6 "Deleting group %s..." group)
2136 (if (not (gnus-request-delete-group group force))
2137 (gnus-error 3 "Couldn't delete group %s" group)
2138 (gnus-message 6 "Deleting group %s...done" group)
2139 (gnus-group-goto-group group)
2140 (gnus-group-kill-group 1 t)
2141 (gnus-sethash group nil gnus-active-hashtb)
2143 (gnus-group-position-point)))
2145 (defun gnus-group-rename-group (group new-name)
2146 "Rename group from GROUP to NEW-NAME.
2147 When used interactively, GROUP is the group under point
2148 and NEW-NAME will be prompted for."
2151 (gnus-group-group-name)
2153 (unless (gnus-check-backend-function
2154 'request-rename-group (gnus-group-group-name))
2155 (error "This backend does not support renaming groups"))
2156 (gnus-read-group "Rename group to: "
2157 (gnus-group-real-name (gnus-group-group-name))))))
2159 (unless (gnus-check-backend-function 'request-rename-group group)
2160 (error "This backend does not support renaming groups"))
2162 (error "No group to rename"))
2163 (when (equal (gnus-group-real-name group) new-name)
2164 (error "Can't rename to the same name"))
2166 ;; We find the proper prefixed name.
2168 (if (gnus-group-native-p group)
2172 (gnus-group-prefixed-name
2173 (gnus-group-real-name new-name)
2174 (gnus-info-method (gnus-get-info group)))))
2176 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2179 (gnus-group-goto-group group)
2180 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2181 (gnus-request-rename-group group new-name))))
2182 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2183 ;; We rename the group internally by killing it...
2184 (gnus-group-kill-group)
2185 ;; ... changing its name ...
2186 (setcar (cdar gnus-list-of-killed-groups) new-name)
2187 ;; ... and then yanking it. Magic!
2188 (gnus-group-yank-group)
2189 (gnus-set-active new-name (gnus-active group))
2190 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2192 (setq gnus-killed-list (delete group gnus-killed-list))
2193 (gnus-set-active group nil)
2194 (gnus-dribble-touch)
2195 (gnus-group-position-point)))
2197 (defun gnus-group-edit-group (group &optional part)
2198 "Edit the group on the current line."
2199 (interactive (list (gnus-group-group-name)))
2200 (let ((part (or part 'info))
2203 (error "No group on current line"))
2204 (unless (setq info (gnus-get-info group))
2205 (error "Killed group; can't be edited"))
2207 (gnus-close-group group))
2209 ;; Find the proper form to edit.
2210 (cond ((eq part 'method)
2211 (or (gnus-info-method info) "native"))
2213 (gnus-info-params info))
2215 ;; The proper documentation.
2217 "Editing the %s for `%s'."
2219 ((eq part 'method) "select method")
2220 ((eq part 'params) "group parameters")
2222 (gnus-group-decoded-name group))
2224 (gnus-group-edit-group-done ',part ,group form)))))
2226 (defun gnus-group-edit-group-method (group)
2227 "Edit the select method of GROUP."
2228 (interactive (list (gnus-group-group-name)))
2229 (gnus-group-edit-group group 'method))
2231 (defun gnus-group-edit-group-parameters (group)
2232 "Edit the group parameters of GROUP."
2233 (interactive (list (gnus-group-group-name)))
2234 (gnus-group-edit-group group 'params))
2236 (defun gnus-group-edit-group-done (part group form)
2238 (let* ((method (cond ((eq part 'info) (nth 4 form))
2239 ((eq part 'method) form)
2241 (info (cond ((eq part 'info) form)
2242 ((eq part 'method) (gnus-get-info group))
2245 (if (or (not method)
2247 gnus-select-method method))
2248 (gnus-group-real-name (car info))
2249 (gnus-group-prefixed-name
2250 (gnus-group-real-name (car info)) method))
2252 (when (and new-group
2253 (not (equal new-group group)))
2254 (when (gnus-group-goto-group group)
2255 (gnus-group-kill-group 1))
2256 (gnus-activate-group new-group))
2258 (if (not (and info new-group))
2259 (gnus-group-set-info form (or new-group group) part)
2260 (setq info (gnus-copy-sequence info))
2261 (setcar info new-group)
2262 (unless (gnus-server-equal method "native")
2263 (unless (nthcdr 3 info)
2264 (nconc info (list nil nil)))
2265 (unless (nthcdr 4 info)
2266 (nconc info (list nil)))
2267 (gnus-info-set-method info method))
2268 (gnus-group-set-info info))
2269 (gnus-group-update-group (or new-group group))
2270 (gnus-group-position-point)))
2272 (defun gnus-group-make-useful-group (group method)
2273 "Create one of the groups described in `gnus-useful-groups'."
2275 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2277 gnus-useful-groups)))
2278 (list (cadr entry) (caddr entry))))
2279 (setq method (gnus-copy-sequence method))
2281 (while (setq entry (memq (assq 'eval method) method))
2282 (setcar entry (eval (cadar entry)))))
2283 (gnus-group-make-group group method))
2285 (defun gnus-group-make-help-group ()
2286 "Create the Gnus documentation group."
2288 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2289 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2290 (when (gnus-gethash name gnus-newsrc-hashtb)
2291 (error "Documentation group already exists"))
2293 (gnus-message 1 "Couldn't find doc group")
2294 (gnus-group-make-group
2295 (gnus-group-real-name name)
2296 (list 'nndoc "gnus-help"
2297 (list 'nndoc-address file)
2298 (list 'nndoc-article-type 'mbox)))))
2299 (gnus-group-position-point))
2301 (defun gnus-group-make-doc-group (file type)
2302 "Create a group that uses a single file as the source."
2304 (list (read-file-name "File name: ")
2305 (and current-prefix-arg 'ask)))
2306 (when (eq type 'ask)
2311 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2313 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2314 ((= char ?b) 'babyl)
2315 ((= char ?d) 'digest)
2316 ((= char ?f) 'forward)
2318 ((= char ?g) 'guess)
2319 (t (setq err (format "%c unknown. " char))
2322 (let* ((file (expand-file-name file))
2323 (name (gnus-generate-new-group-name
2324 (gnus-group-prefixed-name
2325 (file-name-nondirectory file) '(nndoc "")))))
2326 (gnus-group-make-group
2327 (gnus-group-real-name name)
2329 (list 'nndoc-address file)
2330 (list 'nndoc-article-type (or type 'guess))))))
2332 (defvar nnweb-type-definition)
2333 (defvar gnus-group-web-type-history nil)
2334 (defvar gnus-group-web-search-history nil)
2335 (defun gnus-group-make-web-group (&optional solid)
2336 "Create an ephemeral nnweb group.
2337 If SOLID (the prefix), create a solid group."
2341 (if solid (gnus-read-group "Group name: ")
2342 (message-unique-id)))
2343 (default-type (or (car gnus-group-web-type-history)
2344 (symbol-name (caar nnweb-type-definition))))
2348 (format "Search engine type (default %s): " default-type)
2349 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2350 nnweb-type-definition)
2351 nil t nil 'gnus-group-web-type-history)
2356 (cons (or (car gnus-group-web-search-history) "") 0)
2357 'gnus-group-web-search-history))
2359 `(nnweb ,group (nnweb-search ,search)
2360 (nnweb-type ,(intern type))
2361 (nnweb-ephemeral-p t))))
2363 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2364 (gnus-group-read-ephemeral-group
2366 (cons (current-buffer)
2367 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2369 (defvar nnwarchive-type-definition)
2370 (defvar gnus-group-warchive-type-history nil)
2371 (defvar gnus-group-warchive-login-history nil)
2372 (defvar gnus-group-warchive-address-history nil)
2374 (defun gnus-group-make-warchive-group ()
2375 "Create a nnwarchive group."
2377 (require 'nnwarchive)
2378 (let* ((group (gnus-read-group "Group name: "))
2379 (default-type (or (car gnus-group-warchive-type-history)
2380 (symbol-name (caar nnwarchive-type-definition))))
2384 (format "Warchive type (default %s): " default-type)
2385 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2386 nnwarchive-type-definition)
2387 nil t nil 'gnus-group-warchive-type-history)
2389 (address (read-string "Warchive address: "
2390 nil 'gnus-group-warchive-address-history))
2391 (default-login (or (car gnus-group-warchive-login-history)
2396 (format "Warchive login (default %s): " user-mail-address)
2397 default-login 'gnus-group-warchive-login-history)
2400 `(nnwarchive ,address
2401 (nnwarchive-type ,(intern type))
2402 (nnwarchive-login ,login))))
2403 (gnus-group-make-group group method)))
2405 (defun gnus-group-make-archive-group (&optional all)
2406 "Create the (ding) Gnus archive group of the most recent articles.
2407 Given a prefix, create a full group."
2409 (let ((group (gnus-group-prefixed-name
2410 (if all "ding.archives" "ding.recent") '(nndir ""))))
2411 (when (gnus-gethash group gnus-newsrc-hashtb)
2412 (error "Archive group already exists"))
2413 (gnus-group-make-group
2414 (gnus-group-real-name group)
2415 (list 'nndir (if all "hpc" "edu")
2416 (list 'nndir-directory
2417 (if all gnus-group-archive-directory
2418 gnus-group-recent-archive-directory))))
2419 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2421 (defun gnus-group-make-directory-group (dir)
2422 "Create an nndir group.
2423 The user will be prompted for a directory. The contents of this
2424 directory will be used as a newsgroup. The directory should contain
2425 mail messages or news articles in files that have numeric names."
2427 (list (read-file-name "Create group from directory: ")))
2428 (unless (file-exists-p dir)
2429 (error "No such directory"))
2430 (unless (file-directory-p dir)
2431 (error "Not a directory"))
2435 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2437 (gnus-group-prefixed-name
2438 (expand-file-name ext dir)
2440 (setq ext (format "<%d>" (setq i (1+ i)))))
2441 (gnus-group-make-group
2442 (gnus-group-real-name group)
2443 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2445 (eval-when-compile (defvar nnkiboze-score-file))
2446 (defun gnus-group-make-kiboze-group (group address scores)
2447 "Create an nnkiboze group.
2448 The user will be prompted for a name, a regexp to match groups, and
2449 score file entries for articles to include in the group."
2452 (read-string "nnkiboze group name: ")
2453 (read-string "Source groups (regexp): ")
2454 (let ((headers (mapcar (lambda (group) (list group))
2455 '("subject" "from" "number" "date" "message-id"
2456 "references" "chars" "lines" "xref"
2457 "followup" "all" "body" "head")))
2458 scores header regexp regexps)
2459 (while (not (equal "" (setq header (completing-read
2460 "Match on header: " headers nil t))))
2462 (while (not (equal "" (setq regexp (read-string
2463 (format "Match on %s (regexp): "
2465 (push (list regexp nil nil 'r) regexps))
2466 (push (cons header regexps) scores))
2468 (gnus-group-make-group group "nnkiboze" address)
2469 (let* ((nnkiboze-current-group group)
2470 (score-file (car (nnkiboze-score-file "")))
2471 (score-dir (file-name-directory score-file)))
2472 (unless (file-exists-p score-dir)
2473 (make-directory score-dir))
2474 (with-temp-file score-file
2475 (let (emacs-lisp-mode-hook)
2476 (pp scores (current-buffer))))))
2478 (defun gnus-group-add-to-virtual (n vgroup)
2479 "Add the current group to a virtual group."
2481 (list current-prefix-arg
2482 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2484 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2485 (error "%s is not an nnvirtual group" vgroup))
2486 (gnus-close-group vgroup)
2487 (let* ((groups (gnus-group-process-prefix n))
2488 (method (gnus-info-method (gnus-get-info vgroup))))
2489 (setcar (cdr method)
2491 (nth 1 method) "\\|"
2494 (gnus-group-remove-mark s)
2495 (concat "\\(^" (regexp-quote s) "$\\)"))
2497 (gnus-group-position-point))
2499 (defun gnus-group-make-empty-virtual (group)
2500 "Create a new, fresh, empty virtual group."
2501 (interactive "sCreate new, empty virtual group: ")
2502 (let* ((method (list 'nnvirtual "^$"))
2503 (pgroup (gnus-group-prefixed-name group method)))
2504 ;; Check whether it exists already.
2505 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2506 (error "Group %s already exists" pgroup))
2507 ;; Subscribe the new group after the group on the current line.
2508 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2509 (gnus-group-update-group pgroup)
2511 (gnus-group-position-point)))
2513 (defun gnus-group-enter-directory (dir)
2514 "Enter an ephemeral nneething group."
2515 (interactive "DDirectory to read: ")
2516 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2517 (leaf (gnus-group-prefixed-name
2518 (file-name-nondirectory (directory-file-name dir))
2520 (name (gnus-generate-new-group-name leaf)))
2521 (unless (gnus-group-read-ephemeral-group
2523 (cons (current-buffer)
2524 (if (eq major-mode 'gnus-summary-mode)
2526 (error "Couldn't enter %s" dir))))
2529 (autoload 'nnimap-expunge "nnimap")
2530 (autoload 'nnimap-acl-get "nnimap")
2531 (autoload 'nnimap-acl-edit "nnimap"))
2533 (defun gnus-group-nnimap-expunge (group)
2534 "Expunge deleted articles in current nnimap GROUP."
2535 (interactive (list (gnus-group-group-name)))
2536 (let ((mailbox (gnus-group-real-name group)) method)
2538 (error "No group on current line"))
2539 (unless (gnus-get-info group)
2540 (error "Killed group; can't be edited"))
2541 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2542 (error "%s is not an nnimap group" group))
2543 (nnimap-expunge mailbox (cadr method))))
2545 (defun gnus-group-nnimap-edit-acl (group)
2546 "Edit the Access Control List of current nnimap GROUP."
2547 (interactive (list (gnus-group-group-name)))
2548 (let ((mailbox (gnus-group-real-name group)) method acl)
2550 (error "No group on current line"))
2551 (unless (gnus-get-info group)
2552 (error "Killed group; can't be edited"))
2553 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2554 (error "%s is not an nnimap group" group))
2555 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2556 (error "Server does not support ACL's"))
2557 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2559 An access control list is a list of (identifier . rights) elements.
2561 The identifier string specifies the corresponding user. The
2562 identifier \"anyone\" is reserved to refer to the universal identity.
2564 Rights is a string listing a (possibly empty) set of alphanumeric
2565 characters, each character listing a set of operations which is being
2566 controlled. Letters are reserved for ``standard'' rights, listed
2567 below. Digits are reserved for implementation or site defined rights.
2569 l - lookup (mailbox is visible to LIST/LSUB commands)
2570 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2571 SEARCH, COPY from mailbox)
2572 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2573 w - write (STORE flags other than \\SEEN and \\DELETED)
2574 i - insert (perform APPEND, COPY into mailbox)
2575 p - post (send mail to submission address for mailbox,
2576 not enforced by IMAP4 itself)
2577 c - create and delete mailbox (CREATE new sub-mailboxes in any
2578 implementation-defined hierarchy, RENAME or DELETE mailbox)
2579 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2580 a - administer (perform SETACL)" group)
2583 ,mailbox ',method ',acl form)))))
2585 ;; Group sorting commands
2586 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2588 (defun gnus-group-sort-groups (func &optional reverse)
2589 "Sort the group buffer according to FUNC.
2590 When used interactively, the sorting function used will be
2591 determined by the `gnus-group-sort-function' variable.
2592 If REVERSE (the prefix), reverse the sorting order."
2593 (interactive (list gnus-group-sort-function current-prefix-arg))
2594 (funcall gnus-group-sort-alist-function
2595 (gnus-make-sort-function func) reverse)
2596 (gnus-group-list-groups)
2597 (gnus-dribble-touch))
2599 (defun gnus-group-sort-flat (func reverse)
2600 ;; We peel off the dummy group from the alist.
2602 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2603 (pop gnus-newsrc-alist))
2605 (setq gnus-newsrc-alist
2606 (sort gnus-newsrc-alist func))
2608 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2609 ;; Regenerate the hash table.
2610 (gnus-make-hashtable-from-newsrc-alist)))
2612 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2613 "Sort the group buffer alphabetically by group name.
2614 If REVERSE, sort in reverse order."
2616 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2618 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2619 "Sort the group buffer by number of unread articles.
2620 If REVERSE, sort in reverse order."
2622 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2624 (defun gnus-group-sort-groups-by-level (&optional reverse)
2625 "Sort the group buffer by group level.
2626 If REVERSE, sort in reverse order."
2628 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2630 (defun gnus-group-sort-groups-by-score (&optional reverse)
2631 "Sort the group buffer by group score.
2632 If REVERSE, sort in reverse order."
2634 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2636 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2637 "Sort the group buffer by group rank.
2638 If REVERSE, sort in reverse order."
2640 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2642 (defun gnus-group-sort-groups-by-method (&optional reverse)
2643 "Sort the group buffer alphabetically by backend name.
2644 If REVERSE, sort in reverse order."
2646 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2648 (defun gnus-group-sort-groups-by-server (&optional reverse)
2649 "Sort the group buffer alphabetically by server name.
2650 If REVERSE, sort in reverse order."
2652 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2654 ;;; Selected group sorting.
2656 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2657 "Sort the process/prefixed groups."
2658 (interactive (list current-prefix-arg gnus-group-sort-function))
2659 (let ((groups (gnus-group-process-prefix n)))
2660 (funcall gnus-group-sort-selected-function
2661 groups (gnus-make-sort-function func) reverse)
2662 (gnus-group-list-groups)))
2664 (defun gnus-group-sort-selected-flat (groups func reverse)
2665 (let (entries infos)
2666 ;; First find all the group entries for these groups.
2668 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2670 ;; Then sort the infos.
2674 (lambda (entry) (car entry))
2675 (setq entries (nreverse entries)))
2678 (setq infos (nreverse infos)))
2679 ;; Go through all the infos and replace the old entries
2680 ;; with the new infos.
2682 (setcar (car entries) (pop infos))
2684 ;; Update the hashtable.
2685 (gnus-make-hashtable-from-newsrc-alist)))
2687 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2688 "Sort the group buffer alphabetically by group name.
2689 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2690 sort in reverse order."
2691 (interactive (gnus-interactive "P\ny"))
2692 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2694 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2695 "Sort the group buffer by number of unread articles.
2696 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2697 sort in reverse order."
2698 (interactive (gnus-interactive "P\ny"))
2699 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2701 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2702 "Sort the group buffer by group level.
2703 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2704 sort in reverse order."
2705 (interactive (gnus-interactive "P\ny"))
2706 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2708 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2709 "Sort the group buffer by group score.
2710 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2711 sort in reverse order."
2712 (interactive (gnus-interactive "P\ny"))
2713 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2715 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2716 "Sort the group buffer by group rank.
2717 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2718 sort in reverse order."
2719 (interactive (gnus-interactive "P\ny"))
2720 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2722 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2723 "Sort the group buffer alphabetically by backend name.
2724 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2725 sort in reverse order."
2726 (interactive (gnus-interactive "P\ny"))
2727 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2729 ;;; Sorting predicates.
2731 (defun gnus-group-sort-by-alphabet (info1 info2)
2732 "Sort alphabetically."
2733 (string< (gnus-info-group info1) (gnus-info-group info2)))
2735 (defun gnus-group-sort-by-real-name (info1 info2)
2736 "Sort alphabetically on real (unprefixed) names."
2737 (string< (gnus-group-real-name (gnus-info-group info1))
2738 (gnus-group-real-name (gnus-info-group info2))))
2740 (defun gnus-group-sort-by-unread (info1 info2)
2741 "Sort by number of unread articles."
2742 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2743 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2744 (< (or (and (numberp n1) n1) 0)
2745 (or (and (numberp n2) n2) 0))))
2747 (defun gnus-group-sort-by-level (info1 info2)
2749 (< (gnus-info-level info1) (gnus-info-level info2)))
2751 (defun gnus-group-sort-by-method (info1 info2)
2752 "Sort alphabetically by backend name."
2753 (string< (symbol-name (car (gnus-find-method-for-group
2754 (gnus-info-group info1) info1)))
2755 (symbol-name (car (gnus-find-method-for-group
2756 (gnus-info-group info2) info2)))))
2758 (defun gnus-group-sort-by-server (info1 info2)
2759 "Sort alphabetically by server name."
2760 (string< (gnus-method-to-server-name
2761 (gnus-find-method-for-group
2762 (gnus-info-group info1) info1))
2763 (gnus-method-to-server-name
2764 (gnus-find-method-for-group
2765 (gnus-info-group info2) info2))))
2767 (defun gnus-group-sort-by-score (info1 info2)
2768 "Sort by group score."
2769 (< (gnus-info-score info1) (gnus-info-score info2)))
2771 (defun gnus-group-sort-by-rank (info1 info2)
2772 "Sort by level and score."
2773 (let ((level1 (gnus-info-level info1))
2774 (level2 (gnus-info-level info2)))
2775 (or (< level1 level2)
2776 (and (= level1 level2)
2777 (> (gnus-info-score info1) (gnus-info-score info2))))))
2781 (defun gnus-group-clear-data (&optional arg)
2782 "Clear all marks and read ranges from the current group."
2784 (gnus-group-iterate arg
2787 (gnus-info-clear-data (setq info (gnus-get-info group)))
2788 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2789 (when (gnus-group-goto-group group)
2790 (gnus-group-update-group-line))))))
2792 (defun gnus-group-clear-data-on-native-groups ()
2793 "Clear all marks and read ranges from all native groups."
2795 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2796 (let ((alist (cdr gnus-newsrc-alist))
2798 (while (setq info (pop alist))
2799 (when (gnus-group-native-p (gnus-info-group info))
2800 (gnus-info-clear-data info)))
2801 (gnus-get-unread-articles)
2802 (gnus-dribble-touch)
2803 (when (gnus-y-or-n-p
2804 "Move the cache away to avoid problems in the future? ")
2805 (call-interactively 'gnus-cache-move-cache)))))
2807 (defun gnus-info-clear-data (info)
2808 "Clear all marks and read ranges from INFO."
2809 (let ((group (gnus-info-group info)))
2812 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2813 (gnus-info-set-read ',info ',(gnus-info-read info))
2814 (when (gnus-group-goto-group ,group)
2815 (gnus-group-update-group-line))))
2816 (gnus-info-set-read info nil)
2817 (when (gnus-info-marks info)
2818 (gnus-info-set-marks info nil))))
2820 ;; Group catching up.
2822 (defun gnus-group-catchup-current (&optional n all)
2823 "Mark all unread articles in the current newsgroup as read.
2824 If prefix argument N is numeric, the next N newsgroups will be
2825 caught up. If ALL is non-nil, marked articles will also be marked as
2826 read. Cross references (Xref: header) of articles are ignored.
2827 The number of newsgroups that this function was unable to catch
2830 (let ((groups (gnus-group-process-prefix n))
2833 (unless groups (error "No groups selected"))
2835 (or (not gnus-interactive-catchup) ;Without confirmation?
2840 "Do you really want to mark all articles in %s as read? "
2841 "Mark all unread articles in %s as read? ")
2842 (if (= (length groups) 1)
2844 (format "these %d groups" (length groups)))))))
2846 (while (setq group (pop groups))
2847 (gnus-group-remove-mark group)
2848 ;; Virtual groups have to be given special treatment.
2849 (let ((method (gnus-find-method-for-group group)))
2850 (when (eq 'nnvirtual (car method))
2851 (nnvirtual-catchup-group
2852 (gnus-group-real-name group) (nth 1 method) all)))
2853 (if (>= (gnus-group-level group) gnus-level-zombie)
2854 (gnus-message 2 "Dead groups can't be caught up")
2856 (gnus-group-goto-group group)
2857 (gnus-group-catchup group all))
2858 (gnus-group-update-group-line)
2859 (setq ret (1+ ret)))))
2860 (gnus-group-next-unread-group 1)
2863 (defun gnus-group-catchup-current-all (&optional n)
2864 "Mark all articles in current newsgroup as read.
2865 Cross references (Xref: header) of articles are ignored."
2867 (gnus-group-catchup-current n 'all))
2869 (defun gnus-group-catchup (group &optional all)
2870 "Mark all articles in GROUP as read.
2871 If ALL is non-nil, all articles are marked as read.
2872 The return value is the number of articles that were marked as read,
2873 or nil if no action could be taken."
2874 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2876 ;; Remove entries for this group.
2877 (nnmail-purge-split-history (gnus-group-real-name group))
2878 ;; Do the updating only if the newsgroup isn't killed.
2879 (if (not (numberp (car entry)))
2880 (gnus-message 1 "Can't catch up %s; non-active group" group)
2881 ;; Do auto-expirable marks if that's required.
2882 (when (gnus-group-auto-expirable-p group)
2883 (gnus-add-marked-articles
2884 group 'expire (gnus-list-of-unread-articles group))
2886 (let ((marks (nth 3 (nth 2 entry))))
2887 (gnus-add-marked-articles
2888 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2889 (gnus-add-marked-articles
2890 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2892 (gnus-update-read-articles group nil)
2893 ;; Also nix out the lists of marks and dormants.
2895 (gnus-add-marked-articles group 'tick nil nil 'force)
2896 (gnus-add-marked-articles group 'dormant nil nil 'force))
2897 (let ((gnus-newsgroup-name group))
2898 (gnus-run-hooks 'gnus-group-catchup-group-hook))
2901 (defun gnus-group-expire-articles (&optional n)
2902 "Expire all expirable articles in the current newsgroup."
2904 (let ((groups (gnus-group-process-prefix n))
2907 (error "No groups to expire"))
2908 (while (setq group (pop groups))
2909 (gnus-group-remove-mark group)
2910 (gnus-group-expire-articles-1 group)
2911 (gnus-dribble-touch)
2912 (gnus-group-position-point))))
2914 (defun gnus-group-expire-articles-1 (group)
2915 (when (gnus-check-backend-function 'request-expire-articles group)
2916 (gnus-message 6 "Expiring articles in %s..." group)
2917 (let* ((info (gnus-get-info group))
2918 (expirable (if (gnus-group-total-expirable-p group)
2919 (cons nil (gnus-list-of-read-articles group))
2920 (assq 'expire (gnus-info-marks info))))
2921 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
2922 (nnmail-expiry-target
2923 (or (gnus-group-find-parameter group 'expiry-target)
2924 nnmail-expiry-target)))
2926 (gnus-check-group group)
2929 (gnus-compress-sequence
2931 ;; We set the expiry variables to the group
2933 (let ((nnmail-expiry-wait-function nil)
2934 (nnmail-expiry-wait expiry-wait))
2935 (gnus-request-expire-articles
2936 (gnus-uncompress-sequence (cdr expirable)) group))
2937 ;; Just expire using the normal expiry values.
2938 (gnus-request-expire-articles
2939 (gnus-uncompress-sequence (cdr expirable)) group))))
2940 (gnus-close-group group))
2941 (gnus-message 6 "Expiring articles in %s...done" group)
2942 ;; Return the list of un-expired articles.
2945 (defun gnus-group-expire-all-groups ()
2946 "Expire all expirable articles in all newsgroups."
2949 (gnus-message 5 "Expiring...")
2950 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2951 (cdr gnus-newsrc-alist))))
2952 (gnus-group-expire-articles nil)))
2953 (gnus-group-position-point)
2954 (gnus-message 5 "Expiring...done"))
2956 (defun gnus-group-set-current-level (n level)
2957 "Set the level of the next N groups to LEVEL."
2962 (let ((s (read-string
2963 (format "Level (default %s): "
2964 (or (gnus-group-group-level)
2965 gnus-level-default-subscribed)))))
2966 (if (string-match "^\\s-*$" s)
2967 (int-to-string (or (gnus-group-group-level)
2968 gnus-level-default-subscribed))
2970 (unless (and (>= level 1) (<= level gnus-level-killed))
2971 (error "Invalid level: %d" level))
2972 (let ((groups (gnus-group-process-prefix n))
2974 (while (setq group (pop groups))
2975 (gnus-group-remove-mark group)
2976 (gnus-message 6 "Changed level of %s from %d to %d"
2977 group (or (gnus-group-group-level) gnus-level-killed)
2979 (gnus-group-change-level
2980 group level (or (gnus-group-group-level) gnus-level-killed))
2981 (gnus-group-update-group-line)))
2982 (gnus-group-position-point))
2984 (defun gnus-group-unsubscribe (&optional n)
2985 "Unsubscribe the current group."
2987 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2989 (defun gnus-group-subscribe (&optional n)
2990 "Subscribe the current group."
2992 (gnus-group-unsubscribe-current-group n 'subscribe))
2994 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2995 "Toggle subscription of the current group.
2996 If given numerical prefix, toggle the N next groups."
2998 (let ((groups (gnus-group-process-prefix n))
3001 (setq group (car groups)
3002 groups (cdr groups))
3003 (gnus-group-remove-mark group)
3004 (gnus-group-unsubscribe-group
3007 ((eq do-sub 'unsubscribe)
3008 gnus-level-default-unsubscribed)
3009 ((eq do-sub 'subscribe)
3010 gnus-level-default-subscribed)
3011 ((<= (gnus-group-group-level) gnus-level-subscribed)
3012 gnus-level-default-unsubscribed)
3014 gnus-level-default-subscribed))
3016 (gnus-group-update-group-line))
3017 (gnus-group-next-group 1)))
3019 (defun gnus-group-unsubscribe-group (group &optional level silent)
3020 "Toggle subscription to GROUP.
3021 Killed newsgroups are subscribed. If SILENT, don't try to update the
3024 (list (completing-read
3025 "Group: " gnus-active-hashtb nil
3026 (gnus-read-active-file-p)
3028 'gnus-group-history)))
3029 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3031 ((string-match "^[ \t]*$" group)
3032 (error "Empty group name"))
3034 ;; Toggle subscription flag.
3035 (gnus-group-change-level
3036 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3037 gnus-level-subscribed)
3038 (1+ gnus-level-subscribed)
3039 gnus-level-default-subscribed)))
3041 (gnus-group-update-group group)))
3042 ((and (stringp group)
3043 (or (not (gnus-read-active-file-p))
3044 (gnus-active group)))
3045 ;; Add new newsgroup.
3046 (gnus-group-change-level
3048 (if level level gnus-level-default-subscribed)
3049 (or (and (member group gnus-zombie-list)
3052 (when (gnus-group-group-name)
3053 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3055 (gnus-group-update-group group)))
3056 (t (error "No such newsgroup: %s" group)))
3057 (gnus-group-position-point)))
3059 (defun gnus-group-transpose-groups (n)
3060 "Move the current newsgroup up N places.
3061 If given a negative prefix, move down instead. The difference between
3062 N and the number of steps taken is returned."
3064 (unless (gnus-group-group-name)
3065 (error "No group on current line"))
3066 (gnus-group-kill-group 1)
3068 (forward-line (- n))
3069 (gnus-group-yank-group)
3070 (gnus-group-position-point)))
3072 (defun gnus-group-kill-all-zombies (&optional dummy)
3073 "Kill all zombie newsgroups.
3074 The optional DUMMY should always be nil."
3075 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3077 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3078 (setq gnus-zombie-list nil)
3079 (gnus-dribble-touch)
3080 (gnus-group-list-groups)))
3082 (defun gnus-group-kill-region (begin end)
3083 "Kill newsgroups in current region (excluding current point).
3084 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3099 (beginning-of-line) ;Important when LINES < 1
3100 (gnus-group-kill-group lines)))
3102 (defun gnus-group-kill-group (&optional n discard)
3103 "Kill the next N groups.
3104 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3105 However, only groups that were alive can be yanked; already killed
3106 groups or zombie groups can't be yanked.
3107 The return value is the name of the group that was killed, or a list
3110 (let ((buffer-read-only nil)
3111 (groups (gnus-group-process-prefix n))
3112 group entry level out)
3113 (if (< (length groups) 10)
3114 ;; This is faster when there are few groups.
3116 (push (setq group (pop groups)) out)
3117 (gnus-group-remove-mark group)
3118 (setq level (gnus-group-group-level))
3120 (when (and (not discard)
3121 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3124 (gnus-group-goto-group ,(gnus-group-group-name))
3125 (gnus-group-yank-group)))
3126 (push (cons (car entry) (nth 2 entry))
3127 gnus-list-of-killed-groups))
3128 (gnus-group-change-level
3129 (if entry entry group) gnus-level-killed (if entry nil level))
3130 (message "Killed group %s" group))
3131 ;; If there are lots and lots of groups to be killed, we use
3132 ;; this thing instead.
3134 (setq groups (nreverse groups))
3136 (gnus-group-remove-mark (setq group (pop groups)))
3138 (push group gnus-killed-list)
3139 (setq gnus-newsrc-alist
3140 (delq (assoc group gnus-newsrc-alist)
3142 (when gnus-group-change-level-function
3143 (funcall gnus-group-change-level-function
3144 group gnus-level-killed 3))
3146 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3147 (push (cons (car entry) (nth 2 entry))
3148 gnus-list-of-killed-groups)
3149 (setcdr (cdr entry) (cdddr entry)))
3150 ((member group gnus-zombie-list)
3151 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3152 ;; There may be more than one instance displayed.
3153 (while (gnus-group-goto-group group)
3154 (gnus-delete-line)))
3155 (gnus-make-hashtable-from-newsrc-alist)))
3157 (gnus-group-position-point)
3158 (if (< (length out) 2) (car out) (nreverse out))))
3160 (defun gnus-group-yank-group (&optional arg)
3161 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3162 The numeric ARG specifies how many newsgroups are to be yanked. The
3163 name of the newsgroup yanked is returned, or (if several groups are
3164 yanked) a list of yanked groups is returned."
3166 (setq arg (or arg 1))
3167 (let (info group prev out)
3168 (while (>= (decf arg) 0)
3169 (when (not (setq info (pop gnus-list-of-killed-groups)))
3170 (error "No more newsgroups to yank"))
3171 (push (setq group (nth 1 info)) out)
3172 ;; Find which newsgroup to insert this one before - search
3173 ;; backward until something suitable is found. If there are no
3174 ;; other newsgroups in this buffer, just make this newsgroup the
3176 (setq prev (gnus-group-group-name))
3177 (gnus-group-change-level
3178 info (gnus-info-level (cdr info)) gnus-level-killed
3179 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3181 (gnus-group-insert-group-line-info group)
3183 `(when (gnus-group-goto-group ,group)
3184 (gnus-group-kill-group 1))))
3186 (gnus-group-position-point)
3187 (if (< (length out) 2) (car out) (nreverse out))))
3189 (defun gnus-group-kill-level (level)
3190 "Kill all groups that is on a certain LEVEL."
3191 (interactive "nKill all groups on level: ")
3193 ((= level gnus-level-zombie)
3194 (setq gnus-killed-list
3195 (nconc gnus-zombie-list gnus-killed-list))
3196 (setq gnus-zombie-list nil))
3197 ((and (< level gnus-level-zombie)
3199 (or gnus-expert-user
3202 "Do you really want to kill all groups on level %d? "
3204 (let* ((prev gnus-newsrc-alist)
3207 (if (= (gnus-info-level (car alist)) level)
3209 (push (gnus-info-group (car alist)) gnus-killed-list)
3210 (setcdr prev (cdr alist)))
3212 (setq alist (cdr alist)))
3213 (gnus-make-hashtable-from-newsrc-alist)
3214 (gnus-group-list-groups)))
3216 (error "Can't kill; invalid level: %d" level))))
3218 (defun gnus-group-list-all-groups (&optional arg)
3219 "List all newsgroups with level ARG or lower.
3220 Default is gnus-level-unsubscribed, which lists all subscribed and most
3221 unsubscribed groups."
3223 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3225 ;; Redefine this to list ALL killed groups if prefix arg used.
3226 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3227 (defun gnus-group-list-killed (&optional arg)
3228 "List all killed newsgroups in the group buffer.
3229 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3230 entail asking the server for the groups."
3232 ;; Find all possible killed newsgroups if arg.
3234 (gnus-get-killed-groups))
3235 (if (not gnus-killed-list)
3236 (gnus-message 6 "No killed groups")
3237 (let (gnus-group-list-mode)
3238 (funcall gnus-group-prepare-function
3239 gnus-level-killed t gnus-level-killed))
3240 (goto-char (point-min)))
3241 (gnus-group-position-point))
3243 (defun gnus-group-list-zombies ()
3244 "List all zombie newsgroups in the group buffer."
3246 (if (not gnus-zombie-list)
3247 (gnus-message 6 "No zombie groups")
3248 (let (gnus-group-list-mode)
3249 (funcall gnus-group-prepare-function
3250 gnus-level-zombie t gnus-level-zombie))
3251 (goto-char (point-min)))
3252 (gnus-group-position-point))
3254 (defun gnus-group-list-active ()
3255 "List all groups that are available from the server(s)."
3257 ;; First we make sure that we have really read the active file.
3258 (unless (gnus-read-active-file-p)
3259 (let ((gnus-read-active-file t)
3260 (gnus-agent nil)) ; Trick the agent into ignoring the active file.
3261 (gnus-read-active-file)))
3262 ;; Find all groups and sort them.
3270 (push (symbol-name sym) list)))
3274 (buffer-read-only nil)
3278 (setq group (pop groups))
3279 (gnus-add-text-properties
3280 (point) (prog1 (1+ (point))
3282 (gnus-group-name-decode group
3283 (gnus-group-name-charset
3286 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3288 'gnus-level (inline (gnus-group-level group)))))
3289 (goto-char (point-min))))
3291 (defun gnus-activate-all-groups (level)
3292 "Activate absolutely all groups."
3293 (interactive (list gnus-level-unsubscribed))
3294 (let ((gnus-activate-level level)
3295 (gnus-activate-foreign-newsgroups level))
3296 (gnus-group-get-new-news)))
3298 (defun gnus-group-get-new-news (&optional arg)
3299 "Get newly arrived articles.
3300 If ARG is a number, it specifies which levels you are interested in
3301 re-scanning. If ARG is non-nil and not a number, this will force
3302 \"hard\" re-reading of the active files from all servers."
3305 (let ((gnus-inhibit-demon t)
3306 ;; Binding this variable will inhibit multiple fetchings
3307 ;; of the same mail source.
3308 (nnmail-fetched-sources (list t)))
3309 (gnus-run-hooks 'gnus-get-new-news-hook)
3311 ;; Read any slave files.
3313 (gnus-master-read-slave-newsrc))
3315 ;; We might read in new NoCeM messages here.
3316 (when (and gnus-use-nocem
3318 (gnus-nocem-scan-groups))
3319 ;; If ARG is not a number, then we read the active file.
3320 (when (and arg (not (numberp arg)))
3321 (let ((gnus-read-active-file t))
3322 (gnus-read-active-file))
3325 ;; If the user wants it, we scan for new groups.
3326 (when (eq gnus-check-new-newsgroups 'always)
3327 (gnus-find-new-newsgroups)))
3329 (setq arg (gnus-group-default-level arg t))
3330 (if (and gnus-read-active-file (not arg))
3332 (gnus-read-active-file)
3333 (gnus-get-unread-articles arg))
3334 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3335 (gnus-get-unread-articles arg)))
3336 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3337 (gnus-group-list-groups (and (numberp arg)
3338 (max (car gnus-group-list-mode) arg)))))
3340 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3341 "Check for newly arrived news in the current group (and the N-1 next groups).
3342 The difference between N and the number of newsgroup checked is returned.
3343 If N is negative, this group and the N-1 previous groups will be checked."
3345 (let* ((groups (gnus-group-process-prefix n))
3346 (ret (if (numberp n) (- n (length groups)) 0))
3350 (gnus-inhibit-demon t)
3351 ;; Binding this variable will inhibit multiple fetchings
3352 ;; of the same mail source.
3353 (nnmail-fetched-sources (list t)))
3354 (gnus-run-hooks 'gnus-get-new-news-hook)
3355 (while (setq group (pop groups))
3356 (gnus-group-remove-mark group)
3357 ;; Bypass any previous denials from the server.
3358 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3359 (if (gnus-activate-group group (if dont-scan nil 'scan))
3361 (gnus-get-unread-articles-in-group
3362 (gnus-get-info group) (gnus-active group) t)
3363 (unless (gnus-virtual-group-p group)
3364 (gnus-close-group group))
3366 (gnus-agent-save-group-info
3367 method (gnus-group-real-name group) (gnus-active group)))
3368 (gnus-group-update-group group))
3369 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3371 (gnus-error 3 "Server denied access")
3372 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3375 (when gnus-goto-next-group-when-activating
3376 (gnus-group-next-unread-group 1 t))
3377 (gnus-summary-position-point)
3380 (defun gnus-group-fetch-faq (group &optional faq-dir)
3381 "Fetch the FAQ for the current group.
3382 If given a prefix argument, prompt for the FAQ dir
3386 (gnus-group-group-name)
3387 (when current-prefix-arg
3389 "Faq dir: " (and (listp gnus-group-faq-directory)
3391 gnus-group-faq-directory))))))
3393 (error "No group name given"))
3394 (let ((dirs (or faq-dir gnus-group-faq-directory))
3396 (unless (listp dirs)
3397 (setq dirs (list dirs)))
3398 (while (and (not found)
3399 (setq dir (pop dirs)))
3400 (let ((name (gnus-group-real-name group)))
3401 (setq file (expand-file-name name dir)))
3402 (if (not (file-exists-p file))
3403 (gnus-message 1 "No such file: %s" file)
3404 (let ((enable-local-variables nil))
3408 (defun gnus-group-describe-group (force &optional group)
3409 "Display a description of the current newsgroup."
3410 (interactive (list current-prefix-arg (gnus-group-group-name)))
3411 (let* ((method (gnus-find-method-for-group group))
3412 (mname (gnus-group-prefixed-name "" method))
3415 gnus-description-hashtb)
3416 (gnus-sethash mname nil gnus-description-hashtb))
3418 (error "No group name given"))
3419 (when (or (and gnus-description-hashtb
3420 ;; We check whether this group's method has been
3421 ;; queried for a description file.
3422 (gnus-gethash mname gnus-description-hashtb))
3423 (setq desc (gnus-group-get-description group))
3424 (gnus-read-descriptions-file method))
3426 (or desc (gnus-gethash group gnus-description-hashtb)
3427 "No description available")))))
3429 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3430 (defun gnus-group-describe-all-groups (&optional force)
3431 "Pop up a buffer with descriptions of all newsgroups."
3434 (setq gnus-description-hashtb nil))
3435 (when (not (or gnus-description-hashtb
3436 (gnus-read-all-descriptions-files)))
3437 (error "Couldn't request descriptions file"))
3438 (let ((buffer-read-only nil)
3444 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3445 (insert (format " *: %-20s %s\n"
3446 (gnus-group-name-decode
3447 (symbol-name group) charset)
3448 (gnus-group-name-decode
3449 (symbol-value group) charset))))
3450 (gnus-add-text-properties
3451 b (1+ b) (list 'gnus-group group
3452 'gnus-unread t 'gnus-marked nil
3453 'gnus-level (1+ gnus-level-subscribed))))
3454 gnus-description-hashtb)
3455 (goto-char (point-min))
3456 (gnus-group-position-point)))
3458 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3459 (defun gnus-group-apropos (regexp &optional search-description)
3460 "List all newsgroups that have names that match a regexp."
3461 (interactive "sGnus apropos (regexp): ")
3463 (obuf (current-buffer))
3465 ;; Go through all newsgroups that are known to Gnus.
3468 (and (symbol-name group)
3469 (string-match regexp (symbol-name group))
3470 (symbol-value group)
3471 (push (symbol-name group) groups)))
3473 ;; Also go through all descriptions that are known to Gnus.
3474 (when search-description
3477 (and (string-match regexp (symbol-value group))
3478 (push (symbol-name group) groups)))
3479 gnus-description-hashtb))
3481 (gnus-message 3 "No groups matched \"%s\"." regexp)
3482 ;; Print out all the groups.
3484 (pop-to-buffer "*Gnus Help*")
3485 (buffer-disable-undo)
3487 (setq groups (sort groups 'string<))
3489 ;; Groups may be entered twice into the list of groups.
3490 (when (not (string= (car groups) prev))
3491 (setq prev (car groups))
3492 (let ((charset (gnus-group-name-charset nil prev)))
3493 (insert (gnus-group-name-decode prev charset) "\n")
3494 (when (and gnus-description-hashtb
3495 (setq des (gnus-gethash (car groups)
3496 gnus-description-hashtb)))
3497 (insert " " (gnus-group-name-decode des charset) "\n"))))
3498 (setq groups (cdr groups)))
3499 (goto-char (point-min))))
3500 (pop-to-buffer obuf)))
3502 (defun gnus-group-description-apropos (regexp)
3503 "List all newsgroups that have names or descriptions that match a regexp."
3504 (interactive "sGnus description apropos (regexp): ")
3505 (when (not (or gnus-description-hashtb
3506 (gnus-read-all-descriptions-files)))
3507 (error "Couldn't request descriptions file"))
3508 (gnus-group-apropos regexp t))
3510 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3511 (defun gnus-group-list-matching (level regexp &optional all lowest)
3512 "List all groups with unread articles that match REGEXP.
3513 If the prefix LEVEL is non-nil, it should be a number that says which
3514 level to cut off listing groups.
3515 If ALL, also list groups with no unread articles.
3516 If LOWEST, don't list groups with level lower than LOWEST.
3518 This command may read the active file."
3519 (interactive "P\nsList newsgroups matching: ")
3520 ;; First make sure active file has been read.
3522 (> (prefix-numeric-value level) gnus-level-killed))
3523 (gnus-get-killed-groups))
3524 (funcall gnus-group-prepare-function
3525 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3526 (goto-char (point-min))
3527 (gnus-group-position-point))
3529 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3530 "List all groups that match REGEXP.
3531 If the prefix LEVEL is non-nil, it should be a number that says which
3532 level to cut off listing groups.
3533 If LOWEST, don't list groups with level lower than LOWEST."
3534 (interactive "P\nsList newsgroups matching: ")
3536 (setq level (prefix-numeric-value level)))
3537 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3539 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3540 (defun gnus-group-save-newsrc (&optional force)
3541 "Save the Gnus startup files.
3542 If FORCE, force saving whether it is necessary or not."
3544 (gnus-save-newsrc-file force))
3546 (defun gnus-group-restart (&optional arg)
3547 "Force Gnus to read the .newsrc file."
3549 (when (gnus-yes-or-no-p
3550 (format "Are you sure you want to restart Gnus? "))
3551 (gnus-save-newsrc-file)
3555 (defun gnus-group-read-init-file ()
3556 "Read the Gnus elisp init file."
3558 (gnus-read-init-file)
3559 (gnus-message 5 "Read %s" gnus-init-file))
3561 (defun gnus-group-check-bogus-groups (&optional silent)
3562 "Check bogus newsgroups.
3563 If given a prefix, don't ask for confirmation before removing a bogus
3566 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3567 (gnus-group-list-groups))
3569 (defun gnus-group-find-new-groups (&optional arg)
3570 "Search for new groups and add them.
3571 Each new group will be treated with `gnus-subscribe-newsgroup-method.'
3572 With 1 C-u, use the `ask-server' method to query the server for new
3574 With 2 C-u's, use most complete method possible to query the server
3575 for new groups, and subscribe the new groups as zombies."
3577 (gnus-find-new-newsgroups (or arg 1))
3578 (gnus-group-list-groups))
3580 (defun gnus-group-edit-global-kill (&optional article group)
3581 "Edit the global kill file.
3582 If GROUP, edit that local kill file instead."
3584 (setq gnus-current-kill-article article)
3585 (gnus-kill-file-edit-file group)
3588 (substitute-command-keys
3589 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3590 (if group "local" "global")))))
3592 (defun gnus-group-edit-local-kill (article group)
3593 "Edit a local kill file."
3594 (interactive (list nil (gnus-group-group-name)))
3595 (gnus-group-edit-global-kill article group))
3597 (defun gnus-group-force-update ()
3598 "Update `.newsrc' file."
3600 (gnus-save-newsrc-file))
3602 (defun gnus-group-suspend ()
3603 "Suspend the current Gnus session.
3604 In fact, cleanup buffers except for group mode buffer.
3605 The hook gnus-suspend-gnus-hook is called before actually suspending."
3607 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3608 ;; Kill Gnus buffers except for group mode buffer.
3609 (let ((group-buf (get-buffer gnus-group-buffer)))
3610 (mapcar (lambda (buf)
3611 (unless (member buf (list group-buf gnus-dribble-buffer))
3614 (gnus-kill-gnus-frames)
3616 (bury-buffer group-buf)
3617 (delete-windows-on group-buf t))))
3619 (defun gnus-group-clear-dribble ()
3620 "Clear all information from the dribble buffer."
3622 (gnus-dribble-clear)
3623 (gnus-message 7 "Cleared dribble buffer"))
3625 (defun gnus-group-exit ()
3626 "Quit reading news after updating .newsrc.eld and .newsrc.
3627 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3630 (or noninteractive ;For gnus-batch-kill
3631 (not gnus-interactive-exit) ;Without confirmation
3633 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3634 (gnus-run-hooks 'gnus-exit-gnus-hook)
3635 ;; Offer to save data from non-quitted summary buffers.
3636 (gnus-offer-save-summaries)
3637 ;; Save the newsrc file(s).
3638 (gnus-save-newsrc-file)
3640 (gnus-close-backends)
3641 ;; Reset everything.
3643 ;; Allow the user to do things after cleaning up.
3644 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3646 (defun gnus-group-quit ()
3647 "Quit reading news without updating .newsrc.eld or .newsrc.
3648 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3650 (when (or noninteractive ;For gnus-batch-kill
3651 (zerop (buffer-size))
3652 (not (gnus-server-opened gnus-select-method))
3654 (not gnus-current-startup-file)
3656 (format "Quit reading news without saving %s? "
3657 (file-name-nondirectory gnus-current-startup-file))))
3658 (gnus-run-hooks 'gnus-exit-gnus-hook)
3659 (gnus-configure-windows 'group t)
3661 (gnus-close-backends)
3663 (gnus-kill-buffer gnus-group-buffer)
3664 ;; Allow the user to do things after cleaning up.
3665 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3667 (defun gnus-group-describe-briefly ()
3668 "Give a one line description of the group mode commands."
3670 (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")))
3672 (defun gnus-group-browse-foreign-server (method)
3673 "Browse a foreign news server.
3674 If called interactively, this function will ask for a select method
3675 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3676 If not, METHOD should be a list where the first element is the method
3677 and the second element is the address."
3679 (list (let ((how (completing-read
3681 (append gnus-valid-select-methods gnus-server-alist)
3682 nil t (cons "nntp" 0) 'gnus-method-history)))
3683 ;; We either got a backend name or a virtual server name.
3684 ;; If the first, we also need an address.
3685 (if (assoc how gnus-valid-select-methods)
3687 ;; Suggested by mapjph@bath.ac.uk.
3690 (mapcar (lambda (server) (list server))
3691 gnus-secondary-servers)))
3692 ;; We got a server name.
3694 (gnus-browse-foreign-server method))
3696 (defun gnus-group-set-info (info &optional method-only-group part)
3697 (when (or info part)
3698 (let* ((entry (gnus-gethash
3699 (or method-only-group (gnus-info-group info))
3700 gnus-newsrc-hashtb))
3702 (info (if method-only-group (nth 2 entry) info))
3704 (when method-only-group
3706 (error "Trying to change non-existent group %s" method-only-group))
3707 ;; We have received parts of the actual group info - either the
3708 ;; select method or the group parameters. We first check
3709 ;; whether we have to extend the info, and if so, do that.
3710 (let ((len (length info))
3711 (total (if (eq part 'method) 5 6)))
3713 (setcdr (nthcdr (1- len) info)
3714 (make-list (- total len) nil)))
3715 ;; Then we enter the new info.
3716 (setcar (nthcdr (1- total) info) part-info)))
3718 ;; This is a new group, so we just create it.
3720 (set-buffer gnus-group-buffer)
3721 (setq method (gnus-info-method info))
3722 (when (gnus-server-equal method "native")
3725 (set-buffer gnus-group-buffer)
3727 ;; It's a foreign group...
3728 (gnus-group-make-group
3729 (gnus-group-real-name (gnus-info-group info))
3730 (if (stringp method) method
3731 (prin1-to-string (car method)))
3733 (nth 1 (gnus-info-method info))))
3734 ;; It's a native group.
3735 (gnus-group-make-group (gnus-info-group info))))
3736 (gnus-message 6 "Note: New group created")
3738 (gnus-gethash (gnus-group-prefixed-name
3739 (gnus-group-real-name (gnus-info-group info))
3740 (or (gnus-info-method info) gnus-select-method))
3741 gnus-newsrc-hashtb))))
3742 ;; Whether it was a new group or not, we now have the entry, so we
3743 ;; can do the update.
3746 (setcar (nthcdr 2 entry) info)
3747 (when (and (not (eq (car entry) t))
3748 (gnus-active (gnus-info-group info)))
3749 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3750 (error "No such group: %s" (gnus-info-group info))))))
3752 (defun gnus-group-set-method-info (group select-method)
3753 (gnus-group-set-info select-method group 'method))
3755 (defun gnus-group-set-params-info (group params)
3756 (gnus-group-set-info params group 'params))
3758 (defun gnus-add-marked-articles (group type articles &optional info force)
3759 ;; Add ARTICLES of TYPE to the info of GROUP.
3760 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3761 ;; add, but replace marked articles of TYPE with ARTICLES.
3762 (let ((info (or info (gnus-get-info group)))
3765 (and (not (setq marked (nthcdr 3 info)))
3767 (setcdr (nthcdr 2 info)
3768 (list (list (cons type (gnus-compress-sequence
3770 (and (not (setq m (assq type (car marked))))
3773 (cons (cons type (gnus-compress-sequence articles t) )
3777 (setcar (nthcdr 3 info)
3778 (gnus-delete-alist type (car marked)))
3779 (setcdr m (gnus-compress-sequence articles t)))
3780 (setcdr m (gnus-compress-sequence
3781 (sort (nconc (gnus-uncompress-range (cdr m))
3782 (copy-sequence articles)) '<) t))))))
3785 ;;; Group timestamps
3788 (defun gnus-group-set-timestamp ()
3789 "Change the timestamp of the current group to the current time.
3790 This function can be used in hooks like `gnus-select-group-hook'
3791 or `gnus-group-catchup-group-hook'."
3792 (when gnus-newsgroup-name
3793 (let ((time (current-time)))
3794 (setcdr (cdr time) nil)
3795 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3797 (defsubst gnus-group-timestamp (group)
3798 "Return the timestamp for GROUP."
3799 (gnus-group-get-parameter group 'timestamp t))
3801 (defun gnus-group-timestamp-delta (group)
3802 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3803 (let* ((time (or (gnus-group-timestamp group)
3805 (delta (subtract-time (current-time) time)))
3806 (+ (* (nth 0 delta) 65536.0)
3809 (defun gnus-group-timestamp-string (group)
3810 "Return a string of the timestamp for GROUP."
3811 (let ((time (gnus-group-timestamp group)))
3814 (gnus-time-iso8601 time))))
3816 (defun gnus-group-list-cached (level &optional lowest)
3817 "List all groups with cached articles.
3818 If the prefix LEVEL is non-nil, it should be a number that says which
3819 level to cut off listing groups.
3820 If LOWEST, don't list groups with level lower than LOWEST.
3822 This command may read the active file."
3825 (setq level (prefix-numeric-value level)))
3826 (when (or (not level) (>= level gnus-level-zombie))
3828 (funcall gnus-group-prepare-function
3829 (or level gnus-level-subscribed)
3831 (let ((marks (gnus-info-marks info)))
3832 (assq 'cache marks)))
3835 (or (gnus-gethash group
3836 gnus-cache-active-hashtb)
3837 ;; Cache active file might use "."
3840 (mapconcat 'identity
3841 (split-string group ":")
3843 gnus-cache-active-hashtb))))
3844 (goto-char (point-min))
3845 (gnus-group-position-point))
3847 (defun gnus-group-list-dormant (level &optional lowest)
3848 "List all groups with dormant articles.
3849 If the prefix LEVEL is non-nil, it should be a number that says which
3850 level to cut off listing groups.
3851 If LOWEST, don't list groups with level lower than LOWEST.
3853 This command may read the active file."
3856 (setq level (prefix-numeric-value level)))
3857 (when (or (not level) (>= level gnus-level-zombie))
3859 (funcall gnus-group-prepare-function
3860 (or level gnus-level-subscribed)
3862 (let ((marks (gnus-info-marks info)))
3863 (assq 'dormant marks)))
3866 (goto-char (point-min))
3867 (gnus-group-position-point))
3869 (defun gnus-group-listed-groups ()
3870 "Return a list of listed groups."
3872 (goto-char (point-min))
3873 (while (setq point (text-property-not-all (point) (point-max)
3876 (push (symbol-name (get-text-property point 'gnus-group)) groups)
3880 (defun gnus-group-list-plus (&optional args)
3881 "List groups plus the current selection."
3883 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
3884 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
3886 (push last-command-event unread-command-events)
3887 (if (featurep 'xemacs)
3888 (push (make-event 'key-press '(key ?A)) unread-command-events)
3889 (push ?A unread-command-events))
3890 (let (gnus-pick-mode keys)
3891 (setq keys (if (featurep 'xemacs)
3892 (events-to-keys (read-key-sequence nil))
3893 (read-key-sequence nil)))
3894 (setq func (lookup-key (current-local-map) keys)))
3898 (call-interactively func))))
3900 (defun gnus-group-list-flush (&optional args)
3901 "Flush groups from the current selection."
3903 (let ((gnus-group-list-option 'flush))
3904 (gnus-group-list-plus args)))
3906 (defun gnus-group-list-limit (&optional args)
3907 "List groups limited within the current selection."
3909 (let ((gnus-group-list-option 'limit))
3910 (gnus-group-list-plus args)))
3912 (provide 'gnus-group)
3914 ;;; gnus-group.el ends here