1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
40 (defcustom gnus-group-archive-directory
41 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
42 "*The address of the (ding) archives."
43 :group 'gnus-group-foreign
46 (defcustom gnus-group-recent-archive-directory
47 "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
48 "*The address of the most recent (ding) articles."
49 :group 'gnus-group-foreign
52 (defcustom gnus-no-groups-message "No news is no news"
53 "*Message displayed by Gnus when no groups are available."
57 (defcustom gnus-keep-same-level nil
58 "*Non-nil means that the next newsgroup after the current will be on the same level.
59 When you type, for instance, `n' after reading the last article in the
60 current newsgroup, you will go to the next newsgroup. If this variable
61 is nil, the next newsgroup will be the next from the group
63 If this variable is non-nil, Gnus will either put you in the
64 next newsgroup with the same level, or, if no such newsgroup is
65 available, the next newsgroup with the lowest possible level higher
66 than the current level.
67 If this variable is `best', Gnus will make the next newsgroup the one
69 :group 'gnus-group-levels
70 :type '(choice (const nil)
72 (sexp :tag "other" t)))
74 (defcustom gnus-group-goto-unread t
75 "*If non-nil, movement commands will go to the next unread and subscribed group."
76 :link '(custom-manual "(gnus)Group Maneuvering")
77 :group 'gnus-group-various
80 (defcustom gnus-goto-next-group-when-activating t
81 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
82 :link '(custom-manual "(gnus)Scanning New Messages")
83 :group 'gnus-group-various
86 (defcustom gnus-permanently-visible-groups nil
87 "*Regexp to match groups that should always be listed in the group buffer.
88 This means that they will still be listed even when there are no
89 unread articles in the groups.
91 If nil, no groups are permanently visible."
92 :group 'gnus-group-listing
95 (defcustom gnus-list-groups-with-ticked-articles t
96 "*If non-nil, list groups that have only ticked articles.
97 If nil, only list groups that have unread articles."
98 :group 'gnus-group-listing
101 (defcustom gnus-group-default-list-level gnus-level-subscribed
102 "*Default listing level.
103 Ignored if `gnus-group-use-permanent-levels' is non-nil."
104 :group 'gnus-group-listing
107 (defcustom gnus-group-list-inactive-groups t
108 "*If non-nil, inactive groups will be listed."
109 :group 'gnus-group-listing
110 :group 'gnus-group-levels
113 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
114 "*Function used for sorting the group buffer.
115 This function will be called with group info entries as the arguments
116 for the groups to be sorted. Pre-made functions include
117 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
118 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
119 `gnus-group-sort-by-score', `gnus-group-sort-by-method', and
120 `gnus-group-sort-by-rank'.
122 This variable can also be a list of sorting functions. In that case,
123 the most significant sort function should be the last function in the
125 :group 'gnus-group-listing
126 :link '(custom-manual "(gnus)Sorting Groups")
127 :type '(radio (function-item gnus-group-sort-by-alphabet)
128 (function-item gnus-group-sort-by-real-name)
129 (function-item gnus-group-sort-by-unread)
130 (function-item gnus-group-sort-by-level)
131 (function-item gnus-group-sort-by-score)
132 (function-item gnus-group-sort-by-method)
133 (function-item gnus-group-sort-by-rank)
134 (function :tag "other" nil)))
136 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
137 "*Format of group lines.
138 It works along the same lines as a normal formatting string,
139 with some simple extensions.
141 %M Only marked articles (character, \"*\" or \" \")
142 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
143 %L Level of subscribedness (integer)
144 %N Number of unread articles (integer)
145 %I Number of dormant articles (integer)
146 %i Number of ticked and dormant (integer)
147 %T Number of ticked articles (integer)
148 %R Number of read articles (integer)
149 %t Estimated total number of articles (integer)
150 %y Number of unread, unticked articles (integer)
151 %G Group name (string)
152 %g Qualified group name (string)
153 %D Group description (string)
154 %s Select method (string)
155 %o Moderated group (char, \"m\")
156 %p Process mark (char)
157 %O Moderated group (string, \"(m)\" or \"\")
158 %P Topic indentation (string)
159 %m Whether there is new(ish) mail in the group (char, \"%\")
160 %l Whether there are GroupLens predictions for this group (string)
161 %n Select from where (string)
162 %z A string that look like `<%s:%n>' if a foreign select method is used
163 %d The date the group was last entered.
164 %u User defined specifier. The next character in the format string should
165 be a letter. Gnus will call the function gnus-user-format-function-X,
166 where X is the letter following %u. The function will be passed the
167 current header as argument. The function should return a string, which
168 will be inserted into the buffer just like information from any other
171 Text between %( and %) will be highlighted with `gnus-mouse-face' when
172 the mouse point move inside the area. There can only be one such area.
174 Note that this format specification is not always respected. For
175 reasons of efficiency, when listing killed groups, this specification
176 is ignored altogether. If the spec is changed considerably, your
177 output may end up looking strange when listing both alive and killed
180 If you use %o or %O, reading the active file will be slower and quite
181 a bit of extra memory will be used. %D will also worsen performance.
182 Also note that if you change the format specification to include any
183 of these specs, you must probably re-start Gnus to see them go into
185 :group 'gnus-group-visual
188 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
189 "*The format specification for the group mode line.
190 It works along the same lines as a normal formatting string,
191 with some simple extensions:
193 %S The native news server.
194 %M The native select method.
195 %: \":\" if %S isn't \"\"."
196 :group 'gnus-group-visual
199 (defcustom gnus-group-mode-hook nil
200 "Hook for Gnus group mode."
201 :group 'gnus-group-various
202 :options '(gnus-topic-mode)
205 (defcustom gnus-group-menu-hook nil
206 "Hook run after the creation of the group mode menu."
207 :group 'gnus-group-various
210 (defcustom gnus-group-catchup-group-hook nil
211 "Hook run when catching up a group from the group buffer."
212 :group 'gnus-group-various
213 :link '(custom-manual "(gnus)Group Data")
216 (defcustom gnus-group-update-group-hook nil
217 "Hook called when updating group lines."
218 :group 'gnus-group-visual
221 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
222 "*A function that is called to generate the group buffer.
223 The function is called with three arguments: The first is a number;
224 all group with a level less or equal to that number should be listed,
225 if the second is non-nil, empty groups should also be displayed. If
226 the third is non-nil, it is a number. No groups with a level lower
227 than this number should be displayed.
229 The only current function implemented is `gnus-group-prepare-flat'."
230 :group 'gnus-group-listing
233 (defcustom gnus-group-prepare-hook nil
234 "Hook called after the group buffer has been generated.
235 If you want to modify the group buffer, you can use this hook."
236 :group 'gnus-group-listing
239 (defcustom gnus-suspend-gnus-hook nil
240 "Hook called when suspending (not exiting) Gnus."
244 (defcustom gnus-exit-gnus-hook nil
245 "Hook called when exiting Gnus."
249 (defcustom gnus-after-exiting-gnus-hook nil
250 "Hook called after exiting Gnus."
254 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
255 "Hook called when a group line is changed.
256 The hook will not be called if `gnus-visual' is nil.
258 The default function `gnus-group-highlight-line' will
259 highlight the line according to the `gnus-group-highlight'
261 :group 'gnus-group-visual
264 (defcustom gnus-useful-groups
265 '(("(ding) mailing list mirrored at sunsite.auc.dk"
267 (nntp "sunsite.auc.dk"
268 (nntp-address "sunsite.auc.dk")))
271 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
275 (nndoc-article-type mbox)
276 (eval `(nndoc-address
277 ,(let ((file (nnheader-find-etc-directory
280 (error "Couldn't find doc group"))
282 "*Alist of useful group-server pairs."
283 :group 'gnus-group-listing
284 :type '(repeat (list (string :tag "Description")
286 (sexp :tag "Method"))))
288 (defcustom gnus-group-highlight
290 ((and (= unread 0) (not mailp) (eq level 1)) .
291 gnus-group-news-1-empty-face)
292 ((and (not mailp) (eq level 1)) .
293 gnus-group-news-1-face)
294 ((and (= unread 0) (not mailp) (eq level 2)) .
295 gnus-group-news-2-empty-face)
296 ((and (not mailp) (eq level 2)) .
297 gnus-group-news-2-face)
298 ((and (= unread 0) (not mailp) (eq level 3)) .
299 gnus-group-news-3-empty-face)
300 ((and (not mailp) (eq level 3)) .
301 gnus-group-news-3-face)
302 ((and (= unread 0) (not mailp)) .
303 gnus-group-news-low-empty-face)
305 gnus-group-news-low-face)
307 ((and (= unread 0) (eq level 1)) .
308 gnus-group-mail-1-empty-face)
310 gnus-group-mail-1-face)
311 ((and (= unread 0) (eq level 2)) .
312 gnus-group-mail-2-empty-face)
314 gnus-group-mail-2-face)
315 ((and (= unread 0) (eq level 3)) .
316 gnus-group-mail-3-empty-face)
318 gnus-group-mail-3-face)
320 gnus-group-mail-low-empty-face)
322 gnus-group-mail-low-face))
323 "*Controls the highlighting of group buffer lines.
325 Below is a list of `Form'/`Face' pairs. When deciding how a a
326 particular group line should be displayed, each form is
327 evaluated. The content of the face field after the first true form is
328 used. You can change how those group lines are displayed by
329 editing the face field.
331 It is also possible to change and add form fields, but currently that
332 requires an understanding of Lisp expressions. Hopefully this will
333 change in a future release. For now, you can use the following
334 variables in the Lisp expression:
336 group: The name of the group.
337 unread: The number of unread articles in the group.
338 method: The select method used.
339 mailp: Whether it's a mail group or not.
340 level: The level of the group.
341 score: The score of the group.
342 ticked: The number of ticked articles."
343 :group 'gnus-group-visual
344 :type '(repeat (cons (sexp :tag "Form") face)))
346 (defcustom gnus-new-mail-mark ?%
347 "Mark used for groups with new mail."
348 :group 'gnus-group-visual
351 ;;; Internal variables
353 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
354 "Function for sorting the group buffer.")
356 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
357 "Function for sorting the selected groups in the group buffer.")
359 (defvar gnus-group-indentation-function nil)
360 (defvar gnus-goto-missing-group-function nil)
361 (defvar gnus-group-update-group-function nil)
362 (defvar gnus-group-goto-next-group-function nil
363 "Function to override finding the next group after listing groups.")
365 (defvar gnus-group-edit-buffer nil)
367 (defvar gnus-group-line-format-alist
368 `((?M gnus-tmp-marked-mark ?c)
369 (?S gnus-tmp-subscribed ?c)
370 (?L gnus-tmp-level ?d)
371 (?N (cond ((eq number t) "*" )
375 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
376 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
378 (?R gnus-tmp-number-of-read ?s)
379 (?t gnus-tmp-number-total ?d)
380 (?y gnus-tmp-number-of-unread ?s)
381 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
382 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
383 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
384 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
385 (?g gnus-tmp-group ?s)
386 (?G gnus-tmp-qualified-group ?s)
387 (?c (gnus-short-group-name gnus-tmp-group) ?s)
388 (?D gnus-tmp-newsgroup-description ?s)
389 (?o gnus-tmp-moderated ?c)
390 (?O gnus-tmp-moderated-string ?s)
391 (?p gnus-tmp-process-marked ?c)
392 (?s gnus-tmp-news-server ?s)
393 (?n gnus-tmp-news-method ?s)
394 (?P gnus-group-indentation ?s)
395 (?l gnus-tmp-grouplens ?s)
396 (?z gnus-tmp-news-method-string ?s)
397 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
398 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
399 (?u gnus-tmp-user-defined ?s)))
401 (defvar gnus-group-mode-line-format-alist
402 `((?S gnus-tmp-news-server ?s)
403 (?M gnus-tmp-news-method ?s)
404 (?u gnus-tmp-user-defined ?s)
405 (?: gnus-tmp-colon ?s)))
407 (defvar gnus-topic-topology nil
408 "The complete topic hierarchy.")
410 (defvar gnus-topic-alist nil
411 "The complete topic-group alist.")
413 (defvar gnus-group-marked nil)
415 (defvar gnus-group-list-mode nil)
421 (put 'gnus-group-mode 'mode-class 'special)
424 (gnus-define-keys gnus-group-mode-map
425 " " gnus-group-read-group
426 "=" gnus-group-select-group
427 "\r" gnus-group-select-group
428 "\M-\r" gnus-group-quick-select-group
429 [(meta control return)] gnus-group-select-group-ephemerally
430 "j" gnus-group-jump-to-group
431 "n" gnus-group-next-unread-group
432 "p" gnus-group-prev-unread-group
433 "\177" gnus-group-prev-unread-group
434 [delete] gnus-group-prev-unread-group
435 [backspace] gnus-group-prev-unread-group
436 "N" gnus-group-next-group
437 "P" gnus-group-prev-group
438 "\M-n" gnus-group-next-unread-group-same-level
439 "\M-p" gnus-group-prev-unread-group-same-level
440 "," gnus-group-best-unread-group
441 "." gnus-group-first-unread-group
442 "u" gnus-group-unsubscribe-current-group
443 "U" gnus-group-unsubscribe-group
444 "c" gnus-group-catchup-current
445 "C" gnus-group-catchup-current-all
446 "\M-c" gnus-group-clear-data
447 "l" gnus-group-list-groups
448 "L" gnus-group-list-all-groups
450 "g" gnus-group-get-new-news
451 "\M-g" gnus-group-get-new-news-this-group
452 "R" gnus-group-restart
453 "r" gnus-group-read-init-file
454 "B" gnus-group-browse-foreign-server
455 "b" gnus-group-check-bogus-groups
456 "F" gnus-group-find-new-groups
457 "\C-c\C-d" gnus-group-describe-group
458 "\M-d" gnus-group-describe-all-groups
459 "\C-c\C-a" gnus-group-apropos
460 "\C-c\M-\C-a" gnus-group-description-apropos
461 "a" gnus-group-post-news
462 "\ek" gnus-group-edit-local-kill
463 "\eK" gnus-group-edit-global-kill
464 "\C-k" gnus-group-kill-group
465 "\C-y" gnus-group-yank-group
466 "\C-w" gnus-group-kill-region
467 "\C-x\C-t" gnus-group-transpose-groups
468 "\C-c\C-l" gnus-group-list-killed
469 "\C-c\C-x" gnus-group-expire-articles
470 "\C-c\M-\C-x" gnus-group-expire-all-groups
472 "s" gnus-group-save-newsrc
473 "z" gnus-group-suspend
476 "?" gnus-group-describe-briefly
477 "\C-c\C-i" gnus-info-find-node
478 "\M-e" gnus-group-edit-group-method
479 "^" gnus-group-enter-server-mode
480 gnus-mouse-2 gnus-mouse-pick-group
481 "<" beginning-of-buffer
484 "\C-c\C-s" gnus-group-sort-groups
486 "\C-c\M-g" gnus-activate-all-groups
487 "\M-&" gnus-group-universal-argument
488 "#" gnus-group-mark-group
489 "\M-#" gnus-group-unmark-group)
491 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
492 "m" gnus-group-mark-group
493 "u" gnus-group-unmark-group
494 "w" gnus-group-mark-region
495 "b" gnus-group-mark-buffer
496 "r" gnus-group-mark-regexp
497 "U" gnus-group-unmark-all-groups)
499 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
500 "d" gnus-group-make-directory-group
501 "h" gnus-group-make-help-group
502 "u" gnus-group-make-useful-group
503 "a" gnus-group-make-archive-group
504 "k" gnus-group-make-kiboze-group
505 "m" gnus-group-make-group
506 "E" gnus-group-edit-group
507 "e" gnus-group-edit-group-method
508 "p" gnus-group-edit-group-parameters
509 "v" gnus-group-add-to-virtual
510 "V" gnus-group-make-empty-virtual
511 "D" gnus-group-enter-directory
512 "f" gnus-group-make-doc-group
513 "w" gnus-group-make-web-group
514 "r" gnus-group-rename-group
515 "c" gnus-group-customize
516 "\177" gnus-group-delete-group
517 [delete] gnus-group-delete-group)
519 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
520 "b" gnus-group-brew-soup
521 "w" gnus-soup-save-areas
522 "s" gnus-soup-send-replies
523 "p" gnus-soup-pack-packet
524 "r" nnsoup-pack-replies)
526 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
527 "s" gnus-group-sort-groups
528 "a" gnus-group-sort-groups-by-alphabet
529 "u" gnus-group-sort-groups-by-unread
530 "l" gnus-group-sort-groups-by-level
531 "v" gnus-group-sort-groups-by-score
532 "r" gnus-group-sort-groups-by-rank
533 "m" gnus-group-sort-groups-by-method)
535 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
536 "s" gnus-group-sort-selected-groups
537 "a" gnus-group-sort-selected-groups-by-alphabet
538 "u" gnus-group-sort-selected-groups-by-unread
539 "l" gnus-group-sort-selected-groups-by-level
540 "v" gnus-group-sort-selected-groups-by-score
541 "r" gnus-group-sort-selected-groups-by-rank
542 "m" gnus-group-sort-selected-groups-by-method)
544 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
545 "k" gnus-group-list-killed
546 "z" gnus-group-list-zombies
547 "s" gnus-group-list-groups
548 "u" gnus-group-list-all-groups
549 "A" gnus-group-list-active
550 "a" gnus-group-apropos
551 "d" gnus-group-description-apropos
552 "m" gnus-group-list-matching
553 "M" gnus-group-list-all-matching
554 "l" gnus-group-list-level)
556 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
557 "f" gnus-score-flush-cache)
559 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
560 "d" gnus-group-describe-group
561 "f" gnus-group-fetch-faq
564 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
565 "l" gnus-group-set-current-level
566 "t" gnus-group-unsubscribe-current-group
567 "s" gnus-group-unsubscribe-group
568 "k" gnus-group-kill-group
569 "y" gnus-group-yank-group
570 "w" gnus-group-kill-region
571 "\C-k" gnus-group-kill-level
572 "z" gnus-group-kill-all-zombies))
574 (defun gnus-group-make-menu-bar ()
575 (gnus-turn-off-edit-menu 'group)
576 (unless (boundp 'gnus-group-reading-menu)
579 gnus-group-reading-menu gnus-group-mode-map ""
581 ["Read" gnus-group-read-group (gnus-group-group-name)]
582 ["Select" gnus-group-select-group (gnus-group-group-name)]
583 ["See old articles" (gnus-group-select-group 'all)
584 :keys "C-u SPC" :active (gnus-group-group-name)]
585 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
586 ["Catch up all articles" gnus-group-catchup-current-all
587 (gnus-group-group-name)]
588 ["Check for new articles" gnus-group-get-new-news-this-group
589 (gnus-group-group-name)]
590 ["Toggle subscription" gnus-group-unsubscribe-current-group
591 (gnus-group-group-name)]
592 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
593 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
594 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
595 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
596 ;; Actually one should check, if any of the marked groups gives t for
597 ;; (gnus-check-backend-function 'request-expire-articles ...)
598 ["Expire articles" gnus-group-expire-articles
599 (or (and (gnus-group-group-name)
600 (gnus-check-backend-function
601 'request-expire-articles
602 (gnus-group-group-name))) gnus-group-marked)]
603 ["Set group level" gnus-group-set-current-level
604 (gnus-group-group-name)]
605 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
606 ["Customize" gnus-group-customize (gnus-group-group-name)]
608 ["Parameters" gnus-group-edit-group-parameters
609 (gnus-group-group-name)]
610 ["Select method" gnus-group-edit-group-method
611 (gnus-group-group-name)]
612 ["Info" gnus-group-edit-group (gnus-group-group-name)]
613 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
614 ["Global kill file" gnus-group-edit-global-kill t])))
617 gnus-group-group-menu gnus-group-mode-map ""
620 ["List unread subscribed groups" gnus-group-list-groups t]
621 ["List (un)subscribed groups" gnus-group-list-all-groups t]
622 ["List killed groups" gnus-group-list-killed gnus-killed-list]
623 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
624 ["List level..." gnus-group-list-level t]
625 ["Describe all groups" gnus-group-describe-all-groups t]
626 ["Group apropos..." gnus-group-apropos t]
627 ["Group and description apropos..." gnus-group-description-apropos t]
628 ["List groups matching..." gnus-group-list-matching t]
629 ["List all groups matching..." gnus-group-list-all-matching t]
630 ["List active file" gnus-group-list-active t])
632 ["Default sort" gnus-group-sort-groups t]
633 ["Sort by method" gnus-group-sort-groups-by-method t]
634 ["Sort by rank" gnus-group-sort-groups-by-rank t]
635 ["Sort by score" gnus-group-sort-groups-by-score t]
636 ["Sort by level" gnus-group-sort-groups-by-level t]
637 ["Sort by unread" gnus-group-sort-groups-by-unread t]
638 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
639 ("Sort process/prefixed"
640 ["Default sort" gnus-group-sort-selected-groups
641 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
642 ["Sort by method" gnus-group-sort-selected-groups-by-method
643 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
644 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
645 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
646 ["Sort by score" gnus-group-sort-selected-groups-by-score
647 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
648 ["Sort by level" gnus-group-sort-selected-groups-by-level
649 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
650 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
651 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
652 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
653 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
655 ["Mark group" gnus-group-mark-group
656 (and (gnus-group-group-name)
657 (not (memq (gnus-group-group-name) gnus-group-marked)))]
658 ["Unmark group" gnus-group-unmark-group
659 (and (gnus-group-group-name)
660 (memq (gnus-group-group-name) gnus-group-marked))]
661 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
662 ["Mark regexp..." gnus-group-mark-regexp t]
663 ["Mark region" gnus-group-mark-region t]
664 ["Mark buffer" gnus-group-mark-buffer t]
665 ["Execute command" gnus-group-universal-argument
666 (or gnus-group-marked (gnus-group-group-name))])
668 ["Subscribe to a group" gnus-group-unsubscribe-group t]
669 ["Kill all newsgroups in region" gnus-group-kill-region t]
670 ["Kill all zombie groups" gnus-group-kill-all-zombies
672 ["Kill all groups on level..." gnus-group-kill-level t])
674 ["Make a foreign group" gnus-group-make-group t]
675 ["Add a directory group" gnus-group-make-directory-group t]
676 ["Add the help group" gnus-group-make-help-group t]
677 ["Add the archive group" gnus-group-make-archive-group t]
678 ["Make a doc group" gnus-group-make-doc-group t]
679 ["Make a web group" gnus-group-make-web-group t]
680 ["Make a kiboze group" gnus-group-make-kiboze-group t]
681 ["Make a virtual group" gnus-group-make-empty-virtual t]
682 ["Add a group to a virtual" gnus-group-add-to-virtual t]
683 ["Rename group" gnus-group-rename-group
684 (gnus-check-backend-function
685 'request-rename-group (gnus-group-group-name))]
686 ["Delete group" gnus-group-delete-group
687 (gnus-check-backend-function
688 'request-delete-group (gnus-group-group-name))])
690 ["Next" gnus-group-next-group t]
691 ["Previous" gnus-group-prev-group t]
692 ["Next unread" gnus-group-next-unread-group t]
693 ["Previous unread" gnus-group-prev-unread-group t]
694 ["Next unread same level" gnus-group-next-unread-group-same-level t]
695 ["Previous unread same level"
696 gnus-group-prev-unread-group-same-level t]
697 ["Jump to group" gnus-group-jump-to-group t]
698 ["First unread group" gnus-group-first-unread-group t]
699 ["Best unread group" gnus-group-best-unread-group t])
700 ["Delete bogus groups" gnus-group-check-bogus-groups t]
701 ["Find new newsgroups" gnus-group-find-new-groups t]
702 ["Transpose" gnus-group-transpose-groups
703 (gnus-group-group-name)]
704 ["Read a directory as a group..." gnus-group-enter-directory t]))
707 gnus-group-misc-menu gnus-group-mode-map ""
710 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
711 ["Send replies" gnus-soup-send-replies
712 (fboundp 'gnus-soup-pack-packet)]
713 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
714 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
715 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
716 ["Send a bug report" gnus-bug t]
717 ["Send a mail" gnus-group-mail t]
718 ["Post an article..." gnus-group-post-news t]
719 ["Check for new news" gnus-group-get-new-news t]
720 ["Activate all groups" gnus-activate-all-groups t]
721 ["Restart Gnus" gnus-group-restart t]
722 ["Read init file" gnus-group-read-init-file t]
723 ["Browse foreign server" gnus-group-browse-foreign-server t]
724 ["Enter server buffer" gnus-group-enter-server-mode t]
725 ["Expire all expirable articles" gnus-group-expire-all-groups t]
726 ["Generate any kiboze groups" nnkiboze-generate-groups t]
727 ["Gnus version" gnus-version t]
728 ["Save .newsrc files" gnus-group-save-newsrc t]
729 ["Suspend Gnus" gnus-group-suspend t]
730 ["Clear dribble buffer" gnus-group-clear-dribble t]
731 ["Read manual" gnus-info-find-node t]
732 ["Flush score cache" gnus-score-flush-cache t]
733 ["Toggle topics" gnus-topic-mode t]
734 ["Send a bug report" gnus-bug t]
735 ["Exit from Gnus" gnus-group-exit t]
736 ["Exit without saving" gnus-group-quit t]))
738 (gnus-run-hooks 'gnus-group-menu-hook)))
740 (defun gnus-group-mode ()
741 "Major mode for reading news.
743 All normal editing commands are switched off.
744 \\<gnus-group-mode-map>
745 The group buffer lists (some of) the groups available. For instance,
746 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
747 lists all zombie groups.
749 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
750 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
752 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
754 The following commands are available:
756 \\{gnus-group-mode-map}"
758 (when (gnus-visual-p 'group-menu 'menu)
759 (gnus-group-make-menu-bar))
760 (kill-all-local-variables)
761 (gnus-simplify-mode-line)
762 (setq major-mode 'gnus-group-mode)
763 (setq mode-name "Group")
764 (gnus-group-set-mode-line)
765 (setq mode-line-process nil)
766 (use-local-map gnus-group-mode-map)
767 (buffer-disable-undo)
768 (setq truncate-lines t)
769 (setq buffer-read-only t)
770 (gnus-set-default-directory)
771 (gnus-update-format-specifications nil 'group 'group-mode)
772 (gnus-update-group-mark-positions)
773 (make-local-hook 'post-command-hook)
774 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
779 (gnus-run-hooks 'gnus-group-mode-hook))
781 (defun gnus-update-group-mark-positions ()
783 (let ((gnus-process-mark ?\200)
784 (gnus-group-marked '("dummy.group"))
785 (gnus-active-hashtb (make-vector 10 0))
787 (gnus-set-active "dummy.group" '(0 . 0))
788 (gnus-set-work-buffer)
789 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
790 (goto-char (point-min))
791 (setq gnus-group-mark-positions
792 (list (cons 'process (and (search-forward "\200" nil t)
795 (defun gnus-clear-inboxes-moved ()
796 (setq nnmail-moved-inboxes nil))
798 (defun gnus-mouse-pick-group (e)
799 "Enter the group under the mouse pointer."
802 (gnus-group-read-group nil))
804 ;; Look at LEVEL and find out what the level is really supposed to be.
805 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
806 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
807 (defun gnus-group-default-level (&optional level number-or-nil)
809 (gnus-group-use-permanent-levels
810 (or (setq gnus-group-use-permanent-levels
811 (or level (if (numberp gnus-group-use-permanent-levels)
812 gnus-group-use-permanent-levels
813 (or gnus-group-default-list-level
814 gnus-level-subscribed))))
815 gnus-group-default-list-level gnus-level-subscribed))
819 (or level gnus-group-default-list-level gnus-level-subscribed))))
821 (defun gnus-group-setup-buffer ()
822 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
823 (unless (eq major-mode 'gnus-group-mode)
826 (gnus-carpal-setup-buffer 'group))))
828 (defun gnus-group-list-groups (&optional level unread lowest)
829 "List newsgroups with level LEVEL or lower that have unread articles.
830 Default is all subscribed groups.
831 If argument UNREAD is non-nil, groups with no unread articles are also
834 Also see the `gnus-group-use-permanent-levels' variable."
836 (list (if current-prefix-arg
837 (prefix-numeric-value current-prefix-arg)
839 (gnus-group-default-level nil t)
840 gnus-group-default-list-level
841 gnus-level-subscribed))))
842 ;; Just do this here, for no particular good reason.
843 (gnus-clear-inboxes-moved)
845 (setq level (car gnus-group-list-mode)
846 unread (cdr gnus-group-list-mode)))
847 (setq level (gnus-group-default-level level))
848 (gnus-group-setup-buffer)
849 (gnus-update-format-specifications nil 'group 'group-mode)
850 (let ((case-fold-search nil)
851 (props (text-properties-at (gnus-point-at-bol)))
852 (empty (= (point-min) (point-max)))
853 (group (gnus-group-group-name))
855 (set-buffer gnus-group-buffer)
856 (setq number (funcall gnus-group-prepare-function level unread lowest))
857 (when (or (and (numberp number)
859 (zerop (buffer-size)))
860 ;; No groups in the buffer.
861 (gnus-message 5 gnus-no-groups-message))
862 ;; We have some groups displayed.
863 (goto-char (point-max))
864 (when (or (not gnus-group-goto-next-group-function)
865 (not (funcall gnus-group-goto-next-group-function
869 (goto-char (point-min)))
871 ;; Go to the first group with unread articles.
872 (gnus-group-search-forward t))
874 ;; Find the right group to put point on. If the current group
875 ;; has disappeared in the new listing, try to find the next
876 ;; one. If no next one can be found, just leave point at the
877 ;; first newsgroup in the buffer.
878 (when (not (gnus-goto-char
880 (point-min) (point-max)
881 'gnus-group (gnus-intern-safe
882 group gnus-active-hashtb))))
883 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
887 (point-min) (point-max) 'gnus-group
889 (caar newsrc) gnus-active-hashtb)))))
890 (setq newsrc (cdr newsrc)))
892 (goto-char (point-max))
893 (forward-line -1)))))))
894 ;; Adjust cursor point.
895 (gnus-group-position-point)))
897 (defun gnus-group-list-level (level &optional all)
898 "List groups on LEVEL.
899 If ALL (the prefix), also list groups that have no unread articles."
900 (interactive "nList groups on level: \nP")
901 (gnus-group-list-groups level all level))
903 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
904 "List all newsgroups with unread articles of level LEVEL or lower.
905 If ALL is non-nil, list groups that have no unread articles.
906 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
907 If REGEXP, only list groups matching REGEXP."
908 (set-buffer gnus-group-buffer)
909 (let ((buffer-read-only nil)
910 (newsrc (cdr gnus-newsrc-alist))
911 (lowest (or lowest 1))
912 info clevel unread group params)
914 (when (< lowest gnus-level-zombie)
915 ;; List living groups.
917 (setq info (car newsrc)
918 group (gnus-info-group info)
919 params (gnus-info-params info)
921 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
922 (and unread ; This group might be bogus
924 (string-match regexp group))
925 (<= (setq clevel (gnus-info-level info)) level)
927 (or all ; We list all groups?
928 (if (eq unread t) ; Unactivated?
929 gnus-group-list-inactive-groups ; We list unactivated
930 (> unread 0)) ; We list groups with unread articles
931 (and gnus-list-groups-with-ticked-articles
932 (cdr (assq 'tick (gnus-info-marks info))))
933 ; And groups with tickeds
934 ;; Check for permanent visibility.
935 (and gnus-permanently-visible-groups
936 (string-match gnus-permanently-visible-groups
938 (memq 'visible params)
939 (cdr (assq 'visible params)))
940 (gnus-group-insert-group-line
941 group (gnus-info-level info)
942 (gnus-info-marks info) unread (gnus-info-method info)))))
945 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
946 (gnus-group-prepare-flat-list-dead
947 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
950 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
951 (gnus-group-prepare-flat-list-dead
952 (setq gnus-killed-list (sort gnus-killed-list 'string<))
953 gnus-level-killed ?K regexp))
955 (gnus-group-set-mode-line)
956 (setq gnus-group-list-mode (cons level all))
957 (gnus-run-hooks 'gnus-group-prepare-hook)
960 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
961 ;; List zombies and killed lists somewhat faster, which was
962 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
963 ;; this by ignoring the group format specification altogether.
966 ;; This loop is used when listing groups that match some
969 (setq group (pop groups))
970 (when (string-match regexp group)
971 (gnus-add-text-properties
972 (point) (prog1 (1+ (point))
973 (insert " " mark " *: " group "\n"))
974 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
976 'gnus-level level))))
977 ;; This loop is used when listing all groups.
979 (gnus-add-text-properties
980 (point) (prog1 (1+ (point))
981 (insert " " mark " *: "
982 (setq group (pop groups)) "\n"))
983 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
985 'gnus-level level))))))
987 (defun gnus-group-update-group-line ()
988 "Update the current line in the group buffer."
989 (let* ((buffer-read-only nil)
990 (group (gnus-group-group-name))
991 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
992 gnus-group-indentation)
995 (not (gnus-ephemeral-group-p group))
997 (concat "(gnus-group-set-info '"
998 (gnus-prin1-to-string (nth 2 entry))
1000 (setq gnus-group-indentation (gnus-group-group-indentation))
1002 (gnus-group-insert-group-line-info group)
1004 (gnus-group-position-point))))
1006 (defun gnus-group-insert-group-line-info (group)
1007 "Insert GROUP on the current line."
1008 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1009 (gnus-group-indentation (gnus-group-group-indentation))
1013 ;; (Un)subscribed group.
1014 (setq info (nth 2 entry))
1015 (gnus-group-insert-group-line
1016 group (gnus-info-level info) (gnus-info-marks info)
1017 (or (car entry) t) (gnus-info-method info)))
1018 ;; This group is dead.
1019 (gnus-group-insert-group-line
1021 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1023 (if (setq active (gnus-active group))
1024 (if (zerop (cdr active))
1026 (- (1+ (cdr active)) (car active)))
1030 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1031 gnus-tmp-marked number
1033 "Insert a group line in the group buffer."
1034 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
1035 (gnus-tmp-number-total
1037 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1039 (gnus-tmp-number-of-unread
1040 (if (numberp number) (int-to-string (max 0 number))
1042 (gnus-tmp-number-of-read
1043 (if (numberp number)
1044 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1046 (gnus-tmp-subscribed
1047 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1048 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1049 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1051 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
1052 (gnus-tmp-newsgroup-description
1053 (if gnus-description-hashtb
1054 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
1057 (if (and gnus-moderated-hashtb
1058 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1060 (gnus-tmp-moderated-string
1061 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1063 (gnus-server-get-method gnus-tmp-group gnus-tmp-method)) ;
1064 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1065 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1066 (gnus-tmp-news-method-string
1068 (format "(%s:%s)" (car gnus-tmp-method)
1069 (cadr gnus-tmp-method)) ""))
1070 (gnus-tmp-marked-mark
1071 (if (and (numberp number)
1073 (cdr (assq 'tick gnus-tmp-marked)))
1075 (gnus-tmp-process-marked
1076 (if (member gnus-tmp-group gnus-group-marked)
1077 gnus-process-mark ? ))
1079 (or (and gnus-use-grouplens
1080 (bbb-grouplens-group-p gnus-tmp-group))
1082 (buffer-read-only nil)
1083 header gnus-tmp-header) ; passed as parameter to user-funcs.
1085 (gnus-add-text-properties
1089 (eval gnus-group-line-format-spec))
1090 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1091 gnus-unread ,(if (numberp number)
1092 (string-to-int gnus-tmp-number-of-unread)
1094 gnus-marked ,gnus-tmp-marked-mark
1095 gnus-indentation ,gnus-group-indentation
1096 gnus-level ,gnus-tmp-level))
1097 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1099 (gnus-run-hooks 'gnus-group-update-hook)
1101 ;; Allow XEmacs to remove front-sticky text properties.
1102 (gnus-group-remove-excess-properties)))
1104 (defun gnus-group-highlight-line ()
1105 "Highlight the current line according to `gnus-group-highlight'."
1106 (let* ((list gnus-group-highlight)
1108 (end (progn (end-of-line) (point)))
1109 ;; now find out where the line starts and leave point there.
1110 (beg (progn (beginning-of-line) (point)))
1111 (group (gnus-group-group-name))
1112 (entry (gnus-group-entry group))
1113 (unread (if (numberp (car entry)) (car entry) 0))
1114 (active (gnus-active group))
1115 (total (if active (1+ (- (cdr active) (car active))) 0))
1116 (info (nth 2 entry))
1117 (method (gnus-server-get-method group (gnus-info-method info)))
1118 (marked (gnus-info-marks info))
1119 (mailp (memq 'mail (assoc (symbol-name
1120 (car (or method gnus-select-method)))
1121 gnus-valid-select-methods)))
1122 (level (or (gnus-info-level info) gnus-level-killed))
1123 (score (or (gnus-info-score info) 0))
1124 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1125 (group-age (gnus-group-timestamp-delta group))
1126 (inhibit-read-only t))
1127 ;; Eval the cars of the lists until we find a match.
1129 (not (eval (caar list))))
1130 (setq list (cdr list)))
1131 (let ((face (cdar list)))
1132 (unless (eq face (get-text-property beg 'face))
1133 (gnus-put-text-property-excluding-characters-with-faces
1135 (setq face (if (boundp face) (symbol-value face) face)))
1136 (gnus-extent-start-open beg)))
1139 (defun gnus-group-update-group (group &optional visible-only)
1140 "Update all lines where GROUP appear.
1141 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1143 ;; Can't use `save-excursion' here, so we do it manually.
1144 (let ((buf (current-buffer))
1146 (set-buffer gnus-group-buffer)
1147 (setq mark (point-marker))
1148 ;; The buffer may be narrowed.
1151 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1153 found buffer-read-only)
1154 ;; Enter the current status into the dribble buffer.
1155 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1157 (not (gnus-ephemeral-group-p group)))
1159 (concat "(gnus-group-set-info '"
1160 (gnus-prin1-to-string (nth 2 entry))
1162 ;; Find all group instances. If topics are in use, each group
1163 ;; may be listed in more than once.
1164 (while (setq loc (text-property-any
1165 loc (point-max) 'gnus-group ident))
1168 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1170 (gnus-group-insert-group-line-info group)
1173 (gnus-run-hooks 'gnus-group-update-group-hook)))
1174 (setq loc (1+ loc)))
1175 (unless (or found visible-only)
1176 ;; No such line in the buffer, find out where it's supposed to
1177 ;; go, and insert it there (or at the end of the buffer).
1178 (if gnus-goto-missing-group-function
1179 (funcall gnus-goto-missing-group-function group)
1180 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1181 (while (and entry (car entry)
1185 (point-min) (point-max)
1186 'gnus-group (gnus-intern-safe
1187 (caar entry) gnus-active-hashtb)))))
1188 (setq entry (cdr entry)))
1189 (or entry (goto-char (point-max)))))
1190 ;; Finally insert the line.
1191 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1192 (gnus-group-insert-group-line-info group)
1195 (gnus-run-hooks 'gnus-group-update-group-hook))))
1196 (when gnus-group-update-group-function
1197 (funcall gnus-group-update-group-function group))
1198 (gnus-group-set-mode-line)))
1200 (set-marker mark nil)
1203 (defun gnus-group-set-mode-line ()
1204 "Update the mode line in the group buffer."
1205 (when (memq 'group gnus-updated-mode-lines)
1206 ;; Yes, we want to keep this mode line updated.
1208 (set-buffer gnus-group-buffer)
1209 (let* ((gformat (or gnus-group-mode-line-format-spec
1210 (gnus-set-format 'group-mode)))
1211 (gnus-tmp-news-server (cadr gnus-select-method))
1212 (gnus-tmp-news-method (car gnus-select-method))
1213 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1215 gnus-tmp-header ;Dummy binding for user-defined formats
1216 ;; Get the resulting string.
1218 (and gnus-dribble-buffer
1219 (buffer-name gnus-dribble-buffer)
1220 (buffer-modified-p gnus-dribble-buffer)
1222 (set-buffer gnus-dribble-buffer)
1223 (not (zerop (buffer-size))))))
1224 (mode-string (eval gformat)))
1225 ;; Say whether the dribble buffer has been modified.
1226 (setq mode-line-modified
1227 (if modified (car gnus-mode-line-modified)
1228 (cdr gnus-mode-line-modified)))
1229 ;; If the line is too long, we chop it off.
1230 (when (> (length mode-string) max-len)
1231 (setq mode-string (substring mode-string 0 (- max-len 4))))
1233 (setq mode-line-buffer-identification
1234 (gnus-mode-line-buffer-identification
1235 (list mode-string)))
1236 (set-buffer-modified-p modified))))))
1238 (defun gnus-group-group-name ()
1239 "Get the name of the newsgroup on the current line."
1240 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1242 (symbol-name group))))
1244 (defun gnus-group-group-level ()
1245 "Get the level of the newsgroup on the current line."
1246 (get-text-property (gnus-point-at-bol) 'gnus-level))
1248 (defun gnus-group-group-indentation ()
1249 "Get the indentation of the newsgroup on the current line."
1250 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1251 (and gnus-group-indentation-function
1252 (funcall gnus-group-indentation-function))
1255 (defun gnus-group-group-unread ()
1256 "Get the number of unread articles of the newsgroup on the current line."
1257 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1259 (defun gnus-group-new-mail (group)
1260 (if (nnmail-new-mail-p (gnus-group-real-name group))
1264 (defun gnus-group-level (group)
1265 "Return the estimated level of GROUP."
1266 (or (gnus-info-level (gnus-get-info group))
1267 (and (member group gnus-zombie-list) gnus-level-zombie)
1270 (defun gnus-group-search-forward (&optional backward all level first-too)
1271 "Find the next newsgroup with unread articles.
1272 If BACKWARD is non-nil, find the previous newsgroup instead.
1273 If ALL is non-nil, just find any newsgroup.
1274 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1276 If FIRST-TOO, the current line is also eligible as a target."
1277 (let ((way (if backward -1 1))
1278 (low gnus-level-killed)
1281 (if (and backward (progn (beginning-of-line)) (bobp))
1290 (get-text-property (point) 'gnus-group)
1294 (get-text-property (point) 'gnus-unread)))
1295 (and (numberp unread) (> unread 0)))
1296 (setq lev (get-text-property (point)
1298 (<= lev gnus-level-subscribed)))
1300 (and (setq lev (get-text-property (point)
1309 (zerop (forward-line way)))))
1311 (progn (gnus-group-position-point) t)
1312 (goto-char (or pos beg))
1315 ;;; Gnus group mode commands
1319 (defun gnus-group-mark-group (n &optional unmark no-advance)
1320 "Mark the current group."
1322 (let ((buffer-read-only nil)
1326 (when (setq group (gnus-group-group-name))
1327 ;; Go to the mark position.
1329 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1330 (subst-char-in-region
1331 (point) (1+ (point)) (following-char)
1334 (setq gnus-group-marked (delete group gnus-group-marked))
1336 (setq gnus-group-marked
1337 (cons group (delete group gnus-group-marked)))
1338 gnus-process-mark)))
1340 (gnus-group-next-group 1))
1342 (gnus-summary-position-point)
1345 (defun gnus-group-unmark-group (n)
1346 "Remove the mark from the current group."
1348 (gnus-group-mark-group n 'unmark)
1349 (gnus-group-position-point))
1351 (defun gnus-group-unmark-all-groups ()
1352 "Unmark all groups."
1354 (let ((groups gnus-group-marked))
1357 (gnus-group-remove-mark (pop groups)))))
1358 (gnus-group-position-point))
1360 (defun gnus-group-mark-region (unmark beg end)
1361 "Mark all groups between point and mark.
1362 If UNMARK, remove the mark instead."
1363 (interactive "P\nr")
1364 (let ((num (count-lines beg end)))
1367 (- num (gnus-group-mark-group num unmark)))))
1369 (defun gnus-group-mark-buffer (&optional unmark)
1370 "Mark all groups in the buffer.
1371 If UNMARK, remove the mark instead."
1373 (gnus-group-mark-region unmark (point-min) (point-max)))
1375 (defun gnus-group-mark-regexp (regexp)
1376 "Mark all groups that match some regexp."
1377 (interactive "sMark (regexp): ")
1378 (let ((alist (cdr gnus-newsrc-alist))
1381 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1382 (gnus-group-set-mark group))))
1383 (gnus-group-position-point))
1385 (defun gnus-group-remove-mark (group)
1386 "Remove the process mark from GROUP and move point there.
1387 Return nil if the group isn't displayed."
1388 (if (gnus-group-goto-group group)
1390 (gnus-group-mark-group 1 'unmark t)
1392 (setq gnus-group-marked
1393 (delete group gnus-group-marked))
1396 (defun gnus-group-set-mark (group)
1397 "Set the process mark on GROUP."
1398 (if (gnus-group-goto-group group)
1400 (gnus-group-mark-group 1 nil t))
1401 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1403 (defun gnus-group-universal-argument (arg &optional groups func)
1404 "Perform any command on all groups according to the process/prefix convention."
1406 (if (eq (setq func (or func
1409 (substitute-command-keys
1410 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1412 (gnus-error 1 "Undefined key")
1413 (gnus-group-iterate arg
1415 (command-execute func))))
1416 (gnus-group-position-point))
1418 (defun gnus-group-process-prefix (n)
1419 "Return a list of groups to work on.
1420 Take into consideration N (the prefix) and the list of marked groups."
1423 (setq n (prefix-numeric-value n))
1424 ;; There is a prefix, so we return a list of the N next
1426 (let ((way (if (< n 0) -1 1))
1431 (if (setq group (gnus-group-group-name))
1432 (push group groups))
1434 (gnus-group-next-group way)))
1436 ((gnus-region-active-p)
1437 ;; Work on the region between point and mark.
1438 (let ((max (max (point) (mark)))
1441 (goto-char (min (point) (mark)))
1444 (push (gnus-group-group-name) groups)
1445 (zerop (gnus-group-next-group 1))
1447 (nreverse groups))))
1449 ;; No prefix, but a list of marked articles.
1450 (reverse gnus-group-marked))
1452 ;; Neither marked articles or a prefix, so we return the
1454 (let ((group (gnus-group-group-name)))
1455 (and group (list group))))))
1457 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1458 ;;; imagine why I went through these contortions...
1460 (let ((function (make-symbol "gnus-group-iterate-function"))
1461 (window (make-symbol "gnus-group-iterate-window"))
1462 (groups (make-symbol "gnus-group-iterate-groups"))
1463 (group (make-symbol "gnus-group-iterate-group")))
1465 `(defun gnus-group-iterate (arg ,function)
1466 "Iterate FUNCTION over all process/prefixed groups.
1467 FUNCTION will be called with the group name as the paremeter
1468 and with point over the group in question."
1469 (let ((,groups (gnus-group-process-prefix arg))
1470 (,window (selected-window))
1472 (while (setq ,group (pop ,groups))
1473 (select-window ,window)
1474 (gnus-group-remove-mark ,group)
1475 (save-selected-window
1477 (funcall ,function ,group)))))))))
1479 (put 'gnus-group-iterate 'lisp-indent-function 1)
1481 ;; Selecting groups.
1483 (defun gnus-group-read-group (&optional all no-article group select-articles)
1484 "Read news in this newsgroup.
1485 If the prefix argument ALL is non-nil, already read articles become
1486 readable. IF ALL is a number, fetch this number of articles. If the
1487 optional argument NO-ARTICLE is non-nil, no article will be
1488 auto-selected upon group entry. If GROUP is non-nil, fetch that
1491 (let ((no-display (eq all 0))
1492 (group (or group (gnus-group-group-name)))
1493 number active marked entry)
1497 (error "No group on current line"))
1498 (setq marked (gnus-info-marks
1499 (nth 2 (setq entry (gnus-gethash
1500 group gnus-newsrc-hashtb)))))
1501 ;; This group might be a dead group. In that case we have to get
1502 ;; the number of unread articles from `gnus-active-hashtb'.
1504 (cond ((numberp all) all)
1506 ((setq active (gnus-active group))
1507 (- (1+ (cdr active)) (car active)))))
1508 (gnus-summary-read-group
1509 group (or all (and (numberp number)
1510 (zerop (+ number (gnus-range-length
1511 (cdr (assq 'tick marked)))
1513 (cdr (assq 'dormant marked)))))))
1514 no-article nil no-display nil select-articles)))
1516 (defun gnus-group-select-group (&optional all)
1517 "Select this newsgroup.
1518 No article is selected automatically.
1519 If ALL is non-nil, already read articles become readable.
1520 If ALL is a number, fetch this number of articles."
1522 (gnus-group-read-group all t))
1524 (defun gnus-group-quick-select-group (&optional all)
1525 "Select the current group \"quickly\".
1526 This means that no highlighting or scoring will be performed.
1527 If ALL (the prefix argument) is 0, don't even generate the summary
1530 This might be useful if you want to toggle threading
1531 before entering the group."
1533 (require 'gnus-score)
1535 gnus-score-find-score-files-function
1536 gnus-home-score-file
1537 gnus-apply-kill-hook
1538 gnus-summary-expunge-below)
1539 (gnus-group-read-group all t)))
1541 (defun gnus-group-visible-select-group (&optional all)
1542 "Select the current group without hiding any articles."
1544 (let ((gnus-inhibit-limiting t))
1545 (gnus-group-read-group all t)))
1547 (defun gnus-group-select-group-ephemerally ()
1548 "Select the current group without doing any processing whatsoever.
1549 You will actually be entered into a group that's a copy of
1550 the current group; no changes you make while in this group will
1553 (require 'gnus-score)
1555 gnus-score-find-score-files-function gnus-apply-kill-hook
1556 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1557 gnus-summary-mode-hook gnus-select-group-hook
1558 (group (gnus-group-group-name))
1559 (method (gnus-find-method-for-group group)))
1560 (gnus-group-read-ephemeral-group
1561 (gnus-group-prefixed-name group method) method)))
1564 (defun gnus-fetch-group (group)
1565 "Start Gnus if necessary and enter GROUP.
1566 Returns whether the fetching was successful or not."
1567 (interactive "sGroup name: ")
1568 (unless (get-buffer gnus-group-buffer)
1570 (gnus-group-read-group nil nil group))
1573 (defun gnus-fetch-group-other-frame (group)
1574 "Pop up a frame and enter GROUP."
1576 (let ((window (get-buffer-window gnus-group-buffer)))
1578 (select-frame (window-frame window)))
1579 ((= (length (frame-list)) 1)
1580 (select-frame (make-frame)))
1583 (gnus-fetch-group group))
1585 (defvar gnus-ephemeral-group-server 0)
1587 ;; Enter a group that is not in the group buffer. Non-nil is returned
1588 ;; if selection was successful.
1589 (defun gnus-group-read-ephemeral-group (group method &optional activate
1590 quit-config request-only
1592 "Read GROUP from METHOD as an ephemeral group.
1593 If ACTIVATE, request the group first.
1594 If QUIT-CONFIG, use that window configuration when exiting from the
1596 If REQUEST-ONLY, don't actually read the group; just request it.
1597 If SELECT-ARTICLES, only select those articles.
1599 Return the name of the group is selection was successful."
1600 ;; Transform the select method into a unique server.
1601 (when (stringp method)
1602 (setq method (gnus-server-to-method method)))
1604 `(,(car method) ,(concat (cadr method) "-ephemeral")
1605 (,(intern (format "%s-address" (car method))) ,(cadr method))
1607 (let ((group (if (gnus-group-foreign-p group) group
1608 (gnus-group-prefixed-name group method))))
1612 ,gnus-level-default-subscribed nil nil ,method
1614 ,(if quit-config quit-config
1615 (cons gnus-summary-buffer
1616 gnus-current-window-configuration))))))
1618 (push method gnus-ephemeral-servers)
1619 (set-buffer gnus-group-buffer)
1620 (unless (gnus-check-server method)
1621 (error "Unable to contact server: %s" (gnus-status-message method)))
1623 (gnus-activate-group group 'scan)
1624 (unless (gnus-request-group group)
1625 (error "Couldn't request group: %s"
1626 (nnheader-get-report (car method)))))
1630 (when (gnus-group-read-group t t group select-articles)
1635 (defun gnus-group-jump-to-group (group)
1636 "Jump to newsgroup GROUP."
1638 (list (completing-read
1639 "Group: " gnus-active-hashtb nil
1640 (gnus-read-active-file-p)
1642 'gnus-group-history)))
1644 (when (equal group "")
1645 (error "Empty group name"))
1647 (unless (gnus-ephemeral-group-p group)
1648 ;; Either go to the line in the group buffer...
1649 (unless (gnus-group-goto-group group)
1650 ;; ... or insert the line.
1651 (gnus-group-update-group group)
1652 (gnus-group-goto-group group)))
1653 ;; Adjust cursor point.
1654 (gnus-group-position-point))
1656 (defun gnus-group-goto-group (group &optional far)
1657 "Goto to newsgroup GROUP.
1658 If FAR, it is likely that the group is not on the current line."
1663 (point-min) (point-max)
1664 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
1667 ;; It's quite likely that we are on the right line, so
1668 ;; we check the current line first.
1669 ((eq (get-text-property (point) 'gnus-group)
1670 (gnus-intern-safe group gnus-active-hashtb))
1672 ;; Previous and next line are also likely, so we check them as well.
1675 (eq (get-text-property (point) 'gnus-group)
1676 (gnus-intern-safe group gnus-active-hashtb)))
1681 (eq (get-text-property (point) 'gnus-group)
1682 (gnus-intern-safe group gnus-active-hashtb)))
1686 ;; Search through the entire buffer.
1689 (point-min) (point-max)
1690 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
1692 (defun gnus-group-next-group (n &optional silent)
1693 "Go to next N'th newsgroup.
1694 If N is negative, search backward instead.
1695 Returns the difference between N and the number of skips actually
1698 (gnus-group-next-unread-group n t nil silent))
1700 (defun gnus-group-next-unread-group (n &optional all level silent)
1701 "Go to next N'th unread newsgroup.
1702 If N is negative, search backward instead.
1703 If ALL is non-nil, choose any newsgroup, unread or not.
1704 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1705 such group can be found, the next group with a level higher than
1707 Returns the difference between N and the number of skips actually
1710 (let ((backward (< n 0))
1713 (gnus-group-search-forward
1714 backward (or (not gnus-group-goto-unread) all) level))
1718 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1719 (if level " on this level or higher" "")))
1722 (defun gnus-group-prev-group (n)
1723 "Go to previous N'th newsgroup.
1724 Returns the difference between N and the number of skips actually
1727 (gnus-group-next-unread-group (- n) t))
1729 (defun gnus-group-prev-unread-group (n)
1730 "Go to previous N'th unread newsgroup.
1731 Returns the difference between N and the number of skips actually
1734 (gnus-group-next-unread-group (- n)))
1736 (defun gnus-group-next-unread-group-same-level (n)
1737 "Go to next N'th unread newsgroup on the same level.
1738 If N is negative, search backward instead.
1739 Returns the difference between N and the number of skips actually
1742 (gnus-group-next-unread-group n t (gnus-group-group-level))
1743 (gnus-group-position-point))
1745 (defun gnus-group-prev-unread-group-same-level (n)
1746 "Go to next N'th unread newsgroup on the same level.
1747 Returns the difference between N and the number of skips actually
1750 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1751 (gnus-group-position-point))
1753 (defun gnus-group-best-unread-group (&optional exclude-group)
1754 "Go to the group with the highest level.
1755 If EXCLUDE-GROUP, do not go to that group."
1757 (goto-char (point-min))
1761 (setq unread (get-text-property (point) 'gnus-unread))
1762 (when (and (numberp unread) (> unread 0))
1763 (when (and (get-text-property (point) 'gnus-level)
1764 (< (get-text-property (point) 'gnus-level) best)
1765 (or (not exclude-group)
1766 (not (equal exclude-group (gnus-group-group-name)))))
1767 (setq best (get-text-property (point) 'gnus-level))
1768 (setq best-point (point))))
1771 (goto-char best-point))
1772 (gnus-summary-position-point)
1773 (and best-point (gnus-group-group-name))))
1775 (defun gnus-group-first-unread-group ()
1776 "Go to the first group with unread articles."
1779 (let ((opoint (point))
1781 (goto-char (point-min))
1782 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1783 (and (numberp unread) ; Not a topic.
1784 (not (zerop unread))) ; Has unread articles.
1785 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1788 nil)) ; Not success.
1789 (gnus-group-position-point)))
1791 (defun gnus-group-enter-server-mode ()
1792 "Jump to the server buffer."
1794 (gnus-enter-server-buffer))
1796 (defun gnus-group-make-group (name &optional method address args)
1797 "Add a new newsgroup.
1798 The user will be prompted for a NAME, for a select METHOD, and an
1802 (gnus-read-group "Group name: ")
1803 (gnus-read-method "From method: ")))
1805 (when (stringp method)
1806 (setq method (gnus-server-to-method method)))
1807 (let* ((meth (when (and method
1808 (not (gnus-server-equal method gnus-select-method)))
1809 (if address (list (intern method) address)
1811 (nname (if method (gnus-group-prefixed-name name meth) name))
1813 (when (gnus-gethash nname gnus-newsrc-hashtb)
1814 (error "Group %s already exists" nname))
1815 ;; Subscribe to the new group.
1816 (gnus-group-change-level
1817 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1818 gnus-level-default-subscribed gnus-level-killed
1819 (and (gnus-group-group-name)
1820 (gnus-gethash (gnus-group-group-name)
1821 gnus-newsrc-hashtb))
1824 (gnus-set-active nname (cons 1 0))
1825 (unless (gnus-ephemeral-group-p name)
1827 (concat "(gnus-group-set-info '"
1828 (gnus-prin1-to-string (cdr info)) ")")))
1830 (gnus-group-insert-group-line-info nname)
1832 (gnus-group-position-point)
1834 ;; Load the backend and try to make the backend create
1835 ;; the group as well.
1836 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1838 gnus-valid-select-methods)
1840 (gnus-check-server meth)
1841 (when (gnus-check-backend-function 'request-create-group nname)
1842 (gnus-request-create-group nname nil args))
1845 (defun gnus-group-delete-group (group &optional force)
1846 "Delete the current group. Only meaningful with mail groups.
1847 If FORCE (the prefix) is non-nil, all the articles in the group will
1848 be deleted. This is \"deleted\" as in \"removed forever from the face
1849 of the Earth\". There is no undo. The user will be prompted before
1850 doing the deletion."
1852 (list (gnus-group-group-name)
1853 current-prefix-arg))
1855 (error "No group to rename"))
1856 (unless (gnus-check-backend-function 'request-delete-group group)
1857 (error "This backend does not support group deletion"))
1859 (if (not (gnus-yes-or-no-p
1861 "Do you really want to delete %s%s? "
1862 group (if force " and all its contents" ""))))
1864 (gnus-message 6 "Deleting group %s..." group)
1865 (if (not (gnus-request-delete-group group force))
1866 (gnus-error 3 "Couldn't delete group %s" group)
1867 (gnus-message 6 "Deleting group %s...done" group)
1868 (gnus-group-goto-group group)
1869 (gnus-group-kill-group 1 t)
1870 (gnus-sethash group nil gnus-active-hashtb)
1872 (gnus-group-position-point)))
1874 (defun gnus-group-rename-group (group new-name)
1875 "Rename group from GROUP to NEW-NAME.
1876 When used interactively, GROUP is the group under point
1877 and NEW-NAME will be prompted for."
1880 (gnus-group-group-name)
1882 (unless (gnus-check-backend-function
1883 'request-rename-group (gnus-group-group-name))
1884 (error "This backend does not support renaming groups"))
1885 (gnus-read-group "Rename group to: "
1886 (gnus-group-real-name (gnus-group-group-name))))))
1888 (unless (gnus-check-backend-function 'request-rename-group group)
1889 (error "This backend does not support renaming groups"))
1891 (error "No group to rename"))
1892 (when (equal (gnus-group-real-name group) new-name)
1893 (error "Can't rename to the same name"))
1895 ;; We find the proper prefixed name.
1897 (if (gnus-group-native-p group)
1901 (gnus-group-prefixed-name
1902 (gnus-group-real-name new-name)
1903 (gnus-info-method (gnus-get-info group)))))
1905 (gnus-message 6 "Renaming group %s to %s..." group new-name)
1907 (if (not (gnus-request-rename-group group new-name))
1908 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
1909 ;; We rename the group internally by killing it...
1910 (gnus-group-goto-group group)
1911 (gnus-group-kill-group)
1912 ;; ... changing its name ...
1913 (setcar (cdar gnus-list-of-killed-groups) new-name)
1914 ;; ... and then yanking it. Magic!
1915 (gnus-group-yank-group)
1916 (gnus-set-active new-name (gnus-active group))
1917 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
1919 (setq gnus-killed-list (delete group gnus-killed-list))
1920 (gnus-set-active group nil)
1921 (gnus-dribble-touch)
1922 (gnus-group-position-point)))
1924 (defun gnus-group-edit-group (group &optional part)
1925 "Edit the group on the current line."
1926 (interactive (list (gnus-group-group-name)))
1927 (let ((part (or part 'info))
1930 (error "No group on current line"))
1931 (unless (setq info (gnus-get-info group))
1932 (error "Killed group; can't be edited"))
1934 (gnus-close-group group))
1936 ;; Find the proper form to edit.
1937 (cond ((eq part 'method)
1938 (or (gnus-info-method info) "native"))
1940 (gnus-info-params info))
1942 ;; The proper documentation.
1944 "Editing the %s for `%s'."
1946 ((eq part 'method) "select method")
1947 ((eq part 'params) "group parameters")
1951 (gnus-group-edit-group-done ',part ,group form)))))
1953 (defun gnus-group-edit-group-method (group)
1954 "Edit the select method of GROUP."
1955 (interactive (list (gnus-group-group-name)))
1956 (gnus-group-edit-group group 'method))
1958 (defun gnus-group-edit-group-parameters (group)
1959 "Edit the group parameters of GROUP."
1960 (interactive (list (gnus-group-group-name)))
1961 (gnus-group-edit-group group 'params))
1963 (defun gnus-group-edit-group-done (part group form)
1965 (let* ((method (cond ((eq part 'info) (nth 4 form))
1966 ((eq part 'method) form)
1968 (info (cond ((eq part 'info) form)
1969 ((eq part 'method) (gnus-get-info group))
1972 (if (or (not method)
1974 gnus-select-method method))
1975 (gnus-group-real-name (car info))
1976 (gnus-group-prefixed-name
1977 (gnus-group-real-name (car info)) method))
1979 (when (and new-group
1980 (not (equal new-group group)))
1981 (when (gnus-group-goto-group group)
1982 (gnus-group-kill-group 1))
1983 (gnus-activate-group new-group))
1985 (if (not (and info new-group))
1986 (gnus-group-set-info form (or new-group group) part)
1987 (setq info (gnus-copy-sequence info))
1988 (setcar info new-group)
1989 (unless (gnus-server-equal method "native")
1990 (unless (nthcdr 3 info)
1991 (nconc info (list nil nil)))
1992 (unless (nthcdr 4 info)
1993 (nconc info (list nil)))
1994 (gnus-info-set-method info method))
1995 (gnus-group-set-info info))
1996 (gnus-group-update-group (or new-group group))
1997 (gnus-group-position-point)))
1999 (defun gnus-group-make-useful-group (group method)
2000 "Create one of the groups described in `gnus-useful-groups'."
2002 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2004 gnus-useful-groups)))
2005 (list (cadr entry) (caddr entry))))
2006 (setq method (gnus-copy-sequence method))
2008 (while (setq entry (memq (assq 'eval method) method))
2009 (setcar entry (eval (cadar entry)))))
2010 (gnus-group-make-group group method))
2012 (defun gnus-group-make-help-group ()
2013 "Create the Gnus documentation group."
2015 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2016 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2017 (when (gnus-gethash name gnus-newsrc-hashtb)
2018 (error "Documentation group already exists"))
2020 (gnus-message 1 "Couldn't find doc group")
2021 (gnus-group-make-group
2022 (gnus-group-real-name name)
2023 (list 'nndoc "gnus-help"
2024 (list 'nndoc-address file)
2025 (list 'nndoc-article-type 'mbox)))))
2026 (gnus-group-position-point))
2028 (defun gnus-group-make-doc-group (file type)
2029 "Create a group that uses a single file as the source."
2031 (list (read-file-name "File name: ")
2032 (and current-prefix-arg 'ask)))
2033 (when (eq type 'ask)
2038 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
2040 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2041 ((= char ?b) 'babyl)
2042 ((= char ?d) 'digest)
2043 ((= char ?f) 'forward)
2045 (t (setq err (format "%c unknown. " char))
2048 (let* ((file (expand-file-name file))
2049 (name (gnus-generate-new-group-name
2050 (gnus-group-prefixed-name
2051 (file-name-nondirectory file) '(nndoc "")))))
2052 (gnus-group-make-group
2053 (gnus-group-real-name name)
2055 (list 'nndoc-address file)
2056 (list 'nndoc-article-type (or type 'guess))))))
2058 (defvar nnweb-type-definition)
2059 (defvar gnus-group-web-type-history nil)
2060 (defvar gnus-group-web-search-history nil)
2061 (defun gnus-group-make-web-group (&optional solid)
2062 "Create an ephemeral nnweb group.
2063 If SOLID (the prefix), create a solid group."
2067 (if solid (gnus-read-group "Group name: ")
2068 (message-unique-id)))
2069 (default-type (or (car gnus-group-web-type-history)
2070 (symbol-name (caar nnweb-type-definition))))
2074 (format "Search engine type (default %s): " default-type)
2075 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2076 nnweb-type-definition)
2077 nil t nil 'gnus-group-web-type-history)
2082 (cons (or (car gnus-group-web-search-history) "") 0)
2083 'gnus-group-web-search-history))
2085 `(nnweb ,group (nnweb-search ,search)
2086 (nnweb-type ,(intern type))
2087 (nnweb-ephemeral-p t))))
2089 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2090 (gnus-group-read-ephemeral-group
2092 (cons (current-buffer)
2093 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2095 (defun gnus-group-make-archive-group (&optional all)
2096 "Create the (ding) Gnus archive group of the most recent articles.
2097 Given a prefix, create a full group."
2099 (let ((group (gnus-group-prefixed-name
2100 (if all "ding.archives" "ding.recent") '(nndir ""))))
2101 (when (gnus-gethash group gnus-newsrc-hashtb)
2102 (error "Archive group already exists"))
2103 (gnus-group-make-group
2104 (gnus-group-real-name group)
2105 (list 'nndir (if all "hpc" "edu")
2106 (list 'nndir-directory
2107 (if all gnus-group-archive-directory
2108 gnus-group-recent-archive-directory))))
2109 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2111 (defun gnus-group-make-directory-group (dir)
2112 "Create an nndir group.
2113 The user will be prompted for a directory. The contents of this
2114 directory will be used as a newsgroup. The directory should contain
2115 mail messages or news articles in files that have numeric names."
2117 (list (read-file-name "Create group from directory: ")))
2118 (unless (file-exists-p dir)
2119 (error "No such directory"))
2120 (unless (file-directory-p dir)
2121 (error "Not a directory"))
2125 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2127 (gnus-group-prefixed-name
2128 (concat (file-name-as-directory (directory-file-name dir))
2131 (setq ext (format "<%d>" (setq i (1+ i)))))
2132 (gnus-group-make-group
2133 (gnus-group-real-name group)
2134 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2136 (defun gnus-group-make-kiboze-group (group address scores)
2137 "Create an nnkiboze group.
2138 The user will be prompted for a name, a regexp to match groups, and
2139 score file entries for articles to include in the group."
2142 (read-string "nnkiboze group name: ")
2143 (read-string "Source groups (regexp): ")
2144 (let ((headers (mapcar (lambda (group) (list group))
2145 '("subject" "from" "number" "date" "message-id"
2146 "references" "chars" "lines" "xref"
2147 "followup" "all" "body" "head")))
2148 scores header regexp regexps)
2149 (while (not (equal "" (setq header (completing-read
2150 "Match on header: " headers nil t))))
2152 (while (not (equal "" (setq regexp (read-string
2153 (format "Match on %s (string): "
2155 (push (list regexp nil nil 'r) regexps))
2156 (push (cons header regexps) scores))
2158 (gnus-group-make-group group "nnkiboze" address)
2159 (with-temp-file (gnus-score-file-name (concat "nnkiboze:" group))
2160 (let (emacs-lisp-mode-hook)
2161 (pp scores (current-buffer)))))
2163 (defun gnus-group-add-to-virtual (n vgroup)
2164 "Add the current group to a virtual group."
2166 (list current-prefix-arg
2167 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2169 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2170 (error "%s is not an nnvirtual group" vgroup))
2171 (gnus-close-group vgroup)
2172 (let* ((groups (gnus-group-process-prefix n))
2173 (method (gnus-info-method (gnus-get-info vgroup))))
2174 (setcar (cdr method)
2176 (nth 1 method) "\\|"
2179 (gnus-group-remove-mark s)
2180 (concat "\\(^" (regexp-quote s) "$\\)"))
2182 (gnus-group-position-point))
2184 (defun gnus-group-make-empty-virtual (group)
2185 "Create a new, fresh, empty virtual group."
2186 (interactive "sCreate new, empty virtual group: ")
2187 (let* ((method (list 'nnvirtual "^$"))
2188 (pgroup (gnus-group-prefixed-name group method)))
2189 ;; Check whether it exists already.
2190 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2191 (error "Group %s already exists" pgroup))
2192 ;; Subscribe the new group after the group on the current line.
2193 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2194 (gnus-group-update-group pgroup)
2196 (gnus-group-position-point)))
2198 (defun gnus-group-enter-directory (dir)
2199 "Enter an ephemeral nneething group."
2200 (interactive "DDirectory to read: ")
2201 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2202 (leaf (gnus-group-prefixed-name
2203 (file-name-nondirectory (directory-file-name dir))
2205 (name (gnus-generate-new-group-name leaf)))
2206 (unless (gnus-group-read-ephemeral-group
2208 (cons (current-buffer)
2209 (if (eq major-mode 'gnus-summary-mode)
2211 (error "Couldn't enter %s" dir))))
2213 ;; Group sorting commands
2214 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2216 (defun gnus-group-sort-groups (func &optional reverse)
2217 "Sort the group buffer according to FUNC.
2218 When used interactively, the sorting function used will be
2219 determined by the `gnus-group-sort-function' variable.
2220 If REVERSE (the prefix), reverse the sorting order."
2221 (interactive (list gnus-group-sort-function current-prefix-arg))
2222 (funcall gnus-group-sort-alist-function
2223 (gnus-make-sort-function func) reverse)
2224 (gnus-group-list-groups)
2225 (gnus-dribble-touch))
2227 (defun gnus-group-sort-flat (func reverse)
2228 ;; We peel off the dummy group from the alist.
2230 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2231 (pop gnus-newsrc-alist))
2233 (setq gnus-newsrc-alist
2234 (sort gnus-newsrc-alist func))
2236 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2237 ;; Regenerate the hash table.
2238 (gnus-make-hashtable-from-newsrc-alist)))
2240 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2241 "Sort the group buffer alphabetically by group name.
2242 If REVERSE, sort in reverse order."
2244 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2246 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2247 "Sort the group buffer by number of unread articles.
2248 If REVERSE, sort in reverse order."
2250 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2252 (defun gnus-group-sort-groups-by-level (&optional reverse)
2253 "Sort the group buffer by group level.
2254 If REVERSE, sort in reverse order."
2256 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2258 (defun gnus-group-sort-groups-by-score (&optional reverse)
2259 "Sort the group buffer by group score.
2260 If REVERSE, sort in reverse order."
2262 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2264 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2265 "Sort the group buffer by group rank.
2266 If REVERSE, sort in reverse order."
2268 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2270 (defun gnus-group-sort-groups-by-method (&optional reverse)
2271 "Sort the group buffer alphabetically by backend name.
2272 If REVERSE, sort in reverse order."
2274 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2276 ;;; Selected group sorting.
2278 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2279 "Sort the process/prefixed groups."
2280 (interactive (list current-prefix-arg gnus-group-sort-function))
2281 (let ((groups (gnus-group-process-prefix n)))
2282 (funcall gnus-group-sort-selected-function
2283 groups (gnus-make-sort-function func) reverse)
2284 (gnus-group-list-groups)))
2286 (defun gnus-group-sort-selected-flat (groups func reverse)
2287 (let (entries infos)
2288 ;; First find all the group entries for these groups.
2290 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2292 ;; Then sort the infos.
2296 (lambda (entry) (car entry))
2297 (setq entries (nreverse entries)))
2300 (setq infos (nreverse infos)))
2301 ;; Go through all the infos and replace the old entries
2302 ;; with the new infos.
2304 (setcar (car entries) (pop infos))
2306 ;; Update the hashtable.
2307 (gnus-make-hashtable-from-newsrc-alist)))
2309 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2310 "Sort the group buffer alphabetically by group name.
2311 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2312 sort in reverse order."
2313 (interactive (gnus-interactive "P\ny"))
2314 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2316 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
2317 "Sort the group buffer by number of unread articles.
2318 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2319 sort in reverse order."
2320 (interactive (gnus-interactive "P\ny"))
2321 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
2323 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
2324 "Sort the group buffer by group level.
2325 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2326 sort in reverse order."
2327 (interactive (gnus-interactive "P\ny"))
2328 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
2330 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
2331 "Sort the group buffer by group score.
2332 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2333 sort in reverse order."
2334 (interactive (gnus-interactive "P\ny"))
2335 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
2337 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
2338 "Sort the group buffer by group rank.
2339 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2340 sort in reverse order."
2341 (interactive (gnus-interactive "P\ny"))
2342 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
2344 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
2345 "Sort the group buffer alphabetically by backend name.
2346 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2347 sort in reverse order."
2348 (interactive (gnus-interactive "P\ny"))
2349 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
2351 ;;; Sorting predicates.
2353 (defun gnus-group-sort-by-alphabet (info1 info2)
2354 "Sort alphabetically."
2355 (string< (gnus-info-group info1) (gnus-info-group info2)))
2357 (defun gnus-group-sort-by-real-name (info1 info2)
2358 "Sort alphabetically on real (unprefixed) names."
2359 (string< (gnus-group-real-name (gnus-info-group info1))
2360 (gnus-group-real-name (gnus-info-group info2))))
2362 (defun gnus-group-sort-by-unread (info1 info2)
2363 "Sort by number of unread articles."
2364 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2365 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2366 (< (or (and (numberp n1) n1) 0)
2367 (or (and (numberp n2) n2) 0))))
2369 (defun gnus-group-sort-by-level (info1 info2)
2371 (< (gnus-info-level info1) (gnus-info-level info2)))
2373 (defun gnus-group-sort-by-method (info1 info2)
2374 "Sort alphabetically by backend name."
2375 (string< (symbol-name (car (gnus-find-method-for-group
2376 (gnus-info-group info1) info1)))
2377 (symbol-name (car (gnus-find-method-for-group
2378 (gnus-info-group info2) info2)))))
2380 (defun gnus-group-sort-by-score (info1 info2)
2381 "Sort by group score."
2382 (< (gnus-info-score info1) (gnus-info-score info2)))
2384 (defun gnus-group-sort-by-rank (info1 info2)
2385 "Sort by level and score."
2386 (let ((level1 (gnus-info-level info1))
2387 (level2 (gnus-info-level info2)))
2388 (or (< level1 level2)
2389 (and (= level1 level2)
2390 (> (gnus-info-score info1) (gnus-info-score info2))))))
2394 (defun gnus-group-clear-data (&optional arg)
2395 "Clear all marks and read ranges from the current group."
2397 (gnus-group-iterate arg
2400 (gnus-info-clear-data (setq info (gnus-get-info group)))
2401 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2402 (when (gnus-group-goto-group group)
2403 (gnus-group-update-group-line))))))
2405 (defun gnus-group-clear-data-on-native-groups ()
2406 "Clear all marks and read ranges from all native groups."
2408 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2409 (let ((alist (cdr gnus-newsrc-alist))
2411 (while (setq info (pop alist))
2412 (when (gnus-group-native-p (gnus-info-group info))
2413 (gnus-info-clear-data info)))
2414 (gnus-get-unread-articles)
2415 (gnus-dribble-touch)
2416 (when (gnus-y-or-n-p
2417 "Move the cache away to avoid problems in the future? ")
2418 (call-interactively 'gnus-cache-move-cache)))))
2420 (defun gnus-info-clear-data (info)
2421 "Clear all marks and read ranges from INFO."
2422 (let ((group (gnus-info-group info)))
2425 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2426 (gnus-info-set-read ',info ',(gnus-info-read info))
2427 (when (gnus-group-goto-group ,group)
2428 (gnus-group-update-group-line))))
2429 (gnus-info-set-read info nil)
2430 (when (gnus-info-marks info)
2431 (gnus-info-set-marks info nil))))
2433 ;; Group catching up.
2435 (defun gnus-group-catchup-current (&optional n all)
2436 "Mark all articles not marked as unread in current newsgroup as read.
2437 If prefix argument N is numeric, the next N newsgroups will be
2438 caught up. If ALL is non-nil, marked articles will also be marked as
2439 read. Cross references (Xref: header) of articles are ignored.
2440 The number of newsgroups that this function was unable to catch
2443 (let ((groups (gnus-group-process-prefix n))
2445 (unless groups (error "No groups selected"))
2447 (or (not gnus-interactive-catchup) ;Without confirmation?
2452 "Do you really want to mark all articles in %s as read? "
2453 "Mark all unread articles in %s as read? ")
2454 (if (= (length groups) 1)
2456 (format "these %d groups" (length groups)))))))
2459 ;; Virtual groups have to be given special treatment.
2460 (let ((method (gnus-find-method-for-group (car groups))))
2461 (when (eq 'nnvirtual (car method))
2462 (nnvirtual-catchup-group
2463 (gnus-group-real-name (car groups)) (nth 1 method) all)))
2464 (gnus-group-remove-mark (car groups))
2465 (if (>= (gnus-group-group-level) gnus-level-zombie)
2466 (gnus-message 2 "Dead groups can't be caught up")
2468 (gnus-group-goto-group (car groups))
2469 (gnus-group-catchup (car groups) all))
2470 (gnus-group-update-group-line)
2471 (setq ret (1+ ret))))
2472 (setq groups (cdr groups)))
2473 (gnus-group-next-unread-group 1)
2476 (defun gnus-group-catchup-current-all (&optional n)
2477 "Mark all articles in current newsgroup as read.
2478 Cross references (Xref: header) of articles are ignored."
2480 (gnus-group-catchup-current n 'all))
2482 (defun gnus-group-catchup (group &optional all)
2483 "Mark all articles in GROUP as read.
2484 If ALL is non-nil, all articles are marked as read.
2485 The return value is the number of articles that were marked as read,
2486 or nil if no action could be taken."
2487 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2489 ;; Do the updating only if the newsgroup isn't killed.
2490 (if (not (numberp (car entry)))
2491 (gnus-message 1 "Can't catch up %s; non-active group" group)
2492 ;; Do auto-expirable marks if that's required.
2493 (when (gnus-group-auto-expirable-p group)
2494 (gnus-add-marked-articles
2495 group 'expire (gnus-list-of-unread-articles group))
2497 (let ((marks (nth 3 (nth 2 entry))))
2498 (gnus-add-marked-articles
2499 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2500 (gnus-add-marked-articles
2501 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2503 (gnus-update-read-articles group nil)
2504 ;; Also nix out the lists of marks and dormants.
2506 (gnus-add-marked-articles group 'tick nil nil 'force)
2507 (gnus-add-marked-articles group 'dormant nil nil 'force))
2508 (let ((gnus-newsgroup-name group))
2509 (gnus-run-hooks 'gnus-group-catchup-group-hook))
2512 (defun gnus-group-expire-articles (&optional n)
2513 "Expire all expirable articles in the current newsgroup."
2515 (let ((groups (gnus-group-process-prefix n))
2518 (error "No groups to expire"))
2519 (while (setq group (pop groups))
2520 (gnus-group-remove-mark group)
2521 (when (gnus-check-backend-function 'request-expire-articles group)
2522 (gnus-message 6 "Expiring articles in %s..." group)
2523 (let* ((info (gnus-get-info group))
2524 (expirable (if (gnus-group-total-expirable-p group)
2525 (cons nil (gnus-list-of-read-articles group))
2526 (assq 'expire (gnus-info-marks info))))
2527 (expiry-wait (gnus-group-find-parameter group 'expiry-wait)))
2531 (gnus-compress-sequence
2533 ;; We set the expiry variables to the group
2535 (let ((nnmail-expiry-wait-function nil)
2536 (nnmail-expiry-wait expiry-wait))
2537 (gnus-request-expire-articles
2538 (gnus-uncompress-sequence (cdr expirable)) group))
2539 ;; Just expire using the normal expiry values.
2540 (gnus-request-expire-articles
2541 (gnus-uncompress-sequence (cdr expirable)) group))))
2542 (gnus-close-group group))
2543 (gnus-message 6 "Expiring articles in %s...done" group)))
2544 (gnus-dribble-touch)
2545 (gnus-group-position-point))))
2547 (defun gnus-group-expire-all-groups ()
2548 "Expire all expirable articles in all newsgroups."
2551 (gnus-message 5 "Expiring...")
2552 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2553 (cdr gnus-newsrc-alist))))
2554 (gnus-group-expire-articles nil)))
2555 (gnus-group-position-point)
2556 (gnus-message 5 "Expiring...done"))
2558 (defun gnus-group-set-current-level (n level)
2559 "Set the level of the next N groups to LEVEL."
2564 (let ((s (read-string
2565 (format "Level (default %s): "
2566 (or (gnus-group-group-level)
2567 gnus-level-default-subscribed)))))
2568 (if (string-match "^\\s-*$" s)
2569 (int-to-string (or (gnus-group-group-level)
2570 gnus-level-default-subscribed))
2572 (unless (and (>= level 1) (<= level gnus-level-killed))
2573 (error "Illegal level: %d" level))
2574 (let ((groups (gnus-group-process-prefix n))
2576 (while (setq group (pop groups))
2577 (gnus-group-remove-mark group)
2578 (gnus-message 6 "Changed level of %s from %d to %d"
2579 group (or (gnus-group-group-level) gnus-level-killed)
2581 (gnus-group-change-level
2582 group level (or (gnus-group-group-level) gnus-level-killed))
2583 (gnus-group-update-group-line)))
2584 (gnus-group-position-point))
2586 (defun gnus-group-unsubscribe (&optional n)
2587 "Unsubscribe the current group."
2589 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2591 (defun gnus-group-subscribe (&optional n)
2592 "Subscribe the current group."
2594 (gnus-group-unsubscribe-current-group n 'subscribe))
2596 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2597 "Toggle subscription of the current group.
2598 If given numerical prefix, toggle the N next groups."
2600 (let ((groups (gnus-group-process-prefix n))
2603 (setq group (car groups)
2604 groups (cdr groups))
2605 (gnus-group-remove-mark group)
2606 (gnus-group-unsubscribe-group
2609 ((eq do-sub 'unsubscribe)
2610 gnus-level-default-unsubscribed)
2611 ((eq do-sub 'subscribe)
2612 gnus-level-default-subscribed)
2613 ((<= (gnus-group-group-level) gnus-level-subscribed)
2614 gnus-level-default-unsubscribed)
2616 gnus-level-default-subscribed))
2618 (gnus-group-update-group-line))
2619 (gnus-group-next-group 1)))
2621 (defun gnus-group-unsubscribe-group (group &optional level silent)
2622 "Toggle subscription to GROUP.
2623 Killed newsgroups are subscribed. If SILENT, don't try to update the
2626 (list (completing-read
2627 "Group: " gnus-active-hashtb nil
2628 (gnus-read-active-file-p)
2630 'gnus-group-history)))
2631 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2633 ((string-match "^[ \t]*$" group)
2634 (error "Empty group name"))
2636 ;; Toggle subscription flag.
2637 (gnus-group-change-level
2638 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
2639 gnus-level-subscribed)
2640 (1+ gnus-level-subscribed)
2641 gnus-level-default-subscribed)))
2643 (gnus-group-update-group group)))
2644 ((and (stringp group)
2645 (or (not (gnus-read-active-file-p))
2646 (gnus-active group)))
2647 ;; Add new newsgroup.
2648 (gnus-group-change-level
2650 (if level level gnus-level-default-subscribed)
2651 (or (and (member group gnus-zombie-list)
2654 (when (gnus-group-group-name)
2655 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2657 (gnus-group-update-group group)))
2658 (t (error "No such newsgroup: %s" group)))
2659 (gnus-group-position-point)))
2661 (defun gnus-group-transpose-groups (n)
2662 "Move the current newsgroup up N places.
2663 If given a negative prefix, move down instead. The difference between
2664 N and the number of steps taken is returned."
2666 (unless (gnus-group-group-name)
2667 (error "No group on current line"))
2668 (gnus-group-kill-group 1)
2670 (forward-line (- n))
2671 (gnus-group-yank-group)
2672 (gnus-group-position-point)))
2674 (defun gnus-group-kill-all-zombies ()
2675 "Kill all zombie newsgroups."
2677 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2678 (setq gnus-zombie-list nil)
2679 (gnus-dribble-touch)
2680 (gnus-group-list-groups))
2682 (defun gnus-group-kill-region (begin end)
2683 "Kill newsgroups in current region (excluding current point).
2684 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2699 (beginning-of-line) ;Important when LINES < 1
2700 (gnus-group-kill-group lines)))
2702 (defun gnus-group-kill-group (&optional n discard)
2703 "Kill the next N groups.
2704 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2705 However, only groups that were alive can be yanked; already killed
2706 groups or zombie groups can't be yanked.
2707 The return value is the name of the group that was killed, or a list
2710 (let ((buffer-read-only nil)
2711 (groups (gnus-group-process-prefix n))
2712 group entry level out)
2713 (if (< (length groups) 10)
2714 ;; This is faster when there are few groups.
2716 (push (setq group (pop groups)) out)
2717 (gnus-group-remove-mark group)
2718 (setq level (gnus-group-group-level))
2720 (when (and (not discard)
2721 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2724 (gnus-group-goto-group ,(gnus-group-group-name))
2725 (gnus-group-yank-group)))
2726 (push (cons (car entry) (nth 2 entry))
2727 gnus-list-of-killed-groups))
2728 (gnus-group-change-level
2729 (if entry entry group) gnus-level-killed (if entry nil level)))
2730 ;; If there are lots and lots of groups to be killed, we use
2731 ;; this thing instead.
2733 (setq groups (nreverse groups))
2735 (gnus-group-remove-mark (setq group (pop groups)))
2737 (push group gnus-killed-list)
2738 (setq gnus-newsrc-alist
2739 (delq (assoc group gnus-newsrc-alist)
2741 (when gnus-group-change-level-function
2742 (funcall gnus-group-change-level-function
2743 group gnus-level-killed 3))
2745 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2746 (push (cons (car entry) (nth 2 entry))
2747 gnus-list-of-killed-groups)
2748 (setcdr (cdr entry) (cdddr entry)))
2749 ((member group gnus-zombie-list)
2750 (setq gnus-zombie-list (delete group gnus-zombie-list))))
2751 ;; There may be more than one instance displayed.
2752 (while (gnus-group-goto-group group)
2753 (gnus-delete-line)))
2754 (gnus-make-hashtable-from-newsrc-alist)))
2756 (gnus-group-position-point)
2757 (if (< (length out) 2) (car out) (nreverse out))))
2759 (defun gnus-group-yank-group (&optional arg)
2760 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
2761 The numeric ARG specifies how many newsgroups are to be yanked. The
2762 name of the newsgroup yanked is returned, or (if several groups are
2763 yanked) a list of yanked groups is returned."
2765 (setq arg (or arg 1))
2766 (let (info group prev out)
2767 (while (>= (decf arg) 0)
2768 (when (not (setq info (pop gnus-list-of-killed-groups)))
2769 (error "No more newsgroups to yank"))
2770 (push (setq group (nth 1 info)) out)
2771 ;; Find which newsgroup to insert this one before - search
2772 ;; backward until something suitable is found. If there are no
2773 ;; other newsgroups in this buffer, just make this newsgroup the
2775 (setq prev (gnus-group-group-name))
2776 (gnus-group-change-level
2777 info (gnus-info-level (cdr info)) gnus-level-killed
2778 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
2780 (gnus-group-insert-group-line-info group)
2782 `(when (gnus-group-goto-group ,group)
2783 (gnus-group-kill-group 1))))
2785 (gnus-group-position-point)
2786 (if (< (length out) 2) (car out) (nreverse out))))
2788 (defun gnus-group-kill-level (level)
2789 "Kill all groups that is on a certain LEVEL."
2790 (interactive "nKill all groups on level: ")
2792 ((= level gnus-level-zombie)
2793 (setq gnus-killed-list
2794 (nconc gnus-zombie-list gnus-killed-list))
2795 (setq gnus-zombie-list nil))
2796 ((and (< level gnus-level-zombie)
2798 (or gnus-expert-user
2801 "Do you really want to kill all groups on level %d? "
2803 (let* ((prev gnus-newsrc-alist)
2806 (if (= (gnus-info-level (car alist)) level)
2808 (push (gnus-info-group (car alist)) gnus-killed-list)
2809 (setcdr prev (cdr alist)))
2811 (setq alist (cdr alist)))
2812 (gnus-make-hashtable-from-newsrc-alist)
2813 (gnus-group-list-groups)))
2815 (error "Can't kill; illegal level: %d" level))))
2817 (defun gnus-group-list-all-groups (&optional arg)
2818 "List all newsgroups with level ARG or lower.
2819 Default is gnus-level-unsubscribed, which lists all subscribed and most
2820 unsubscribed groups."
2822 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
2824 ;; Redefine this to list ALL killed groups if prefix arg used.
2825 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
2826 (defun gnus-group-list-killed (&optional arg)
2827 "List all killed newsgroups in the group buffer.
2828 If ARG is non-nil, list ALL killed groups known to Gnus. This may
2829 entail asking the server for the groups."
2831 ;; Find all possible killed newsgroups if arg.
2833 (gnus-get-killed-groups))
2834 (if (not gnus-killed-list)
2835 (gnus-message 6 "No killed groups")
2836 (let (gnus-group-list-mode)
2837 (funcall gnus-group-prepare-function
2838 gnus-level-killed t gnus-level-killed))
2839 (goto-char (point-min)))
2840 (gnus-group-position-point))
2842 (defun gnus-group-list-zombies ()
2843 "List all zombie newsgroups in the group buffer."
2845 (if (not gnus-zombie-list)
2846 (gnus-message 6 "No zombie groups")
2847 (let (gnus-group-list-mode)
2848 (funcall gnus-group-prepare-function
2849 gnus-level-zombie t gnus-level-zombie))
2850 (goto-char (point-min)))
2851 (gnus-group-position-point))
2853 (defun gnus-group-list-active ()
2854 "List all groups that are available from the server(s)."
2856 ;; First we make sure that we have really read the active file.
2857 (unless (gnus-read-active-file-p)
2858 (let ((gnus-read-active-file t))
2859 (gnus-read-active-file)))
2860 ;; Find all groups and sort them.
2868 (push (symbol-name sym) list)))
2872 (buffer-read-only nil)
2876 (gnus-add-text-properties
2877 (point) (prog1 (1+ (point))
2879 (setq group (pop groups)) "\n"))
2880 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
2882 'gnus-level (inline (gnus-group-level group)))))
2883 (goto-char (point-min))))
2885 (defun gnus-activate-all-groups (level)
2886 "Activate absolutely all groups."
2887 (interactive (list gnus-level-unsubscribed))
2888 (let ((gnus-activate-level level)
2889 (gnus-activate-foreign-newsgroups level))
2890 (gnus-group-get-new-news)))
2892 (defun gnus-group-get-new-news (&optional arg)
2893 "Get newly arrived articles.
2894 If ARG is a number, it specifies which levels you are interested in
2895 re-scanning. If ARG is non-nil and not a number, this will force
2896 \"hard\" re-reading of the active files from all servers."
2898 (let ((gnus-inhibit-demon t))
2899 (gnus-run-hooks 'gnus-get-new-news-hook)
2901 ;; Read any slave files.
2903 (gnus-master-read-slave-newsrc))
2905 ;; We might read in new NoCeM messages here.
2906 (when (and gnus-use-nocem
2908 (gnus-nocem-scan-groups))
2909 ;; If ARG is not a number, then we read the active file.
2910 (when (and arg (not (numberp arg)))
2911 (let ((gnus-read-active-file t))
2912 (gnus-read-active-file))
2915 ;; If the user wants it, we scan for new groups.
2916 (when (eq gnus-check-new-newsgroups 'always)
2917 (gnus-find-new-newsgroups)))
2919 (setq arg (gnus-group-default-level arg t))
2920 (if (and gnus-read-active-file (not arg))
2922 (gnus-read-active-file)
2923 (gnus-get-unread-articles arg))
2924 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
2925 (gnus-get-unread-articles arg)))
2926 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
2927 (gnus-group-list-groups (and (numberp arg)
2928 (max (car gnus-group-list-mode) arg)))))
2930 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
2931 "Check for newly arrived news in the current group (and the N-1 next groups).
2932 The difference between N and the number of newsgroup checked is returned.
2933 If N is negative, this group and the N-1 previous groups will be checked."
2935 (let* ((groups (gnus-group-process-prefix n))
2936 (ret (if (numberp n) (- n (length groups)) 0))
2940 (while (setq group (pop groups))
2941 (gnus-group-remove-mark group)
2942 ;; Bypass any previous denials from the server.
2943 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
2944 (if (gnus-activate-group group (if dont-scan nil 'scan))
2946 (gnus-get-unread-articles-in-group
2947 (gnus-get-info group) (gnus-active group) t)
2948 (unless (gnus-virtual-group-p group)
2949 (gnus-close-group group))
2951 (gnus-agent-save-group-info
2952 method (gnus-group-real-name group) (gnus-active group)))
2953 (gnus-group-update-group group))
2954 (if (eq (gnus-server-status (gnus-find-method-for-group group))
2956 (gnus-error 3 "Server denied access")
2957 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
2960 (when gnus-goto-next-group-when-activating
2961 (gnus-group-next-unread-group 1 t))
2962 (gnus-summary-position-point)
2965 (defun gnus-group-fetch-faq (group &optional faq-dir)
2966 "Fetch the FAQ for the current group.
2967 If given a prefix argument, prompt for the FAQ dir
2971 (gnus-group-group-name)
2972 (when current-prefix-arg
2974 "Faq dir: " (and (listp gnus-group-faq-directory)
2975 (mapcar (lambda (file) (list file))
2976 gnus-group-faq-directory))))))
2978 (error "No group name given"))
2979 (let ((dirs (or faq-dir gnus-group-faq-directory))
2981 (unless (listp dirs)
2982 (setq dirs (list dirs)))
2983 (while (and (not found)
2984 (setq dir (pop dirs)))
2985 (let ((name (gnus-group-real-name group)))
2986 (setq file (concat (file-name-as-directory dir) name)))
2987 (if (not (file-exists-p file))
2988 (gnus-message 1 "No such file: %s" file)
2989 (let ((enable-local-variables nil))
2993 (defun gnus-group-describe-group (force &optional group)
2994 "Display a description of the current newsgroup."
2995 (interactive (list current-prefix-arg (gnus-group-group-name)))
2996 (let* ((method (gnus-find-method-for-group group))
2997 (mname (gnus-group-prefixed-name "" method))
3000 gnus-description-hashtb)
3001 (gnus-sethash mname nil gnus-description-hashtb))
3003 (error "No group name given"))
3004 (when (or (and gnus-description-hashtb
3005 ;; We check whether this group's method has been
3006 ;; queried for a description file.
3007 (gnus-gethash mname gnus-description-hashtb))
3008 (setq desc (gnus-group-get-description group))
3009 (gnus-read-descriptions-file method))
3011 (or desc (gnus-gethash group gnus-description-hashtb)
3012 "No description available")))))
3014 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3015 (defun gnus-group-describe-all-groups (&optional force)
3016 "Pop up a buffer with descriptions of all newsgroups."
3019 (setq gnus-description-hashtb nil))
3020 (when (not (or gnus-description-hashtb
3021 (gnus-read-all-descriptions-files)))
3022 (error "Couldn't request descriptions file"))
3023 (let ((buffer-read-only nil)
3029 (insert (format " *: %-20s %s\n" (symbol-name group)
3030 (symbol-value group)))
3031 (gnus-add-text-properties
3032 b (1+ b) (list 'gnus-group group
3033 'gnus-unread t 'gnus-marked nil
3034 'gnus-level (1+ gnus-level-subscribed))))
3035 gnus-description-hashtb)
3036 (goto-char (point-min))
3037 (gnus-group-position-point)))
3039 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3040 (defun gnus-group-apropos (regexp &optional search-description)
3041 "List all newsgroups that have names that match a regexp."
3042 (interactive "sGnus apropos (regexp): ")
3044 (obuf (current-buffer))
3046 ;; Go through all newsgroups that are known to Gnus.
3049 (and (symbol-name group)
3050 (string-match regexp (symbol-name group))
3051 (symbol-value group)
3052 (push (symbol-name group) groups)))
3054 ;; Also go through all descriptions that are known to Gnus.
3055 (when search-description
3058 (and (string-match regexp (symbol-value group))
3059 (gnus-active (symbol-name group))
3060 (push (symbol-name group) groups)))
3061 gnus-description-hashtb))
3063 (gnus-message 3 "No groups matched \"%s\"." regexp)
3064 ;; Print out all the groups.
3066 (pop-to-buffer "*Gnus Help*")
3067 (buffer-disable-undo)
3069 (setq groups (sort groups 'string<))
3071 ;; Groups may be entered twice into the list of groups.
3072 (when (not (string= (car groups) prev))
3073 (insert (setq prev (car groups)) "\n")
3074 (when (and gnus-description-hashtb
3075 (setq des (gnus-gethash (car groups)
3076 gnus-description-hashtb)))
3077 (insert " " des "\n")))
3078 (setq groups (cdr groups)))
3079 (goto-char (point-min))))
3080 (pop-to-buffer obuf)))
3082 (defun gnus-group-description-apropos (regexp)
3083 "List all newsgroups that have names or descriptions that match a regexp."
3084 (interactive "sGnus description apropos (regexp): ")
3085 (when (not (or gnus-description-hashtb
3086 (gnus-read-all-descriptions-files)))
3087 (error "Couldn't request descriptions file"))
3088 (gnus-group-apropos regexp t))
3090 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3091 (defun gnus-group-list-matching (level regexp &optional all lowest)
3092 "List all groups with unread articles that match REGEXP.
3093 If the prefix LEVEL is non-nil, it should be a number that says which
3094 level to cut off listing groups.
3095 If ALL, also list groups with no unread articles.
3096 If LOWEST, don't list groups with level lower than LOWEST.
3098 This command may read the active file."
3099 (interactive "P\nsList newsgroups matching: ")
3100 ;; First make sure active file has been read.
3102 (> (prefix-numeric-value level) gnus-level-killed))
3103 (gnus-get-killed-groups))
3104 (gnus-group-prepare-flat
3105 (or level gnus-level-subscribed) all (or lowest 1) regexp)
3106 (goto-char (point-min))
3107 (gnus-group-position-point))
3109 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3110 "List all groups that match REGEXP.
3111 If the prefix LEVEL is non-nil, it should be a number that says which
3112 level to cut off listing groups.
3113 If LOWEST, don't list groups with level lower than LOWEST."
3114 (interactive "P\nsList newsgroups matching: ")
3116 (setq level (prefix-numeric-value level)))
3117 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3119 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3120 (defun gnus-group-save-newsrc (&optional force)
3121 "Save the Gnus startup files.
3122 If FORCE, force saving whether it is necessary or not."
3124 (gnus-save-newsrc-file force))
3126 (defun gnus-group-restart (&optional arg)
3127 "Force Gnus to read the .newsrc file."
3129 (when (gnus-yes-or-no-p
3130 (format "Are you sure you want to restart Gnus? "))
3131 (gnus-save-newsrc-file)
3135 (defun gnus-group-read-init-file ()
3136 "Read the Gnus elisp init file."
3138 (gnus-read-init-file)
3139 (gnus-message 5 "Read %s" gnus-init-file))
3141 (defun gnus-group-check-bogus-groups (&optional silent)
3142 "Check bogus newsgroups.
3143 If given a prefix, don't ask for confirmation before removing a bogus
3146 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3147 (gnus-group-list-groups))
3149 (defun gnus-group-find-new-groups (&optional arg)
3150 "Search for new groups and add them.
3151 Each new group will be treated with `gnus-subscribe-newsgroup-method.'
3152 With 1 C-u, use the `ask-server' method to query the server for new
3154 With 2 C-u's, use most complete method possible to query the server
3155 for new groups, and subscribe the new groups as zombies."
3157 (gnus-find-new-newsgroups (or arg 1))
3158 (gnus-group-list-groups))
3160 (defun gnus-group-edit-global-kill (&optional article group)
3161 "Edit the global kill file.
3162 If GROUP, edit that local kill file instead."
3164 (setq gnus-current-kill-article article)
3165 (gnus-kill-file-edit-file group)
3168 (substitute-command-keys
3169 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3170 (if group "local" "global")))))
3172 (defun gnus-group-edit-local-kill (article group)
3173 "Edit a local kill file."
3174 (interactive (list nil (gnus-group-group-name)))
3175 (gnus-group-edit-global-kill article group))
3177 (defun gnus-group-force-update ()
3178 "Update `.newsrc' file."
3180 (gnus-save-newsrc-file))
3182 (defun gnus-group-suspend ()
3183 "Suspend the current Gnus session.
3184 In fact, cleanup buffers except for group mode buffer.
3185 The hook gnus-suspend-gnus-hook is called before actually suspending."
3187 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3188 ;; Kill Gnus buffers except for group mode buffer.
3189 (let ((group-buf (get-buffer gnus-group-buffer)))
3190 (mapcar (lambda (buf)
3191 (unless (member buf (list group-buf gnus-dribble-buffer))
3194 (gnus-kill-gnus-frames)
3196 (bury-buffer group-buf)
3197 (delete-windows-on group-buf t))))
3199 (defun gnus-group-clear-dribble ()
3200 "Clear all information from the dribble buffer."
3202 (gnus-dribble-clear)
3203 (gnus-message 7 "Cleared dribble buffer"))
3205 (defun gnus-group-exit ()
3206 "Quit reading news after updating .newsrc.eld and .newsrc.
3207 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3210 (or noninteractive ;For gnus-batch-kill
3211 (not gnus-interactive-exit) ;Without confirmation
3213 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3214 (gnus-run-hooks 'gnus-exit-gnus-hook)
3215 ;; Offer to save data from non-quitted summary buffers.
3216 (gnus-offer-save-summaries)
3217 ;; Save the newsrc file(s).
3218 (gnus-save-newsrc-file)
3220 (gnus-close-backends)
3221 ;; Reset everything.
3223 ;; Allow the user to do things after cleaning up.
3224 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3226 (defun gnus-group-quit ()
3227 "Quit reading news without updating .newsrc.eld or .newsrc.
3228 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3230 (when (or noninteractive ;For gnus-batch-kill
3231 (zerop (buffer-size))
3232 (not (gnus-server-opened gnus-select-method))
3234 (not gnus-current-startup-file)
3236 (format "Quit reading news without saving %s? "
3237 (file-name-nondirectory gnus-current-startup-file))))
3238 (gnus-run-hooks 'gnus-exit-gnus-hook)
3239 (gnus-configure-windows 'group t)
3241 (gnus-close-backends)
3243 (gnus-kill-buffer gnus-group-buffer)
3244 ;; Allow the user to do things after cleaning up.
3245 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
3247 (defun gnus-group-describe-briefly ()
3248 "Give a one line description of the group mode commands."
3250 (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")))
3252 (defun gnus-group-browse-foreign-server (method)
3253 "Browse a foreign news server.
3254 If called interactively, this function will ask for a select method
3255 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3256 If not, METHOD should be a list where the first element is the method
3257 and the second element is the address."
3259 (list (let ((how (completing-read
3261 (append gnus-valid-select-methods gnus-server-alist)
3262 nil t (cons "nntp" 0) 'gnus-method-history)))
3263 ;; We either got a backend name or a virtual server name.
3264 ;; If the first, we also need an address.
3265 (if (assoc how gnus-valid-select-methods)
3267 ;; Suggested by mapjph@bath.ac.uk.
3270 (mapcar (lambda (server) (list server))
3271 gnus-secondary-servers)))
3272 ;; We got a server name.
3274 (gnus-browse-foreign-server method))
3276 (defun gnus-group-set-info (info &optional method-only-group part)
3277 (let* ((entry (gnus-gethash
3278 (or method-only-group (gnus-info-group info))
3279 gnus-newsrc-hashtb))
3281 (info (if method-only-group (nth 2 entry) info))
3283 (when method-only-group
3285 (error "Trying to change non-existent group %s" method-only-group))
3286 ;; We have received parts of the actual group info - either the
3287 ;; select method or the group parameters. We first check
3288 ;; whether we have to extend the info, and if so, do that.
3289 (let ((len (length info))
3290 (total (if (eq part 'method) 5 6)))
3292 (setcdr (nthcdr (1- len) info)
3293 (make-list (- total len) nil)))
3294 ;; Then we enter the new info.
3295 (setcar (nthcdr (1- total) info) part-info)))
3297 ;; This is a new group, so we just create it.
3299 (set-buffer gnus-group-buffer)
3300 (setq method (gnus-info-method info))
3301 (when (gnus-server-equal method "native")
3304 (set-buffer gnus-group-buffer)
3306 ;; It's a foreign group...
3307 (gnus-group-make-group
3308 (gnus-group-real-name (gnus-info-group info))
3309 (if (stringp method) method
3310 (prin1-to-string (car method)))
3312 (nth 1 (gnus-info-method info))))
3313 ;; It's a native group.
3314 (gnus-group-make-group (gnus-info-group info))))
3315 (gnus-message 6 "Note: New group created")
3317 (gnus-gethash (gnus-group-prefixed-name
3318 (gnus-group-real-name (gnus-info-group info))
3319 (or (gnus-info-method info) gnus-select-method))
3320 gnus-newsrc-hashtb))))
3321 ;; Whether it was a new group or not, we now have the entry, so we
3322 ;; can do the update.
3325 (setcar (nthcdr 2 entry) info)
3326 (when (and (not (eq (car entry) t))
3327 (gnus-active (gnus-info-group info)))
3328 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3329 (error "No such group: %s" (gnus-info-group info)))))
3331 (defun gnus-group-set-method-info (group select-method)
3332 (gnus-group-set-info select-method group 'method))
3334 (defun gnus-group-set-params-info (group params)
3335 (gnus-group-set-info params group 'params))
3337 (defun gnus-add-marked-articles (group type articles &optional info force)
3338 ;; Add ARTICLES of TYPE to the info of GROUP.
3339 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3340 ;; add, but replace marked articles of TYPE with ARTICLES.
3341 (let ((info (or info (gnus-get-info group)))
3344 (and (not (setq marked (nthcdr 3 info)))
3346 (setcdr (nthcdr 2 info)
3347 (list (list (cons type (gnus-compress-sequence
3349 (and (not (setq m (assq type (car marked))))
3352 (cons (cons type (gnus-compress-sequence articles t) )
3356 (setcar (nthcdr 3 info)
3357 (gnus-delete-alist type (car marked)))
3358 (setcdr m (gnus-compress-sequence articles t)))
3359 (setcdr m (gnus-compress-sequence
3360 (sort (nconc (gnus-uncompress-range (cdr m))
3361 (copy-sequence articles)) '<) t))))))
3364 ;;; Group timestamps
3367 (defun gnus-group-set-timestamp ()
3368 "Change the timestamp of the current group to the current time.
3369 This function can be used in hooks like `gnus-select-group-hook'
3370 or `gnus-group-catchup-group-hook'."
3371 (when gnus-newsgroup-name
3372 (let ((time (current-time)))
3373 (setcdr (cdr time) nil)
3374 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3376 (defsubst gnus-group-timestamp (group)
3377 "Return the timestamp for GROUP."
3378 (gnus-group-get-parameter group 'timestamp t))
3380 (defun gnus-group-timestamp-delta (group)
3381 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3382 (let* ((time (or (gnus-group-timestamp group)
3384 (delta (subtract-time (current-time) time)))
3385 (+ (* (nth 0 delta) 65536.0)
3388 (defun gnus-group-timestamp-string (group)
3389 "Return a string of the timestamp for GROUP."
3390 (let ((time (gnus-group-timestamp group)))
3393 (gnus-time-iso8601 time))))
3395 (provide 'gnus-group)
3397 ;;; gnus-group.el ends here