1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
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.
37 (defvar gnus-group-archive-directory
38 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
39 "*The address of the (ding) archives.")
41 (defvar gnus-group-recent-archive-directory
42 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
43 "*The address of the most recent (ding) articles.")
45 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
46 (defvar gnus-no-groups-message "No news is horrible news"
47 "*Message displayed by Gnus when no groups are available.")
49 (defvar gnus-keep-same-level nil
50 "*Non-nil means that the next newsgroup after the current will be on the same level.
51 When you type, for instance, `n' after reading the last article in the
52 current newsgroup, you will go to the next newsgroup. If this variable
53 is nil, the next newsgroup will be the next from the group
55 If this variable is non-nil, Gnus will either put you in the
56 next newsgroup with the same level, or, if no such newsgroup is
57 available, the next newsgroup with the lowest possible level higher
58 than the current level.
59 If this variable is `best', Gnus will make the next newsgroup the one
60 with the best level.")
62 (defvar gnus-group-goto-unread t
63 "*If non-nil, movement commands will go to the next unread and subscribed group.")
65 (defvar gnus-goto-next-group-when-activating t
66 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
68 (defvar gnus-permanently-visible-groups nil
69 "*Regexp to match groups that should always be listed in the group buffer.
70 This means that they will still be listed when there are no unread
71 articles in the groups.")
73 (defvar gnus-list-groups-with-ticked-articles t
74 "*If non-nil, list groups that have only ticked articles.
75 If nil, only list groups that have unread articles.")
77 (defvar gnus-group-default-list-level gnus-level-subscribed
78 "*Default listing level.
79 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
81 (defvar gnus-group-list-inactive-groups t
82 "*If non-nil, inactive groups will be listed.")
84 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
85 "*Function used for sorting the group buffer.
86 This function will be called with group info entries as the arguments
87 for the groups to be sorted. Pre-made functions include
88 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
89 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
90 `gnus-group-sort-by-score', `gnus-group-sort-by-method', and
91 `gnus-group-sort-by-rank'.
93 This variable can also be a list of sorting functions. In that case,
94 the most significant sort function should be the last function in the
97 (defvar gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
98 "*Format of group lines.
99 It works along the same lines as a normal formatting string,
100 with some simple extensions.
102 %M Only marked articles (character, \"*\" or \" \")
103 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
104 %L Level of subscribedness (integer)
105 %N Number of unread articles (integer)
106 %I Number of dormant articles (integer)
107 %i Number of ticked and dormant (integer)
108 %T Number of ticked articles (integer)
109 %R Number of read articles (integer)
110 %t Estimated total number of articles (integer)
111 %y Number of unread, unticked articles (integer)
112 %G Group name (string)
113 %g Qualified group name (string)
114 %D Group description (string)
115 %s Select method (string)
116 %o Moderated group (char, \"m\")
117 %p Process mark (char)
118 %O Moderated group (string, \"(m)\" or \"\")
119 %P Topic indentation (string)
120 %l Whether there are GroupLens predictions for this group (string)
121 %n Select from where (string)
122 %z A string that look like `<%s:%n>' if a foreign select method is used
123 %u User defined specifier. The next character in the format string should
124 be a letter. Gnus will call the function gnus-user-format-function-X,
125 where X is the letter following %u. The function will be passed the
126 current header as argument. The function should return a string, which
127 will be inserted into the buffer just like information from any other
130 Text between %( and %) will be highlighted with `gnus-mouse-face' when
131 the mouse point move inside the area. There can only be one such area.
133 Note that this format specification is not always respected. For
134 reasons of efficiency, when listing killed groups, this specification
135 is ignored altogether. If the spec is changed considerably, your
136 output may end up looking strange when listing both alive and killed
139 If you use %o or %O, reading the active file will be slower and quite
140 a bit of extra memory will be used. %D will also worsen performance.
141 Also note that if you change the format specification to include any
142 of these specs, you must probably re-start Gnus to see them go into
145 (defvar gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
146 "*The format specification for the group mode line.
147 It works along the same lines as a normal formatting string,
148 with some simple extensions:
150 %S The native news server.
151 %M The native select method.
152 %: \":\" if %S isn't \"\".")
154 (defvar gnus-group-mode-hook nil
155 "*A hook for Gnus group mode.")
157 (defvar gnus-group-menu-hook nil
158 "*Hook run after the creation of the group mode menu.")
160 (defvar gnus-group-catchup-group-hook nil
161 "*A hook run when catching up a group from the group buffer.")
163 (defvar gnus-group-update-group-hook nil
164 "*A hook called when updating group lines.")
166 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
167 "*A function that is called to generate the group buffer.
168 The function is called with three arguments: The first is a number;
169 all group with a level less or equal to that number should be listed,
170 if the second is non-nil, empty groups should also be displayed. If
171 the third is non-nil, it is a number. No groups with a level lower
172 than this number should be displayed.
174 The only current function implemented is `gnus-group-prepare-flat'.")
176 (defvar gnus-group-prepare-hook nil
177 "*A hook called after the group buffer has been generated.
178 If you want to modify the group buffer, you can use this hook.")
180 (defvar gnus-suspend-gnus-hook nil
181 "*A hook called when suspending (not exiting) Gnus.")
183 (defvar gnus-exit-gnus-hook nil
184 "*A hook called when exiting Gnus.")
186 (defvar gnus-after-exiting-gnus-hook nil
187 "*A hook called after exiting Gnus.")
189 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
190 "*A hook called when a group line is changed.
191 The hook will not be called if `gnus-visual' is nil.
193 The default function `gnus-group-highlight-line' will
194 highlight the line according to the `gnus-group-highlight'
197 ;;; Internal variables
199 (defvar gnus-group-indentation-function nil)
200 (defvar gnus-goto-missing-group-function nil)
201 (defvar gnus-group-update-group-function nil)
202 (defvar gnus-group-get-parameter-function 'gnus-group-get-parameter)
203 (defvar gnus-group-goto-next-group-function nil
204 "Function to override finding the next group after listing groups.")
206 (defvar gnus-group-edit-buffer nil)
208 (defvar gnus-group-line-format-alist
209 `((?M gnus-tmp-marked-mark ?c)
210 (?S gnus-tmp-subscribed ?c)
211 (?L gnus-tmp-level ?d)
212 (?N (cond ((eq number t) "*" )
216 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
217 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
219 (?R gnus-tmp-number-of-read ?s)
220 (?t gnus-tmp-number-total ?d)
221 (?y gnus-tmp-number-of-unread ?s)
222 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
223 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
224 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
225 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
226 (?g gnus-tmp-group ?s)
227 (?G gnus-tmp-qualified-group ?s)
228 (?c (gnus-short-group-name gnus-tmp-group) ?s)
229 (?D gnus-tmp-newsgroup-description ?s)
230 (?o gnus-tmp-moderated ?c)
231 (?O gnus-tmp-moderated-string ?s)
232 (?p gnus-tmp-process-marked ?c)
233 (?s gnus-tmp-news-server ?s)
234 (?n gnus-tmp-news-method ?s)
235 (?P gnus-group-indentation ?s)
236 (?l gnus-tmp-grouplens ?s)
237 (?z gnus-tmp-news-method-string ?s)
238 (?u gnus-tmp-user-defined ?s)))
240 (defvar gnus-group-mode-line-format-alist
241 `((?S gnus-tmp-news-server ?s)
242 (?M gnus-tmp-news-method ?s)
243 (?u gnus-tmp-user-defined ?s)
244 (?: gnus-tmp-colon ?s)))
246 (defvar gnus-topic-topology nil
247 "The complete topic hierarchy.")
249 (defvar gnus-topic-alist nil
250 "The complete topic-group alist.")
252 (defvar gnus-group-marked nil)
254 (defvar gnus-group-list-mode nil)
260 (put 'gnus-group-mode 'mode-class 'special)
263 (gnus-define-keys gnus-group-mode-map
264 " " gnus-group-read-group
265 "=" gnus-group-select-group
266 "\r" gnus-group-select-group
267 "\M-\r" gnus-group-quick-select-group
268 "j" gnus-group-jump-to-group
269 "n" gnus-group-next-unread-group
270 "p" gnus-group-prev-unread-group
271 "\177" gnus-group-prev-unread-group
272 [delete] gnus-group-prev-unread-group
273 "N" gnus-group-next-group
274 "P" gnus-group-prev-group
275 "\M-n" gnus-group-next-unread-group-same-level
276 "\M-p" gnus-group-prev-unread-group-same-level
277 "," gnus-group-best-unread-group
278 "." gnus-group-first-unread-group
279 "u" gnus-group-unsubscribe-current-group
280 "U" gnus-group-unsubscribe-group
281 "c" gnus-group-catchup-current
282 "C" gnus-group-catchup-current-all
283 "\M-c" gnus-group-clear-data
284 "l" gnus-group-list-groups
285 "L" gnus-group-list-all-groups
287 "g" gnus-group-get-new-news
288 "\M-g" gnus-group-get-new-news-this-group
289 "R" gnus-group-restart
290 "r" gnus-group-read-init-file
291 "B" gnus-group-browse-foreign-server
292 "b" gnus-group-check-bogus-groups
293 "F" gnus-find-new-newsgroups
294 "\C-c\C-d" gnus-group-describe-group
295 "\M-d" gnus-group-describe-all-groups
296 "\C-c\C-a" gnus-group-apropos
297 "\C-c\M-\C-a" gnus-group-description-apropos
298 "a" gnus-group-post-news
299 "\ek" gnus-group-edit-local-kill
300 "\eK" gnus-group-edit-global-kill
301 "\C-k" gnus-group-kill-group
302 "\C-y" gnus-group-yank-group
303 "\C-w" gnus-group-kill-region
304 "\C-x\C-t" gnus-group-transpose-groups
305 "\C-c\C-l" gnus-group-list-killed
306 "\C-c\C-x" gnus-group-expire-articles
307 "\C-c\M-\C-x" gnus-group-expire-all-groups
309 "s" gnus-group-save-newsrc
310 "z" gnus-group-suspend
311 ; "Z" gnus-group-clear-dribble
314 "?" gnus-group-describe-briefly
315 "\C-c\C-i" gnus-info-find-node
316 "\M-e" gnus-group-edit-group-method
317 "^" gnus-group-enter-server-mode
318 gnus-mouse-2 gnus-mouse-pick-group
319 "<" beginning-of-buffer
322 "\C-c\C-s" gnus-group-sort-groups
324 "\C-c\M-g" gnus-activate-all-groups
325 "\M-&" gnus-group-universal-argument
326 "#" gnus-group-mark-group
327 "\M-#" gnus-group-unmark-group)
329 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
330 "m" gnus-group-mark-group
331 "u" gnus-group-unmark-group
332 "w" gnus-group-mark-region
333 "m" gnus-group-mark-buffer
334 "r" gnus-group-mark-regexp
335 "U" gnus-group-unmark-all-groups)
337 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
338 "d" gnus-group-make-directory-group
339 "h" gnus-group-make-help-group
340 "a" gnus-group-make-archive-group
341 "k" gnus-group-make-kiboze-group
342 "m" gnus-group-make-group
343 "E" gnus-group-edit-group
344 "e" gnus-group-edit-group-method
345 "p" gnus-group-edit-group-parameters
346 "v" gnus-group-add-to-virtual
347 "V" gnus-group-make-empty-virtual
348 "D" gnus-group-enter-directory
349 "f" gnus-group-make-doc-group
350 "n" gnus-group-make-web-group
351 "r" gnus-group-rename-group
352 "\177" gnus-group-delete-group
353 [delete] gnus-group-delete-group)
355 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
356 "b" gnus-group-brew-soup
357 "w" gnus-soup-save-areas
358 "s" gnus-soup-send-replies
359 "p" gnus-soup-pack-packet
360 "r" nnsoup-pack-replies)
362 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
363 "s" gnus-group-sort-groups
364 "a" gnus-group-sort-groups-by-alphabet
365 "u" gnus-group-sort-groups-by-unread
366 "l" gnus-group-sort-groups-by-level
367 "v" gnus-group-sort-groups-by-score
368 "r" gnus-group-sort-groups-by-rank
369 "m" gnus-group-sort-groups-by-method)
371 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
372 "k" gnus-group-list-killed
373 "z" gnus-group-list-zombies
374 "s" gnus-group-list-groups
375 "u" gnus-group-list-all-groups
376 "A" gnus-group-list-active
377 "a" gnus-group-apropos
378 "d" gnus-group-description-apropos
379 "m" gnus-group-list-matching
380 "M" gnus-group-list-all-matching
381 "l" gnus-group-list-level)
383 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
384 "f" gnus-score-flush-cache)
386 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
387 "f" gnus-group-fetch-faq)
389 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
390 "l" gnus-group-set-current-level
391 "t" gnus-group-unsubscribe-current-group
392 "s" gnus-group-unsubscribe-group
393 "k" gnus-group-kill-group
394 "y" gnus-group-yank-group
395 "w" gnus-group-kill-region
396 "\C-k" gnus-group-kill-level
397 "z" gnus-group-kill-all-zombies))
399 (defun gnus-group-make-menu-bar ()
400 (gnus-turn-off-edit-menu 'group)
401 (unless (boundp 'gnus-group-reading-menu)
404 gnus-group-reading-menu gnus-group-mode-map ""
406 ["Read" gnus-group-read-group (gnus-group-group-name)]
407 ["Select" gnus-group-select-group (gnus-group-group-name)]
408 ["See old articles" (gnus-group-select-group 'all)
409 :keys "C-u SPC" :active (gnus-group-group-name)]
410 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
411 ["Catch up all articles" gnus-group-catchup-current-all
412 (gnus-group-group-name)]
413 ["Check for new articles" gnus-group-get-new-news-this-group
414 (gnus-group-group-name)]
415 ["Toggle subscription" gnus-group-unsubscribe-current-group
416 (gnus-group-group-name)]
417 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
418 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
419 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
420 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
421 ["Edit kill file" gnus-group-edit-local-kill
422 (gnus-group-group-name)]
423 ;; Actually one should check, if any of the marked groups gives t for
424 ;; (gnus-check-backend-function 'request-expire-articles ...)
425 ["Expire articles" gnus-group-expire-articles
426 (or (and (gnus-group-group-name)
427 (gnus-check-backend-function
428 'request-expire-articles
429 (gnus-group-group-name))) gnus-group-marked)]
430 ["Set group level" gnus-group-set-current-level
431 (gnus-group-group-name)]
432 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
436 gnus-group-group-menu gnus-group-mode-map ""
439 ["List unread subscribed groups" gnus-group-list-groups t]
440 ["List (un)subscribed groups" gnus-group-list-all-groups t]
441 ["List killed groups" gnus-group-list-killed gnus-killed-list]
442 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
443 ["List level..." gnus-group-list-level t]
444 ["Describe all groups" gnus-group-describe-all-groups t]
445 ["Group apropos..." gnus-group-apropos t]
446 ["Group and description apropos..." gnus-group-description-apropos t]
447 ["List groups matching..." gnus-group-list-matching t]
448 ["List all groups matching..." gnus-group-list-all-matching t]
449 ["List active file" gnus-group-list-active t])
451 ["Default sort" gnus-group-sort-groups
452 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
453 ["Sort by method" gnus-group-sort-groups-by-method
454 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
455 ["Sort by rank" gnus-group-sort-groups-by-rank
456 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
457 ["Sort by score" gnus-group-sort-groups-by-score
458 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
459 ["Sort by level" gnus-group-sort-groups-by-level
460 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
461 ["Sort by unread" gnus-group-sort-groups-by-unread
462 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
463 ["Sort by name" gnus-group-sort-groups-by-alphabet
464 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
466 ["Mark group" gnus-group-mark-group
467 (and (gnus-group-group-name)
468 (not (memq (gnus-group-group-name) gnus-group-marked)))]
469 ["Unmark group" gnus-group-unmark-group
470 (and (gnus-group-group-name)
471 (memq (gnus-group-group-name) gnus-group-marked))]
472 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
473 ["Mark regexp..." gnus-group-mark-regexp t]
474 ["Mark region" gnus-group-mark-region t]
475 ["Mark buffer" gnus-group-mark-buffer t]
476 ["Execute command" gnus-group-universal-argument
477 (or gnus-group-marked (gnus-group-group-name))])
479 ["Subscribe to a group" gnus-group-unsubscribe-group t]
480 ["Kill all newsgroups in region" gnus-group-kill-region t]
481 ["Kill all zombie groups" gnus-group-kill-all-zombies
483 ["Kill all groups on level..." gnus-group-kill-level t])
485 ["Make a foreign group" gnus-group-make-group t]
486 ["Add a directory group" gnus-group-make-directory-group t]
487 ["Add the help group" gnus-group-make-help-group t]
488 ["Add the archive group" gnus-group-make-archive-group t]
489 ["Make a doc group" gnus-group-make-doc-group t]
490 ["Make a kiboze group" gnus-group-make-kiboze-group t]
491 ["Make a virtual group" gnus-group-make-empty-virtual t]
492 ["Add a group to a virtual" gnus-group-add-to-virtual t]
493 ["Rename group" gnus-group-rename-group
494 (gnus-check-backend-function
495 'request-rename-group (gnus-group-group-name))]
496 ["Delete group" gnus-group-delete-group
497 (gnus-check-backend-function
498 'request-delete-group (gnus-group-group-name))])
500 ["Parameters" gnus-group-edit-group-parameters
501 (gnus-group-group-name)]
502 ["Select method" gnus-group-edit-group-method
503 (gnus-group-group-name)]
504 ["Info" gnus-group-edit-group (gnus-group-group-name)])
506 ["Flush cache" gnus-score-flush-cache t])
508 ["Next" gnus-group-next-group t]
509 ["Previous" gnus-group-prev-group t]
510 ["Next unread" gnus-group-next-unread-group t]
511 ["Previous unread" gnus-group-prev-unread-group t]
512 ["Next unread same level" gnus-group-next-unread-group-same-level t]
513 ["Previous unread same level"
514 gnus-group-previous-unread-group-same-level t]
515 ["Jump to group" gnus-group-jump-to-group t]
516 ["First unread group" gnus-group-first-unread-group t]
517 ["Best unread group" gnus-group-best-unread-group t])
518 ["Transpose" gnus-group-transpose-groups
519 (gnus-group-group-name)]
520 ["Read a directory as a group..." gnus-group-enter-directory t]
524 gnus-group-misc-menu gnus-group-mode-map ""
526 ["Send a bug report" gnus-bug t]
527 ["Send a mail" gnus-group-mail t]
528 ["Post an article..." gnus-group-post-news t]
529 ["Customize score file" gnus-score-customize t]
530 ["Check for new news" gnus-group-get-new-news t]
531 ["Activate all groups" gnus-activate-all-groups t]
532 ["Delete bogus groups" gnus-group-check-bogus-groups t]
533 ["Find new newsgroups" gnus-find-new-newsgroups t]
534 ["Restart Gnus" gnus-group-restart t]
535 ["Read init file" gnus-group-read-init-file t]
536 ["Browse foreign server" gnus-group-browse-foreign-server t]
537 ["Enter server buffer" gnus-group-enter-server-mode t]
538 ["Expire all expirable articles" gnus-group-expire-all-groups t]
539 ["Generate any kiboze groups" nnkiboze-generate-groups t]
540 ["Gnus version" gnus-version t]
541 ["Save .newsrc files" gnus-group-save-newsrc t]
542 ["Suspend Gnus" gnus-group-suspend t]
543 ["Clear dribble buffer" gnus-group-clear-dribble t]
544 ["Edit global kill file" gnus-group-edit-global-kill t]
545 ["Read manual" gnus-info-find-node t]
546 ["Toggle topics" gnus-topic-mode t]
548 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
549 ["Send replies" gnus-soup-send-replies
550 (fboundp 'gnus-soup-pack-packet)]
551 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
552 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
553 ["Brew SOUP" gnus-soup-brew-soup (fboundp 'gnus-soup-pack-packet)])
554 ["Exit from Gnus" gnus-group-exit t]
555 ["Exit without saving" gnus-group-quit t]
558 (run-hooks 'gnus-group-menu-hook)
561 (defun gnus-group-mode ()
562 "Major mode for reading news.
564 All normal editing commands are switched off.
565 \\<gnus-group-mode-map>
566 The group buffer lists (some of) the groups available. For instance,
567 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
568 lists all zombie groups.
570 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
571 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
573 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
575 The following commands are available:
577 \\{gnus-group-mode-map}"
579 (when (and menu-bar-mode
580 (gnus-visual-p 'group-menu 'menu))
581 (gnus-group-make-menu-bar))
582 (kill-all-local-variables)
583 (gnus-simplify-mode-line)
584 (setq major-mode 'gnus-group-mode)
585 (setq mode-name "Group")
586 (gnus-group-set-mode-line)
587 (setq mode-line-process nil)
588 (use-local-map gnus-group-mode-map)
589 (buffer-disable-undo (current-buffer))
590 (setq truncate-lines t)
591 (setq buffer-read-only t)
592 (gnus-set-default-directory)
593 (gnus-update-format-specifications nil 'group 'group-mode)
594 (gnus-update-group-mark-positions)
595 (gnus-make-local-hook 'post-command-hook)
596 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
599 (run-hooks 'gnus-group-mode-hook))
601 (defun gnus-update-group-mark-positions ()
603 (let ((gnus-process-mark 128)
604 (gnus-group-marked '("dummy.group"))
605 (gnus-active-hashtb (make-vector 10 0)))
606 (gnus-set-active "dummy.group" '(0 . 0))
607 (gnus-set-work-buffer)
608 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
609 (goto-char (point-min))
610 (setq gnus-group-mark-positions
611 (list (cons 'process (and (search-forward "\200" nil t)
614 (defun gnus-clear-inboxes-moved ()
615 (setq nnmail-moved-inboxes nil))
617 (defun gnus-mouse-pick-group (e)
618 "Enter the group under the mouse pointer."
621 (gnus-group-read-group nil))
623 ;; Look at LEVEL and find out what the level is really supposed to be.
624 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
625 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
626 (defun gnus-group-default-level (&optional level number-or-nil)
628 (gnus-group-use-permanent-levels
629 (or (setq gnus-group-use-permanent-levels
630 (or level (if (numberp gnus-group-use-permanent-levels)
631 gnus-group-use-permanent-levels
632 (or gnus-group-default-list-level
633 gnus-level-subscribed))))
634 gnus-group-default-list-level gnus-level-subscribed))
638 (or level gnus-group-default-list-level gnus-level-subscribed))))
640 (defun gnus-group-setup-buffer ()
641 (switch-to-buffer gnus-group-buffer)
642 (unless (eq major-mode 'gnus-group-mode)
643 (gnus-add-current-to-buffer-list)
646 (gnus-carpal-setup-buffer 'group))))
648 (defun gnus-group-list-groups (&optional level unread lowest)
649 "List newsgroups with level LEVEL or lower that have unread articles.
650 Default is all subscribed groups.
651 If argument UNREAD is non-nil, groups with no unread articles are also
654 (list (if current-prefix-arg
655 (prefix-numeric-value current-prefix-arg)
657 (gnus-group-default-level nil t)
658 gnus-group-default-list-level
659 gnus-level-subscribed))))
661 (setq level (car gnus-group-list-mode)
662 unread (cdr gnus-group-list-mode)))
663 (setq level (gnus-group-default-level level))
664 (gnus-group-setup-buffer) ;May call from out of group buffer
665 (gnus-update-format-specifications)
666 (let ((case-fold-search nil)
667 (props (text-properties-at (gnus-point-at-bol)))
668 (group (gnus-group-group-name)))
669 (set-buffer gnus-group-buffer)
670 (funcall gnus-group-prepare-function level unread lowest)
671 (if (zerop (buffer-size))
672 (gnus-message 5 gnus-no-groups-message)
673 (goto-char (point-max))
674 (when (or (not gnus-group-goto-next-group-function)
675 (not (funcall gnus-group-goto-next-group-function
678 ;; Go to the first group with unread articles.
679 (gnus-group-search-forward t)
680 ;; Find the right group to put point on. If the current group
681 ;; has disappeared in the new listing, try to find the next
682 ;; one. If no next one can be found, just leave point at the
683 ;; first newsgroup in the buffer.
684 (when (not (gnus-goto-char
686 (point-min) (point-max)
687 'gnus-group (gnus-intern-safe
688 group gnus-active-hashtb))))
689 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
693 (point-min) (point-max) 'gnus-group
695 (caar newsrc) gnus-active-hashtb)))))
696 (setq newsrc (cdr newsrc)))
698 (goto-char (point-max))
699 (forward-line -1))))))
700 ;; Adjust cursor point.
701 (gnus-group-position-point))))
703 (defun gnus-group-list-level (level &optional all)
704 "List groups on LEVEL.
705 If ALL (the prefix), also list groups that have no unread articles."
706 (interactive "nList groups on level: \nP")
707 (gnus-group-list-groups level all level))
709 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
710 "List all newsgroups with unread articles of level LEVEL or lower.
711 If ALL is non-nil, list groups that have no unread articles.
712 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
713 If REGEXP, only list groups matching REGEXP."
714 (set-buffer gnus-group-buffer)
715 (let ((buffer-read-only nil)
716 (newsrc (cdr gnus-newsrc-alist))
717 (lowest (or lowest 1))
718 info clevel unread group params)
720 (if (< lowest gnus-level-zombie)
721 ;; List living groups.
723 (setq info (car newsrc)
724 group (gnus-info-group info)
725 params (gnus-info-params info)
727 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
728 (and unread ; This group might be bogus
730 (string-match regexp group))
731 (<= (setq clevel (gnus-info-level info)) level)
733 (or all ; We list all groups?
734 (if (eq unread t) ; Unactivated?
735 gnus-group-list-inactive-groups ; We list unactivated
736 (> unread 0)) ; We list groups with unread articles
737 (and gnus-list-groups-with-ticked-articles
738 (cdr (assq 'tick (gnus-info-marks info))))
739 ; And groups with tickeds
740 ;; Check for permanent visibility.
741 (and gnus-permanently-visible-groups
742 (string-match gnus-permanently-visible-groups
744 (memq 'visible params)
745 (cdr (assq 'visible params)))
746 (gnus-group-insert-group-line
747 group (gnus-info-level info)
748 (gnus-info-marks info) unread (gnus-info-method info)))))
751 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
752 (gnus-group-prepare-flat-list-dead
753 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
756 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
757 (gnus-group-prepare-flat-list-dead
758 (setq gnus-killed-list (sort gnus-killed-list 'string<))
759 gnus-level-killed ?K regexp))
761 (gnus-group-set-mode-line)
762 (setq gnus-group-list-mode (cons level all))
763 (run-hooks 'gnus-group-prepare-hook)))
765 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
766 ;; List zombies and killed lists somewhat faster, which was
767 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
768 ;; this by ignoring the group format specification altogether.
771 ;; This loop is used when listing groups that match some
774 (setq group (pop groups))
775 (when (string-match regexp group)
776 (gnus-add-text-properties
777 (point) (prog1 (1+ (point))
778 (insert " " mark " *: " group "\n"))
779 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
781 'gnus-level level))))
782 ;; This loop is used when listing all groups.
784 (gnus-add-text-properties
785 (point) (prog1 (1+ (point))
786 (insert " " mark " *: "
787 (setq group (pop groups)) "\n"))
788 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
790 'gnus-level level))))))
792 (defun gnus-group-update-group-line ()
793 "Update the current line in the group buffer."
794 (let* ((buffer-read-only nil)
795 (group (gnus-group-group-name))
796 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
797 gnus-group-indentation)
800 (not (gnus-ephemeral-group-p group))
802 (concat "(gnus-group-set-info '"
803 (gnus-prin1-to-string (nth 2 entry)) ")")))
804 (setq gnus-group-indentation (gnus-group-group-indentation))
806 (gnus-group-insert-group-line-info group)
808 (gnus-group-position-point))))
810 (defun gnus-group-insert-group-line-info (group)
811 "Insert GROUP on the current line."
812 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
816 ;; (Un)subscribed group.
817 (setq info (nth 2 entry))
818 (gnus-group-insert-group-line
819 group (gnus-info-level info) (gnus-info-marks info)
820 (or (car entry) t) (gnus-info-method info)))
821 ;; This group is dead.
822 (gnus-group-insert-group-line
824 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
826 (if (setq active (gnus-active group))
827 (- (1+ (cdr active)) (car active)) 0)
830 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
831 gnus-tmp-marked number
833 "Insert a group line in the group buffer."
834 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
835 (gnus-tmp-number-total
837 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
839 (gnus-tmp-number-of-unread
840 (if (numberp number) (int-to-string (max 0 number))
842 (gnus-tmp-number-of-read
844 (int-to-string (max 0 (- gnus-tmp-number-total number)))
847 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
848 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
849 ((= gnus-tmp-level gnus-level-zombie) ?Z)
851 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
852 (gnus-tmp-newsgroup-description
853 (if gnus-description-hashtb
854 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
857 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
858 (gnus-tmp-moderated-string
859 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
861 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
862 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
863 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
864 (gnus-tmp-news-method-string
866 (format "(%s:%s)" (car gnus-tmp-method)
867 (cadr gnus-tmp-method)) ""))
868 (gnus-tmp-marked-mark
869 (if (and (numberp number)
871 (cdr (assq 'tick gnus-tmp-marked)))
873 (gnus-tmp-process-marked
874 (if (member gnus-tmp-group gnus-group-marked)
875 gnus-process-mark ? ))
877 (or (and gnus-use-grouplens
878 (bbb-grouplens-group-p gnus-tmp-group))
880 (buffer-read-only nil)
881 header gnus-tmp-header) ; passed as parameter to user-funcs.
883 (gnus-add-text-properties
887 (eval gnus-group-line-format-spec))
888 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
889 gnus-unread ,(if (numberp number)
890 (string-to-int gnus-tmp-number-of-unread)
892 gnus-marked ,gnus-tmp-marked-mark
893 gnus-indentation ,gnus-group-indentation
894 gnus-level ,gnus-tmp-level))
895 (when (inline (gnus-visual-p 'group-highlight 'highlight))
897 (run-hooks 'gnus-group-update-hook)
899 ;; Allow XEmacs to remove front-sticky text properties.
900 (gnus-group-remove-excess-properties)))
902 (defun gnus-group-highlight-line ()
903 "Highlight the current line according to `gnus-group-highlight'."
904 (let* ((list gnus-group-highlight)
906 (end (progn (end-of-line) (point)))
907 ;; now find out where the line starts and leave point there.
908 (beg (progn (beginning-of-line) (point)))
909 (group (gnus-group-group-name))
910 (entry (gnus-group-entry group))
911 (unread (if (numberp (car entry)) (car entry) 0))
912 (active (gnus-active group))
913 (total (if active (1+ (- (cdr active) (car active))) 0))
915 (method (gnus-server-get-method group (gnus-info-method info)))
916 (marked (gnus-info-marks info))
917 (mailp (memq 'mail (assoc (symbol-name
918 (car (or method gnus-select-method)))
919 gnus-valid-select-methods)))
920 (level (or (gnus-info-level info) 9))
921 (score (or (gnus-info-score info) 0))
922 (ticked (gnus-range-length (cdr (assq 'tick marked))))
923 (inhibit-read-only t))
924 ;; Eval the cars of the lists until we find a match.
926 (not (eval (caar list))))
927 (setq list (cdr list)))
928 (let ((face (cdar list)))
929 (unless (eq face (get-text-property beg 'face))
930 (gnus-put-text-property
932 (setq face (if (boundp face) (symbol-value face) face)))
933 (gnus-extent-start-open beg)))
936 (defun gnus-group-update-group (group &optional visible-only)
937 "Update all lines where GROUP appear.
938 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
941 (set-buffer gnus-group-buffer)
942 ;; The buffer may be narrowed.
945 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
947 found buffer-read-only)
948 ;; Enter the current status into the dribble buffer.
949 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
950 (if (and entry (not (gnus-ephemeral-group-p group)))
952 (concat "(gnus-group-set-info '"
953 (gnus-prin1-to-string (nth 2 entry))
955 ;; Find all group instances. If topics are in use, each group
956 ;; may be listed in more than once.
957 (while (setq loc (text-property-any
958 loc (point-max) 'gnus-group ident))
961 (let ((gnus-group-indentation (gnus-group-group-indentation)))
963 (gnus-group-insert-group-line-info group)
966 (run-hooks 'gnus-group-update-group-hook)))
968 (unless (or found visible-only)
969 ;; No such line in the buffer, find out where it's supposed to
970 ;; go, and insert it there (or at the end of the buffer).
971 (if gnus-goto-missing-group-function
972 (funcall gnus-goto-missing-group-function group)
973 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
974 (while (and entry (car entry)
978 (point-min) (point-max)
979 'gnus-group (gnus-intern-safe
980 (caar entry) gnus-active-hashtb)))))
981 (setq entry (cdr entry)))
982 (or entry (goto-char (point-max)))))
983 ;; Finally insert the line.
984 (let ((gnus-group-indentation (gnus-group-group-indentation)))
985 (gnus-group-insert-group-line-info group)
988 (run-hooks 'gnus-group-update-group-hook))))
989 (when gnus-group-update-group-function
990 (funcall gnus-group-update-group-function group))
991 (gnus-group-set-mode-line)))))
993 (defun gnus-group-set-mode-line ()
994 "Update the mode line in the group buffer."
995 (when (memq 'group gnus-updated-mode-lines)
996 ;; Yes, we want to keep this mode line updated.
998 (set-buffer gnus-group-buffer)
999 (let* ((gformat (or gnus-group-mode-line-format-spec
1000 (setq gnus-group-mode-line-format-spec
1002 gnus-group-mode-line-format
1003 gnus-group-mode-line-format-alist))))
1004 (gnus-tmp-news-server (cadr gnus-select-method))
1005 (gnus-tmp-news-method (car gnus-select-method))
1006 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1008 gnus-tmp-header ;Dummy binding for user-defined formats
1009 ;; Get the resulting string.
1011 (and gnus-dribble-buffer
1012 (buffer-name gnus-dribble-buffer)
1013 (buffer-modified-p gnus-dribble-buffer)
1015 (set-buffer gnus-dribble-buffer)
1016 (not (zerop (buffer-size))))))
1017 (mode-string (eval gformat)))
1018 ;; Say whether the dribble buffer has been modified.
1019 (setq mode-line-modified
1020 (if modified "---*- " "----- "))
1021 ;; If the line is too long, we chop it off.
1022 (when (> (length mode-string) max-len)
1023 (setq mode-string (substring mode-string 0 (- max-len 4))))
1025 (setq mode-line-buffer-identification
1026 (gnus-mode-line-buffer-identification
1027 (list mode-string)))
1028 (set-buffer-modified-p modified))))))
1030 (defun gnus-group-group-name ()
1031 "Get the name of the newsgroup on the current line."
1032 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1033 (and group (symbol-name group))))
1035 (defun gnus-group-group-level ()
1036 "Get the level of the newsgroup on the current line."
1037 (get-text-property (gnus-point-at-bol) 'gnus-level))
1039 (defun gnus-group-group-indentation ()
1040 "Get the indentation of the newsgroup on the current line."
1041 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1042 (and gnus-group-indentation-function
1043 (funcall gnus-group-indentation-function))
1046 (defun gnus-group-group-unread ()
1047 "Get the number of unread articles of the newsgroup on the current line."
1048 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1050 (defun gnus-group-search-forward (&optional backward all level first-too)
1051 "Find the next newsgroup with unread articles.
1052 If BACKWARD is non-nil, find the previous newsgroup instead.
1053 If ALL is non-nil, just find any newsgroup.
1054 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1056 If FIRST-TOO, the current line is also eligible as a target."
1057 (let ((way (if backward -1 1))
1058 (low gnus-level-killed)
1061 (if (and backward (progn (beginning-of-line)) (bobp))
1063 (or first-too (forward-line way))
1071 (get-text-property (point) 'gnus-unread)))
1072 (and (numberp unread) (> unread 0)))
1073 (setq lev (get-text-property (point)
1075 (<= lev gnus-level-subscribed)))
1077 (and (setq lev (get-text-property (point)
1086 (zerop (forward-line way)))))
1088 (progn (gnus-group-position-point) t)
1089 (goto-char (or pos beg))
1092 ;;; Gnus group mode commands
1096 (defun gnus-group-mark-group (n &optional unmark no-advance)
1097 "Mark the current group."
1099 (let ((buffer-read-only nil)
1103 (when (setq group (gnus-group-group-name))
1104 ;; Go to the mark position.
1106 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1107 (subst-char-in-region
1108 (point) (1+ (point)) (following-char)
1111 (setq gnus-group-marked (delete group gnus-group-marked))
1113 (setq gnus-group-marked
1114 (cons group (delete group gnus-group-marked)))
1115 gnus-process-mark)))
1117 (gnus-group-next-group 1))
1119 (gnus-summary-position-point)
1122 (defun gnus-group-unmark-group (n)
1123 "Remove the mark from the current group."
1125 (gnus-group-mark-group n 'unmark)
1126 (gnus-group-position-point))
1128 (defun gnus-group-unmark-all-groups ()
1129 "Unmark all groups."
1131 (let ((groups gnus-group-marked))
1134 (gnus-group-remove-mark (pop groups)))))
1135 (gnus-group-position-point))
1137 (defun gnus-group-mark-region (unmark beg end)
1138 "Mark all groups between point and mark.
1139 If UNMARK, remove the mark instead."
1140 (interactive "P\nr")
1141 (let ((num (count-lines beg end)))
1144 (- num (gnus-group-mark-group num unmark)))))
1146 (defun gnus-group-mark-buffer (&optional unmark)
1147 "Mark all groups in the buffer.
1148 If UNMARK, remove the mark instead."
1150 (gnus-group-mark-region unmark (point-min) (point-max)))
1152 (defun gnus-group-mark-regexp (regexp)
1153 "Mark all groups that match some regexp."
1154 (interactive "sMark (regexp): ")
1155 (let ((alist (cdr gnus-newsrc-alist))
1158 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1159 (gnus-group-set-mark group))))
1160 (gnus-group-position-point))
1162 (defun gnus-group-remove-mark (group)
1163 "Remove the process mark from GROUP and move point there.
1164 Return nil if the group isn't displayed."
1165 (if (gnus-group-goto-group group)
1167 (gnus-group-mark-group 1 'unmark t)
1169 (setq gnus-group-marked
1170 (delete group gnus-group-marked))
1173 (defun gnus-group-set-mark (group)
1174 "Set the process mark on GROUP."
1175 (if (gnus-group-goto-group group)
1177 (gnus-group-mark-group 1 nil t))
1178 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1180 (defun gnus-group-universal-argument (arg &optional groups func)
1181 "Perform any command on all groups accoring to the process/prefix convention."
1183 (let ((groups (or groups (gnus-group-process-prefix arg)))
1185 (if (eq (setq func (or func
1188 (substitute-command-keys
1189 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1191 (gnus-error 1 "Undefined key")
1193 (gnus-group-remove-mark (setq group (pop groups)))
1194 (command-execute func))))
1195 (gnus-group-position-point))
1197 (defun gnus-group-process-prefix (n)
1198 "Return a list of groups to work on.
1199 Take into consideration N (the prefix) and the list of marked groups."
1202 (setq n (prefix-numeric-value n))
1203 ;; There is a prefix, so we return a list of the N next
1205 (let ((way (if (< n 0) -1 1))
1210 (setq group (gnus-group-group-name)))
1211 (setq groups (cons group groups))
1213 (gnus-group-next-group way)))
1215 ((and (boundp 'transient-mark-mode)
1217 (boundp 'mark-active)
1219 ;; Work on the region between point and mark.
1220 (let ((max (max (point) (mark)))
1223 (goto-char (min (point) (mark)))
1226 (push (gnus-group-group-name) groups)
1227 (zerop (gnus-group-next-group 1))
1229 (nreverse groups))))
1231 ;; No prefix, but a list of marked articles.
1232 (reverse gnus-group-marked))
1234 ;; Neither marked articles or a prefix, so we return the
1236 (let ((group (gnus-group-group-name)))
1237 (and group (list group))))))
1239 ;; Selecting groups.
1241 (defun gnus-group-read-group (&optional all no-article group)
1242 "Read news in this newsgroup.
1243 If the prefix argument ALL is non-nil, already read articles become
1244 readable. IF ALL is a number, fetch this number of articles. If the
1245 optional argument NO-ARTICLE is non-nil, no article will be
1246 auto-selected upon group entry. If GROUP is non-nil, fetch that
1249 (let ((no-display (eq all 0))
1250 (group (or group (gnus-group-group-name)))
1251 number active marked entry)
1255 (error "No group on current line"))
1256 (setq marked (gnus-info-marks
1257 (nth 2 (setq entry (gnus-gethash
1258 group gnus-newsrc-hashtb)))))
1259 ;; This group might be a dead group. In that case we have to get
1260 ;; the number of unread articles from `gnus-active-hashtb'.
1262 (cond ((numberp all) all)
1264 ((setq active (gnus-active group))
1265 (- (1+ (cdr active)) (car active)))))
1266 (gnus-summary-read-group
1267 group (or all (and (numberp number)
1268 (zerop (+ number (gnus-range-length
1269 (cdr (assq 'tick marked)))
1271 (cdr (assq 'dormant marked)))))))
1272 no-article nil no-display)))
1274 (defun gnus-group-select-group (&optional all)
1275 "Select this newsgroup.
1276 No article is selected automatically.
1277 If ALL is non-nil, already read articles become readable.
1278 If ALL is a number, fetch this number of articles."
1280 (gnus-group-read-group all t))
1282 (defun gnus-group-quick-select-group (&optional all)
1283 "Select the current group \"quickly\".
1284 This means that no highlighting or scoring will be performed.
1285 If ALL (the prefix argument) is 0, don't even generate the summary
1289 gnus-score-find-score-files-function
1290 gnus-apply-kill-hook
1291 gnus-summary-expunge-below)
1292 (gnus-group-read-group all t)))
1294 (defun gnus-group-visible-select-group (&optional all)
1295 "Select the current group without hiding any articles."
1297 (let ((gnus-inhibit-limiting t))
1298 (gnus-group-read-group all t)))
1301 (defun gnus-fetch-group (group)
1302 "Start Gnus if necessary and enter GROUP.
1303 Returns whether the fetching was successful or not."
1304 (interactive "sGroup name: ")
1305 (or (get-buffer gnus-group-buffer)
1307 (gnus-group-read-group nil nil group))
1309 ;; Enter a group that is not in the group buffer. Non-nil is returned
1310 ;; if selection was successful.
1311 (defun gnus-group-read-ephemeral-group (group method &optional activate
1312 quit-config request-only)
1313 "Read GROUP from METHOD as an ephemeral group.
1314 If ACTIVATE, request the group first.
1315 If QUIT-CONFIG, use that window configuration when exiting from the
1317 If REQUEST-ONLY, don't actually read the group; just request it.
1319 Return the name of the group is selection was successful."
1320 (let ((group (if (gnus-group-foreign-p group) group
1321 (gnus-group-prefixed-name group method))))
1324 `(-1 nil (,group ,gnus-level-default-subscribed nil nil ,method
1325 ((quit-config . ,(if quit-config quit-config
1326 (cons (current-buffer) 'summary))))))
1328 (set-buffer gnus-group-buffer)
1329 (unless (gnus-check-server method)
1330 (error "Unable to contact server: %s" (gnus-status-message method)))
1332 (unless (gnus-request-group group)
1333 (error "Couldn't request group: %s"
1334 (nnheader-get-report (car method))))
1335 (gnus-activate-group group nil t))
1339 (when (gnus-group-read-group t t group)
1344 (defun gnus-group-jump-to-group (group)
1345 "Jump to newsgroup GROUP."
1347 (list (completing-read
1348 "Group: " gnus-active-hashtb nil
1349 (gnus-read-active-file-p)
1351 'gnus-group-history)))
1353 (when (equal group "")
1354 (error "Empty group name"))
1356 (when (string-match "[\000-\032]" group)
1357 (error "Control characters in group: %s" group))
1359 (let ((b (text-property-any
1360 (point-min) (point-max)
1361 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
1362 (unless (gnus-ephemeral-group-p group)
1364 ;; Either go to the line in the group buffer...
1366 ;; ... or insert the line.
1368 t ;; Don't activate group.
1370 (gnus-activate-group group)
1371 (error "%s error: %s" group (gnus-status-message group)))
1373 (gnus-group-update-group group)
1374 (goto-char (text-property-any
1375 (point-min) (point-max)
1376 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
1377 ;; Adjust cursor point.
1378 (gnus-group-position-point)))
1380 (defun gnus-group-goto-group (group &optional far)
1381 "Goto to newsgroup GROUP.
1382 If FAR, it is likely that the group is not on the current line."
1387 (point-min) (point-max)
1388 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
1391 ;; It's quite likely that we are on the right line, so
1392 ;; we check the current line first.
1393 ((eq (get-text-property (point) 'gnus-group)
1394 (gnus-intern-safe group gnus-active-hashtb))
1396 ;; Previous and next line are also likely, so we check them as well.
1399 (eq (get-text-property (point) 'gnus-group)
1400 (gnus-intern-safe group gnus-active-hashtb)))
1405 (eq (get-text-property (point) 'gnus-group)
1406 (gnus-intern-safe group gnus-active-hashtb)))
1410 ;; Search through the entire buffer.
1413 (point-min) (point-max)
1414 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
1416 (defun gnus-group-next-group (n &optional silent)
1417 "Go to next N'th newsgroup.
1418 If N is negative, search backward instead.
1419 Returns the difference between N and the number of skips actually
1422 (gnus-group-next-unread-group n t nil silent))
1424 (defun gnus-group-next-unread-group (n &optional all level silent)
1425 "Go to next N'th unread newsgroup.
1426 If N is negative, search backward instead.
1427 If ALL is non-nil, choose any newsgroup, unread or not.
1428 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1429 such group can be found, the next group with a level higher than
1431 Returns the difference between N and the number of skips actually
1434 (let ((backward (< n 0))
1437 (gnus-group-search-forward
1438 backward (or (not gnus-group-goto-unread) all) level))
1442 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1443 (if level " on this level or higher" "")))
1446 (defun gnus-group-prev-group (n)
1447 "Go to previous N'th newsgroup.
1448 Returns the difference between N and the number of skips actually
1451 (gnus-group-next-unread-group (- n) t))
1453 (defun gnus-group-prev-unread-group (n)
1454 "Go to previous N'th unread newsgroup.
1455 Returns the difference between N and the number of skips actually
1458 (gnus-group-next-unread-group (- n)))
1460 (defun gnus-group-next-unread-group-same-level (n)
1461 "Go to next N'th unread newsgroup on the same level.
1462 If N is negative, search backward instead.
1463 Returns the difference between N and the number of skips actually
1466 (gnus-group-next-unread-group n t (gnus-group-group-level))
1467 (gnus-group-position-point))
1469 (defun gnus-group-prev-unread-group-same-level (n)
1470 "Go to next N'th unread newsgroup on the same level.
1471 Returns the difference between N and the number of skips actually
1474 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1475 (gnus-group-position-point))
1477 (defun gnus-group-best-unread-group (&optional exclude-group)
1478 "Go to the group with the highest level.
1479 If EXCLUDE-GROUP, do not go to that group."
1481 (goto-char (point-min))
1485 (setq unread (get-text-property (point) 'gnus-unread))
1486 (if (and (numberp unread) (> unread 0))
1488 (if (and (get-text-property (point) 'gnus-level)
1489 (< (get-text-property (point) 'gnus-level) best)
1490 (or (not exclude-group)
1491 (not (equal exclude-group (gnus-group-group-name)))))
1493 (setq best (get-text-property (point) 'gnus-level))
1494 (setq best-point (point))))))
1496 (if best-point (goto-char best-point))
1497 (gnus-summary-position-point)
1498 (and best-point (gnus-group-group-name))))
1500 (defun gnus-group-first-unread-group ()
1501 "Go to the first group with unread articles."
1504 (let ((opoint (point))
1506 (goto-char (point-min))
1507 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1508 (and (numberp unread) ; Not a topic.
1509 (not (zerop unread))) ; Has unread articles.
1510 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1513 nil)) ; Not success.
1514 (gnus-group-position-point)))
1516 (defun gnus-group-enter-server-mode ()
1517 "Jump to the server buffer."
1519 (gnus-enter-server-buffer))
1521 (defun gnus-group-make-group (name &optional method address)
1522 "Add a new newsgroup.
1523 The user will be prompted for a NAME, for a select METHOD, and an
1527 (read-string "Group name: ")
1528 (gnus-read-method "From method: ")))
1530 (let* ((meth (when (and method
1531 (not (gnus-server-equal method gnus-select-method)))
1532 (if address (list (intern method) address)
1534 (nname (if method (gnus-group-prefixed-name name meth) name))
1536 (when (gnus-gethash nname gnus-newsrc-hashtb)
1537 (error "Group %s already exists" nname))
1538 ;; Subscribe to the new group.
1539 (gnus-group-change-level
1540 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1541 gnus-level-default-subscribed gnus-level-killed
1542 (and (gnus-group-group-name)
1543 (gnus-gethash (gnus-group-group-name)
1544 gnus-newsrc-hashtb))
1547 (gnus-set-active nname (cons 1 0))
1548 (or (gnus-ephemeral-group-p name)
1550 (concat "(gnus-group-set-info '"
1551 (gnus-prin1-to-string (cdr info)) ")")))
1553 (gnus-group-insert-group-line-info nname)
1555 (gnus-group-position-point)
1557 ;; Load the backend and try to make the backend create
1558 ;; the group as well.
1559 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1561 gnus-valid-select-methods)
1563 (gnus-check-server meth)
1564 (and (gnus-check-backend-function 'request-create-group nname)
1565 (gnus-request-create-group nname))
1568 (defun gnus-group-delete-group (group &optional force)
1569 "Delete the current group. Only meaningful with mail groups.
1570 If FORCE (the prefix) is non-nil, all the articles in the group will
1571 be deleted. This is \"deleted\" as in \"removed forever from the face
1572 of the Earth\". There is no undo. The user will be prompted before
1573 doing the deletion."
1575 (list (gnus-group-group-name)
1576 current-prefix-arg))
1577 (or group (error "No group to rename"))
1578 (or (gnus-check-backend-function 'request-delete-group group)
1579 (error "This backend does not support group deletion"))
1581 (if (not (gnus-yes-or-no-p
1583 "Do you really want to delete %s%s? "
1584 group (if force " and all its contents" ""))))
1586 (gnus-message 6 "Deleting group %s..." group)
1587 (if (not (gnus-request-delete-group group force))
1588 (gnus-error 3 "Couldn't delete group %s" group)
1589 (gnus-message 6 "Deleting group %s...done" group)
1590 (gnus-group-goto-group group)
1591 (gnus-group-kill-group 1 t)
1592 (gnus-sethash group nil gnus-active-hashtb)
1594 (gnus-group-position-point)))
1596 (defun gnus-group-rename-group (group new-name)
1597 "Rename group from GROUP to NEW-NAME.
1598 When used interactively, GROUP is the group under point
1599 and NEW-NAME will be prompted for."
1602 (gnus-group-group-name)
1604 (unless (gnus-check-backend-function
1605 'request-rename-group (gnus-group-group-name))
1606 (error "This backend does not support renaming groups"))
1607 (read-string "New group name: " (gnus-group-group-name)))))
1609 (unless (gnus-check-backend-function 'request-rename-group group)
1610 (error "This backend does not support renaming groups"))
1612 (error "No group to rename"))
1613 (when (string-match "^[ \t]*$" new-name)
1614 (error "Not a valid group name"))
1615 (when (equal group new-name)
1616 (error "Can't rename to the same name"))
1618 ;; We find the proper prefixed name.
1620 (if (equal (gnus-group-real-name new-name) new-name)
1624 (gnus-group-prefixed-name
1625 (gnus-group-real-name new-name)
1626 (gnus-info-method (gnus-get-info group)))))
1628 (gnus-message 6 "Renaming group %s to %s..." group new-name)
1630 (if (not (gnus-request-rename-group group new-name))
1631 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
1632 ;; We rename the group internally by killing it...
1633 (gnus-group-goto-group group)
1634 (gnus-group-kill-group)
1635 ;; ... changing its name ...
1636 (setcar (cdar gnus-list-of-killed-groups) new-name)
1637 ;; ... and then yanking it. Magic!
1638 (gnus-group-yank-group)
1639 (gnus-set-active new-name (gnus-active group))
1640 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
1642 (gnus-group-position-point)))
1644 (defun gnus-group-edit-group (group &optional part)
1645 "Edit the group on the current line."
1646 (interactive (list (gnus-group-group-name)))
1647 (let ((part (or part 'info))
1650 (error "No group on current line"))
1651 (unless (setq info (gnus-get-info group))
1652 (error "Killed group; can't be edited"))
1654 ;; Find the proper form to edit.
1655 (cond ((eq part 'method)
1656 (or (gnus-info-method info) "native"))
1658 (gnus-info-params info))
1660 ;; The proper documentation.
1664 ((eq part 'method) "select method")
1665 ((eq part 'params) "group parameters")
1668 (gnus-group-edit-group-done ',part ,group form)))))
1670 (defun gnus-group-edit-group-method (group)
1671 "Edit the select method of GROUP."
1672 (interactive (list (gnus-group-group-name)))
1673 (gnus-group-edit-group group 'method))
1675 (defun gnus-group-edit-group-parameters (group)
1676 "Edit the group parameters of GROUP."
1677 (interactive (list (gnus-group-group-name)))
1678 (gnus-group-edit-group group 'params))
1680 (defun gnus-group-edit-group-done (part group form)
1682 (let* ((method (cond ((eq part 'info) (nth 4 form))
1683 ((eq part 'method) form)
1685 (info (cond ((eq part 'info) form)
1686 ((eq part 'method) (gnus-get-info group))
1689 (if (or (not method)
1691 gnus-select-method method))
1692 (gnus-group-real-name (car info))
1693 (gnus-group-prefixed-name
1694 (gnus-group-real-name (car info)) method))
1696 (when (and new-group
1697 (not (equal new-group group)))
1698 (when (gnus-group-goto-group group)
1699 (gnus-group-kill-group 1))
1700 (gnus-activate-group new-group))
1702 (if (not (and info new-group))
1703 (gnus-group-set-info form (or new-group group) part)
1704 (setq info (gnus-copy-sequence info))
1705 (setcar info new-group)
1706 (unless (gnus-server-equal method "native")
1707 (unless (nthcdr 3 info)
1708 (nconc info (list nil nil)))
1709 (unless (nthcdr 4 info)
1710 (nconc info (list nil)))
1711 (gnus-info-set-method info method))
1712 (gnus-group-set-info info))
1713 (gnus-group-update-group (or new-group group))
1714 (gnus-group-position-point)))
1716 (defun gnus-group-make-help-group ()
1717 "Create the Gnus documentation group."
1719 (let ((path load-path)
1720 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
1722 (and (gnus-gethash name gnus-newsrc-hashtb)
1723 (error "Documentation group already exists"))
1725 (setq dir (file-name-as-directory (expand-file-name (pop path)))
1727 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
1729 (setq file (concat (file-name-directory
1730 (directory-file-name dir))
1731 "etc/gnus-tut.txt"))))
1734 (gnus-message 1 "Couldn't find doc group")
1735 (gnus-group-make-group
1736 (gnus-group-real-name name)
1737 (list 'nndoc "gnus-help"
1738 (list 'nndoc-address file)
1739 (list 'nndoc-article-type 'mbox)))))
1740 (gnus-group-position-point))
1742 (defun gnus-group-make-doc-group (file type)
1743 "Create a group that uses a single file as the source."
1745 (list (read-file-name "File name: ")
1746 (and current-prefix-arg 'ask)))
1747 (when (eq type 'ask)
1752 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
1754 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
1755 ((= char ?b) 'babyl)
1756 ((= char ?d) 'digest)
1757 ((= char ?f) 'forward)
1759 (t (setq err (format "%c unknown. " char))
1762 (let* ((file (expand-file-name file))
1763 (name (gnus-generate-new-group-name
1764 (gnus-group-prefixed-name
1765 (file-name-nondirectory file) '(nndoc "")))))
1766 (gnus-group-make-group
1767 (gnus-group-real-name name)
1769 (list 'nndoc-address file)
1770 (list 'nndoc-article-type (or type 'guess))))))
1772 (defvar nnweb-type-definition)
1773 (defvar gnus-group-web-type-history nil)
1774 (defvar gnus-group-web-search-history nil)
1775 (defun gnus-group-make-web-group (&optional solid)
1776 "Create an ephemeral nnweb group.
1777 If SOLID (the prefix), create a solid group."
1781 (if solid (read-string "Group name: ") (message-unique-id)))
1784 "Search engine type: "
1785 (mapcar (lambda (elem) (list (symbol-name (car elem))))
1786 nnweb-type-definition)
1787 nil t (cons (or (car gnus-group-web-type-history)
1788 (symbol-name (caar nnweb-type-definition)))
1790 'gnus-group-web-type-history))
1794 (cons (or (car gnus-group-web-search-history) "") 0)
1795 'gnus-group-web-search-history))
1797 `(nnweb ,group (nnweb-search ,search)
1798 (nnweb-type ,(intern type)))))
1800 (gnus-group-make-group group method)
1801 (gnus-group-read-ephemeral-group
1803 (cons (current-buffer)
1804 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
1806 (defun gnus-group-make-archive-group (&optional all)
1807 "Create the (ding) Gnus archive group of the most recent articles.
1808 Given a prefix, create a full group."
1810 (let ((group (gnus-group-prefixed-name
1811 (if all "ding.archives" "ding.recent") '(nndir ""))))
1812 (when (gnus-gethash group gnus-newsrc-hashtb)
1813 (error "Archive group already exists"))
1814 (gnus-group-make-group
1815 (gnus-group-real-name group)
1816 (list 'nndir (if all "hpc" "edu")
1817 (list 'nndir-directory
1818 (if all gnus-group-archive-directory
1819 gnus-group-recent-archive-directory))))
1820 (gnus-group-add-parameter group (cons 'to-address "ding@ifi.uio.no"))))
1822 (defun gnus-group-make-directory-group (dir)
1823 "Create an nndir group.
1824 The user will be prompted for a directory. The contents of this
1825 directory will be used as a newsgroup. The directory should contain
1826 mail messages or news articles in files that have numeric names."
1828 (list (read-file-name "Create group from directory: ")))
1829 (or (file-exists-p dir) (error "No such directory"))
1830 (or (file-directory-p dir) (error "Not a directory"))
1834 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
1836 (gnus-group-prefixed-name
1837 (concat (file-name-as-directory (directory-file-name dir))
1840 (setq ext (format "<%d>" (setq i (1+ i)))))
1841 (gnus-group-make-group
1842 (gnus-group-real-name group)
1843 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
1845 (defun gnus-group-make-kiboze-group (group address scores)
1846 "Create an nnkiboze group.
1847 The user will be prompted for a name, a regexp to match groups, and
1848 score file entries for articles to include in the group."
1851 (read-string "nnkiboze group name: ")
1852 (read-string "Source groups (regexp): ")
1853 (let ((headers (mapcar (lambda (group) (list group))
1854 '("subject" "from" "number" "date" "message-id"
1855 "references" "chars" "lines" "xref"
1856 "followup" "all" "body" "head")))
1857 scores header regexp regexps)
1858 (while (not (equal "" (setq header (completing-read
1859 "Match on header: " headers nil t))))
1861 (while (not (equal "" (setq regexp (read-string
1862 (format "Match on %s (string): "
1864 (setq regexps (cons (list regexp nil nil 'r) regexps)))
1865 (setq scores (cons (cons header regexps) scores)))
1867 (gnus-group-make-group group "nnkiboze" address)
1868 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
1869 (let (emacs-lisp-mode-hook)
1870 (pp scores (current-buffer)))))
1872 (defun gnus-group-add-to-virtual (n vgroup)
1873 "Add the current group to a virtual group."
1875 (list current-prefix-arg
1876 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
1878 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
1879 (error "%s is not an nnvirtual group" vgroup))
1880 (let* ((groups (gnus-group-process-prefix n))
1881 (method (gnus-info-method (gnus-get-info vgroup))))
1882 (setcar (cdr method)
1884 (nth 1 method) "\\|"
1887 (gnus-group-remove-mark s)
1888 (concat "\\(^" (regexp-quote s) "$\\)"))
1890 (gnus-group-position-point))
1892 (defun gnus-group-make-empty-virtual (group)
1893 "Create a new, fresh, empty virtual group."
1894 (interactive "sCreate new, empty virtual group: ")
1895 (let* ((method (list 'nnvirtual "^$"))
1896 (pgroup (gnus-group-prefixed-name group method)))
1897 ;; Check whether it exists already.
1898 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
1899 (error "Group %s already exists." pgroup))
1900 ;; Subscribe the new group after the group on the current line.
1901 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
1902 (gnus-group-update-group pgroup)
1904 (gnus-group-position-point)))
1906 (defun gnus-group-enter-directory (dir)
1907 "Enter an ephemeral nneething group."
1908 (interactive "DDirectory to read: ")
1909 (let* ((method (list 'nneething dir '(nneething-read-only t)))
1910 (leaf (gnus-group-prefixed-name
1911 (file-name-nondirectory (directory-file-name dir))
1913 (name (gnus-generate-new-group-name leaf)))
1914 (unless (gnus-group-read-ephemeral-group
1916 (cons (current-buffer)
1917 (if (eq major-mode 'gnus-summary-mode)
1919 (error "Couldn't enter %s" dir))))
1921 ;; Group sorting commands
1922 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
1924 (defun gnus-group-sort-groups (func &optional reverse)
1925 "Sort the group buffer according to FUNC.
1926 If REVERSE, reverse the sorting order."
1927 (interactive (list gnus-group-sort-function
1928 current-prefix-arg))
1930 ((not (listp func)) func)
1932 ((= 1 (length func)) (car func))
1934 ,(gnus-make-sort-function
1935 (reverse func)))))))
1936 ;; We peel off the dummy group from the alist.
1938 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
1939 (pop gnus-newsrc-alist))
1941 (setq gnus-newsrc-alist
1942 (sort gnus-newsrc-alist func))
1944 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
1945 ;; Regenerate the hash table.
1946 (gnus-make-hashtable-from-newsrc-alist)
1947 (gnus-group-list-groups))))
1949 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
1950 "Sort the group buffer alphabetically by group name.
1951 If REVERSE, sort in reverse order."
1953 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
1955 (defun gnus-group-sort-groups-by-unread (&optional reverse)
1956 "Sort the group buffer by number of unread articles.
1957 If REVERSE, sort in reverse order."
1959 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
1961 (defun gnus-group-sort-groups-by-level (&optional reverse)
1962 "Sort the group buffer by group level.
1963 If REVERSE, sort in reverse order."
1965 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
1967 (defun gnus-group-sort-groups-by-score (&optional reverse)
1968 "Sort the group buffer by group score.
1969 If REVERSE, sort in reverse order."
1971 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
1973 (defun gnus-group-sort-groups-by-rank (&optional reverse)
1974 "Sort the group buffer by group rank.
1975 If REVERSE, sort in reverse order."
1977 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
1979 (defun gnus-group-sort-groups-by-method (&optional reverse)
1980 "Sort the group buffer alphabetically by backend name.
1981 If REVERSE, sort in reverse order."
1983 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
1985 (defun gnus-group-sort-by-alphabet (info1 info2)
1986 "Sort alphabetically."
1987 (string< (gnus-info-group info1) (gnus-info-group info2)))
1989 (defun gnus-group-sort-by-real-name (info1 info2)
1990 "Sort alphabetically on real (unprefixed) names."
1991 (string< (gnus-group-real-name (gnus-info-group info1))
1992 (gnus-group-real-name (gnus-info-group info2))))
1994 (defun gnus-group-sort-by-unread (info1 info2)
1995 "Sort by number of unread articles."
1996 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
1997 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
1998 (< (or (and (numberp n1) n1) 0)
1999 (or (and (numberp n2) n2) 0))))
2001 (defun gnus-group-sort-by-level (info1 info2)
2003 (< (gnus-info-level info1) (gnus-info-level info2)))
2005 (defun gnus-group-sort-by-method (info1 info2)
2006 "Sort alphabetically by backend name."
2007 (string< (symbol-name (car (gnus-find-method-for-group
2008 (gnus-info-group info1) info1)))
2009 (symbol-name (car (gnus-find-method-for-group
2010 (gnus-info-group info2) info2)))))
2012 (defun gnus-group-sort-by-score (info1 info2)
2013 "Sort by group score."
2014 (< (gnus-info-score info1) (gnus-info-score info2)))
2016 (defun gnus-group-sort-by-rank (info1 info2)
2017 "Sort by level and score."
2018 (let ((level1 (gnus-info-level info1))
2019 (level2 (gnus-info-level info2)))
2020 (or (< level1 level2)
2021 (and (= level1 level2)
2022 (> (gnus-info-score info1) (gnus-info-score info2))))))
2026 (defun gnus-group-clear-data (n)
2027 "Clear all marks and read ranges from the current group."
2029 (let ((groups (gnus-group-process-prefix n))
2031 (while (setq group (pop groups))
2032 (gnus-info-clear-data (setq info (gnus-get-info group)))
2033 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2034 (when (gnus-group-goto-group group)
2035 (gnus-group-remove-mark group)
2036 (gnus-group-update-group-line)))))
2038 (defun gnus-group-clear-data-on-native-groups ()
2039 "Clear all marks and read ranges from all native groups."
2041 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2042 (let ((alist (cdr gnus-newsrc-alist))
2044 (while (setq info (pop alist))
2045 (gnus-info-clear-data info))
2046 (gnus-get-unread-articles))))
2048 (defun gnus-info-clear-data (info)
2049 "Clear all marks and read ranges from INFO."
2050 (let ((group (gnus-info-group info)))
2053 (gnus-info-set-marks ,info ,(gnus-info-marks info))
2054 (gnus-info-set-read ,info ,(gnus-info-read info))
2055 (when (gnus-group-goto-group ,group)
2056 (gnus-group-update-group-line))))
2057 (gnus-info-set-read info nil)
2058 (when (gnus-info-marks info)
2059 (gnus-info-set-marks info nil))))
2061 ;; Group catching up.
2063 (defun gnus-group-catchup-current (&optional n all)
2064 "Mark all articles not marked as unread in current newsgroup as read.
2065 If prefix argument N is numeric, the ARG next newsgroups will be
2066 caught up. If ALL is non-nil, marked articles will also be marked as
2067 read. Cross references (Xref: header) of articles are ignored.
2068 The difference between N and actual number of newsgroups that were
2069 caught up is returned."
2071 (unless (gnus-group-group-name)
2072 (error "No group on the current line"))
2073 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
2077 "Do you really want to mark all articles as read? "
2078 "Mark all unread articles as read? "))))
2080 (let ((groups (gnus-group-process-prefix n))
2083 ;; Virtual groups have to be given special treatment.
2084 (let ((method (gnus-find-method-for-group (car groups))))
2085 (if (eq 'nnvirtual (car method))
2086 (nnvirtual-catchup-group
2087 (gnus-group-real-name (car groups)) (nth 1 method) all)))
2088 (gnus-group-remove-mark (car groups))
2089 (if (>= (gnus-group-group-level) gnus-level-zombie)
2090 (gnus-message 2 "Dead groups can't be caught up")
2092 (gnus-group-goto-group (car groups))
2093 (gnus-group-catchup (car groups) all))
2094 (gnus-group-update-group-line)
2095 (setq ret (1+ ret))))
2096 (setq groups (cdr groups)))
2097 (gnus-group-next-unread-group 1)
2100 (defun gnus-group-catchup-current-all (&optional n)
2101 "Mark all articles in current newsgroup as read.
2102 Cross references (Xref: header) of articles are ignored."
2104 (gnus-group-catchup-current n 'all))
2106 (defun gnus-group-catchup (group &optional all)
2107 "Mark all articles in GROUP as read.
2108 If ALL is non-nil, all articles are marked as read.
2109 The return value is the number of articles that were marked as read,
2110 or nil if no action could be taken."
2111 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2113 ;; Do the updating only if the newsgroup isn't killed.
2114 (if (not (numberp (car entry)))
2115 (gnus-message 1 "Can't catch up; non-active group")
2116 ;; Do auto-expirable marks if that's required.
2117 (when (gnus-group-auto-expirable-p group)
2118 (gnus-add-marked-articles
2119 group 'expire (gnus-list-of-unread-articles group))
2121 (let ((marks (nth 3 (nth 2 entry))))
2122 (gnus-add-marked-articles
2123 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2124 (gnus-add-marked-articles
2125 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2127 (gnus-update-read-articles group nil)
2128 ;; Also nix out the lists of marks and dormants.
2130 (gnus-add-marked-articles group 'tick nil nil 'force)
2131 (gnus-add-marked-articles group 'dormant nil nil 'force))
2132 (run-hooks 'gnus-group-catchup-group-hook)
2135 (defun gnus-group-expire-articles (&optional n)
2136 "Expire all expirable articles in the current newsgroup."
2138 (let ((groups (gnus-group-process-prefix n))
2141 (error "No groups to expire"))
2142 (while (setq group (pop groups))
2143 (gnus-group-remove-mark group)
2144 (when (gnus-check-backend-function 'request-expire-articles group)
2145 (gnus-message 6 "Expiring articles in %s..." group)
2146 (let* ((info (gnus-get-info group))
2147 (expirable (if (gnus-group-total-expirable-p group)
2148 (cons nil (gnus-list-of-read-articles group))
2149 (assq 'expire (gnus-info-marks info))))
2150 (expiry-wait (gnus-group-find-parameter group 'expiry-wait)))
2154 (gnus-compress-sequence
2156 ;; We set the expiry variables to the groupp
2158 (let ((nnmail-expiry-wait-function nil)
2159 (nnmail-expiry-wait expiry-wait))
2160 (gnus-request-expire-articles
2161 (gnus-uncompress-sequence (cdr expirable)) group))
2162 ;; Just expire using the normal expiry values.
2163 (gnus-request-expire-articles
2164 (gnus-uncompress-sequence (cdr expirable)) group))))
2165 (gnus-close-group group))
2166 (gnus-message 6 "Expiring articles in %s...done" group)))
2167 (gnus-group-position-point))))
2169 (defun gnus-group-expire-all-groups ()
2170 "Expire all expirable articles in all newsgroups."
2173 (gnus-message 5 "Expiring...")
2174 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2175 (cdr gnus-newsrc-alist))))
2176 (gnus-group-expire-articles nil)))
2177 (gnus-group-position-point)
2178 (gnus-message 5 "Expiring...done"))
2180 (defun gnus-group-set-current-level (n level)
2181 "Set the level of the next N groups to LEVEL."
2186 (let ((s (read-string
2187 (format "Level (default %s): "
2188 (or (gnus-group-group-level)
2189 gnus-level-default-subscribed)))))
2190 (if (string-match "^\\s-*$" s)
2191 (int-to-string (or (gnus-group-group-level)
2192 gnus-level-default-subscribed))
2194 (or (and (>= level 1) (<= level gnus-level-killed))
2195 (error "Illegal level: %d" level))
2196 (let ((groups (gnus-group-process-prefix n))
2198 (while (setq group (pop groups))
2199 (gnus-group-remove-mark group)
2200 (gnus-message 6 "Changed level of %s from %d to %d"
2201 group (or (gnus-group-group-level) gnus-level-killed)
2203 (gnus-group-change-level
2204 group level (or (gnus-group-group-level) gnus-level-killed))
2205 (gnus-group-update-group-line)))
2206 (gnus-group-position-point))
2208 (defun gnus-group-unsubscribe-current-group (&optional n)
2209 "Toggle subscription of the current group.
2210 If given numerical prefix, toggle the N next groups."
2212 (let ((groups (gnus-group-process-prefix n))
2215 (setq group (car groups)
2216 groups (cdr groups))
2217 (gnus-group-remove-mark group)
2218 (gnus-group-unsubscribe-group
2219 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
2220 gnus-level-default-unsubscribed
2221 gnus-level-default-subscribed) t)
2222 (gnus-group-update-group-line))
2223 (gnus-group-next-group 1)))
2225 (defun gnus-group-unsubscribe-group (group &optional level silent)
2226 "Toggle subscription to GROUP.
2227 Killed newsgroups are subscribed. If SILENT, don't try to update the
2230 (list (completing-read
2231 "Group: " gnus-active-hashtb nil
2232 (gnus-read-active-file-p)
2234 'gnus-group-history)))
2235 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2237 ((string-match "^[ \t]$" group)
2238 (error "Empty group name"))
2240 ;; Toggle subscription flag.
2241 (gnus-group-change-level
2242 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
2243 gnus-level-subscribed)
2244 (1+ gnus-level-subscribed)
2245 gnus-level-default-subscribed)))
2247 (gnus-group-update-group group)))
2248 ((and (stringp group)
2249 (or (not (gnus-read-active-file-p))
2250 (gnus-active group)))
2251 ;; Add new newsgroup.
2252 (gnus-group-change-level
2254 (if level level gnus-level-default-subscribed)
2255 (or (and (member group gnus-zombie-list)
2258 (and (gnus-group-group-name)
2259 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2261 (gnus-group-update-group group)))
2262 (t (error "No such newsgroup: %s" group)))
2263 (gnus-group-position-point)))
2265 (defun gnus-group-transpose-groups (n)
2266 "Move the current newsgroup up N places.
2267 If given a negative prefix, move down instead. The difference between
2268 N and the number of steps taken is returned."
2270 (or (gnus-group-group-name)
2271 (error "No group on current line"))
2272 (gnus-group-kill-group 1)
2274 (forward-line (- n))
2275 (gnus-group-yank-group)
2276 (gnus-group-position-point)))
2278 (defun gnus-group-kill-all-zombies ()
2279 "Kill all zombie newsgroups."
2281 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2282 (setq gnus-zombie-list nil)
2283 (gnus-group-list-groups))
2285 (defun gnus-group-kill-region (begin end)
2286 "Kill newsgroups in current region (excluding current point).
2287 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2302 (beginning-of-line) ;Important when LINES < 1
2303 (gnus-group-kill-group lines)))
2305 (defun gnus-group-kill-group (&optional n discard)
2306 "Kill the next N groups.
2307 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2308 However, only groups that were alive can be yanked; already killed
2309 groups or zombie groups can't be yanked.
2310 The return value is the name of the group that was killed, or a list
2313 (let ((buffer-read-only nil)
2314 (groups (gnus-group-process-prefix n))
2315 group entry level out)
2316 (if (< (length groups) 10)
2317 ;; This is faster when there are few groups.
2319 (push (setq group (pop groups)) out)
2320 (gnus-group-remove-mark group)
2321 (setq level (gnus-group-group-level))
2323 (when (and (not discard)
2324 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2327 (gnus-group-goto-group ,(gnus-group-group-name))
2328 (gnus-group-yank-group)))
2329 (push (cons (car entry) (nth 2 entry))
2330 gnus-list-of-killed-groups))
2331 (gnus-group-change-level
2332 (if entry entry group) gnus-level-killed (if entry nil level)))
2333 ;; If there are lots and lots of groups to be killed, we use
2334 ;; this thing instead.
2336 (setq groups (nreverse groups))
2338 (gnus-group-remove-mark (setq group (pop groups)))
2340 (push group gnus-killed-list)
2341 (setq gnus-newsrc-alist
2342 (delq (assoc group gnus-newsrc-alist)
2344 (when gnus-group-change-level-function
2345 (funcall gnus-group-change-level-function group 9 3))
2347 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2348 (push (cons (car entry) (nth 2 entry))
2349 gnus-list-of-killed-groups)
2350 (setcdr (cdr entry) (cdddr entry)))
2351 ((member group gnus-zombie-list)
2352 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
2353 (gnus-make-hashtable-from-newsrc-alist)))
2355 (gnus-group-position-point)
2356 (if (< (length out) 2) (car out) (nreverse out))))
2358 (defun gnus-group-yank-group (&optional arg)
2359 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
2360 inserting it before the current newsgroup. The numeric ARG specifies
2361 how many newsgroups are to be yanked. The name of the newsgroup yanked
2362 is returned, or (if several groups are yanked) a list of yanked groups
2365 (setq arg (or arg 1))
2366 (let (info group prev out)
2367 (while (>= (decf arg) 0)
2368 (if (not (setq info (pop gnus-list-of-killed-groups)))
2369 (error "No more newsgroups to yank"))
2370 (push (setq group (nth 1 info)) out)
2371 ;; Find which newsgroup to insert this one before - search
2372 ;; backward until something suitable is found. If there are no
2373 ;; other newsgroups in this buffer, just make this newsgroup the
2375 (setq prev (gnus-group-group-name))
2376 (gnus-group-change-level
2377 info (gnus-info-level (cdr info)) gnus-level-killed
2378 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
2380 (gnus-group-insert-group-line-info group)
2382 `(when (gnus-group-goto-group ,group)
2383 (gnus-group-kill-group 1))))
2385 (gnus-group-position-point)
2386 (if (< (length out) 2) (car out) (nreverse out))))
2388 (defun gnus-group-kill-level (level)
2389 "Kill all groups that is on a certain LEVEL."
2390 (interactive "nKill all groups on level: ")
2392 ((= level gnus-level-zombie)
2393 (setq gnus-killed-list
2394 (nconc gnus-zombie-list gnus-killed-list))
2395 (setq gnus-zombie-list nil))
2396 ((and (< level gnus-level-zombie)
2398 (or gnus-expert-user
2401 "Do you really want to kill all groups on level %d? "
2403 (let* ((prev gnus-newsrc-alist)
2406 (if (= (gnus-info-level (car alist)) level)
2408 (push (gnus-info-group (car alist)) gnus-killed-list)
2409 (setcdr prev (cdr alist)))
2411 (setq alist (cdr alist)))
2412 (gnus-make-hashtable-from-newsrc-alist)
2413 (gnus-group-list-groups)))
2415 (error "Can't kill; illegal level: %d" level))))
2417 (defun gnus-group-list-all-groups (&optional arg)
2418 "List all newsgroups with level ARG or lower.
2419 Default is gnus-level-unsubscribed, which lists all subscribed and most
2420 unsubscribed groups."
2422 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
2424 ;; Redefine this to list ALL killed groups if prefix arg used.
2425 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
2426 (defun gnus-group-list-killed (&optional arg)
2427 "List all killed newsgroups in the group buffer.
2428 If ARG is non-nil, list ALL killed groups known to Gnus. This may
2429 entail asking the server for the groups."
2431 ;; Find all possible killed newsgroups if arg.
2433 (gnus-get-killed-groups))
2434 (if (not gnus-killed-list)
2435 (gnus-message 6 "No killed groups")
2436 (let (gnus-group-list-mode)
2437 (funcall gnus-group-prepare-function
2438 gnus-level-killed t gnus-level-killed))
2439 (goto-char (point-min)))
2440 (gnus-group-position-point))
2442 (defun gnus-group-list-zombies ()
2443 "List all zombie newsgroups in the group buffer."
2445 (if (not gnus-zombie-list)
2446 (gnus-message 6 "No zombie groups")
2447 (let (gnus-group-list-mode)
2448 (funcall gnus-group-prepare-function
2449 gnus-level-zombie t gnus-level-zombie))
2450 (goto-char (point-min)))
2451 (gnus-group-position-point))
2453 (defun gnus-group-list-active ()
2454 "List all groups that are available from the server(s)."
2456 ;; First we make sure that we have really read the active file.
2457 (unless (gnus-read-active-file-p)
2458 (let ((gnus-read-active-file t))
2459 (gnus-read-active-file)))
2460 ;; Find all groups and sort them.
2468 (setq list (cons (symbol-name sym) list))))
2472 (buffer-read-only nil))
2475 (gnus-group-insert-group-line-info (pop groups)))
2476 (goto-char (point-min))))
2478 (defun gnus-activate-all-groups (level)
2479 "Activate absolutely all groups."
2480 (interactive (list 7))
2481 (let ((gnus-activate-level level)
2482 (gnus-activate-foreign-newsgroups level))
2483 (gnus-group-get-new-news)))
2485 (defun gnus-group-get-new-news (&optional arg)
2486 "Get newly arrived articles.
2487 If ARG is a number, it specifies which levels you are interested in
2488 re-scanning. If ARG is non-nil and not a number, this will force
2489 \"hard\" re-reading of the active files from all servers."
2491 (run-hooks 'gnus-get-new-news-hook)
2492 ;; We might read in new NoCeM messages here.
2493 (when (and gnus-use-nocem
2495 (gnus-nocem-scan-groups))
2496 ;; If ARG is not a number, then we read the active file.
2497 (when (and arg (not (numberp arg)))
2498 (let ((gnus-read-active-file t))
2499 (gnus-read-active-file))
2502 (setq arg (gnus-group-default-level arg t))
2503 (if (and gnus-read-active-file (not arg))
2505 (gnus-read-active-file)
2506 (gnus-get-unread-articles arg))
2507 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
2508 (gnus-get-unread-articles arg)))
2509 (run-hooks 'gnus-after-getting-new-news-hook)
2510 (gnus-group-list-groups))
2512 (defun gnus-group-get-new-news-this-group (&optional n)
2513 "Check for newly arrived news in the current group (and the N-1 next groups).
2514 The difference between N and the number of newsgroup checked is returned.
2515 If N is negative, this group and the N-1 previous groups will be checked."
2517 (let* ((groups (gnus-group-process-prefix n))
2518 (ret (if (numberp n) (- n (length groups)) 0))
2519 (beg (unless n (point)))
2521 (while (setq group (pop groups))
2522 (gnus-group-remove-mark group)
2523 ;; Bypass any previous denials from the server.
2524 (gnus-remove-denial (gnus-find-method-for-group group))
2525 (if (gnus-activate-group group 'scan)
2527 (gnus-get-unread-articles-in-group
2528 (gnus-get-info group) (gnus-active group) t)
2529 (unless (gnus-virtual-group-p group)
2530 (gnus-close-group group))
2531 (gnus-group-update-group group))
2532 (if (eq (gnus-server-status (gnus-find-method-for-group group))
2534 (gnus-error 3 "Server denied access")
2535 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
2536 (when beg (goto-char beg))
2537 (when gnus-goto-next-group-when-activating
2538 (gnus-group-next-unread-group 1 t))
2539 (gnus-summary-position-point)
2542 (defun gnus-group-fetch-faq (group &optional faq-dir)
2543 "Fetch the FAQ for the current group.
2544 If given a prefix argument, prompt for the FAQ dir
2548 (gnus-group-group-name)
2549 (cond (current-prefix-arg
2551 "Faq dir: " (and (listp gnus-group-faq-directory)
2552 (mapcar (lambda (file) (list file))
2553 gnus-group-faq-directory)))))))
2555 (error "No group name given"))
2556 (let ((dirs (or faq-dir gnus-group-faq-directory))
2558 (unless (listp dirs)
2559 (setq dirs (list dirs)))
2560 (while (and (not found)
2561 (setq dir (pop dirs)))
2562 (setq file (concat (file-name-as-directory dir)
2563 (gnus-group-real-name group)))
2564 (if (not (file-exists-p file))
2565 (gnus-message 1 "No such file: %s" file)
2569 (defun gnus-group-describe-group (force &optional group)
2570 "Display a description of the current newsgroup."
2571 (interactive (list current-prefix-arg (gnus-group-group-name)))
2572 (let* ((method (gnus-find-method-for-group group))
2573 (mname (gnus-group-prefixed-name "" method))
2576 gnus-description-hashtb)
2577 (gnus-sethash mname nil gnus-description-hashtb))
2578 (or group (error "No group name given"))
2579 (and (or (and gnus-description-hashtb
2580 ;; We check whether this group's method has been
2581 ;; queried for a description file.
2582 (gnus-gethash mname gnus-description-hashtb))
2583 (setq desc (gnus-group-get-description group))
2584 (gnus-read-descriptions-file method))
2586 (or desc (gnus-gethash group gnus-description-hashtb)
2587 "No description available")))))
2589 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
2590 (defun gnus-group-describe-all-groups (&optional force)
2591 "Pop up a buffer with descriptions of all newsgroups."
2593 (and force (setq gnus-description-hashtb nil))
2594 (if (not (or gnus-description-hashtb
2595 (gnus-read-all-descriptions-files)))
2596 (error "Couldn't request descriptions file"))
2597 (let ((buffer-read-only nil)
2603 (insert (format " *: %-20s %s\n" (symbol-name group)
2604 (symbol-value group)))
2605 (gnus-add-text-properties
2606 b (1+ b) (list 'gnus-group group
2607 'gnus-unread t 'gnus-marked nil
2608 'gnus-level (1+ gnus-level-subscribed))))
2609 gnus-description-hashtb)
2610 (goto-char (point-min))
2611 (gnus-group-position-point)))
2613 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
2614 (defun gnus-group-apropos (regexp &optional search-description)
2615 "List all newsgroups that have names that match a regexp."
2616 (interactive "sGnus apropos (regexp): ")
2618 (obuf (current-buffer))
2620 ;; Go through all newsgroups that are known to Gnus.
2623 (and (symbol-name group)
2624 (string-match regexp (symbol-name group))
2625 (setq groups (cons (symbol-name group) groups))))
2627 ;; Also go through all descriptions that are known to Gnus.
2628 (when search-description
2631 (and (string-match regexp (symbol-value group))
2632 (gnus-active (symbol-name group))
2633 (setq groups (cons (symbol-name group) groups))))
2634 gnus-description-hashtb))
2636 (gnus-message 3 "No groups matched \"%s\"." regexp)
2637 ;; Print out all the groups.
2639 (pop-to-buffer "*Gnus Help*")
2640 (buffer-disable-undo (current-buffer))
2642 (setq groups (sort groups 'string<))
2644 ;; Groups may be entered twice into the list of groups.
2645 (if (not (string= (car groups) prev))
2647 (insert (setq prev (car groups)) "\n")
2648 (if (and gnus-description-hashtb
2649 (setq des (gnus-gethash (car groups)
2650 gnus-description-hashtb)))
2651 (insert " " des "\n"))))
2652 (setq groups (cdr groups)))
2653 (goto-char (point-min))))
2654 (pop-to-buffer obuf)))
2656 (defun gnus-group-description-apropos (regexp)
2657 "List all newsgroups that have names or descriptions that match a regexp."
2658 (interactive "sGnus description apropos (regexp): ")
2659 (if (not (or gnus-description-hashtb
2660 (gnus-read-all-descriptions-files)))
2661 (error "Couldn't request descriptions file"))
2662 (gnus-group-apropos regexp t))
2664 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
2665 (defun gnus-group-list-matching (level regexp &optional all lowest)
2666 "List all groups with unread articles that match REGEXP.
2667 If the prefix LEVEL is non-nil, it should be a number that says which
2668 level to cut off listing groups.
2669 If ALL, also list groups with no unread articles.
2670 If LOWEST, don't list groups with level lower than LOWEST.
2672 This command may read the active file."
2673 (interactive "P\nsList newsgroups matching: ")
2674 ;; First make sure active file has been read.
2676 (> (prefix-numeric-value level) gnus-level-killed))
2677 (gnus-get-killed-groups))
2678 (gnus-group-prepare-flat (or level gnus-level-subscribed)
2679 all (or lowest 1) regexp)
2680 (goto-char (point-min))
2681 (gnus-group-position-point))
2683 (defun gnus-group-list-all-matching (level regexp &optional lowest)
2684 "List all groups that match REGEXP.
2685 If the prefix LEVEL is non-nil, it should be a number that says which
2686 level to cut off listing groups.
2687 If LOWEST, don't list groups with level lower than LOWEST."
2688 (interactive "P\nsList newsgroups matching: ")
2689 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
2691 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
2692 (defun gnus-group-save-newsrc (&optional force)
2693 "Save the Gnus startup files.
2694 If FORCE, force saving whether it is necessary or not."
2696 (gnus-save-newsrc-file force))
2698 (defun gnus-group-restart (&optional arg)
2699 "Force Gnus to read the .newsrc file."
2701 (when (gnus-yes-or-no-p
2702 (format "Are you sure you want to restart Gnus? "))
2703 (gnus-save-newsrc-file)
2704 (gnus-setup-news 'force)
2705 (gnus-group-list-groups arg)))
2707 (defun gnus-group-read-init-file ()
2708 "Read the Gnus elisp init file."
2710 (gnus-read-init-file))
2712 (defun gnus-group-check-bogus-groups (&optional silent)
2713 "Check bogus newsgroups.
2714 If given a prefix, don't ask for confirmation before removing a bogus
2717 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
2718 (gnus-group-list-groups))
2720 (defun gnus-group-edit-global-kill (&optional article group)
2721 "Edit the global kill file.
2722 If GROUP, edit that local kill file instead."
2724 (setq gnus-current-kill-article article)
2725 (gnus-kill-file-edit-file group)
2728 (substitute-command-keys
2729 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
2730 (if group "local" "global")))))
2732 (defun gnus-group-edit-local-kill (article group)
2733 "Edit a local kill file."
2734 (interactive (list nil (gnus-group-group-name)))
2735 (gnus-group-edit-global-kill article group))
2737 (defun gnus-group-force-update ()
2738 "Update `.newsrc' file."
2740 (gnus-save-newsrc-file))
2742 (defun gnus-group-suspend ()
2743 "Suspend the current Gnus session.
2744 In fact, cleanup buffers except for group mode buffer.
2745 The hook gnus-suspend-gnus-hook is called before actually suspending."
2747 (run-hooks 'gnus-suspend-gnus-hook)
2748 ;; Kill Gnus buffers except for group mode buffer.
2749 (let* ((group-buf (get-buffer gnus-group-buffer))
2750 ;; Do this on a separate list in case the user does a ^G before we finish
2752 (delete group-buf (delete gnus-dribble-buffer
2753 (append gnus-buffer-list nil)))))
2754 (while gnus-buffer-list
2755 (gnus-kill-buffer (pop gnus-buffer-list)))
2756 (gnus-kill-gnus-frames)
2758 (setq gnus-buffer-list (list group-buf))
2759 (bury-buffer group-buf)
2760 (delete-windows-on group-buf t))))
2762 (defun gnus-group-clear-dribble ()
2763 "Clear all information from the dribble buffer."
2765 (gnus-dribble-clear)
2766 (gnus-message 7 "Cleared dribble buffer"))
2768 (defun gnus-group-exit ()
2769 "Quit reading news after updating .newsrc.eld and .newsrc.
2770 The hook `gnus-exit-gnus-hook' is called before actually exiting."
2773 (or noninteractive ;For gnus-batch-kill
2774 (not gnus-interactive-exit) ;Without confirmation
2776 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
2777 (run-hooks 'gnus-exit-gnus-hook)
2778 ;; Offer to save data from non-quitted summary buffers.
2779 (gnus-offer-save-summaries)
2780 ;; Save the newsrc file(s).
2781 (gnus-save-newsrc-file)
2783 (gnus-close-backends)
2784 ;; Reset everything.
2786 ;; Allow the user to do things after cleaning up.
2787 (run-hooks 'gnus-after-exiting-gnus-hook)))
2789 (defun gnus-group-quit ()
2790 "Quit reading news without updating .newsrc.eld or .newsrc.
2791 The hook `gnus-exit-gnus-hook' is called before actually exiting."
2793 (when (or noninteractive ;For gnus-batch-kill
2794 (zerop (buffer-size))
2795 (not (gnus-server-opened gnus-select-method))
2797 (not gnus-current-startup-file)
2799 (format "Quit reading news without saving %s? "
2800 (file-name-nondirectory gnus-current-startup-file))))
2801 (run-hooks 'gnus-exit-gnus-hook)
2802 (gnus-configure-windows 'group t)
2804 (gnus-close-backends)
2806 (gnus-kill-buffer gnus-group-buffer)
2807 ;; Allow the user to do things after cleaning up.
2808 (run-hooks 'gnus-after-exiting-gnus-hook)))
2810 (defun gnus-group-describe-briefly ()
2811 "Give a one line description of the group mode commands."
2813 (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")))
2815 (defun gnus-group-browse-foreign-server (method)
2816 "Browse a foreign news server.
2817 If called interactively, this function will ask for a select method
2818 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
2819 If not, METHOD should be a list where the first element is the method
2820 and the second element is the address."
2822 (list (let ((how (completing-read
2824 (append gnus-valid-select-methods gnus-server-alist)
2825 nil t (cons "nntp" 0) 'gnus-method-history)))
2826 ;; We either got a backend name or a virtual server name.
2827 ;; If the first, we also need an address.
2828 (if (assoc how gnus-valid-select-methods)
2830 ;; Suggested by mapjph@bath.ac.uk.
2833 (mapcar (lambda (server) (list server))
2834 gnus-secondary-servers)))
2835 ;; We got a server name, so we find the method.
2836 (gnus-server-to-method how)))))
2837 (gnus-browse-foreign-server method))
2839 (defun gnus-group-set-info (info &optional method-only-group part)
2840 (let* ((entry (gnus-gethash
2841 (or method-only-group (gnus-info-group info))
2842 gnus-newsrc-hashtb))
2844 (info (if method-only-group (nth 2 entry) info))
2846 (when method-only-group
2848 (error "Trying to change non-existent group %s" method-only-group))
2849 ;; We have received parts of the actual group info - either the
2850 ;; select method or the group parameters. We first check
2851 ;; whether we have to extend the info, and if so, do that.
2852 (let ((len (length info))
2853 (total (if (eq part 'method) 5 6)))
2855 (setcdr (nthcdr (1- len) info)
2856 (make-list (- total len) nil)))
2857 ;; Then we enter the new info.
2858 (setcar (nthcdr (1- total) info) part-info)))
2860 ;; This is a new group, so we just create it.
2862 (set-buffer gnus-group-buffer)
2863 (setq method (gnus-info-method info))
2864 (when (gnus-server-equal method "native")
2867 (set-buffer gnus-group-buffer)
2869 ;; It's a foreign group...
2870 (gnus-group-make-group
2871 (gnus-group-real-name (gnus-info-group info))
2872 (if (stringp method) method
2873 (prin1-to-string (car method)))
2875 (nth 1 (gnus-info-method info))))
2876 ;; It's a native group.
2877 (gnus-group-make-group (gnus-info-group info))))
2878 (gnus-message 6 "Note: New group created")
2880 (gnus-gethash (gnus-group-prefixed-name
2881 (gnus-group-real-name (gnus-info-group info))
2882 (or (gnus-info-method info) gnus-select-method))
2883 gnus-newsrc-hashtb))))
2884 ;; Whether it was a new group or not, we now have the entry, so we
2885 ;; can do the update.
2888 (setcar (nthcdr 2 entry) info)
2889 (when (and (not (eq (car entry) t))
2890 (gnus-active (gnus-info-group info)))
2891 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
2892 (error "No such group: %s" (gnus-info-group info)))))
2894 (defun gnus-group-set-method-info (group select-method)
2895 (gnus-group-set-info select-method group 'method))
2897 (defun gnus-group-set-params-info (group params)
2898 (gnus-group-set-info params group 'params))
2900 (defun gnus-add-marked-articles (group type articles &optional info force)
2901 ;; Add ARTICLES of TYPE to the info of GROUP.
2902 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
2903 ;; add, but replace marked articles of TYPE with ARTICLES.
2904 (let ((info (or info (gnus-get-info group)))
2905 (uncompressed '(score bookmark killed))
2908 (and (not (setq marked (nthcdr 3 info)))
2910 (setcdr (nthcdr 2 info)
2911 (list (list (cons type (gnus-compress-sequence
2913 (and (not (setq m (assq type (car marked))))
2916 (cons (cons type (gnus-compress-sequence articles t) )
2920 (setcar (nthcdr 3 info)
2921 (delq (assq type (car marked)) (car marked)))
2922 (setcdr m (gnus-compress-sequence articles t)))
2923 (setcdr m (gnus-compress-sequence
2924 (sort (nconc (gnus-uncompress-range (cdr m))
2925 (copy-sequence articles)) '<) t))))))
2927 (defun gnus-update-read-articles (group unread)
2928 "Update the list of read articles in GROUP."
2929 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
2930 (entry (gnus-gethash group gnus-newsrc-hashtb))
2931 (info (nth 2 entry))
2933 (unread (sort (copy-sequence unread) '<))
2935 (if (or (not info) (not active))
2936 ;; There is no info on this group if it was, in fact,
2937 ;; killed. Gnus stores no information on killed groups, so
2938 ;; there's nothing to be done.
2939 ;; One could store the information somewhere temporarily,
2940 ;; perhaps... Hmmm...
2942 ;; Remove any negative articles numbers.
2943 (while (and unread (< (car unread) 0))
2944 (setq unread (cdr unread)))
2945 ;; Remove any expired article numbers
2946 (while (and unread (< (car unread) (car active)))
2947 (setq unread (cdr unread)))
2948 ;; Compute the ranges of read articles by looking at the list of
2951 (if (/= (car unread) prev)
2952 (setq read (cons (if (= prev (1- (car unread))) prev
2953 (cons prev (1- (car unread)))) read)))
2954 (setq prev (1+ (car unread)))
2955 (setq unread (cdr unread)))
2956 (when (<= prev (cdr active))
2957 (setq read (cons (cons prev (cdr active)) read)))
2960 (gnus-info-set-marks ,info ,(gnus-info-marks info))
2961 (gnus-info-set-read ,info ,(gnus-info-read info))
2962 (gnus-get-unread-articles-in-group ,info (gnus-active ,group))))
2963 ;; Enter this list into the group info.
2965 info (if (> (length read) 1) (nreverse read) read))
2966 ;; Set the number of unread articles in gnus-newsrc-hashtb.
2967 (gnus-get-unread-articles-in-group info (gnus-active group))
2970 (provide 'gnus-group)
2972 ;;; gnus-group.el ends here