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 ((group (or group (gnus-group-group-name)))
1250 number active marked entry)
1251 (or group (error "No group on current line"))
1252 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
1253 group gnus-newsrc-hashtb)))))
1254 ;; This group might be a dead group. In that case we have to get
1255 ;; the number of unread articles from `gnus-active-hashtb'.
1257 (cond ((numberp all) all)
1259 ((setq active (gnus-active group))
1260 (- (1+ (cdr active)) (car active)))))
1261 (gnus-summary-read-group
1262 group (or all (and (numberp number)
1263 (zerop (+ number (gnus-range-length
1264 (cdr (assq 'tick marked)))
1266 (cdr (assq 'dormant marked)))))))
1269 (defun gnus-group-select-group (&optional all)
1270 "Select this newsgroup.
1271 No article is selected automatically.
1272 If ALL is non-nil, already read articles become readable.
1273 If ALL is a number, fetch this number of articles."
1275 (gnus-group-read-group all t))
1277 (defun gnus-group-quick-select-group (&optional all)
1278 "Select the current group \"quickly\".
1279 This means that no highlighting or scoring will be performed."
1282 gnus-score-find-score-files-function
1283 gnus-apply-kill-hook
1284 gnus-summary-expunge-below)
1285 (gnus-group-read-group all t)))
1287 (defun gnus-group-visible-select-group (&optional all)
1288 "Select the current group without hiding any articles."
1290 (let ((gnus-inhibit-limiting t))
1291 (gnus-group-read-group all t)))
1294 (defun gnus-fetch-group (group)
1295 "Start Gnus if necessary and enter GROUP.
1296 Returns whether the fetching was successful or not."
1297 (interactive "sGroup name: ")
1298 (or (get-buffer gnus-group-buffer)
1300 (gnus-group-read-group nil nil group))
1302 ;; Enter a group that is not in the group buffer. Non-nil is returned
1303 ;; if selection was successful.
1304 (defun gnus-group-read-ephemeral-group (group method &optional activate
1305 quit-config request-only)
1306 "Read GROUP from METHOD as an ephemeral group.
1307 If ACTIVATE, request the group first.
1308 If QUIT-CONFIG, use that window configuration when exiting from the
1310 If REQUEST-ONLY, don't actually read the group; just request it.
1312 Return the name of the group is selection was successful."
1313 (let ((group (if (gnus-group-foreign-p group) group
1314 (gnus-group-prefixed-name group method))))
1317 `(-1 nil (,group ,gnus-level-default-subscribed nil nil ,method
1318 ((quit-config . ,(if quit-config quit-config
1319 (cons (current-buffer) 'summary))))))
1321 (set-buffer gnus-group-buffer)
1322 (unless (gnus-check-server method)
1323 (error "Unable to contact server: %s" (gnus-status-message method)))
1325 (unless (gnus-request-group group)
1326 (error "Couldn't request group: %s"
1327 (nnheader-get-report (car method))))
1328 (gnus-activate-group group nil t))
1332 (when (gnus-group-read-group t t group)
1337 (defun gnus-group-jump-to-group (group)
1338 "Jump to newsgroup GROUP."
1340 (list (completing-read
1341 "Group: " gnus-active-hashtb nil
1342 (gnus-read-active-file-p)
1344 'gnus-group-history)))
1346 (when (equal group "")
1347 (error "Empty group name"))
1349 (when (string-match "[\000-\032]" group)
1350 (error "Control characters in group: %s" group))
1352 (let ((b (text-property-any
1353 (point-min) (point-max)
1354 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
1355 (unless (gnus-ephemeral-group-p group)
1357 ;; Either go to the line in the group buffer...
1359 ;; ... or insert the line.
1361 t ;; Don't activate group.
1363 (gnus-activate-group group)
1364 (error "%s error: %s" group (gnus-status-message group)))
1366 (gnus-group-update-group group)
1367 (goto-char (text-property-any
1368 (point-min) (point-max)
1369 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
1370 ;; Adjust cursor point.
1371 (gnus-group-position-point)))
1373 (defun gnus-group-goto-group (group &optional far)
1374 "Goto to newsgroup GROUP.
1375 If FAR, it is likely that the group is not on the current line."
1380 (point-min) (point-max)
1381 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
1384 ;; It's quite likely that we are on the right line, so
1385 ;; we check the current line first.
1386 ((eq (get-text-property (point) 'gnus-group)
1387 (gnus-intern-safe group gnus-active-hashtb))
1389 ;; Previous and next line are also likely, so we check them as well.
1392 (eq (get-text-property (point) 'gnus-group)
1393 (gnus-intern-safe group gnus-active-hashtb)))
1398 (eq (get-text-property (point) 'gnus-group)
1399 (gnus-intern-safe group gnus-active-hashtb)))
1403 ;; Search through the entire buffer.
1406 (point-min) (point-max)
1407 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
1409 (defun gnus-group-next-group (n &optional silent)
1410 "Go to next N'th newsgroup.
1411 If N is negative, search backward instead.
1412 Returns the difference between N and the number of skips actually
1415 (gnus-group-next-unread-group n t nil silent))
1417 (defun gnus-group-next-unread-group (n &optional all level silent)
1418 "Go to next N'th unread newsgroup.
1419 If N is negative, search backward instead.
1420 If ALL is non-nil, choose any newsgroup, unread or not.
1421 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1422 such group can be found, the next group with a level higher than
1424 Returns the difference between N and the number of skips actually
1427 (let ((backward (< n 0))
1430 (gnus-group-search-forward
1431 backward (or (not gnus-group-goto-unread) all) level))
1435 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1436 (if level " on this level or higher" "")))
1439 (defun gnus-group-prev-group (n)
1440 "Go to previous N'th newsgroup.
1441 Returns the difference between N and the number of skips actually
1444 (gnus-group-next-unread-group (- n) t))
1446 (defun gnus-group-prev-unread-group (n)
1447 "Go to previous N'th unread newsgroup.
1448 Returns the difference between N and the number of skips actually
1451 (gnus-group-next-unread-group (- n)))
1453 (defun gnus-group-next-unread-group-same-level (n)
1454 "Go to next N'th unread newsgroup on the same level.
1455 If N is negative, search backward instead.
1456 Returns the difference between N and the number of skips actually
1459 (gnus-group-next-unread-group n t (gnus-group-group-level))
1460 (gnus-group-position-point))
1462 (defun gnus-group-prev-unread-group-same-level (n)
1463 "Go to next N'th unread newsgroup on the same level.
1464 Returns the difference between N and the number of skips actually
1467 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1468 (gnus-group-position-point))
1470 (defun gnus-group-best-unread-group (&optional exclude-group)
1471 "Go to the group with the highest level.
1472 If EXCLUDE-GROUP, do not go to that group."
1474 (goto-char (point-min))
1478 (setq unread (get-text-property (point) 'gnus-unread))
1479 (if (and (numberp unread) (> unread 0))
1481 (if (and (get-text-property (point) 'gnus-level)
1482 (< (get-text-property (point) 'gnus-level) best)
1483 (or (not exclude-group)
1484 (not (equal exclude-group (gnus-group-group-name)))))
1486 (setq best (get-text-property (point) 'gnus-level))
1487 (setq best-point (point))))))
1489 (if best-point (goto-char best-point))
1490 (gnus-summary-position-point)
1491 (and best-point (gnus-group-group-name))))
1493 (defun gnus-group-first-unread-group ()
1494 "Go to the first group with unread articles."
1497 (let ((opoint (point))
1499 (goto-char (point-min))
1500 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1501 (and (numberp unread) ; Not a topic.
1502 (not (zerop unread))) ; Has unread articles.
1503 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1506 nil)) ; Not success.
1507 (gnus-group-position-point)))
1509 (defun gnus-group-enter-server-mode ()
1510 "Jump to the server buffer."
1512 (gnus-enter-server-buffer))
1514 (defun gnus-group-make-group (name &optional method address)
1515 "Add a new newsgroup.
1516 The user will be prompted for a NAME, for a select METHOD, and an
1520 (read-string "Group name: ")
1521 (gnus-read-method "From method: ")))
1523 (let* ((meth (when (and method
1524 (not (gnus-server-equal method gnus-select-method)))
1525 (if address (list (intern method) address)
1527 (nname (if method (gnus-group-prefixed-name name meth) name))
1529 (when (gnus-gethash nname gnus-newsrc-hashtb)
1530 (error "Group %s already exists" nname))
1531 ;; Subscribe to the new group.
1532 (gnus-group-change-level
1533 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1534 gnus-level-default-subscribed gnus-level-killed
1535 (and (gnus-group-group-name)
1536 (gnus-gethash (gnus-group-group-name)
1537 gnus-newsrc-hashtb))
1540 (gnus-set-active nname (cons 1 0))
1541 (or (gnus-ephemeral-group-p name)
1543 (concat "(gnus-group-set-info '"
1544 (gnus-prin1-to-string (cdr info)) ")")))
1546 (gnus-group-insert-group-line-info nname)
1548 (gnus-group-position-point)
1550 ;; Load the backend and try to make the backend create
1551 ;; the group as well.
1552 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1554 gnus-valid-select-methods)
1556 (gnus-check-server meth)
1557 (and (gnus-check-backend-function 'request-create-group nname)
1558 (gnus-request-create-group nname))
1561 (defun gnus-group-delete-group (group &optional force)
1562 "Delete the current group. Only meaningful with mail groups.
1563 If FORCE (the prefix) is non-nil, all the articles in the group will
1564 be deleted. This is \"deleted\" as in \"removed forever from the face
1565 of the Earth\". There is no undo. The user will be prompted before
1566 doing the deletion."
1568 (list (gnus-group-group-name)
1569 current-prefix-arg))
1570 (or group (error "No group to rename"))
1571 (or (gnus-check-backend-function 'request-delete-group group)
1572 (error "This backend does not support group deletion"))
1574 (if (not (gnus-yes-or-no-p
1576 "Do you really want to delete %s%s? "
1577 group (if force " and all its contents" ""))))
1579 (gnus-message 6 "Deleting group %s..." group)
1580 (if (not (gnus-request-delete-group group force))
1581 (gnus-error 3 "Couldn't delete group %s" group)
1582 (gnus-message 6 "Deleting group %s...done" group)
1583 (gnus-group-goto-group group)
1584 (gnus-group-kill-group 1 t)
1585 (gnus-sethash group nil gnus-active-hashtb)
1587 (gnus-group-position-point)))
1589 (defun gnus-group-rename-group (group new-name)
1590 "Rename group from GROUP to NEW-NAME.
1591 When used interactively, GROUP is the group under point
1592 and NEW-NAME will be prompted for."
1595 (gnus-group-group-name)
1597 (unless (gnus-check-backend-function
1598 'request-rename-group (gnus-group-group-name))
1599 (error "This backend does not support renaming groups"))
1600 (read-string "New group name: " (gnus-group-group-name)))))
1602 (unless (gnus-check-backend-function 'request-rename-group group)
1603 (error "This backend does not support renaming groups"))
1605 (error "No group to rename"))
1606 (when (string-match "^[ \t]*$" new-name)
1607 (error "Not a valid group name"))
1608 (when (equal group new-name)
1609 (error "Can't rename to the same name"))
1611 ;; We find the proper prefixed name.
1613 (if (equal (gnus-group-real-name new-name) new-name)
1617 (gnus-group-prefixed-name
1618 (gnus-group-real-name new-name)
1619 (gnus-info-method (gnus-get-info group)))))
1621 (gnus-message 6 "Renaming group %s to %s..." group new-name)
1623 (if (not (gnus-request-rename-group group new-name))
1624 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
1625 ;; We rename the group internally by killing it...
1626 (gnus-group-goto-group group)
1627 (gnus-group-kill-group)
1628 ;; ... changing its name ...
1629 (setcar (cdar gnus-list-of-killed-groups) new-name)
1630 ;; ... and then yanking it. Magic!
1631 (gnus-group-yank-group)
1632 (gnus-set-active new-name (gnus-active group))
1633 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
1635 (gnus-group-position-point)))
1637 (defun gnus-group-edit-group (group &optional part)
1638 "Edit the group on the current line."
1639 (interactive (list (gnus-group-group-name)))
1640 (let ((part (or part 'info))
1643 (error "No group on current line"))
1644 (unless (setq info (gnus-get-info group))
1645 (error "Killed group; can't be edited"))
1647 ;; Find the proper form to edit.
1648 (cond ((eq part 'method)
1649 (or (gnus-info-method info) "native"))
1651 (gnus-info-params info))
1653 ;; The proper documentation.
1657 ((eq part 'method) "select method")
1658 ((eq part 'params) "group parameters")
1661 (gnus-group-edit-group-done ',part ,group form)))))
1663 (defun gnus-group-edit-group-method (group)
1664 "Edit the select method of GROUP."
1665 (interactive (list (gnus-group-group-name)))
1666 (gnus-group-edit-group group 'method))
1668 (defun gnus-group-edit-group-parameters (group)
1669 "Edit the group parameters of GROUP."
1670 (interactive (list (gnus-group-group-name)))
1671 (gnus-group-edit-group group 'params))
1673 (defun gnus-group-edit-group-done (part group form)
1675 (let* ((method (cond ((eq part 'info) (nth 4 form))
1676 ((eq part 'method) form)
1678 (info (cond ((eq part 'info) form)
1679 ((eq part 'method) (gnus-get-info group))
1682 (if (or (not method)
1684 gnus-select-method method))
1685 (gnus-group-real-name (car info))
1686 (gnus-group-prefixed-name
1687 (gnus-group-real-name (car info)) method))
1689 (when (and new-group
1690 (not (equal new-group group)))
1691 (when (gnus-group-goto-group group)
1692 (gnus-group-kill-group 1))
1693 (gnus-activate-group new-group))
1695 (if (not (and info new-group))
1696 (gnus-group-set-info form (or new-group group) part)
1697 (setq info (gnus-copy-sequence info))
1698 (setcar info new-group)
1699 (unless (gnus-server-equal method "native")
1700 (unless (nthcdr 3 info)
1701 (nconc info (list nil nil)))
1702 (unless (nthcdr 4 info)
1703 (nconc info (list nil)))
1704 (gnus-info-set-method info method))
1705 (gnus-group-set-info info))
1706 (gnus-group-update-group (or new-group group))
1707 (gnus-group-position-point)))
1709 (defun gnus-group-make-help-group ()
1710 "Create the Gnus documentation group."
1712 (let ((path load-path)
1713 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
1715 (and (gnus-gethash name gnus-newsrc-hashtb)
1716 (error "Documentation group already exists"))
1718 (setq dir (file-name-as-directory (expand-file-name (pop path)))
1720 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
1722 (setq file (concat (file-name-directory
1723 (directory-file-name dir))
1724 "etc/gnus-tut.txt"))))
1727 (gnus-message 1 "Couldn't find doc group")
1728 (gnus-group-make-group
1729 (gnus-group-real-name name)
1730 (list 'nndoc "gnus-help"
1731 (list 'nndoc-address file)
1732 (list 'nndoc-article-type 'mbox)))))
1733 (gnus-group-position-point))
1735 (defun gnus-group-make-doc-group (file type)
1736 "Create a group that uses a single file as the source."
1738 (list (read-file-name "File name: ")
1739 (and current-prefix-arg 'ask)))
1740 (when (eq type 'ask)
1745 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
1747 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
1748 ((= char ?b) 'babyl)
1749 ((= char ?d) 'digest)
1750 ((= char ?f) 'forward)
1752 (t (setq err (format "%c unknown. " char))
1755 (let* ((file (expand-file-name file))
1756 (name (gnus-generate-new-group-name
1757 (gnus-group-prefixed-name
1758 (file-name-nondirectory file) '(nndoc "")))))
1759 (gnus-group-make-group
1760 (gnus-group-real-name name)
1762 (list 'nndoc-address file)
1763 (list 'nndoc-article-type (or type 'guess))))))
1765 (defvar nnweb-type-definition)
1766 (defvar gnus-group-web-type-history nil)
1767 (defvar gnus-group-web-search-history nil)
1768 (defun gnus-group-make-web-group (&optional solid)
1769 "Create an ephemeral nnweb group.
1770 If SOLID (the prefix), create a solid group."
1774 (if solid (read-string "Group name: ") (message-unique-id)))
1777 "Search engine type: "
1778 (mapcar (lambda (elem) (list (symbol-name (car elem))))
1779 nnweb-type-definition)
1780 nil t (cons (or (car gnus-group-web-type-history)
1781 (symbol-name (caar nnweb-type-definition)))
1783 'gnus-group-web-type-history))
1787 (cons (or (car gnus-group-web-search-history) "") 0)
1788 'gnus-group-web-search-history))
1790 `(nnweb ,group (nnweb-search ,search)
1791 (nnweb-type ,(intern type)))))
1793 (gnus-group-make-group group method)
1794 (gnus-group-read-ephemeral-group
1796 (cons (current-buffer)
1797 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
1799 (defun gnus-group-make-archive-group (&optional all)
1800 "Create the (ding) Gnus archive group of the most recent articles.
1801 Given a prefix, create a full group."
1803 (let ((group (gnus-group-prefixed-name
1804 (if all "ding.archives" "ding.recent") '(nndir ""))))
1805 (when (gnus-gethash group gnus-newsrc-hashtb)
1806 (error "Archive group already exists"))
1807 (gnus-group-make-group
1808 (gnus-group-real-name group)
1809 (list 'nndir (if all "hpc" "edu")
1810 (list 'nndir-directory
1811 (if all gnus-group-archive-directory
1812 gnus-group-recent-archive-directory))))
1813 (gnus-group-add-parameter group (cons 'to-address "ding@ifi.uio.no"))))
1815 (defun gnus-group-make-directory-group (dir)
1816 "Create an nndir group.
1817 The user will be prompted for a directory. The contents of this
1818 directory will be used as a newsgroup. The directory should contain
1819 mail messages or news articles in files that have numeric names."
1821 (list (read-file-name "Create group from directory: ")))
1822 (or (file-exists-p dir) (error "No such directory"))
1823 (or (file-directory-p dir) (error "Not a directory"))
1827 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
1829 (gnus-group-prefixed-name
1830 (concat (file-name-as-directory (directory-file-name dir))
1833 (setq ext (format "<%d>" (setq i (1+ i)))))
1834 (gnus-group-make-group
1835 (gnus-group-real-name group)
1836 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
1838 (defun gnus-group-make-kiboze-group (group address scores)
1839 "Create an nnkiboze group.
1840 The user will be prompted for a name, a regexp to match groups, and
1841 score file entries for articles to include in the group."
1844 (read-string "nnkiboze group name: ")
1845 (read-string "Source groups (regexp): ")
1846 (let ((headers (mapcar (lambda (group) (list group))
1847 '("subject" "from" "number" "date" "message-id"
1848 "references" "chars" "lines" "xref"
1849 "followup" "all" "body" "head")))
1850 scores header regexp regexps)
1851 (while (not (equal "" (setq header (completing-read
1852 "Match on header: " headers nil t))))
1854 (while (not (equal "" (setq regexp (read-string
1855 (format "Match on %s (string): "
1857 (setq regexps (cons (list regexp nil nil 'r) regexps)))
1858 (setq scores (cons (cons header regexps) scores)))
1860 (gnus-group-make-group group "nnkiboze" address)
1861 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
1862 (let (emacs-lisp-mode-hook)
1863 (pp scores (current-buffer)))))
1865 (defun gnus-group-add-to-virtual (n vgroup)
1866 "Add the current group to a virtual group."
1868 (list current-prefix-arg
1869 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
1871 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
1872 (error "%s is not an nnvirtual group" vgroup))
1873 (let* ((groups (gnus-group-process-prefix n))
1874 (method (gnus-info-method (gnus-get-info vgroup))))
1875 (setcar (cdr method)
1877 (nth 1 method) "\\|"
1880 (gnus-group-remove-mark s)
1881 (concat "\\(^" (regexp-quote s) "$\\)"))
1883 (gnus-group-position-point))
1885 (defun gnus-group-make-empty-virtual (group)
1886 "Create a new, fresh, empty virtual group."
1887 (interactive "sCreate new, empty virtual group: ")
1888 (let* ((method (list 'nnvirtual "^$"))
1889 (pgroup (gnus-group-prefixed-name group method)))
1890 ;; Check whether it exists already.
1891 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
1892 (error "Group %s already exists." pgroup))
1893 ;; Subscribe the new group after the group on the current line.
1894 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
1895 (gnus-group-update-group pgroup)
1897 (gnus-group-position-point)))
1899 (defun gnus-group-enter-directory (dir)
1900 "Enter an ephemeral nneething group."
1901 (interactive "DDirectory to read: ")
1902 (let* ((method (list 'nneething dir '(nneething-read-only t)))
1903 (leaf (gnus-group-prefixed-name
1904 (file-name-nondirectory (directory-file-name dir))
1906 (name (gnus-generate-new-group-name leaf)))
1907 (unless (gnus-group-read-ephemeral-group
1909 (cons (current-buffer)
1910 (if (eq major-mode 'gnus-summary-mode)
1912 (error "Couldn't enter %s" dir))))
1914 ;; Group sorting commands
1915 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
1917 (defun gnus-group-sort-groups (func &optional reverse)
1918 "Sort the group buffer according to FUNC.
1919 If REVERSE, reverse the sorting order."
1920 (interactive (list gnus-group-sort-function
1921 current-prefix-arg))
1923 ((not (listp func)) func)
1925 ((= 1 (length func)) (car func))
1927 ,(gnus-make-sort-function
1928 (reverse func)))))))
1929 ;; We peel off the dummy group from the alist.
1931 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
1932 (pop gnus-newsrc-alist))
1934 (setq gnus-newsrc-alist
1935 (sort gnus-newsrc-alist func))
1937 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
1938 ;; Regenerate the hash table.
1939 (gnus-make-hashtable-from-newsrc-alist)
1940 (gnus-group-list-groups))))
1942 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
1943 "Sort the group buffer alphabetically by group name.
1944 If REVERSE, sort in reverse order."
1946 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
1948 (defun gnus-group-sort-groups-by-unread (&optional reverse)
1949 "Sort the group buffer by number of unread articles.
1950 If REVERSE, sort in reverse order."
1952 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
1954 (defun gnus-group-sort-groups-by-level (&optional reverse)
1955 "Sort the group buffer by group level.
1956 If REVERSE, sort in reverse order."
1958 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
1960 (defun gnus-group-sort-groups-by-score (&optional reverse)
1961 "Sort the group buffer by group score.
1962 If REVERSE, sort in reverse order."
1964 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
1966 (defun gnus-group-sort-groups-by-rank (&optional reverse)
1967 "Sort the group buffer by group rank.
1968 If REVERSE, sort in reverse order."
1970 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
1972 (defun gnus-group-sort-groups-by-method (&optional reverse)
1973 "Sort the group buffer alphabetically by backend name.
1974 If REVERSE, sort in reverse order."
1976 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
1978 (defun gnus-group-sort-by-alphabet (info1 info2)
1979 "Sort alphabetically."
1980 (string< (gnus-info-group info1) (gnus-info-group info2)))
1982 (defun gnus-group-sort-by-real-name (info1 info2)
1983 "Sort alphabetically on real (unprefixed) names."
1984 (string< (gnus-group-real-name (gnus-info-group info1))
1985 (gnus-group-real-name (gnus-info-group info2))))
1987 (defun gnus-group-sort-by-unread (info1 info2)
1988 "Sort by number of unread articles."
1989 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
1990 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
1991 (< (or (and (numberp n1) n1) 0)
1992 (or (and (numberp n2) n2) 0))))
1994 (defun gnus-group-sort-by-level (info1 info2)
1996 (< (gnus-info-level info1) (gnus-info-level info2)))
1998 (defun gnus-group-sort-by-method (info1 info2)
1999 "Sort alphabetically by backend name."
2000 (string< (symbol-name (car (gnus-find-method-for-group
2001 (gnus-info-group info1) info1)))
2002 (symbol-name (car (gnus-find-method-for-group
2003 (gnus-info-group info2) info2)))))
2005 (defun gnus-group-sort-by-score (info1 info2)
2006 "Sort by group score."
2007 (< (gnus-info-score info1) (gnus-info-score info2)))
2009 (defun gnus-group-sort-by-rank (info1 info2)
2010 "Sort by level and score."
2011 (let ((level1 (gnus-info-level info1))
2012 (level2 (gnus-info-level info2)))
2013 (or (< level1 level2)
2014 (and (= level1 level2)
2015 (> (gnus-info-score info1) (gnus-info-score info2))))))
2019 (defun gnus-group-clear-data (n)
2020 "Clear all marks and read ranges from the current group."
2022 (let ((groups (gnus-group-process-prefix n))
2024 (while (setq group (pop groups))
2025 (gnus-info-clear-data (setq info (gnus-get-info group)))
2026 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2027 (when (gnus-group-goto-group group)
2028 (gnus-group-remove-mark group)
2029 (gnus-group-update-group-line)))))
2031 (defun gnus-group-clear-data-on-native-groups ()
2032 "Clear all marks and read ranges from all native groups."
2034 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2035 (let ((alist (cdr gnus-newsrc-alist))
2037 (while (setq info (pop alist))
2038 (gnus-info-clear-data info))
2039 (gnus-get-unread-articles))))
2041 (defun gnus-info-clear-data (info)
2042 "Clear all marks and read ranges from INFO."
2043 (let ((group (gnus-info-group info)))
2046 (gnus-info-set-marks ,info ,(gnus-info-marks info))
2047 (gnus-info-set-read ,info ,(gnus-info-read info))
2048 (when (gnus-group-goto-group ,group)
2049 (gnus-group-update-group-line))))
2050 (gnus-info-set-read info nil)
2051 (when (gnus-info-marks info)
2052 (gnus-info-set-marks info nil))))
2054 ;; Group catching up.
2056 (defun gnus-group-catchup-current (&optional n all)
2057 "Mark all articles not marked as unread in current newsgroup as read.
2058 If prefix argument N is numeric, the ARG next newsgroups will be
2059 caught up. If ALL is non-nil, marked articles will also be marked as
2060 read. Cross references (Xref: header) of articles are ignored.
2061 The difference between N and actual number of newsgroups that were
2062 caught up is returned."
2064 (unless (gnus-group-group-name)
2065 (error "No group on the current line"))
2066 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
2070 "Do you really want to mark all articles as read? "
2071 "Mark all unread articles as read? "))))
2073 (let ((groups (gnus-group-process-prefix n))
2076 ;; Virtual groups have to be given special treatment.
2077 (let ((method (gnus-find-method-for-group (car groups))))
2078 (if (eq 'nnvirtual (car method))
2079 (nnvirtual-catchup-group
2080 (gnus-group-real-name (car groups)) (nth 1 method) all)))
2081 (gnus-group-remove-mark (car groups))
2082 (if (>= (gnus-group-group-level) gnus-level-zombie)
2083 (gnus-message 2 "Dead groups can't be caught up")
2085 (gnus-group-goto-group (car groups))
2086 (gnus-group-catchup (car groups) all))
2087 (gnus-group-update-group-line)
2088 (setq ret (1+ ret))))
2089 (setq groups (cdr groups)))
2090 (gnus-group-next-unread-group 1)
2093 (defun gnus-group-catchup-current-all (&optional n)
2094 "Mark all articles in current newsgroup as read.
2095 Cross references (Xref: header) of articles are ignored."
2097 (gnus-group-catchup-current n 'all))
2099 (defun gnus-group-catchup (group &optional all)
2100 "Mark all articles in GROUP as read.
2101 If ALL is non-nil, all articles are marked as read.
2102 The return value is the number of articles that were marked as read,
2103 or nil if no action could be taken."
2104 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2106 ;; Do the updating only if the newsgroup isn't killed.
2107 (if (not (numberp (car entry)))
2108 (gnus-message 1 "Can't catch up; non-active group")
2109 ;; Do auto-expirable marks if that's required.
2110 (when (gnus-group-auto-expirable-p group)
2111 (gnus-add-marked-articles
2112 group 'expire (gnus-list-of-unread-articles group))
2114 (let ((marks (nth 3 (nth 2 entry))))
2115 (gnus-add-marked-articles
2116 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2117 (gnus-add-marked-articles
2118 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2120 (gnus-update-read-articles group nil)
2121 ;; Also nix out the lists of marks and dormants.
2123 (gnus-add-marked-articles group 'tick nil nil 'force)
2124 (gnus-add-marked-articles group 'dormant nil nil 'force))
2125 (run-hooks 'gnus-group-catchup-group-hook)
2128 (defun gnus-group-expire-articles (&optional n)
2129 "Expire all expirable articles in the current newsgroup."
2131 (let ((groups (gnus-group-process-prefix n))
2134 (error "No groups to expire"))
2135 (while (setq group (pop groups))
2136 (gnus-group-remove-mark group)
2137 (when (gnus-check-backend-function 'request-expire-articles group)
2138 (gnus-message 6 "Expiring articles in %s..." group)
2139 (let* ((info (gnus-get-info group))
2140 (expirable (if (gnus-group-total-expirable-p group)
2141 (cons nil (gnus-list-of-read-articles group))
2142 (assq 'expire (gnus-info-marks info))))
2143 (expiry-wait (gnus-group-find-parameter group 'expiry-wait)))
2147 (gnus-compress-sequence
2149 ;; We set the expiry variables to the groupp
2151 (let ((nnmail-expiry-wait-function nil)
2152 (nnmail-expiry-wait expiry-wait))
2153 (gnus-request-expire-articles
2154 (gnus-uncompress-sequence (cdr expirable)) group))
2155 ;; Just expire using the normal expiry values.
2156 (gnus-request-expire-articles
2157 (gnus-uncompress-sequence (cdr expirable)) group))))
2158 (gnus-close-group group))
2159 (gnus-message 6 "Expiring articles in %s...done" group)))
2160 (gnus-group-position-point))))
2162 (defun gnus-group-expire-all-groups ()
2163 "Expire all expirable articles in all newsgroups."
2166 (gnus-message 5 "Expiring...")
2167 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2168 (cdr gnus-newsrc-alist))))
2169 (gnus-group-expire-articles nil)))
2170 (gnus-group-position-point)
2171 (gnus-message 5 "Expiring...done"))
2173 (defun gnus-group-set-current-level (n level)
2174 "Set the level of the next N groups to LEVEL."
2179 (let ((s (read-string
2180 (format "Level (default %s): "
2181 (or (gnus-group-group-level)
2182 gnus-level-default-subscribed)))))
2183 (if (string-match "^\\s-*$" s)
2184 (int-to-string (or (gnus-group-group-level)
2185 gnus-level-default-subscribed))
2187 (or (and (>= level 1) (<= level gnus-level-killed))
2188 (error "Illegal level: %d" level))
2189 (let ((groups (gnus-group-process-prefix n))
2191 (while (setq group (pop groups))
2192 (gnus-group-remove-mark group)
2193 (gnus-message 6 "Changed level of %s from %d to %d"
2194 group (or (gnus-group-group-level) gnus-level-killed)
2196 (gnus-group-change-level
2197 group level (or (gnus-group-group-level) gnus-level-killed))
2198 (gnus-group-update-group-line)))
2199 (gnus-group-position-point))
2201 (defun gnus-group-unsubscribe-current-group (&optional n)
2202 "Toggle subscription of the current group.
2203 If given numerical prefix, toggle the N next groups."
2205 (let ((groups (gnus-group-process-prefix n))
2208 (setq group (car groups)
2209 groups (cdr groups))
2210 (gnus-group-remove-mark group)
2211 (gnus-group-unsubscribe-group
2212 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
2213 gnus-level-default-unsubscribed
2214 gnus-level-default-subscribed) t)
2215 (gnus-group-update-group-line))
2216 (gnus-group-next-group 1)))
2218 (defun gnus-group-unsubscribe-group (group &optional level silent)
2219 "Toggle subscription to GROUP.
2220 Killed newsgroups are subscribed. If SILENT, don't try to update the
2223 (list (completing-read
2224 "Group: " gnus-active-hashtb nil
2225 (gnus-read-active-file-p)
2227 'gnus-group-history)))
2228 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2230 ((string-match "^[ \t]$" group)
2231 (error "Empty group name"))
2233 ;; Toggle subscription flag.
2234 (gnus-group-change-level
2235 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
2236 gnus-level-subscribed)
2237 (1+ gnus-level-subscribed)
2238 gnus-level-default-subscribed)))
2240 (gnus-group-update-group group)))
2241 ((and (stringp group)
2242 (or (not (gnus-read-active-file-p))
2243 (gnus-active group)))
2244 ;; Add new newsgroup.
2245 (gnus-group-change-level
2247 (if level level gnus-level-default-subscribed)
2248 (or (and (member group gnus-zombie-list)
2251 (and (gnus-group-group-name)
2252 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2254 (gnus-group-update-group group)))
2255 (t (error "No such newsgroup: %s" group)))
2256 (gnus-group-position-point)))
2258 (defun gnus-group-transpose-groups (n)
2259 "Move the current newsgroup up N places.
2260 If given a negative prefix, move down instead. The difference between
2261 N and the number of steps taken is returned."
2263 (or (gnus-group-group-name)
2264 (error "No group on current line"))
2265 (gnus-group-kill-group 1)
2267 (forward-line (- n))
2268 (gnus-group-yank-group)
2269 (gnus-group-position-point)))
2271 (defun gnus-group-kill-all-zombies ()
2272 "Kill all zombie newsgroups."
2274 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2275 (setq gnus-zombie-list nil)
2276 (gnus-group-list-groups))
2278 (defun gnus-group-kill-region (begin end)
2279 "Kill newsgroups in current region (excluding current point).
2280 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2295 (beginning-of-line) ;Important when LINES < 1
2296 (gnus-group-kill-group lines)))
2298 (defun gnus-group-kill-group (&optional n discard)
2299 "Kill the next N groups.
2300 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2301 However, only groups that were alive can be yanked; already killed
2302 groups or zombie groups can't be yanked.
2303 The return value is the name of the group that was killed, or a list
2306 (let ((buffer-read-only nil)
2307 (groups (gnus-group-process-prefix n))
2308 group entry level out)
2309 (if (< (length groups) 10)
2310 ;; This is faster when there are few groups.
2312 (push (setq group (pop groups)) out)
2313 (gnus-group-remove-mark group)
2314 (setq level (gnus-group-group-level))
2316 (when (and (not discard)
2317 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2320 (gnus-group-goto-group ,(gnus-group-group-name))
2321 (gnus-group-yank-group)))
2322 (push (cons (car entry) (nth 2 entry))
2323 gnus-list-of-killed-groups))
2324 (gnus-group-change-level
2325 (if entry entry group) gnus-level-killed (if entry nil level)))
2326 ;; If there are lots and lots of groups to be killed, we use
2327 ;; this thing instead.
2329 (setq groups (nreverse groups))
2331 (gnus-group-remove-mark (setq group (pop groups)))
2333 (push group gnus-killed-list)
2334 (setq gnus-newsrc-alist
2335 (delq (assoc group gnus-newsrc-alist)
2337 (when gnus-group-change-level-function
2338 (funcall gnus-group-change-level-function group 9 3))
2340 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2341 (push (cons (car entry) (nth 2 entry))
2342 gnus-list-of-killed-groups)
2343 (setcdr (cdr entry) (cdddr entry)))
2344 ((member group gnus-zombie-list)
2345 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
2346 (gnus-make-hashtable-from-newsrc-alist)))
2348 (gnus-group-position-point)
2349 (if (< (length out) 2) (car out) (nreverse out))))
2351 (defun gnus-group-yank-group (&optional arg)
2352 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
2353 inserting it before the current newsgroup. The numeric ARG specifies
2354 how many newsgroups are to be yanked. The name of the newsgroup yanked
2355 is returned, or (if several groups are yanked) a list of yanked groups
2358 (setq arg (or arg 1))
2359 (let (info group prev out)
2360 (while (>= (decf arg) 0)
2361 (if (not (setq info (pop gnus-list-of-killed-groups)))
2362 (error "No more newsgroups to yank"))
2363 (push (setq group (nth 1 info)) out)
2364 ;; Find which newsgroup to insert this one before - search
2365 ;; backward until something suitable is found. If there are no
2366 ;; other newsgroups in this buffer, just make this newsgroup the
2368 (setq prev (gnus-group-group-name))
2369 (gnus-group-change-level
2370 info (gnus-info-level (cdr info)) gnus-level-killed
2371 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
2373 (gnus-group-insert-group-line-info group)
2375 `(when (gnus-group-goto-group ,group)
2376 (gnus-group-kill-group 1))))
2378 (gnus-group-position-point)
2379 (if (< (length out) 2) (car out) (nreverse out))))
2381 (defun gnus-group-kill-level (level)
2382 "Kill all groups that is on a certain LEVEL."
2383 (interactive "nKill all groups on level: ")
2385 ((= level gnus-level-zombie)
2386 (setq gnus-killed-list
2387 (nconc gnus-zombie-list gnus-killed-list))
2388 (setq gnus-zombie-list nil))
2389 ((and (< level gnus-level-zombie)
2391 (or gnus-expert-user
2394 "Do you really want to kill all groups on level %d? "
2396 (let* ((prev gnus-newsrc-alist)
2399 (if (= (gnus-info-level (car alist)) level)
2401 (push (gnus-info-group (car alist)) gnus-killed-list)
2402 (setcdr prev (cdr alist)))
2404 (setq alist (cdr alist)))
2405 (gnus-make-hashtable-from-newsrc-alist)
2406 (gnus-group-list-groups)))
2408 (error "Can't kill; illegal level: %d" level))))
2410 (defun gnus-group-list-all-groups (&optional arg)
2411 "List all newsgroups with level ARG or lower.
2412 Default is gnus-level-unsubscribed, which lists all subscribed and most
2413 unsubscribed groups."
2415 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
2417 ;; Redefine this to list ALL killed groups if prefix arg used.
2418 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
2419 (defun gnus-group-list-killed (&optional arg)
2420 "List all killed newsgroups in the group buffer.
2421 If ARG is non-nil, list ALL killed groups known to Gnus. This may
2422 entail asking the server for the groups."
2424 ;; Find all possible killed newsgroups if arg.
2426 (gnus-get-killed-groups))
2427 (if (not gnus-killed-list)
2428 (gnus-message 6 "No killed groups")
2429 (let (gnus-group-list-mode)
2430 (funcall gnus-group-prepare-function
2431 gnus-level-killed t gnus-level-killed))
2432 (goto-char (point-min)))
2433 (gnus-group-position-point))
2435 (defun gnus-group-list-zombies ()
2436 "List all zombie newsgroups in the group buffer."
2438 (if (not gnus-zombie-list)
2439 (gnus-message 6 "No zombie groups")
2440 (let (gnus-group-list-mode)
2441 (funcall gnus-group-prepare-function
2442 gnus-level-zombie t gnus-level-zombie))
2443 (goto-char (point-min)))
2444 (gnus-group-position-point))
2446 (defun gnus-group-list-active ()
2447 "List all groups that are available from the server(s)."
2449 ;; First we make sure that we have really read the active file.
2450 (unless (gnus-read-active-file-p)
2451 (let ((gnus-read-active-file t))
2452 (gnus-read-active-file)))
2453 ;; Find all groups and sort them.
2461 (setq list (cons (symbol-name sym) list))))
2465 (buffer-read-only nil))
2468 (gnus-group-insert-group-line-info (pop groups)))
2469 (goto-char (point-min))))
2471 (defun gnus-activate-all-groups (level)
2472 "Activate absolutely all groups."
2473 (interactive (list 7))
2474 (let ((gnus-activate-level level)
2475 (gnus-activate-foreign-newsgroups level))
2476 (gnus-group-get-new-news)))
2478 (defun gnus-group-get-new-news (&optional arg)
2479 "Get newly arrived articles.
2480 If ARG is a number, it specifies which levels you are interested in
2481 re-scanning. If ARG is non-nil and not a number, this will force
2482 \"hard\" re-reading of the active files from all servers."
2484 (run-hooks 'gnus-get-new-news-hook)
2485 ;; We might read in new NoCeM messages here.
2486 (when (and gnus-use-nocem
2488 (gnus-nocem-scan-groups))
2489 ;; If ARG is not a number, then we read the active file.
2490 (when (and arg (not (numberp arg)))
2491 (let ((gnus-read-active-file t))
2492 (gnus-read-active-file))
2495 (setq arg (gnus-group-default-level arg t))
2496 (if (and gnus-read-active-file (not arg))
2498 (gnus-read-active-file)
2499 (gnus-get-unread-articles arg))
2500 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
2501 (gnus-get-unread-articles arg)))
2502 (run-hooks 'gnus-after-getting-new-news-hook)
2503 (gnus-group-list-groups))
2505 (defun gnus-group-get-new-news-this-group (&optional n)
2506 "Check for newly arrived news in the current group (and the N-1 next groups).
2507 The difference between N and the number of newsgroup checked is returned.
2508 If N is negative, this group and the N-1 previous groups will be checked."
2510 (let* ((groups (gnus-group-process-prefix n))
2511 (ret (if (numberp n) (- n (length groups)) 0))
2512 (beg (unless n (point)))
2514 (while (setq group (pop groups))
2515 (gnus-group-remove-mark group)
2516 ;; Bypass any previous denials from the server.
2517 (gnus-remove-denial (gnus-find-method-for-group group))
2518 (if (gnus-activate-group group 'scan)
2520 (gnus-get-unread-articles-in-group
2521 (gnus-get-info group) (gnus-active group) t)
2522 (unless (gnus-virtual-group-p group)
2523 (gnus-close-group group))
2524 (gnus-group-update-group group))
2525 (if (eq (gnus-server-status (gnus-find-method-for-group group))
2527 (gnus-error 3 "Server denied access")
2528 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
2529 (when beg (goto-char beg))
2530 (when gnus-goto-next-group-when-activating
2531 (gnus-group-next-unread-group 1 t))
2532 (gnus-summary-position-point)
2535 (defun gnus-group-fetch-faq (group &optional faq-dir)
2536 "Fetch the FAQ for the current group.
2537 If given a prefix argument, prompt for the FAQ dir
2541 (gnus-group-group-name)
2542 (cond (current-prefix-arg
2544 "Faq dir: " (and (listp gnus-group-faq-directory)
2545 (mapcar (lambda (file) (list file))
2546 gnus-group-faq-directory)))))))
2548 (error "No group name given"))
2549 (let ((dirs (or faq-dir gnus-group-faq-directory))
2551 (unless (listp dirs)
2552 (setq dirs (list dirs)))
2553 (while (and (not found)
2554 (setq dir (pop dirs)))
2555 (setq file (concat (file-name-as-directory dir)
2556 (gnus-group-real-name group)))
2557 (if (not (file-exists-p file))
2558 (gnus-message 1 "No such file: %s" file)
2562 (defun gnus-group-describe-group (force &optional group)
2563 "Display a description of the current newsgroup."
2564 (interactive (list current-prefix-arg (gnus-group-group-name)))
2565 (let* ((method (gnus-find-method-for-group group))
2566 (mname (gnus-group-prefixed-name "" method))
2569 gnus-description-hashtb)
2570 (gnus-sethash mname nil gnus-description-hashtb))
2571 (or group (error "No group name given"))
2572 (and (or (and gnus-description-hashtb
2573 ;; We check whether this group's method has been
2574 ;; queried for a description file.
2575 (gnus-gethash mname gnus-description-hashtb))
2576 (setq desc (gnus-group-get-description group))
2577 (gnus-read-descriptions-file method))
2579 (or desc (gnus-gethash group gnus-description-hashtb)
2580 "No description available")))))
2582 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
2583 (defun gnus-group-describe-all-groups (&optional force)
2584 "Pop up a buffer with descriptions of all newsgroups."
2586 (and force (setq gnus-description-hashtb nil))
2587 (if (not (or gnus-description-hashtb
2588 (gnus-read-all-descriptions-files)))
2589 (error "Couldn't request descriptions file"))
2590 (let ((buffer-read-only nil)
2596 (insert (format " *: %-20s %s\n" (symbol-name group)
2597 (symbol-value group)))
2598 (gnus-add-text-properties
2599 b (1+ b) (list 'gnus-group group
2600 'gnus-unread t 'gnus-marked nil
2601 'gnus-level (1+ gnus-level-subscribed))))
2602 gnus-description-hashtb)
2603 (goto-char (point-min))
2604 (gnus-group-position-point)))
2606 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
2607 (defun gnus-group-apropos (regexp &optional search-description)
2608 "List all newsgroups that have names that match a regexp."
2609 (interactive "sGnus apropos (regexp): ")
2611 (obuf (current-buffer))
2613 ;; Go through all newsgroups that are known to Gnus.
2616 (and (symbol-name group)
2617 (string-match regexp (symbol-name group))
2618 (setq groups (cons (symbol-name group) groups))))
2620 ;; Also go through all descriptions that are known to Gnus.
2621 (when search-description
2624 (and (string-match regexp (symbol-value group))
2625 (gnus-active (symbol-name group))
2626 (setq groups (cons (symbol-name group) groups))))
2627 gnus-description-hashtb))
2629 (gnus-message 3 "No groups matched \"%s\"." regexp)
2630 ;; Print out all the groups.
2632 (pop-to-buffer "*Gnus Help*")
2633 (buffer-disable-undo (current-buffer))
2635 (setq groups (sort groups 'string<))
2637 ;; Groups may be entered twice into the list of groups.
2638 (if (not (string= (car groups) prev))
2640 (insert (setq prev (car groups)) "\n")
2641 (if (and gnus-description-hashtb
2642 (setq des (gnus-gethash (car groups)
2643 gnus-description-hashtb)))
2644 (insert " " des "\n"))))
2645 (setq groups (cdr groups)))
2646 (goto-char (point-min))))
2647 (pop-to-buffer obuf)))
2649 (defun gnus-group-description-apropos (regexp)
2650 "List all newsgroups that have names or descriptions that match a regexp."
2651 (interactive "sGnus description apropos (regexp): ")
2652 (if (not (or gnus-description-hashtb
2653 (gnus-read-all-descriptions-files)))
2654 (error "Couldn't request descriptions file"))
2655 (gnus-group-apropos regexp t))
2657 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
2658 (defun gnus-group-list-matching (level regexp &optional all lowest)
2659 "List all groups with unread articles that match REGEXP.
2660 If the prefix LEVEL is non-nil, it should be a number that says which
2661 level to cut off listing groups.
2662 If ALL, also list groups with no unread articles.
2663 If LOWEST, don't list groups with level lower than LOWEST.
2665 This command may read the active file."
2666 (interactive "P\nsList newsgroups matching: ")
2667 ;; First make sure active file has been read.
2669 (> (prefix-numeric-value level) gnus-level-killed))
2670 (gnus-get-killed-groups))
2671 (gnus-group-prepare-flat (or level gnus-level-subscribed)
2672 all (or lowest 1) regexp)
2673 (goto-char (point-min))
2674 (gnus-group-position-point))
2676 (defun gnus-group-list-all-matching (level regexp &optional lowest)
2677 "List all groups that match REGEXP.
2678 If the prefix LEVEL is non-nil, it should be a number that says which
2679 level to cut off listing groups.
2680 If LOWEST, don't list groups with level lower than LOWEST."
2681 (interactive "P\nsList newsgroups matching: ")
2682 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
2684 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
2685 (defun gnus-group-save-newsrc (&optional force)
2686 "Save the Gnus startup files.
2687 If FORCE, force saving whether it is necessary or not."
2689 (gnus-save-newsrc-file force))
2691 (defun gnus-group-restart (&optional arg)
2692 "Force Gnus to read the .newsrc file."
2694 (when (gnus-yes-or-no-p
2695 (format "Are you sure you want to restart Gnus? "))
2696 (gnus-save-newsrc-file)
2697 (gnus-setup-news 'force)
2698 (gnus-group-list-groups arg)))
2700 (defun gnus-group-read-init-file ()
2701 "Read the Gnus elisp init file."
2703 (gnus-read-init-file))
2705 (defun gnus-group-check-bogus-groups (&optional silent)
2706 "Check bogus newsgroups.
2707 If given a prefix, don't ask for confirmation before removing a bogus
2710 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
2711 (gnus-group-list-groups))
2713 (defun gnus-group-edit-global-kill (&optional article group)
2714 "Edit the global kill file.
2715 If GROUP, edit that local kill file instead."
2717 (setq gnus-current-kill-article article)
2718 (gnus-kill-file-edit-file group)
2721 (substitute-command-keys
2722 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
2723 (if group "local" "global")))))
2725 (defun gnus-group-edit-local-kill (article group)
2726 "Edit a local kill file."
2727 (interactive (list nil (gnus-group-group-name)))
2728 (gnus-group-edit-global-kill article group))
2730 (defun gnus-group-force-update ()
2731 "Update `.newsrc' file."
2733 (gnus-save-newsrc-file))
2735 (defun gnus-group-suspend ()
2736 "Suspend the current Gnus session.
2737 In fact, cleanup buffers except for group mode buffer.
2738 The hook gnus-suspend-gnus-hook is called before actually suspending."
2740 (run-hooks 'gnus-suspend-gnus-hook)
2741 ;; Kill Gnus buffers except for group mode buffer.
2742 (let* ((group-buf (get-buffer gnus-group-buffer))
2743 ;; Do this on a separate list in case the user does a ^G before we finish
2745 (delete group-buf (delete gnus-dribble-buffer
2746 (append gnus-buffer-list nil)))))
2747 (while gnus-buffer-list
2748 (gnus-kill-buffer (pop gnus-buffer-list)))
2749 (gnus-kill-gnus-frames)
2751 (setq gnus-buffer-list (list group-buf))
2752 (bury-buffer group-buf)
2753 (delete-windows-on group-buf t))))
2755 (defun gnus-group-clear-dribble ()
2756 "Clear all information from the dribble buffer."
2758 (gnus-dribble-clear)
2759 (gnus-message 7 "Cleared dribble buffer"))
2761 (defun gnus-group-exit ()
2762 "Quit reading news after updating .newsrc.eld and .newsrc.
2763 The hook `gnus-exit-gnus-hook' is called before actually exiting."
2766 (or noninteractive ;For gnus-batch-kill
2767 (not gnus-interactive-exit) ;Without confirmation
2769 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
2770 (run-hooks 'gnus-exit-gnus-hook)
2771 ;; Offer to save data from non-quitted summary buffers.
2772 (gnus-offer-save-summaries)
2773 ;; Save the newsrc file(s).
2774 (gnus-save-newsrc-file)
2776 (gnus-close-backends)
2777 ;; Reset everything.
2779 ;; Allow the user to do things after cleaning up.
2780 (run-hooks 'gnus-after-exiting-gnus-hook)))
2782 (defun gnus-group-quit ()
2783 "Quit reading news without updating .newsrc.eld or .newsrc.
2784 The hook `gnus-exit-gnus-hook' is called before actually exiting."
2786 (when (or noninteractive ;For gnus-batch-kill
2787 (zerop (buffer-size))
2788 (not (gnus-server-opened gnus-select-method))
2790 (not gnus-current-startup-file)
2792 (format "Quit reading news without saving %s? "
2793 (file-name-nondirectory gnus-current-startup-file))))
2794 (run-hooks 'gnus-exit-gnus-hook)
2795 (gnus-configure-windows 'group t)
2797 (gnus-close-backends)
2799 (gnus-kill-buffer gnus-group-buffer)
2800 ;; Allow the user to do things after cleaning up.
2801 (run-hooks 'gnus-after-exiting-gnus-hook)))
2803 (defun gnus-group-describe-briefly ()
2804 "Give a one line description of the group mode commands."
2806 (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")))
2808 (defun gnus-group-browse-foreign-server (method)
2809 "Browse a foreign news server.
2810 If called interactively, this function will ask for a select method
2811 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
2812 If not, METHOD should be a list where the first element is the method
2813 and the second element is the address."
2815 (list (let ((how (completing-read
2817 (append gnus-valid-select-methods gnus-server-alist)
2818 nil t (cons "nntp" 0) 'gnus-method-history)))
2819 ;; We either got a backend name or a virtual server name.
2820 ;; If the first, we also need an address.
2821 (if (assoc how gnus-valid-select-methods)
2823 ;; Suggested by mapjph@bath.ac.uk.
2826 (mapcar (lambda (server) (list server))
2827 gnus-secondary-servers)))
2828 ;; We got a server name, so we find the method.
2829 (gnus-server-to-method how)))))
2830 (gnus-browse-foreign-server method))
2832 (defun gnus-group-set-info (info &optional method-only-group part)
2833 (let* ((entry (gnus-gethash
2834 (or method-only-group (gnus-info-group info))
2835 gnus-newsrc-hashtb))
2837 (info (if method-only-group (nth 2 entry) info))
2839 (when method-only-group
2841 (error "Trying to change non-existent group %s" method-only-group))
2842 ;; We have received parts of the actual group info - either the
2843 ;; select method or the group parameters. We first check
2844 ;; whether we have to extend the info, and if so, do that.
2845 (let ((len (length info))
2846 (total (if (eq part 'method) 5 6)))
2848 (setcdr (nthcdr (1- len) info)
2849 (make-list (- total len) nil)))
2850 ;; Then we enter the new info.
2851 (setcar (nthcdr (1- total) info) part-info)))
2853 ;; This is a new group, so we just create it.
2855 (set-buffer gnus-group-buffer)
2856 (setq method (gnus-info-method info))
2857 (when (gnus-server-equal method "native")
2860 (set-buffer gnus-group-buffer)
2862 ;; It's a foreign group...
2863 (gnus-group-make-group
2864 (gnus-group-real-name (gnus-info-group info))
2865 (if (stringp method) method
2866 (prin1-to-string (car method)))
2868 (nth 1 (gnus-info-method info))))
2869 ;; It's a native group.
2870 (gnus-group-make-group (gnus-info-group info))))
2871 (gnus-message 6 "Note: New group created")
2873 (gnus-gethash (gnus-group-prefixed-name
2874 (gnus-group-real-name (gnus-info-group info))
2875 (or (gnus-info-method info) gnus-select-method))
2876 gnus-newsrc-hashtb))))
2877 ;; Whether it was a new group or not, we now have the entry, so we
2878 ;; can do the update.
2881 (setcar (nthcdr 2 entry) info)
2882 (when (and (not (eq (car entry) t))
2883 (gnus-active (gnus-info-group info)))
2884 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
2885 (error "No such group: %s" (gnus-info-group info)))))
2887 (defun gnus-group-set-method-info (group select-method)
2888 (gnus-group-set-info select-method group 'method))
2890 (defun gnus-group-set-params-info (group params)
2891 (gnus-group-set-info params group 'params))
2893 (defun gnus-add-marked-articles (group type articles &optional info force)
2894 ;; Add ARTICLES of TYPE to the info of GROUP.
2895 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
2896 ;; add, but replace marked articles of TYPE with ARTICLES.
2897 (let ((info (or info (gnus-get-info group)))
2898 (uncompressed '(score bookmark killed))
2901 (and (not (setq marked (nthcdr 3 info)))
2903 (setcdr (nthcdr 2 info)
2904 (list (list (cons type (gnus-compress-sequence
2906 (and (not (setq m (assq type (car marked))))
2909 (cons (cons type (gnus-compress-sequence articles t) )
2913 (setcar (nthcdr 3 info)
2914 (delq (assq type (car marked)) (car marked)))
2915 (setcdr m (gnus-compress-sequence articles t)))
2916 (setcdr m (gnus-compress-sequence
2917 (sort (nconc (gnus-uncompress-range (cdr m))
2918 (copy-sequence articles)) '<) t))))))
2920 (defun gnus-update-read-articles (group unread)
2921 "Update the list of read articles in GROUP."
2922 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
2923 (entry (gnus-gethash group gnus-newsrc-hashtb))
2924 (info (nth 2 entry))
2926 (unread (sort (copy-sequence unread) '<))
2928 (if (or (not info) (not active))
2929 ;; There is no info on this group if it was, in fact,
2930 ;; killed. Gnus stores no information on killed groups, so
2931 ;; there's nothing to be done.
2932 ;; One could store the information somewhere temporarily,
2933 ;; perhaps... Hmmm...
2935 ;; Remove any negative articles numbers.
2936 (while (and unread (< (car unread) 0))
2937 (setq unread (cdr unread)))
2938 ;; Remove any expired article numbers
2939 (while (and unread (< (car unread) (car active)))
2940 (setq unread (cdr unread)))
2941 ;; Compute the ranges of read articles by looking at the list of
2944 (if (/= (car unread) prev)
2945 (setq read (cons (if (= prev (1- (car unread))) prev
2946 (cons prev (1- (car unread)))) read)))
2947 (setq prev (1+ (car unread)))
2948 (setq unread (cdr unread)))
2949 (when (<= prev (cdr active))
2950 (setq read (cons (cons prev (cdr active)) read)))
2953 (gnus-info-set-marks ,info ,(gnus-info-marks info))
2954 (gnus-info-set-read ,info ,(gnus-info-read info))
2955 (gnus-get-unread-articles-in-group ,info (gnus-active ,group))))
2956 ;; Enter this list into the group info.
2958 info (if (> (length read) 1) (nreverse read) read))
2959 ;; Set the number of unread articles in gnus-newsrc-hashtb.
2960 (gnus-get-unread-articles-in-group info (gnus-active group))
2963 (provide 'gnus-group)
2965 ;;; gnus-group.el ends here