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 (defvar gnus-useful-groups
198 `(("(ding) mailing list mirrored at sunsite.auc.dk"
200 (nntp "sunsite.auc.dk"
201 (nntp-address "sunsite.auc.dk")))
205 (nndoc-article-type mbox)
206 (eval `(nndoc-address
207 ,(let ((file (nnheader-find-etc-directory
210 (error "Couldn't find doc group"))
212 "Alist of useful group-server pairs.")
214 ;;; Internal variables
216 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
217 "Function for sorting the group buffer.")
219 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
220 "Function for sorting the selected groups in the group buffer.")
222 (defvar gnus-group-indentation-function nil)
223 (defvar gnus-goto-missing-group-function nil)
224 (defvar gnus-group-update-group-function nil)
225 (defvar gnus-group-goto-next-group-function nil
226 "Function to override finding the next group after listing groups.")
228 (defvar gnus-group-edit-buffer nil)
230 (defvar gnus-group-line-format-alist
231 `((?M gnus-tmp-marked-mark ?c)
232 (?S gnus-tmp-subscribed ?c)
233 (?L gnus-tmp-level ?d)
234 (?N (cond ((eq number t) "*" )
238 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
239 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
241 (?R gnus-tmp-number-of-read ?s)
242 (?t gnus-tmp-number-total ?d)
243 (?y gnus-tmp-number-of-unread ?s)
244 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
245 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
246 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
247 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
248 (?g gnus-tmp-group ?s)
249 (?G gnus-tmp-qualified-group ?s)
250 (?c (gnus-short-group-name gnus-tmp-group) ?s)
251 (?D gnus-tmp-newsgroup-description ?s)
252 (?o gnus-tmp-moderated ?c)
253 (?O gnus-tmp-moderated-string ?s)
254 (?p gnus-tmp-process-marked ?c)
255 (?s gnus-tmp-news-server ?s)
256 (?n gnus-tmp-news-method ?s)
257 (?P gnus-group-indentation ?s)
258 (?l gnus-tmp-grouplens ?s)
259 (?z gnus-tmp-news-method-string ?s)
260 (?u gnus-tmp-user-defined ?s)))
262 (defvar gnus-group-mode-line-format-alist
263 `((?S gnus-tmp-news-server ?s)
264 (?M gnus-tmp-news-method ?s)
265 (?u gnus-tmp-user-defined ?s)
266 (?: gnus-tmp-colon ?s)))
268 (defvar gnus-topic-topology nil
269 "The complete topic hierarchy.")
271 (defvar gnus-topic-alist nil
272 "The complete topic-group alist.")
274 (defvar gnus-group-marked nil)
276 (defvar gnus-group-list-mode nil)
282 (put 'gnus-group-mode 'mode-class 'special)
285 (gnus-define-keys gnus-group-mode-map
286 " " gnus-group-read-group
287 "=" gnus-group-select-group
288 "\r" gnus-group-select-group
289 "\M-\r" gnus-group-quick-select-group
290 "j" gnus-group-jump-to-group
291 "n" gnus-group-next-unread-group
292 "p" gnus-group-prev-unread-group
293 "\177" gnus-group-prev-unread-group
294 [delete] gnus-group-prev-unread-group
295 "N" gnus-group-next-group
296 "P" gnus-group-prev-group
297 "\M-n" gnus-group-next-unread-group-same-level
298 "\M-p" gnus-group-prev-unread-group-same-level
299 "," gnus-group-best-unread-group
300 "." gnus-group-first-unread-group
301 "u" gnus-group-unsubscribe-current-group
302 "U" gnus-group-unsubscribe-group
303 "c" gnus-group-catchup-current
304 "C" gnus-group-catchup-current-all
305 "\M-c" gnus-group-clear-data
306 "l" gnus-group-list-groups
307 "L" gnus-group-list-all-groups
309 "g" gnus-group-get-new-news
310 "\M-g" gnus-group-get-new-news-this-group
311 "R" gnus-group-restart
312 "r" gnus-group-read-init-file
313 "B" gnus-group-browse-foreign-server
314 "b" gnus-group-check-bogus-groups
315 "F" gnus-find-new-newsgroups
316 "\C-c\C-d" gnus-group-describe-group
317 "\M-d" gnus-group-describe-all-groups
318 "\C-c\C-a" gnus-group-apropos
319 "\C-c\M-\C-a" gnus-group-description-apropos
320 "a" gnus-group-post-news
321 "\ek" gnus-group-edit-local-kill
322 "\eK" gnus-group-edit-global-kill
323 "\C-k" gnus-group-kill-group
324 "\C-y" gnus-group-yank-group
325 "\C-w" gnus-group-kill-region
326 "\C-x\C-t" gnus-group-transpose-groups
327 "\C-c\C-l" gnus-group-list-killed
328 "\C-c\C-x" gnus-group-expire-articles
329 "\C-c\M-\C-x" gnus-group-expire-all-groups
331 "s" gnus-group-save-newsrc
332 "z" gnus-group-suspend
335 "?" gnus-group-describe-briefly
336 "\C-c\C-i" gnus-info-find-node
337 "\M-e" gnus-group-edit-group-method
338 "^" gnus-group-enter-server-mode
339 gnus-mouse-2 gnus-mouse-pick-group
340 "<" beginning-of-buffer
343 "\C-c\C-s" gnus-group-sort-groups
345 "\C-c\M-g" gnus-activate-all-groups
346 "\M-&" gnus-group-universal-argument
347 "#" gnus-group-mark-group
348 "\M-#" gnus-group-unmark-group)
350 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
351 "m" gnus-group-mark-group
352 "u" gnus-group-unmark-group
353 "w" gnus-group-mark-region
354 "m" gnus-group-mark-buffer
355 "r" gnus-group-mark-regexp
356 "U" gnus-group-unmark-all-groups)
358 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
359 "d" gnus-group-make-directory-group
360 "h" gnus-group-make-help-group
361 "u" gnus-group-make-useful-group
362 "a" gnus-group-make-archive-group
363 "k" gnus-group-make-kiboze-group
364 "m" gnus-group-make-group
365 "E" gnus-group-edit-group
366 "e" gnus-group-edit-group-method
367 "p" gnus-group-edit-group-parameters
368 "v" gnus-group-add-to-virtual
369 "V" gnus-group-make-empty-virtual
370 "D" gnus-group-enter-directory
371 "f" gnus-group-make-doc-group
372 "w" gnus-group-make-web-group
373 "r" gnus-group-rename-group
374 "\177" gnus-group-delete-group
375 [delete] gnus-group-delete-group)
377 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
378 "b" gnus-group-brew-soup
379 "w" gnus-soup-save-areas
380 "s" gnus-soup-send-replies
381 "p" gnus-soup-pack-packet
382 "r" nnsoup-pack-replies)
384 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
385 "s" gnus-group-sort-groups
386 "a" gnus-group-sort-groups-by-alphabet
387 "u" gnus-group-sort-groups-by-unread
388 "l" gnus-group-sort-groups-by-level
389 "v" gnus-group-sort-groups-by-score
390 "r" gnus-group-sort-groups-by-rank
391 "m" gnus-group-sort-groups-by-method)
393 (gnus-define-keys (gnus-group-sort-map "P" gnus-group-group-map)
394 "s" gnus-group-sort-selected-groups
395 "a" gnus-group-sort-selected-groups-by-alphabet
396 "u" gnus-group-sort-selected-groups-by-unread
397 "l" gnus-group-sort-selected-groups-by-level
398 "v" gnus-group-sort-selected-groups-by-score
399 "r" gnus-group-sort-selected-groups-by-rank
400 "m" gnus-group-sort-selected-groups-by-method)
402 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
403 "k" gnus-group-list-killed
404 "z" gnus-group-list-zombies
405 "s" gnus-group-list-groups
406 "u" gnus-group-list-all-groups
407 "A" gnus-group-list-active
408 "a" gnus-group-apropos
409 "d" gnus-group-description-apropos
410 "m" gnus-group-list-matching
411 "M" gnus-group-list-all-matching
412 "l" gnus-group-list-level)
414 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
415 "f" gnus-score-flush-cache)
417 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
418 "f" gnus-group-fetch-faq)
420 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
421 "l" gnus-group-set-current-level
422 "t" gnus-group-unsubscribe-current-group
423 "s" gnus-group-unsubscribe-group
424 "k" gnus-group-kill-group
425 "y" gnus-group-yank-group
426 "w" gnus-group-kill-region
427 "\C-k" gnus-group-kill-level
428 "z" gnus-group-kill-all-zombies))
430 (defun gnus-group-make-menu-bar ()
431 (gnus-turn-off-edit-menu 'group)
432 (unless (boundp 'gnus-group-reading-menu)
435 gnus-group-reading-menu gnus-group-mode-map ""
437 ["Read" gnus-group-read-group (gnus-group-group-name)]
438 ["Select" gnus-group-select-group (gnus-group-group-name)]
439 ["See old articles" (gnus-group-select-group 'all)
440 :keys "C-u SPC" :active (gnus-group-group-name)]
441 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
442 ["Catch up all articles" gnus-group-catchup-current-all
443 (gnus-group-group-name)]
444 ["Check for new articles" gnus-group-get-new-news-this-group
445 (gnus-group-group-name)]
446 ["Toggle subscription" gnus-group-unsubscribe-current-group
447 (gnus-group-group-name)]
448 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
449 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
450 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
451 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
452 ["Edit kill file" gnus-group-edit-local-kill
453 (gnus-group-group-name)]
454 ;; Actually one should check, if any of the marked groups gives t for
455 ;; (gnus-check-backend-function 'request-expire-articles ...)
456 ["Expire articles" gnus-group-expire-articles
457 (or (and (gnus-group-group-name)
458 (gnus-check-backend-function
459 'request-expire-articles
460 (gnus-group-group-name))) gnus-group-marked)]
461 ["Set group level" gnus-group-set-current-level
462 (gnus-group-group-name)]
463 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
467 gnus-group-group-menu gnus-group-mode-map ""
470 ["List unread subscribed groups" gnus-group-list-groups t]
471 ["List (un)subscribed groups" gnus-group-list-all-groups t]
472 ["List killed groups" gnus-group-list-killed gnus-killed-list]
473 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
474 ["List level..." gnus-group-list-level t]
475 ["Describe all groups" gnus-group-describe-all-groups t]
476 ["Group apropos..." gnus-group-apropos t]
477 ["Group and description apropos..." gnus-group-description-apropos t]
478 ["List groups matching..." gnus-group-list-matching t]
479 ["List all groups matching..." gnus-group-list-all-matching t]
480 ["List active file" gnus-group-list-active t])
482 ["Default sort" gnus-group-sort-groups t]
483 ["Sort by method" gnus-group-sort-groups-by-method t]
484 ["Sort by rank" gnus-group-sort-groups-by-rank t]
485 ["Sort by score" gnus-group-sort-groups-by-score t]
486 ["Sort by level" gnus-group-sort-groups-by-level t]
487 ["Sort by unread" gnus-group-sort-groups-by-unread t]
488 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
489 ("Sort process/prefixed"
490 ["Default sort" gnus-group-sort-selected-groups
491 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
492 ["Sort by method" gnus-group-sort-selected-groups-by-method
493 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
494 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
495 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
496 ["Sort by score" gnus-group-sort-selected-groups-by-score
497 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
498 ["Sort by level" gnus-group-sort-selected-groups-by-level
499 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
500 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
501 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
502 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
503 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
505 ["Mark group" gnus-group-mark-group
506 (and (gnus-group-group-name)
507 (not (memq (gnus-group-group-name) gnus-group-marked)))]
508 ["Unmark group" gnus-group-unmark-group
509 (and (gnus-group-group-name)
510 (memq (gnus-group-group-name) gnus-group-marked))]
511 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
512 ["Mark regexp..." gnus-group-mark-regexp t]
513 ["Mark region" gnus-group-mark-region t]
514 ["Mark buffer" gnus-group-mark-buffer t]
515 ["Execute command" gnus-group-universal-argument
516 (or gnus-group-marked (gnus-group-group-name))])
518 ["Subscribe to a group" gnus-group-unsubscribe-group t]
519 ["Kill all newsgroups in region" gnus-group-kill-region t]
520 ["Kill all zombie groups" gnus-group-kill-all-zombies
522 ["Kill all groups on level..." gnus-group-kill-level t])
524 ["Make a foreign group" gnus-group-make-group t]
525 ["Add a directory group" gnus-group-make-directory-group t]
526 ["Add the help group" gnus-group-make-help-group t]
527 ["Add the archive group" gnus-group-make-archive-group t]
528 ["Make a doc group" gnus-group-make-doc-group t]
529 ["Make a kiboze group" gnus-group-make-kiboze-group t]
530 ["Make a virtual group" gnus-group-make-empty-virtual t]
531 ["Add a group to a virtual" gnus-group-add-to-virtual t]
532 ["Rename group" gnus-group-rename-group
533 (gnus-check-backend-function
534 'request-rename-group (gnus-group-group-name))]
535 ["Delete group" gnus-group-delete-group
536 (gnus-check-backend-function
537 'request-delete-group (gnus-group-group-name))])
539 ["Parameters" gnus-group-edit-group-parameters
540 (gnus-group-group-name)]
541 ["Select method" gnus-group-edit-group-method
542 (gnus-group-group-name)]
543 ["Info" gnus-group-edit-group (gnus-group-group-name)])
545 ["Flush cache" gnus-score-flush-cache t])
547 ["Next" gnus-group-next-group t]
548 ["Previous" gnus-group-prev-group t]
549 ["Next unread" gnus-group-next-unread-group t]
550 ["Previous unread" gnus-group-prev-unread-group t]
551 ["Next unread same level" gnus-group-next-unread-group-same-level t]
552 ["Previous unread same level"
553 gnus-group-prev-unread-group-same-level t]
554 ["Jump to group" gnus-group-jump-to-group t]
555 ["First unread group" gnus-group-first-unread-group t]
556 ["Best unread group" gnus-group-best-unread-group t])
557 ["Transpose" gnus-group-transpose-groups
558 (gnus-group-group-name)]
559 ["Read a directory as a group..." gnus-group-enter-directory t]
563 gnus-group-misc-menu gnus-group-mode-map ""
565 ["Send a bug report" gnus-bug t]
566 ["Send a mail" gnus-group-mail t]
567 ["Post an article..." gnus-group-post-news t]
568 ["Customize score file" gnus-score-customize t]
569 ["Check for new news" gnus-group-get-new-news t]
570 ["Activate all groups" gnus-activate-all-groups t]
571 ["Delete bogus groups" gnus-group-check-bogus-groups t]
572 ["Find new newsgroups" gnus-find-new-newsgroups t]
573 ["Restart Gnus" gnus-group-restart t]
574 ["Read init file" gnus-group-read-init-file t]
575 ["Browse foreign server" gnus-group-browse-foreign-server t]
576 ["Enter server buffer" gnus-group-enter-server-mode t]
577 ["Expire all expirable articles" gnus-group-expire-all-groups t]
578 ["Generate any kiboze groups" nnkiboze-generate-groups t]
579 ["Gnus version" gnus-version t]
580 ["Save .newsrc files" gnus-group-save-newsrc t]
581 ["Suspend Gnus" gnus-group-suspend t]
582 ["Clear dribble buffer" gnus-group-clear-dribble t]
583 ["Edit global kill file" gnus-group-edit-global-kill t]
584 ["Read manual" gnus-info-find-node t]
585 ["Toggle topics" gnus-topic-mode t]
587 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
588 ["Send replies" gnus-soup-send-replies
589 (fboundp 'gnus-soup-pack-packet)]
590 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
591 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
592 ["Brew SOUP" gnus-soup-brew-soup (fboundp 'gnus-soup-pack-packet)])
593 ["Exit from Gnus" gnus-group-exit t]
594 ["Exit without saving" gnus-group-quit t]
597 (run-hooks 'gnus-group-menu-hook)
600 (defun gnus-group-mode ()
601 "Major mode for reading news.
603 All normal editing commands are switched off.
604 \\<gnus-group-mode-map>
605 The group buffer lists (some of) the groups available. For instance,
606 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
607 lists all zombie groups.
609 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
610 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
612 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
614 The following commands are available:
616 \\{gnus-group-mode-map}"
618 (when (and menu-bar-mode
619 (gnus-visual-p 'group-menu 'menu))
620 (gnus-group-make-menu-bar))
621 (kill-all-local-variables)
622 (gnus-simplify-mode-line)
623 (setq major-mode 'gnus-group-mode)
624 (setq mode-name "Group")
625 (gnus-group-set-mode-line)
626 (setq mode-line-process nil)
627 (use-local-map gnus-group-mode-map)
628 (buffer-disable-undo (current-buffer))
629 (setq truncate-lines t)
630 (setq buffer-read-only t)
631 (gnus-set-default-directory)
632 (gnus-update-format-specifications nil 'group 'group-mode)
633 (gnus-update-group-mark-positions)
634 (gnus-make-local-hook 'post-command-hook)
635 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
638 (run-hooks 'gnus-group-mode-hook))
640 (defun gnus-update-group-mark-positions ()
642 (let ((gnus-process-mark 128)
643 (gnus-group-marked '("dummy.group"))
644 (gnus-active-hashtb (make-vector 10 0)))
645 (gnus-set-active "dummy.group" '(0 . 0))
646 (gnus-set-work-buffer)
647 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
648 (goto-char (point-min))
649 (setq gnus-group-mark-positions
650 (list (cons 'process (and (search-forward "\200" nil t)
653 (defun gnus-clear-inboxes-moved ()
654 (setq nnmail-moved-inboxes nil))
656 (defun gnus-mouse-pick-group (e)
657 "Enter the group under the mouse pointer."
660 (gnus-group-read-group nil))
662 ;; Look at LEVEL and find out what the level is really supposed to be.
663 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
664 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
665 (defun gnus-group-default-level (&optional level number-or-nil)
667 (gnus-group-use-permanent-levels
668 (or (setq gnus-group-use-permanent-levels
669 (or level (if (numberp gnus-group-use-permanent-levels)
670 gnus-group-use-permanent-levels
671 (or gnus-group-default-list-level
672 gnus-level-subscribed))))
673 gnus-group-default-list-level gnus-level-subscribed))
677 (or level gnus-group-default-list-level gnus-level-subscribed))))
679 (defun gnus-group-setup-buffer ()
680 (switch-to-buffer gnus-group-buffer)
681 (unless (eq major-mode 'gnus-group-mode)
682 (gnus-add-current-to-buffer-list)
685 (gnus-carpal-setup-buffer 'group))))
687 (defun gnus-group-list-groups (&optional level unread lowest)
688 "List newsgroups with level LEVEL or lower that have unread articles.
689 Default is all subscribed groups.
690 If argument UNREAD is non-nil, groups with no unread articles are also
693 (list (if current-prefix-arg
694 (prefix-numeric-value current-prefix-arg)
696 (gnus-group-default-level nil t)
697 gnus-group-default-list-level
698 gnus-level-subscribed))))
700 (setq level (car gnus-group-list-mode)
701 unread (cdr gnus-group-list-mode)))
702 (setq level (gnus-group-default-level level))
703 (gnus-group-setup-buffer) ;May call from out of group buffer
704 (gnus-update-format-specifications nil 'group 'group-mode)
705 (let ((case-fold-search nil)
706 (props (text-properties-at (gnus-point-at-bol)))
707 (group (gnus-group-group-name)))
708 (set-buffer gnus-group-buffer)
709 (funcall gnus-group-prepare-function level unread lowest)
710 (if (zerop (buffer-size))
711 (gnus-message 5 gnus-no-groups-message)
712 (goto-char (point-max))
713 (when (or (not gnus-group-goto-next-group-function)
714 (not (funcall gnus-group-goto-next-group-function
717 ;; Go to the first group with unread articles.
718 (gnus-group-search-forward t)
719 ;; Find the right group to put point on. If the current group
720 ;; has disappeared in the new listing, try to find the next
721 ;; one. If no next one can be found, just leave point at the
722 ;; first newsgroup in the buffer.
723 (when (not (gnus-goto-char
725 (point-min) (point-max)
726 'gnus-group (gnus-intern-safe
727 group gnus-active-hashtb))))
728 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
732 (point-min) (point-max) 'gnus-group
734 (caar newsrc) gnus-active-hashtb)))))
735 (setq newsrc (cdr newsrc)))
737 (goto-char (point-max))
738 (forward-line -1))))))
739 ;; Adjust cursor point.
740 (gnus-group-position-point))))
742 (defun gnus-group-list-level (level &optional all)
743 "List groups on LEVEL.
744 If ALL (the prefix), also list groups that have no unread articles."
745 (interactive "nList groups on level: \nP")
746 (gnus-group-list-groups level all level))
748 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
749 "List all newsgroups with unread articles of level LEVEL or lower.
750 If ALL is non-nil, list groups that have no unread articles.
751 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
752 If REGEXP, only list groups matching REGEXP."
753 (set-buffer gnus-group-buffer)
754 (let ((buffer-read-only nil)
755 (newsrc (cdr gnus-newsrc-alist))
756 (lowest (or lowest 1))
757 info clevel unread group params)
759 (if (< lowest gnus-level-zombie)
760 ;; List living groups.
762 (setq info (car newsrc)
763 group (gnus-info-group info)
764 params (gnus-info-params info)
766 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
767 (and unread ; This group might be bogus
769 (string-match regexp group))
770 (<= (setq clevel (gnus-info-level info)) level)
772 (or all ; We list all groups?
773 (if (eq unread t) ; Unactivated?
774 gnus-group-list-inactive-groups ; We list unactivated
775 (> unread 0)) ; We list groups with unread articles
776 (and gnus-list-groups-with-ticked-articles
777 (cdr (assq 'tick (gnus-info-marks info))))
778 ; And groups with tickeds
779 ;; Check for permanent visibility.
780 (and gnus-permanently-visible-groups
781 (string-match gnus-permanently-visible-groups
783 (memq 'visible params)
784 (cdr (assq 'visible params)))
785 (gnus-group-insert-group-line
786 group (gnus-info-level info)
787 (gnus-info-marks info) unread (gnus-info-method info)))))
790 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
791 (gnus-group-prepare-flat-list-dead
792 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
795 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
796 (gnus-group-prepare-flat-list-dead
797 (setq gnus-killed-list (sort gnus-killed-list 'string<))
798 gnus-level-killed ?K regexp))
800 (gnus-group-set-mode-line)
801 (setq gnus-group-list-mode (cons level all))
802 (run-hooks 'gnus-group-prepare-hook)))
804 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
805 ;; List zombies and killed lists somewhat faster, which was
806 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
807 ;; this by ignoring the group format specification altogether.
810 ;; This loop is used when listing groups that match some
813 (setq group (pop groups))
814 (when (string-match regexp group)
815 (gnus-add-text-properties
816 (point) (prog1 (1+ (point))
817 (insert " " mark " *: " group "\n"))
818 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
820 'gnus-level level))))
821 ;; This loop is used when listing all groups.
823 (gnus-add-text-properties
824 (point) (prog1 (1+ (point))
825 (insert " " mark " *: "
826 (setq group (pop groups)) "\n"))
827 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
829 'gnus-level level))))))
831 (defun gnus-group-update-group-line ()
832 "Update the current line in the group buffer."
833 (let* ((buffer-read-only nil)
834 (group (gnus-group-group-name))
835 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
836 gnus-group-indentation)
839 (not (gnus-ephemeral-group-p group))
841 (concat "(gnus-group-set-info '"
842 (gnus-prin1-to-string (nth 2 entry)) ")")))
843 (setq gnus-group-indentation (gnus-group-group-indentation))
845 (gnus-group-insert-group-line-info group)
847 (gnus-group-position-point))))
849 (defun gnus-group-insert-group-line-info (group)
850 "Insert GROUP on the current line."
851 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
852 (gnus-group-indentation (gnus-group-group-indentation))
856 ;; (Un)subscribed group.
857 (setq info (nth 2 entry))
858 (gnus-group-insert-group-line
859 group (gnus-info-level info) (gnus-info-marks info)
860 (or (car entry) t) (gnus-info-method info)))
861 ;; This group is dead.
862 (gnus-group-insert-group-line
864 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
866 (if (setq active (gnus-active group))
867 (- (1+ (cdr active)) (car active)) 0)
870 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
871 gnus-tmp-marked number
873 "Insert a group line in the group buffer."
874 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
875 (gnus-tmp-number-total
877 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
879 (gnus-tmp-number-of-unread
880 (if (numberp number) (int-to-string (max 0 number))
882 (gnus-tmp-number-of-read
884 (int-to-string (max 0 (- gnus-tmp-number-total number)))
887 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
888 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
889 ((= gnus-tmp-level gnus-level-zombie) ?Z)
891 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
892 (gnus-tmp-newsgroup-description
893 (if gnus-description-hashtb
894 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
897 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
898 (gnus-tmp-moderated-string
899 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
901 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
902 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
903 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
904 (gnus-tmp-news-method-string
906 (format "(%s:%s)" (car gnus-tmp-method)
907 (cadr gnus-tmp-method)) ""))
908 (gnus-tmp-marked-mark
909 (if (and (numberp number)
911 (cdr (assq 'tick gnus-tmp-marked)))
913 (gnus-tmp-process-marked
914 (if (member gnus-tmp-group gnus-group-marked)
915 gnus-process-mark ? ))
917 (or (and gnus-use-grouplens
918 (bbb-grouplens-group-p gnus-tmp-group))
920 (buffer-read-only nil)
921 header gnus-tmp-header) ; passed as parameter to user-funcs.
923 (gnus-add-text-properties
927 (eval gnus-group-line-format-spec))
928 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
929 gnus-unread ,(if (numberp number)
930 (string-to-int gnus-tmp-number-of-unread)
932 gnus-marked ,gnus-tmp-marked-mark
933 gnus-indentation ,gnus-group-indentation
934 gnus-level ,gnus-tmp-level))
935 (when (inline (gnus-visual-p 'group-highlight 'highlight))
937 (run-hooks 'gnus-group-update-hook)
939 ;; Allow XEmacs to remove front-sticky text properties.
940 (gnus-group-remove-excess-properties)))
942 (defun gnus-group-highlight-line ()
943 "Highlight the current line according to `gnus-group-highlight'."
944 (let* ((list gnus-group-highlight)
946 (end (progn (end-of-line) (point)))
947 ;; now find out where the line starts and leave point there.
948 (beg (progn (beginning-of-line) (point)))
949 (group (gnus-group-group-name))
950 (entry (gnus-group-entry group))
951 (unread (if (numberp (car entry)) (car entry) 0))
952 (active (gnus-active group))
953 (total (if active (1+ (- (cdr active) (car active))) 0))
955 (method (gnus-server-get-method group (gnus-info-method info)))
956 (marked (gnus-info-marks info))
957 (mailp (memq 'mail (assoc (symbol-name
958 (car (or method gnus-select-method)))
959 gnus-valid-select-methods)))
960 (level (or (gnus-info-level info) 9))
961 (score (or (gnus-info-score info) 0))
962 (ticked (gnus-range-length (cdr (assq 'tick marked))))
963 (inhibit-read-only t))
964 ;; Eval the cars of the lists until we find a match.
966 (not (eval (caar list))))
967 (setq list (cdr list)))
968 (let ((face (cdar list)))
969 (unless (eq face (get-text-property beg 'face))
970 (gnus-put-text-property
972 (setq face (if (boundp face) (symbol-value face) face)))
973 (gnus-extent-start-open beg)))
976 (defun gnus-group-update-group (group &optional visible-only)
977 "Update all lines where GROUP appear.
978 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
981 (set-buffer gnus-group-buffer)
982 ;; The buffer may be narrowed.
985 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
987 found buffer-read-only)
988 ;; Enter the current status into the dribble buffer.
989 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
990 (if (and entry (not (gnus-ephemeral-group-p group)))
992 (concat "(gnus-group-set-info '"
993 (gnus-prin1-to-string (nth 2 entry))
995 ;; Find all group instances. If topics are in use, each group
996 ;; may be listed in more than once.
997 (while (setq loc (text-property-any
998 loc (point-max) 'gnus-group ident))
1001 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1003 (gnus-group-insert-group-line-info group)
1006 (run-hooks 'gnus-group-update-group-hook)))
1007 (setq loc (1+ loc)))
1008 (unless (or found visible-only)
1009 ;; No such line in the buffer, find out where it's supposed to
1010 ;; go, and insert it there (or at the end of the buffer).
1011 (if gnus-goto-missing-group-function
1012 (funcall gnus-goto-missing-group-function group)
1013 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1014 (while (and entry (car entry)
1018 (point-min) (point-max)
1019 'gnus-group (gnus-intern-safe
1020 (caar entry) gnus-active-hashtb)))))
1021 (setq entry (cdr entry)))
1022 (or entry (goto-char (point-max)))))
1023 ;; Finally insert the line.
1024 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1025 (gnus-group-insert-group-line-info group)
1028 (run-hooks 'gnus-group-update-group-hook))))
1029 (when gnus-group-update-group-function
1030 (funcall gnus-group-update-group-function group))
1031 (gnus-group-set-mode-line)))))
1033 (defun gnus-group-set-mode-line ()
1034 "Update the mode line in the group buffer."
1035 (when (memq 'group gnus-updated-mode-lines)
1036 ;; Yes, we want to keep this mode line updated.
1038 (set-buffer gnus-group-buffer)
1039 (let* ((gformat (or gnus-group-mode-line-format-spec
1040 (setq gnus-group-mode-line-format-spec
1042 gnus-group-mode-line-format
1043 gnus-group-mode-line-format-alist))))
1044 (gnus-tmp-news-server (cadr gnus-select-method))
1045 (gnus-tmp-news-method (car gnus-select-method))
1046 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1048 gnus-tmp-header ;Dummy binding for user-defined formats
1049 ;; Get the resulting string.
1051 (and gnus-dribble-buffer
1052 (buffer-name gnus-dribble-buffer)
1053 (buffer-modified-p gnus-dribble-buffer)
1055 (set-buffer gnus-dribble-buffer)
1056 (not (zerop (buffer-size))))))
1057 (mode-string (eval gformat)))
1058 ;; Say whether the dribble buffer has been modified.
1059 (setq mode-line-modified
1060 (if modified "---*- " "----- "))
1061 ;; If the line is too long, we chop it off.
1062 (when (> (length mode-string) max-len)
1063 (setq mode-string (substring mode-string 0 (- max-len 4))))
1065 (setq mode-line-buffer-identification
1066 (gnus-mode-line-buffer-identification
1067 (list mode-string)))
1068 (set-buffer-modified-p modified))))))
1070 (defun gnus-group-group-name ()
1071 "Get the name of the newsgroup on the current line."
1072 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1073 (and group (symbol-name group))))
1075 (defun gnus-group-group-level ()
1076 "Get the level of the newsgroup on the current line."
1077 (get-text-property (gnus-point-at-bol) 'gnus-level))
1079 (defun gnus-group-group-indentation ()
1080 "Get the indentation of the newsgroup on the current line."
1081 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1082 (and gnus-group-indentation-function
1083 (funcall gnus-group-indentation-function))
1086 (defun gnus-group-group-unread ()
1087 "Get the number of unread articles of the newsgroup on the current line."
1088 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1090 (defun gnus-group-search-forward (&optional backward all level first-too)
1091 "Find the next newsgroup with unread articles.
1092 If BACKWARD is non-nil, find the previous newsgroup instead.
1093 If ALL is non-nil, just find any newsgroup.
1094 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1096 If FIRST-TOO, the current line is also eligible as a target."
1097 (let ((way (if backward -1 1))
1098 (low gnus-level-killed)
1101 (if (and backward (progn (beginning-of-line)) (bobp))
1103 (or first-too (forward-line way))
1111 (get-text-property (point) 'gnus-unread)))
1112 (and (numberp unread) (> unread 0)))
1113 (setq lev (get-text-property (point)
1115 (<= lev gnus-level-subscribed)))
1117 (and (setq lev (get-text-property (point)
1126 (zerop (forward-line way)))))
1128 (progn (gnus-group-position-point) t)
1129 (goto-char (or pos beg))
1132 ;;; Gnus group mode commands
1136 (defun gnus-group-mark-group (n &optional unmark no-advance)
1137 "Mark the current group."
1139 (let ((buffer-read-only nil)
1143 (when (setq group (gnus-group-group-name))
1144 ;; Go to the mark position.
1146 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1147 (subst-char-in-region
1148 (point) (1+ (point)) (following-char)
1151 (setq gnus-group-marked (delete group gnus-group-marked))
1153 (setq gnus-group-marked
1154 (cons group (delete group gnus-group-marked)))
1155 gnus-process-mark)))
1157 (gnus-group-next-group 1))
1159 (gnus-summary-position-point)
1162 (defun gnus-group-unmark-group (n)
1163 "Remove the mark from the current group."
1165 (gnus-group-mark-group n 'unmark)
1166 (gnus-group-position-point))
1168 (defun gnus-group-unmark-all-groups ()
1169 "Unmark all groups."
1171 (let ((groups gnus-group-marked))
1174 (gnus-group-remove-mark (pop groups)))))
1175 (gnus-group-position-point))
1177 (defun gnus-group-mark-region (unmark beg end)
1178 "Mark all groups between point and mark.
1179 If UNMARK, remove the mark instead."
1180 (interactive "P\nr")
1181 (let ((num (count-lines beg end)))
1184 (- num (gnus-group-mark-group num unmark)))))
1186 (defun gnus-group-mark-buffer (&optional unmark)
1187 "Mark all groups in the buffer.
1188 If UNMARK, remove the mark instead."
1190 (gnus-group-mark-region unmark (point-min) (point-max)))
1192 (defun gnus-group-mark-regexp (regexp)
1193 "Mark all groups that match some regexp."
1194 (interactive "sMark (regexp): ")
1195 (let ((alist (cdr gnus-newsrc-alist))
1198 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1199 (gnus-group-set-mark group))))
1200 (gnus-group-position-point))
1202 (defun gnus-group-remove-mark (group)
1203 "Remove the process mark from GROUP and move point there.
1204 Return nil if the group isn't displayed."
1205 (if (gnus-group-goto-group group)
1207 (gnus-group-mark-group 1 'unmark t)
1209 (setq gnus-group-marked
1210 (delete group gnus-group-marked))
1213 (defun gnus-group-set-mark (group)
1214 "Set the process mark on GROUP."
1215 (if (gnus-group-goto-group group)
1217 (gnus-group-mark-group 1 nil t))
1218 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1220 (defun gnus-group-universal-argument (arg &optional groups func)
1221 "Perform any command on all groups according to the process/prefix convention."
1223 (let ((groups (or groups (gnus-group-process-prefix arg)))
1225 (if (eq (setq func (or func
1228 (substitute-command-keys
1229 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1231 (gnus-error 1 "Undefined key")
1233 (gnus-group-remove-mark (pop groups))
1234 (command-execute func))))
1235 (gnus-group-position-point))
1237 (defun gnus-group-process-prefix (n)
1238 "Return a list of groups to work on.
1239 Take into consideration N (the prefix) and the list of marked groups."
1242 (setq n (prefix-numeric-value n))
1243 ;; There is a prefix, so we return a list of the N next
1245 (let ((way (if (< n 0) -1 1))
1250 (setq group (gnus-group-group-name)))
1251 (setq groups (cons group groups))
1253 (gnus-group-next-group way)))
1255 ((and (boundp 'transient-mark-mode)
1257 (boundp 'mark-active)
1259 ;; Work on the region between point and mark.
1260 (let ((max (max (point) (mark)))
1263 (goto-char (min (point) (mark)))
1266 (push (gnus-group-group-name) groups)
1267 (zerop (gnus-group-next-group 1))
1269 (nreverse groups))))
1271 ;; No prefix, but a list of marked articles.
1272 (reverse gnus-group-marked))
1274 ;; Neither marked articles or a prefix, so we return the
1276 (let ((group (gnus-group-group-name)))
1277 (and group (list group))))))
1279 ;; Selecting groups.
1281 (defun gnus-group-read-group (&optional all no-article group)
1282 "Read news in this newsgroup.
1283 If the prefix argument ALL is non-nil, already read articles become
1284 readable. IF ALL is a number, fetch this number of articles. If the
1285 optional argument NO-ARTICLE is non-nil, no article will be
1286 auto-selected upon group entry. If GROUP is non-nil, fetch that
1289 (let ((no-display (eq all 0))
1290 (group (or group (gnus-group-group-name)))
1291 number active marked entry)
1295 (error "No group on current line"))
1296 (setq marked (gnus-info-marks
1297 (nth 2 (setq entry (gnus-gethash
1298 group gnus-newsrc-hashtb)))))
1299 ;; This group might be a dead group. In that case we have to get
1300 ;; the number of unread articles from `gnus-active-hashtb'.
1302 (cond ((numberp all) all)
1304 ((setq active (gnus-active group))
1305 (- (1+ (cdr active)) (car active)))))
1306 (gnus-summary-read-group
1307 group (or all (and (numberp number)
1308 (zerop (+ number (gnus-range-length
1309 (cdr (assq 'tick marked)))
1311 (cdr (assq 'dormant marked)))))))
1312 no-article nil no-display)))
1314 (defun gnus-group-select-group (&optional all)
1315 "Select this newsgroup.
1316 No article is selected automatically.
1317 If ALL is non-nil, already read articles become readable.
1318 If ALL is a number, fetch this number of articles."
1320 (gnus-group-read-group all t))
1322 (defun gnus-group-quick-select-group (&optional all)
1323 "Select the current group \"quickly\".
1324 This means that no highlighting or scoring will be performed.
1325 If ALL (the prefix argument) is 0, don't even generate the summary
1329 gnus-score-find-score-files-function
1330 gnus-apply-kill-hook
1331 gnus-summary-expunge-below)
1332 (gnus-group-read-group all t)))
1334 (defun gnus-group-visible-select-group (&optional all)
1335 "Select the current group without hiding any articles."
1337 (let ((gnus-inhibit-limiting t))
1338 (gnus-group-read-group all t)))
1341 (defun gnus-fetch-group (group)
1342 "Start Gnus if necessary and enter GROUP.
1343 Returns whether the fetching was successful or not."
1344 (interactive "sGroup name: ")
1345 (or (get-buffer gnus-group-buffer)
1347 (gnus-group-read-group nil nil group))
1349 ;; Enter a group that is not in the group buffer. Non-nil is returned
1350 ;; if selection was successful.
1351 (defun gnus-group-read-ephemeral-group (group method &optional activate
1352 quit-config request-only)
1353 "Read GROUP from METHOD as an ephemeral group.
1354 If ACTIVATE, request the group first.
1355 If QUIT-CONFIG, use that window configuration when exiting from the
1357 If REQUEST-ONLY, don't actually read the group; just request it.
1359 Return the name of the group is selection was successful."
1360 (let ((group (if (gnus-group-foreign-p group) group
1361 (gnus-group-prefixed-name group method))))
1365 ,gnus-level-default-subscribed nil nil ,method
1367 ,(if quit-config quit-config
1368 (cons gnus-summary-buffer
1369 gnus-current-window-configuration))))))
1371 (set-buffer gnus-group-buffer)
1372 (unless (gnus-check-server method)
1373 (error "Unable to contact server: %s" (gnus-status-message method)))
1375 (unless (gnus-request-group group)
1376 (error "Couldn't request group: %s"
1377 (nnheader-get-report (car method))))
1378 (gnus-activate-group group nil t))
1382 (when (gnus-group-read-group t t group)
1387 (defun gnus-group-jump-to-group (group)
1388 "Jump to newsgroup GROUP."
1390 (list (completing-read
1391 "Group: " gnus-active-hashtb nil
1392 (gnus-read-active-file-p)
1394 'gnus-group-history)))
1396 (when (equal group "")
1397 (error "Empty group name"))
1399 (when (string-match "[\000-\032]" group)
1400 (error "Control characters in group: %s" group))
1402 (let ((b (text-property-any
1403 (point-min) (point-max)
1404 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
1405 (unless (gnus-ephemeral-group-p group)
1407 ;; Either go to the line in the group buffer...
1409 ;; ... or insert the line.
1411 t;; Don't activate group.
1413 (gnus-activate-group group)
1414 (error "%s error: %s" group (gnus-status-message group)))
1416 (gnus-group-update-group group)
1417 (goto-char (text-property-any
1418 (point-min) (point-max)
1419 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
1420 ;; Adjust cursor point.
1421 (gnus-group-position-point)))
1423 (defun gnus-group-goto-group (group &optional far)
1424 "Goto to newsgroup GROUP.
1425 If FAR, it is likely that the group is not on the current line."
1430 (point-min) (point-max)
1431 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
1434 ;; It's quite likely that we are on the right line, so
1435 ;; we check the current line first.
1436 ((eq (get-text-property (point) 'gnus-group)
1437 (gnus-intern-safe group gnus-active-hashtb))
1439 ;; Previous and next line are also likely, so we check them as well.
1442 (eq (get-text-property (point) 'gnus-group)
1443 (gnus-intern-safe group gnus-active-hashtb)))
1448 (eq (get-text-property (point) 'gnus-group)
1449 (gnus-intern-safe group gnus-active-hashtb)))
1453 ;; Search through the entire buffer.
1456 (point-min) (point-max)
1457 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
1459 (defun gnus-group-next-group (n &optional silent)
1460 "Go to next N'th newsgroup.
1461 If N is negative, search backward instead.
1462 Returns the difference between N and the number of skips actually
1465 (gnus-group-next-unread-group n t nil silent))
1467 (defun gnus-group-next-unread-group (n &optional all level silent)
1468 "Go to next N'th unread newsgroup.
1469 If N is negative, search backward instead.
1470 If ALL is non-nil, choose any newsgroup, unread or not.
1471 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1472 such group can be found, the next group with a level higher than
1474 Returns the difference between N and the number of skips actually
1477 (let ((backward (< n 0))
1480 (gnus-group-search-forward
1481 backward (or (not gnus-group-goto-unread) all) level))
1485 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1486 (if level " on this level or higher" "")))
1489 (defun gnus-group-prev-group (n)
1490 "Go to previous N'th newsgroup.
1491 Returns the difference between N and the number of skips actually
1494 (gnus-group-next-unread-group (- n) t))
1496 (defun gnus-group-prev-unread-group (n)
1497 "Go to previous N'th unread newsgroup.
1498 Returns the difference between N and the number of skips actually
1501 (gnus-group-next-unread-group (- n)))
1503 (defun gnus-group-next-unread-group-same-level (n)
1504 "Go to next N'th unread newsgroup on the same level.
1505 If N is negative, search backward instead.
1506 Returns the difference between N and the number of skips actually
1509 (gnus-group-next-unread-group n t (gnus-group-group-level))
1510 (gnus-group-position-point))
1512 (defun gnus-group-prev-unread-group-same-level (n)
1513 "Go to next N'th unread newsgroup on the same level.
1514 Returns the difference between N and the number of skips actually
1517 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1518 (gnus-group-position-point))
1520 (defun gnus-group-best-unread-group (&optional exclude-group)
1521 "Go to the group with the highest level.
1522 If EXCLUDE-GROUP, do not go to that group."
1524 (goto-char (point-min))
1528 (setq unread (get-text-property (point) 'gnus-unread))
1529 (if (and (numberp unread) (> unread 0))
1531 (if (and (get-text-property (point) 'gnus-level)
1532 (< (get-text-property (point) 'gnus-level) best)
1533 (or (not exclude-group)
1534 (not (equal exclude-group (gnus-group-group-name)))))
1536 (setq best (get-text-property (point) 'gnus-level))
1537 (setq best-point (point))))))
1539 (if best-point (goto-char best-point))
1540 (gnus-summary-position-point)
1541 (and best-point (gnus-group-group-name))))
1543 (defun gnus-group-first-unread-group ()
1544 "Go to the first group with unread articles."
1547 (let ((opoint (point))
1549 (goto-char (point-min))
1550 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1551 (and (numberp unread) ; Not a topic.
1552 (not (zerop unread))) ; Has unread articles.
1553 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1556 nil)) ; Not success.
1557 (gnus-group-position-point)))
1559 (defun gnus-group-enter-server-mode ()
1560 "Jump to the server buffer."
1562 (gnus-enter-server-buffer))
1564 (defun gnus-group-make-group (name &optional method address)
1565 "Add a new newsgroup.
1566 The user will be prompted for a NAME, for a select METHOD, and an
1570 (read-string "Group name: ")
1571 (gnus-read-method "From method: ")))
1573 (let* ((meth (when (and method
1574 (not (gnus-server-equal method gnus-select-method)))
1575 (if address (list (intern method) address)
1577 (nname (if method (gnus-group-prefixed-name name meth) name))
1579 (when (gnus-gethash nname gnus-newsrc-hashtb)
1580 (error "Group %s already exists" nname))
1581 ;; Subscribe to the new group.
1582 (gnus-group-change-level
1583 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1584 gnus-level-default-subscribed gnus-level-killed
1585 (and (gnus-group-group-name)
1586 (gnus-gethash (gnus-group-group-name)
1587 gnus-newsrc-hashtb))
1590 (gnus-set-active nname (cons 1 0))
1591 (or (gnus-ephemeral-group-p name)
1593 (concat "(gnus-group-set-info '"
1594 (gnus-prin1-to-string (cdr info)) ")")))
1596 (gnus-group-insert-group-line-info nname)
1598 (gnus-group-position-point)
1600 ;; Load the backend and try to make the backend create
1601 ;; the group as well.
1602 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1604 gnus-valid-select-methods)
1606 (gnus-check-server meth)
1607 (and (gnus-check-backend-function 'request-create-group nname)
1608 (gnus-request-create-group nname))
1611 (defun gnus-group-delete-group (group &optional force)
1612 "Delete the current group. Only meaningful with mail groups.
1613 If FORCE (the prefix) is non-nil, all the articles in the group will
1614 be deleted. This is \"deleted\" as in \"removed forever from the face
1615 of the Earth\". There is no undo. The user will be prompted before
1616 doing the deletion."
1618 (list (gnus-group-group-name)
1619 current-prefix-arg))
1620 (or group (error "No group to rename"))
1621 (or (gnus-check-backend-function 'request-delete-group group)
1622 (error "This backend does not support group deletion"))
1624 (if (not (gnus-yes-or-no-p
1626 "Do you really want to delete %s%s? "
1627 group (if force " and all its contents" ""))))
1629 (gnus-message 6 "Deleting group %s..." group)
1630 (if (not (gnus-request-delete-group group force))
1631 (gnus-error 3 "Couldn't delete group %s" group)
1632 (gnus-message 6 "Deleting group %s...done" group)
1633 (gnus-group-goto-group group)
1634 (gnus-group-kill-group 1 t)
1635 (gnus-sethash group nil gnus-active-hashtb)
1637 (gnus-group-position-point)))
1639 (defun gnus-group-rename-group (group new-name)
1640 "Rename group from GROUP to NEW-NAME.
1641 When used interactively, GROUP is the group under point
1642 and NEW-NAME will be prompted for."
1645 (gnus-group-group-name)
1647 (unless (gnus-check-backend-function
1648 'request-rename-group (gnus-group-group-name))
1649 (error "This backend does not support renaming groups"))
1650 (read-string "New group name: " (gnus-group-group-name)))))
1652 (unless (gnus-check-backend-function 'request-rename-group group)
1653 (error "This backend does not support renaming groups"))
1655 (error "No group to rename"))
1656 (when (string-match "^[ \t]*$" new-name)
1657 (error "Not a valid group name"))
1658 (when (equal group new-name)
1659 (error "Can't rename to the same name"))
1661 ;; We find the proper prefixed name.
1663 (if (equal (gnus-group-real-name new-name) new-name)
1667 (gnus-group-prefixed-name
1668 (gnus-group-real-name new-name)
1669 (gnus-info-method (gnus-get-info group)))))
1671 (gnus-message 6 "Renaming group %s to %s..." group new-name)
1673 (if (not (gnus-request-rename-group group new-name))
1674 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
1675 ;; We rename the group internally by killing it...
1676 (gnus-group-goto-group group)
1677 (gnus-group-kill-group)
1678 ;; ... changing its name ...
1679 (setcar (cdar gnus-list-of-killed-groups) new-name)
1680 ;; ... and then yanking it. Magic!
1681 (gnus-group-yank-group)
1682 (gnus-set-active new-name (gnus-active group))
1683 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
1685 (gnus-group-position-point)))
1687 (defun gnus-group-edit-group (group &optional part)
1688 "Edit the group on the current line."
1689 (interactive (list (gnus-group-group-name)))
1690 (let ((part (or part 'info))
1693 (error "No group on current line"))
1694 (unless (setq info (gnus-get-info group))
1695 (error "Killed group; can't be edited"))
1697 ;; Find the proper form to edit.
1698 (cond ((eq part 'method)
1699 (or (gnus-info-method info) "native"))
1701 (gnus-info-params info))
1703 ;; The proper documentation.
1707 ((eq part 'method) "select method")
1708 ((eq part 'params) "group parameters")
1711 (gnus-group-edit-group-done ',part ,group form)))))
1713 (defun gnus-group-edit-group-method (group)
1714 "Edit the select method of GROUP."
1715 (interactive (list (gnus-group-group-name)))
1716 (gnus-group-edit-group group 'method))
1718 (defun gnus-group-edit-group-parameters (group)
1719 "Edit the group parameters of GROUP."
1720 (interactive (list (gnus-group-group-name)))
1721 (gnus-group-edit-group group 'params))
1723 (defun gnus-group-edit-group-done (part group form)
1725 (let* ((method (cond ((eq part 'info) (nth 4 form))
1726 ((eq part 'method) form)
1728 (info (cond ((eq part 'info) form)
1729 ((eq part 'method) (gnus-get-info group))
1732 (if (or (not method)
1734 gnus-select-method method))
1735 (gnus-group-real-name (car info))
1736 (gnus-group-prefixed-name
1737 (gnus-group-real-name (car info)) method))
1739 (when (and new-group
1740 (not (equal new-group group)))
1741 (when (gnus-group-goto-group group)
1742 (gnus-group-kill-group 1))
1743 (gnus-activate-group new-group))
1745 (if (not (and info new-group))
1746 (gnus-group-set-info form (or new-group group) part)
1747 (setq info (gnus-copy-sequence info))
1748 (setcar info new-group)
1749 (unless (gnus-server-equal method "native")
1750 (unless (nthcdr 3 info)
1751 (nconc info (list nil nil)))
1752 (unless (nthcdr 4 info)
1753 (nconc info (list nil)))
1754 (gnus-info-set-method info method))
1755 (gnus-group-set-info info))
1756 (gnus-group-update-group (or new-group group))
1757 (gnus-group-position-point)))
1759 (defun gnus-group-make-useful-group (group method)
1761 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
1763 gnus-useful-groups)))
1764 (list (cadr entry) (caddr entry))))
1765 (setq method (gnus-copy-sequence method))
1767 (while (setq entry (memq (assq 'eval method) method))
1768 (setcar entry (eval (cadar entry)))))
1769 (gnus-group-make-group group method))
1771 (defun gnus-group-make-help-group ()
1772 "Create the Gnus documentation group."
1774 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
1775 (file (nnheader-find-etc-directory "gnus-tut.txt" t))
1777 (when (gnus-gethash name gnus-newsrc-hashtb)
1778 (error "Documentation group already exists"))
1780 (gnus-message 1 "Couldn't find doc group")
1781 (gnus-group-make-group
1782 (gnus-group-real-name name)
1783 (list 'nndoc "gnus-help"
1784 (list 'nndoc-address file)
1785 (list 'nndoc-article-type 'mbox)))))
1786 (gnus-group-position-point))
1788 (defun gnus-group-make-doc-group (file type)
1789 "Create a group that uses a single file as the source."
1791 (list (read-file-name "File name: ")
1792 (and current-prefix-arg 'ask)))
1793 (when (eq type 'ask)
1798 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
1800 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
1801 ((= char ?b) 'babyl)
1802 ((= char ?d) 'digest)
1803 ((= char ?f) 'forward)
1805 (t (setq err (format "%c unknown. " char))
1808 (let* ((file (expand-file-name file))
1809 (name (gnus-generate-new-group-name
1810 (gnus-group-prefixed-name
1811 (file-name-nondirectory file) '(nndoc "")))))
1812 (gnus-group-make-group
1813 (gnus-group-real-name name)
1815 (list 'nndoc-address file)
1816 (list 'nndoc-article-type (or type 'guess))))))
1818 (defvar nnweb-type-definition)
1819 (defvar gnus-group-web-type-history nil)
1820 (defvar gnus-group-web-search-history nil)
1821 (defun gnus-group-make-web-group (&optional solid)
1822 "Create an ephemeral nnweb group.
1823 If SOLID (the prefix), create a solid group."
1827 (if solid (read-string "Group name: ") (message-unique-id)))
1830 "Search engine type: "
1831 (mapcar (lambda (elem) (list (symbol-name (car elem))))
1832 nnweb-type-definition)
1833 nil t (cons (or (car gnus-group-web-type-history)
1834 (symbol-name (caar nnweb-type-definition)))
1836 'gnus-group-web-type-history))
1840 (cons (or (car gnus-group-web-search-history) "") 0)
1841 'gnus-group-web-search-history))
1843 `(nnweb ,group (nnweb-search ,search)
1844 (nnweb-type ,(intern type)))))
1846 (gnus-group-make-group group method)
1847 (gnus-group-read-ephemeral-group
1849 (cons (current-buffer)
1850 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
1852 (defun gnus-group-make-archive-group (&optional all)
1853 "Create the (ding) Gnus archive group of the most recent articles.
1854 Given a prefix, create a full group."
1856 (let ((group (gnus-group-prefixed-name
1857 (if all "ding.archives" "ding.recent") '(nndir ""))))
1858 (when (gnus-gethash group gnus-newsrc-hashtb)
1859 (error "Archive group already exists"))
1860 (gnus-group-make-group
1861 (gnus-group-real-name group)
1862 (list 'nndir (if all "hpc" "edu")
1863 (list 'nndir-directory
1864 (if all gnus-group-archive-directory
1865 gnus-group-recent-archive-directory))))
1866 (gnus-group-add-parameter group (cons 'to-address "ding@ifi.uio.no"))))
1868 (defun gnus-group-make-directory-group (dir)
1869 "Create an nndir group.
1870 The user will be prompted for a directory. The contents of this
1871 directory will be used as a newsgroup. The directory should contain
1872 mail messages or news articles in files that have numeric names."
1874 (list (read-file-name "Create group from directory: ")))
1875 (or (file-exists-p dir) (error "No such directory"))
1876 (or (file-directory-p dir) (error "Not a directory"))
1880 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
1882 (gnus-group-prefixed-name
1883 (concat (file-name-as-directory (directory-file-name dir))
1886 (setq ext (format "<%d>" (setq i (1+ i)))))
1887 (gnus-group-make-group
1888 (gnus-group-real-name group)
1889 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
1891 (defun gnus-group-make-kiboze-group (group address scores)
1892 "Create an nnkiboze group.
1893 The user will be prompted for a name, a regexp to match groups, and
1894 score file entries for articles to include in the group."
1897 (read-string "nnkiboze group name: ")
1898 (read-string "Source groups (regexp): ")
1899 (let ((headers (mapcar (lambda (group) (list group))
1900 '("subject" "from" "number" "date" "message-id"
1901 "references" "chars" "lines" "xref"
1902 "followup" "all" "body" "head")))
1903 scores header regexp regexps)
1904 (while (not (equal "" (setq header (completing-read
1905 "Match on header: " headers nil t))))
1907 (while (not (equal "" (setq regexp (read-string
1908 (format "Match on %s (string): "
1910 (setq regexps (cons (list regexp nil nil 'r) regexps)))
1911 (setq scores (cons (cons header regexps) scores)))
1913 (gnus-group-make-group group "nnkiboze" address)
1914 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
1915 (let (emacs-lisp-mode-hook)
1916 (pp scores (current-buffer)))))
1918 (defun gnus-group-add-to-virtual (n vgroup)
1919 "Add the current group to a virtual group."
1921 (list current-prefix-arg
1922 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
1924 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
1925 (error "%s is not an nnvirtual group" vgroup))
1926 (let* ((groups (gnus-group-process-prefix n))
1927 (method (gnus-info-method (gnus-get-info vgroup))))
1928 (setcar (cdr method)
1930 (nth 1 method) "\\|"
1933 (gnus-group-remove-mark s)
1934 (concat "\\(^" (regexp-quote s) "$\\)"))
1936 (gnus-group-position-point))
1938 (defun gnus-group-make-empty-virtual (group)
1939 "Create a new, fresh, empty virtual group."
1940 (interactive "sCreate new, empty virtual group: ")
1941 (let* ((method (list 'nnvirtual "^$"))
1942 (pgroup (gnus-group-prefixed-name group method)))
1943 ;; Check whether it exists already.
1944 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
1945 (error "Group %s already exists." pgroup))
1946 ;; Subscribe the new group after the group on the current line.
1947 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
1948 (gnus-group-update-group pgroup)
1950 (gnus-group-position-point)))
1952 (defun gnus-group-enter-directory (dir)
1953 "Enter an ephemeral nneething group."
1954 (interactive "DDirectory to read: ")
1955 (let* ((method (list 'nneething dir '(nneething-read-only t)))
1956 (leaf (gnus-group-prefixed-name
1957 (file-name-nondirectory (directory-file-name dir))
1959 (name (gnus-generate-new-group-name leaf)))
1960 (unless (gnus-group-read-ephemeral-group
1962 (cons (current-buffer)
1963 (if (eq major-mode 'gnus-summary-mode)
1965 (error "Couldn't enter %s" dir))))
1967 ;; Group sorting commands
1968 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
1970 (defun gnus-group-sort-groups (func &optional reverse)
1971 "Sort the group buffer according to FUNC.
1972 If REVERSE, reverse the sorting order."
1973 (interactive (list gnus-group-sort-function current-prefix-arg))
1974 (funcall gnus-group-sort-alist-function
1975 (gnus-make-sort-function func) reverse)
1976 (gnus-group-list-groups))
1978 (defun gnus-group-sort-flat (func reverse)
1979 ;; We peel off the dummy group from the alist.
1981 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
1982 (pop gnus-newsrc-alist))
1984 (setq gnus-newsrc-alist
1985 (sort gnus-newsrc-alist func))
1987 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
1988 ;; Regenerate the hash table.
1989 (gnus-make-hashtable-from-newsrc-alist)))
1991 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
1992 "Sort the group buffer alphabetically by group name.
1993 If REVERSE, sort in reverse order."
1995 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
1997 (defun gnus-group-sort-groups-by-unread (&optional reverse)
1998 "Sort the group buffer by number of unread articles.
1999 If REVERSE, sort in reverse order."
2001 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2003 (defun gnus-group-sort-groups-by-level (&optional reverse)
2004 "Sort the group buffer by group level.
2005 If REVERSE, sort in reverse order."
2007 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2009 (defun gnus-group-sort-groups-by-score (&optional reverse)
2010 "Sort the group buffer by group score.
2011 If REVERSE, sort in reverse order."
2013 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2015 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2016 "Sort the group buffer by group rank.
2017 If REVERSE, sort in reverse order."
2019 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2021 (defun gnus-group-sort-groups-by-method (&optional reverse)
2022 "Sort the group buffer alphabetically by backend name.
2023 If REVERSE, sort in reverse order."
2025 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2027 ;;; Selected group sorting.
2029 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2030 "Sort the process/prefixed groups."
2031 (interactive (list current-prefix-arg gnus-group-sort-function))
2032 (let ((groups (gnus-group-process-prefix n)))
2033 (funcall gnus-group-sort-selected-function
2034 groups (gnus-make-sort-function func) reverse)
2035 (gnus-group-list-groups)))
2037 (defun gnus-group-sort-selected-flat (groups func reverse)
2038 (let (entries infos)
2039 ;; First find all the group entries for these groups.
2041 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2043 ;; Then sort the infos.
2047 (lambda (entry) (car entry))
2048 (setq entries (nreverse entries)))
2051 (setq infos (nreverse infos)))
2052 ;; Go through all the infos and replace the old entries
2053 ;; with the new infos.
2055 (setcar entries (pop infos))
2057 ;; Update the hashtable.
2058 (gnus-make-hashtable-from-newsrc-alist)))
2060 (defun gnus-group-sort-selected-groups-by-alphabet (&optional reverse)
2061 "Sort the group buffer alphabetically by group name.
2062 If REVERSE, sort in reverse order."
2064 (gnus-group-sort-selected-groups 'gnus-group-sort-by-alphabet reverse))
2066 (defun gnus-group-sort-selected-groups-by-unread (&optional reverse)
2067 "Sort the group buffer by number of unread articles.
2068 If REVERSE, sort in reverse order."
2070 (gnus-group-sort-selected-groups 'gnus-group-sort-by-unread reverse))
2072 (defun gnus-group-sort-selected-groups-by-level (&optional reverse)
2073 "Sort the group buffer by group level.
2074 If REVERSE, sort in reverse order."
2076 (gnus-group-sort-selected-groups 'gnus-group-sort-by-level reverse))
2078 (defun gnus-group-sort-selected-groups-by-score (&optional reverse)
2079 "Sort the group buffer by group score.
2080 If REVERSE, sort in reverse order."
2082 (gnus-group-sort-selected-groups 'gnus-group-sort-by-score reverse))
2084 (defun gnus-group-sort-selected-groups-by-rank (&optional reverse)
2085 "Sort the group buffer by group rank.
2086 If REVERSE, sort in reverse order."
2088 (gnus-group-sort-selected-groups 'gnus-group-sort-by-rank reverse))
2090 (defun gnus-group-sort-selected-groups-by-method (&optional reverse)
2091 "Sort the group buffer alphabetically by backend name.
2092 If REVERSE, sort in reverse order."
2094 (gnus-group-sort-selected-groups 'gnus-group-sort-by-method reverse))
2096 ;;; Sorting predicates.
2098 (defun gnus-group-sort-by-alphabet (info1 info2)
2099 "Sort alphabetically."
2100 (string< (gnus-info-group info1) (gnus-info-group info2)))
2102 (defun gnus-group-sort-by-real-name (info1 info2)
2103 "Sort alphabetically on real (unprefixed) names."
2104 (string< (gnus-group-real-name (gnus-info-group info1))
2105 (gnus-group-real-name (gnus-info-group info2))))
2107 (defun gnus-group-sort-by-unread (info1 info2)
2108 "Sort by number of unread articles."
2109 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2110 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2111 (< (or (and (numberp n1) n1) 0)
2112 (or (and (numberp n2) n2) 0))))
2114 (defun gnus-group-sort-by-level (info1 info2)
2116 (< (gnus-info-level info1) (gnus-info-level info2)))
2118 (defun gnus-group-sort-by-method (info1 info2)
2119 "Sort alphabetically by backend name."
2120 (string< (symbol-name (car (gnus-find-method-for-group
2121 (gnus-info-group info1) info1)))
2122 (symbol-name (car (gnus-find-method-for-group
2123 (gnus-info-group info2) info2)))))
2125 (defun gnus-group-sort-by-score (info1 info2)
2126 "Sort by group score."
2127 (< (gnus-info-score info1) (gnus-info-score info2)))
2129 (defun gnus-group-sort-by-rank (info1 info2)
2130 "Sort by level and score."
2131 (let ((level1 (gnus-info-level info1))
2132 (level2 (gnus-info-level info2)))
2133 (or (< level1 level2)
2134 (and (= level1 level2)
2135 (> (gnus-info-score info1) (gnus-info-score info2))))))
2139 (defun gnus-group-clear-data (n)
2140 "Clear all marks and read ranges from the current group."
2142 (let ((groups (gnus-group-process-prefix n))
2144 (while (setq group (pop groups))
2145 (gnus-info-clear-data (setq info (gnus-get-info group)))
2146 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2147 (when (gnus-group-goto-group group)
2148 (gnus-group-remove-mark group)
2149 (gnus-group-update-group-line)))))
2151 (defun gnus-group-clear-data-on-native-groups ()
2152 "Clear all marks and read ranges from all native groups."
2154 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2155 (let ((alist (cdr gnus-newsrc-alist))
2157 (while (setq info (pop alist))
2158 (gnus-info-clear-data info))
2159 (gnus-get-unread-articles))))
2161 (defun gnus-info-clear-data (info)
2162 "Clear all marks and read ranges from INFO."
2163 (let ((group (gnus-info-group info)))
2166 (gnus-info-set-marks ,info ,(gnus-info-marks info))
2167 (gnus-info-set-read ,info ,(gnus-info-read info))
2168 (when (gnus-group-goto-group ,group)
2169 (gnus-group-update-group-line))))
2170 (gnus-info-set-read info nil)
2171 (when (gnus-info-marks info)
2172 (gnus-info-set-marks info nil))))
2174 ;; Group catching up.
2176 (defun gnus-group-catchup-current (&optional n all)
2177 "Mark all articles not marked as unread in current newsgroup as read.
2178 If prefix argument N is numeric, the ARG next newsgroups will be
2179 caught up. If ALL is non-nil, marked articles will also be marked as
2180 read. Cross references (Xref: header) of articles are ignored.
2181 The difference between N and actual number of newsgroups that were
2182 caught up is returned."
2184 (unless (gnus-group-group-name)
2185 (error "No group on the current line"))
2186 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
2190 "Do you really want to mark all articles as read? "
2191 "Mark all unread articles as read? "))))
2193 (let ((groups (gnus-group-process-prefix n))
2196 ;; Virtual groups have to be given special treatment.
2197 (let ((method (gnus-find-method-for-group (car groups))))
2198 (if (eq 'nnvirtual (car method))
2199 (nnvirtual-catchup-group
2200 (gnus-group-real-name (car groups)) (nth 1 method) all)))
2201 (gnus-group-remove-mark (car groups))
2202 (if (>= (gnus-group-group-level) gnus-level-zombie)
2203 (gnus-message 2 "Dead groups can't be caught up")
2205 (gnus-group-goto-group (car groups))
2206 (gnus-group-catchup (car groups) all))
2207 (gnus-group-update-group-line)
2208 (setq ret (1+ ret))))
2209 (setq groups (cdr groups)))
2210 (gnus-group-next-unread-group 1)
2213 (defun gnus-group-catchup-current-all (&optional n)
2214 "Mark all articles in current newsgroup as read.
2215 Cross references (Xref: header) of articles are ignored."
2217 (gnus-group-catchup-current n 'all))
2219 (defun gnus-group-catchup (group &optional all)
2220 "Mark all articles in GROUP as read.
2221 If ALL is non-nil, all articles are marked as read.
2222 The return value is the number of articles that were marked as read,
2223 or nil if no action could be taken."
2224 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2226 ;; Do the updating only if the newsgroup isn't killed.
2227 (if (not (numberp (car entry)))
2228 (gnus-message 1 "Can't catch up; non-active group")
2229 ;; Do auto-expirable marks if that's required.
2230 (when (gnus-group-auto-expirable-p group)
2231 (gnus-add-marked-articles
2232 group 'expire (gnus-list-of-unread-articles group))
2234 (let ((marks (nth 3 (nth 2 entry))))
2235 (gnus-add-marked-articles
2236 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2237 (gnus-add-marked-articles
2238 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2240 (gnus-update-read-articles group nil)
2241 ;; Also nix out the lists of marks and dormants.
2243 (gnus-add-marked-articles group 'tick nil nil 'force)
2244 (gnus-add-marked-articles group 'dormant nil nil 'force))
2245 (run-hooks 'gnus-group-catchup-group-hook)
2248 (defun gnus-group-expire-articles (&optional n)
2249 "Expire all expirable articles in the current newsgroup."
2251 (let ((groups (gnus-group-process-prefix n))
2254 (error "No groups to expire"))
2255 (while (setq group (pop groups))
2256 (gnus-group-remove-mark group)
2257 (when (gnus-check-backend-function 'request-expire-articles group)
2258 (gnus-message 6 "Expiring articles in %s..." group)
2259 (let* ((info (gnus-get-info group))
2260 (expirable (if (gnus-group-total-expirable-p group)
2261 (cons nil (gnus-list-of-read-articles group))
2262 (assq 'expire (gnus-info-marks info))))
2263 (expiry-wait (gnus-group-find-parameter group 'expiry-wait)))
2267 (gnus-compress-sequence
2269 ;; We set the expiry variables to the group
2271 (let ((nnmail-expiry-wait-function nil)
2272 (nnmail-expiry-wait expiry-wait))
2273 (gnus-request-expire-articles
2274 (gnus-uncompress-sequence (cdr expirable)) group))
2275 ;; Just expire using the normal expiry values.
2276 (gnus-request-expire-articles
2277 (gnus-uncompress-sequence (cdr expirable)) group))))
2278 (gnus-close-group group))
2279 (gnus-message 6 "Expiring articles in %s...done" group)))
2280 (gnus-group-position-point))))
2282 (defun gnus-group-expire-all-groups ()
2283 "Expire all expirable articles in all newsgroups."
2286 (gnus-message 5 "Expiring...")
2287 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2288 (cdr gnus-newsrc-alist))))
2289 (gnus-group-expire-articles nil)))
2290 (gnus-group-position-point)
2291 (gnus-message 5 "Expiring...done"))
2293 (defun gnus-group-set-current-level (n level)
2294 "Set the level of the next N groups to LEVEL."
2299 (let ((s (read-string
2300 (format "Level (default %s): "
2301 (or (gnus-group-group-level)
2302 gnus-level-default-subscribed)))))
2303 (if (string-match "^\\s-*$" s)
2304 (int-to-string (or (gnus-group-group-level)
2305 gnus-level-default-subscribed))
2307 (or (and (>= level 1) (<= level gnus-level-killed))
2308 (error "Illegal level: %d" level))
2309 (let ((groups (gnus-group-process-prefix n))
2311 (while (setq group (pop groups))
2312 (gnus-group-remove-mark group)
2313 (gnus-message 6 "Changed level of %s from %d to %d"
2314 group (or (gnus-group-group-level) gnus-level-killed)
2316 (gnus-group-change-level
2317 group level (or (gnus-group-group-level) gnus-level-killed))
2318 (gnus-group-update-group-line)))
2319 (gnus-group-position-point))
2321 (defun gnus-group-unsubscribe-current-group (&optional n)
2322 "Toggle subscription of the current group.
2323 If given numerical prefix, toggle the N next groups."
2325 (let ((groups (gnus-group-process-prefix n))
2328 (setq group (car groups)
2329 groups (cdr groups))
2330 (gnus-group-remove-mark group)
2331 (gnus-group-unsubscribe-group
2332 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
2333 gnus-level-default-unsubscribed
2334 gnus-level-default-subscribed) t)
2335 (gnus-group-update-group-line))
2336 (gnus-group-next-group 1)))
2338 (defun gnus-group-unsubscribe-group (group &optional level silent)
2339 "Toggle subscription to GROUP.
2340 Killed newsgroups are subscribed. If SILENT, don't try to update the
2343 (list (completing-read
2344 "Group: " gnus-active-hashtb nil
2345 (gnus-read-active-file-p)
2347 'gnus-group-history)))
2348 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2350 ((string-match "^[ \t]$" group)
2351 (error "Empty group name"))
2353 ;; Toggle subscription flag.
2354 (gnus-group-change-level
2355 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
2356 gnus-level-subscribed)
2357 (1+ gnus-level-subscribed)
2358 gnus-level-default-subscribed)))
2360 (gnus-group-update-group group)))
2361 ((and (stringp group)
2362 (or (not (gnus-read-active-file-p))
2363 (gnus-active group)))
2364 ;; Add new newsgroup.
2365 (gnus-group-change-level
2367 (if level level gnus-level-default-subscribed)
2368 (or (and (member group gnus-zombie-list)
2371 (and (gnus-group-group-name)
2372 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2374 (gnus-group-update-group group)))
2375 (t (error "No such newsgroup: %s" group)))
2376 (gnus-group-position-point)))
2378 (defun gnus-group-transpose-groups (n)
2379 "Move the current newsgroup up N places.
2380 If given a negative prefix, move down instead. The difference between
2381 N and the number of steps taken is returned."
2383 (or (gnus-group-group-name)
2384 (error "No group on current line"))
2385 (gnus-group-kill-group 1)
2387 (forward-line (- n))
2388 (gnus-group-yank-group)
2389 (gnus-group-position-point)))
2391 (defun gnus-group-kill-all-zombies ()
2392 "Kill all zombie newsgroups."
2394 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2395 (setq gnus-zombie-list nil)
2396 (gnus-group-list-groups))
2398 (defun gnus-group-kill-region (begin end)
2399 "Kill newsgroups in current region (excluding current point).
2400 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2415 (beginning-of-line) ;Important when LINES < 1
2416 (gnus-group-kill-group lines)))
2418 (defun gnus-group-kill-group (&optional n discard)
2419 "Kill the next N groups.
2420 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2421 However, only groups that were alive can be yanked; already killed
2422 groups or zombie groups can't be yanked.
2423 The return value is the name of the group that was killed, or a list
2426 (let ((buffer-read-only nil)
2427 (groups (gnus-group-process-prefix n))
2428 group entry level out)
2429 (if (< (length groups) 10)
2430 ;; This is faster when there are few groups.
2432 (push (setq group (pop groups)) out)
2433 (gnus-group-remove-mark group)
2434 (setq level (gnus-group-group-level))
2436 (when (and (not discard)
2437 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2440 (gnus-group-goto-group ,(gnus-group-group-name))
2441 (gnus-group-yank-group)))
2442 (push (cons (car entry) (nth 2 entry))
2443 gnus-list-of-killed-groups))
2444 (gnus-group-change-level
2445 (if entry entry group) gnus-level-killed (if entry nil level)))
2446 ;; If there are lots and lots of groups to be killed, we use
2447 ;; this thing instead.
2449 (setq groups (nreverse groups))
2451 (gnus-group-remove-mark (setq group (pop groups)))
2453 (push group gnus-killed-list)
2454 (setq gnus-newsrc-alist
2455 (delq (assoc group gnus-newsrc-alist)
2457 (when gnus-group-change-level-function
2458 (funcall gnus-group-change-level-function group 9 3))
2460 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2461 (push (cons (car entry) (nth 2 entry))
2462 gnus-list-of-killed-groups)
2463 (setcdr (cdr entry) (cdddr entry)))
2464 ((member group gnus-zombie-list)
2465 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
2466 (gnus-make-hashtable-from-newsrc-alist)))
2468 (gnus-group-position-point)
2469 (if (< (length out) 2) (car out) (nreverse out))))
2471 (defun gnus-group-yank-group (&optional arg)
2472 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
2473 inserting it before the current newsgroup. The numeric ARG specifies
2474 how many newsgroups are to be yanked. The name of the newsgroup yanked
2475 is returned, or (if several groups are yanked) a list of yanked groups
2478 (setq arg (or arg 1))
2479 (let (info group prev out)
2480 (while (>= (decf arg) 0)
2481 (if (not (setq info (pop gnus-list-of-killed-groups)))
2482 (error "No more newsgroups to yank"))
2483 (push (setq group (nth 1 info)) out)
2484 ;; Find which newsgroup to insert this one before - search
2485 ;; backward until something suitable is found. If there are no
2486 ;; other newsgroups in this buffer, just make this newsgroup the
2488 (setq prev (gnus-group-group-name))
2489 (gnus-group-change-level
2490 info (gnus-info-level (cdr info)) gnus-level-killed
2491 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
2493 (gnus-group-insert-group-line-info group)
2495 `(when (gnus-group-goto-group ,group)
2496 (gnus-group-kill-group 1))))
2498 (gnus-group-position-point)
2499 (if (< (length out) 2) (car out) (nreverse out))))
2501 (defun gnus-group-kill-level (level)
2502 "Kill all groups that is on a certain LEVEL."
2503 (interactive "nKill all groups on level: ")
2505 ((= level gnus-level-zombie)
2506 (setq gnus-killed-list
2507 (nconc gnus-zombie-list gnus-killed-list))
2508 (setq gnus-zombie-list nil))
2509 ((and (< level gnus-level-zombie)
2511 (or gnus-expert-user
2514 "Do you really want to kill all groups on level %d? "
2516 (let* ((prev gnus-newsrc-alist)
2519 (if (= (gnus-info-level (car alist)) level)
2521 (push (gnus-info-group (car alist)) gnus-killed-list)
2522 (setcdr prev (cdr alist)))
2524 (setq alist (cdr alist)))
2525 (gnus-make-hashtable-from-newsrc-alist)
2526 (gnus-group-list-groups)))
2528 (error "Can't kill; illegal level: %d" level))))
2530 (defun gnus-group-list-all-groups (&optional arg)
2531 "List all newsgroups with level ARG or lower.
2532 Default is gnus-level-unsubscribed, which lists all subscribed and most
2533 unsubscribed groups."
2535 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
2537 ;; Redefine this to list ALL killed groups if prefix arg used.
2538 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
2539 (defun gnus-group-list-killed (&optional arg)
2540 "List all killed newsgroups in the group buffer.
2541 If ARG is non-nil, list ALL killed groups known to Gnus. This may
2542 entail asking the server for the groups."
2544 ;; Find all possible killed newsgroups if arg.
2546 (gnus-get-killed-groups))
2547 (if (not gnus-killed-list)
2548 (gnus-message 6 "No killed groups")
2549 (let (gnus-group-list-mode)
2550 (funcall gnus-group-prepare-function
2551 gnus-level-killed t gnus-level-killed))
2552 (goto-char (point-min)))
2553 (gnus-group-position-point))
2555 (defun gnus-group-list-zombies ()
2556 "List all zombie newsgroups in the group buffer."
2558 (if (not gnus-zombie-list)
2559 (gnus-message 6 "No zombie groups")
2560 (let (gnus-group-list-mode)
2561 (funcall gnus-group-prepare-function
2562 gnus-level-zombie t gnus-level-zombie))
2563 (goto-char (point-min)))
2564 (gnus-group-position-point))
2566 (defun gnus-group-list-active ()
2567 "List all groups that are available from the server(s)."
2569 ;; First we make sure that we have really read the active file.
2570 (unless (gnus-read-active-file-p)
2571 (let ((gnus-read-active-file t))
2572 (gnus-read-active-file)))
2573 ;; Find all groups and sort them.
2581 (setq list (cons (symbol-name sym) list))))
2585 (buffer-read-only nil))
2588 (gnus-group-insert-group-line-info (pop groups)))
2589 (goto-char (point-min))))
2591 (defun gnus-activate-all-groups (level)
2592 "Activate absolutely all groups."
2593 (interactive (list 7))
2594 (let ((gnus-activate-level level)
2595 (gnus-activate-foreign-newsgroups level))
2596 (gnus-group-get-new-news)))
2598 (defun gnus-group-get-new-news (&optional arg)
2599 "Get newly arrived articles.
2600 If ARG is a number, it specifies which levels you are interested in
2601 re-scanning. If ARG is non-nil and not a number, this will force
2602 \"hard\" re-reading of the active files from all servers."
2604 (run-hooks 'gnus-get-new-news-hook)
2606 ;; Read any slave files.
2608 (gnus-master-read-slave-newsrc))
2610 ;; We might read in new NoCeM messages here.
2611 (when (and gnus-use-nocem
2613 (gnus-nocem-scan-groups))
2614 ;; If ARG is not a number, then we read the active file.
2615 (when (and arg (not (numberp arg)))
2616 (let ((gnus-read-active-file t))
2617 (gnus-read-active-file))
2620 (setq arg (gnus-group-default-level arg t))
2621 (if (and gnus-read-active-file (not arg))
2623 (gnus-read-active-file)
2624 (gnus-get-unread-articles arg))
2625 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
2626 (gnus-get-unread-articles arg)))
2627 (run-hooks 'gnus-after-getting-new-news-hook)
2628 (gnus-group-list-groups))
2630 (defun gnus-group-get-new-news-this-group (&optional n)
2631 "Check for newly arrived news in the current group (and the N-1 next groups).
2632 The difference between N and the number of newsgroup checked is returned.
2633 If N is negative, this group and the N-1 previous groups will be checked."
2635 (let* ((groups (gnus-group-process-prefix n))
2636 (ret (if (numberp n) (- n (length groups)) 0))
2637 (beg (unless n (point)))
2639 (while (setq group (pop groups))
2640 (gnus-group-remove-mark group)
2641 ;; Bypass any previous denials from the server.
2642 (gnus-remove-denial (gnus-find-method-for-group group))
2643 (if (gnus-activate-group group 'scan)
2645 (gnus-get-unread-articles-in-group
2646 (gnus-get-info group) (gnus-active group) t)
2647 (unless (gnus-virtual-group-p group)
2648 (gnus-close-group group))
2649 (gnus-group-update-group group))
2650 (if (eq (gnus-server-status (gnus-find-method-for-group group))
2652 (gnus-error 3 "Server denied access")
2653 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
2654 (when beg (goto-char beg))
2655 (when gnus-goto-next-group-when-activating
2656 (gnus-group-next-unread-group 1 t))
2657 (gnus-summary-position-point)
2660 (defun gnus-group-fetch-faq (group &optional faq-dir)
2661 "Fetch the FAQ for the current group.
2662 If given a prefix argument, prompt for the FAQ dir
2666 (gnus-group-group-name)
2667 (cond (current-prefix-arg
2669 "Faq dir: " (and (listp gnus-group-faq-directory)
2670 (mapcar (lambda (file) (list file))
2671 gnus-group-faq-directory)))))))
2673 (error "No group name given"))
2674 (let ((dirs (or faq-dir gnus-group-faq-directory))
2676 (unless (listp dirs)
2677 (setq dirs (list dirs)))
2678 (while (and (not found)
2679 (setq dir (pop dirs)))
2680 (setq file (concat (file-name-as-directory dir)
2681 (gnus-group-real-name group)))
2682 (if (not (file-exists-p file))
2683 (gnus-message 1 "No such file: %s" file)
2687 (defun gnus-group-describe-group (force &optional group)
2688 "Display a description of the current newsgroup."
2689 (interactive (list current-prefix-arg (gnus-group-group-name)))
2690 (let* ((method (gnus-find-method-for-group group))
2691 (mname (gnus-group-prefixed-name "" method))
2694 gnus-description-hashtb)
2695 (gnus-sethash mname nil gnus-description-hashtb))
2696 (or group (error "No group name given"))
2697 (and (or (and gnus-description-hashtb
2698 ;; We check whether this group's method has been
2699 ;; queried for a description file.
2700 (gnus-gethash mname gnus-description-hashtb))
2701 (setq desc (gnus-group-get-description group))
2702 (gnus-read-descriptions-file method))
2704 (or desc (gnus-gethash group gnus-description-hashtb)
2705 "No description available")))))
2707 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
2708 (defun gnus-group-describe-all-groups (&optional force)
2709 "Pop up a buffer with descriptions of all newsgroups."
2711 (and force (setq gnus-description-hashtb nil))
2712 (if (not (or gnus-description-hashtb
2713 (gnus-read-all-descriptions-files)))
2714 (error "Couldn't request descriptions file"))
2715 (let ((buffer-read-only nil)
2721 (insert (format " *: %-20s %s\n" (symbol-name group)
2722 (symbol-value group)))
2723 (gnus-add-text-properties
2724 b (1+ b) (list 'gnus-group group
2725 'gnus-unread t 'gnus-marked nil
2726 'gnus-level (1+ gnus-level-subscribed))))
2727 gnus-description-hashtb)
2728 (goto-char (point-min))
2729 (gnus-group-position-point)))
2731 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
2732 (defun gnus-group-apropos (regexp &optional search-description)
2733 "List all newsgroups that have names that match a regexp."
2734 (interactive "sGnus apropos (regexp): ")
2736 (obuf (current-buffer))
2738 ;; Go through all newsgroups that are known to Gnus.
2741 (and (symbol-name group)
2742 (string-match regexp (symbol-name group))
2743 (setq groups (cons (symbol-name group) groups))))
2745 ;; Also go through all descriptions that are known to Gnus.
2746 (when search-description
2749 (and (string-match regexp (symbol-value group))
2750 (gnus-active (symbol-name group))
2751 (setq groups (cons (symbol-name group) groups))))
2752 gnus-description-hashtb))
2754 (gnus-message 3 "No groups matched \"%s\"." regexp)
2755 ;; Print out all the groups.
2757 (pop-to-buffer "*Gnus Help*")
2758 (buffer-disable-undo (current-buffer))
2760 (setq groups (sort groups 'string<))
2762 ;; Groups may be entered twice into the list of groups.
2763 (if (not (string= (car groups) prev))
2765 (insert (setq prev (car groups)) "\n")
2766 (if (and gnus-description-hashtb
2767 (setq des (gnus-gethash (car groups)
2768 gnus-description-hashtb)))
2769 (insert " " des "\n"))))
2770 (setq groups (cdr groups)))
2771 (goto-char (point-min))))
2772 (pop-to-buffer obuf)))
2774 (defun gnus-group-description-apropos (regexp)
2775 "List all newsgroups that have names or descriptions that match a regexp."
2776 (interactive "sGnus description apropos (regexp): ")
2777 (if (not (or gnus-description-hashtb
2778 (gnus-read-all-descriptions-files)))
2779 (error "Couldn't request descriptions file"))
2780 (gnus-group-apropos regexp t))
2782 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
2783 (defun gnus-group-list-matching (level regexp &optional all lowest)
2784 "List all groups with unread articles that match REGEXP.
2785 If the prefix LEVEL is non-nil, it should be a number that says which
2786 level to cut off listing groups.
2787 If ALL, also list groups with no unread articles.
2788 If LOWEST, don't list groups with level lower than LOWEST.
2790 This command may read the active file."
2791 (interactive "P\nsList newsgroups matching: ")
2792 ;; First make sure active file has been read.
2794 (> (prefix-numeric-value level) gnus-level-killed))
2795 (gnus-get-killed-groups))
2796 (gnus-group-prepare-flat (or level gnus-level-subscribed)
2797 all (or lowest 1) regexp)
2798 (goto-char (point-min))
2799 (gnus-group-position-point))
2801 (defun gnus-group-list-all-matching (level regexp &optional lowest)
2802 "List all groups that match REGEXP.
2803 If the prefix LEVEL is non-nil, it should be a number that says which
2804 level to cut off listing groups.
2805 If LOWEST, don't list groups with level lower than LOWEST."
2806 (interactive "P\nsList newsgroups matching: ")
2807 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
2809 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
2810 (defun gnus-group-save-newsrc (&optional force)
2811 "Save the Gnus startup files.
2812 If FORCE, force saving whether it is necessary or not."
2814 (gnus-save-newsrc-file force))
2816 (defun gnus-group-restart (&optional arg)
2817 "Force Gnus to read the .newsrc file."
2819 (when (gnus-yes-or-no-p
2820 (format "Are you sure you want to restart Gnus? "))
2821 (gnus-save-newsrc-file)
2822 (gnus-setup-news 'force)
2823 (gnus-group-list-groups arg)))
2825 (defun gnus-group-read-init-file ()
2826 "Read the Gnus elisp init file."
2828 (gnus-read-init-file))
2830 (defun gnus-group-check-bogus-groups (&optional silent)
2831 "Check bogus newsgroups.
2832 If given a prefix, don't ask for confirmation before removing a bogus
2835 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
2836 (gnus-group-list-groups))
2838 (defun gnus-group-edit-global-kill (&optional article group)
2839 "Edit the global kill file.
2840 If GROUP, edit that local kill file instead."
2842 (setq gnus-current-kill-article article)
2843 (gnus-kill-file-edit-file group)
2846 (substitute-command-keys
2847 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
2848 (if group "local" "global")))))
2850 (defun gnus-group-edit-local-kill (article group)
2851 "Edit a local kill file."
2852 (interactive (list nil (gnus-group-group-name)))
2853 (gnus-group-edit-global-kill article group))
2855 (defun gnus-group-force-update ()
2856 "Update `.newsrc' file."
2858 (gnus-save-newsrc-file))
2860 (defun gnus-group-suspend ()
2861 "Suspend the current Gnus session.
2862 In fact, cleanup buffers except for group mode buffer.
2863 The hook gnus-suspend-gnus-hook is called before actually suspending."
2865 (run-hooks 'gnus-suspend-gnus-hook)
2866 ;; Kill Gnus buffers except for group mode buffer.
2867 (let* ((group-buf (get-buffer gnus-group-buffer))
2868 ;; Do this on a separate list in case the user does a ^G before we finish
2870 (delete group-buf (delete gnus-dribble-buffer
2871 (append gnus-buffer-list nil)))))
2872 (while gnus-buffer-list
2873 (gnus-kill-buffer (pop gnus-buffer-list)))
2874 (gnus-kill-gnus-frames)
2876 (setq gnus-buffer-list (list group-buf))
2877 (bury-buffer group-buf)
2878 (delete-windows-on group-buf t))))
2880 (defun gnus-group-clear-dribble ()
2881 "Clear all information from the dribble buffer."
2883 (gnus-dribble-clear)
2884 (gnus-message 7 "Cleared dribble buffer"))
2886 (defun gnus-group-exit ()
2887 "Quit reading news after updating .newsrc.eld and .newsrc.
2888 The hook `gnus-exit-gnus-hook' is called before actually exiting."
2891 (or noninteractive ;For gnus-batch-kill
2892 (not gnus-interactive-exit) ;Without confirmation
2894 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
2895 (run-hooks 'gnus-exit-gnus-hook)
2896 ;; Offer to save data from non-quitted summary buffers.
2897 (gnus-offer-save-summaries)
2898 ;; Save the newsrc file(s).
2899 (gnus-save-newsrc-file)
2901 (gnus-close-backends)
2902 ;; Reset everything.
2904 ;; Allow the user to do things after cleaning up.
2905 (run-hooks 'gnus-after-exiting-gnus-hook)))
2907 (defun gnus-group-quit ()
2908 "Quit reading news without updating .newsrc.eld or .newsrc.
2909 The hook `gnus-exit-gnus-hook' is called before actually exiting."
2911 (when (or noninteractive ;For gnus-batch-kill
2912 (zerop (buffer-size))
2913 (not (gnus-server-opened gnus-select-method))
2915 (not gnus-current-startup-file)
2917 (format "Quit reading news without saving %s? "
2918 (file-name-nondirectory gnus-current-startup-file))))
2919 (run-hooks 'gnus-exit-gnus-hook)
2920 (gnus-configure-windows 'group t)
2922 (gnus-close-backends)
2924 (gnus-kill-buffer gnus-group-buffer)
2925 ;; Allow the user to do things after cleaning up.
2926 (run-hooks 'gnus-after-exiting-gnus-hook)))
2928 (defun gnus-group-describe-briefly ()
2929 "Give a one line description of the group mode commands."
2931 (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")))
2933 (defun gnus-group-browse-foreign-server (method)
2934 "Browse a foreign news server.
2935 If called interactively, this function will ask for a select method
2936 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
2937 If not, METHOD should be a list where the first element is the method
2938 and the second element is the address."
2940 (list (let ((how (completing-read
2942 (append gnus-valid-select-methods gnus-server-alist)
2943 nil t (cons "nntp" 0) 'gnus-method-history)))
2944 ;; We either got a backend name or a virtual server name.
2945 ;; If the first, we also need an address.
2946 (if (assoc how gnus-valid-select-methods)
2948 ;; Suggested by mapjph@bath.ac.uk.
2951 (mapcar (lambda (server) (list server))
2952 gnus-secondary-servers)))
2953 ;; We got a server name, so we find the method.
2954 (gnus-server-to-method how)))))
2955 (gnus-browse-foreign-server method))
2957 (defun gnus-group-set-info (info &optional method-only-group part)
2958 (let* ((entry (gnus-gethash
2959 (or method-only-group (gnus-info-group info))
2960 gnus-newsrc-hashtb))
2962 (info (if method-only-group (nth 2 entry) info))
2964 (when method-only-group
2966 (error "Trying to change non-existent group %s" method-only-group))
2967 ;; We have received parts of the actual group info - either the
2968 ;; select method or the group parameters. We first check
2969 ;; whether we have to extend the info, and if so, do that.
2970 (let ((len (length info))
2971 (total (if (eq part 'method) 5 6)))
2973 (setcdr (nthcdr (1- len) info)
2974 (make-list (- total len) nil)))
2975 ;; Then we enter the new info.
2976 (setcar (nthcdr (1- total) info) part-info)))
2978 ;; This is a new group, so we just create it.
2980 (set-buffer gnus-group-buffer)
2981 (setq method (gnus-info-method info))
2982 (when (gnus-server-equal method "native")
2985 (set-buffer gnus-group-buffer)
2987 ;; It's a foreign group...
2988 (gnus-group-make-group
2989 (gnus-group-real-name (gnus-info-group info))
2990 (if (stringp method) method
2991 (prin1-to-string (car method)))
2993 (nth 1 (gnus-info-method info))))
2994 ;; It's a native group.
2995 (gnus-group-make-group (gnus-info-group info))))
2996 (gnus-message 6 "Note: New group created")
2998 (gnus-gethash (gnus-group-prefixed-name
2999 (gnus-group-real-name (gnus-info-group info))
3000 (or (gnus-info-method info) gnus-select-method))
3001 gnus-newsrc-hashtb))))
3002 ;; Whether it was a new group or not, we now have the entry, so we
3003 ;; can do the update.
3006 (setcar (nthcdr 2 entry) info)
3007 (when (and (not (eq (car entry) t))
3008 (gnus-active (gnus-info-group info)))
3009 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3010 (error "No such group: %s" (gnus-info-group info)))))
3012 (defun gnus-group-set-method-info (group select-method)
3013 (gnus-group-set-info select-method group 'method))
3015 (defun gnus-group-set-params-info (group params)
3016 (gnus-group-set-info params group 'params))
3018 (defun gnus-add-marked-articles (group type articles &optional info force)
3019 ;; Add ARTICLES of TYPE to the info of GROUP.
3020 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3021 ;; add, but replace marked articles of TYPE with ARTICLES.
3022 (let ((info (or info (gnus-get-info group)))
3023 (uncompressed '(score bookmark killed))
3026 (and (not (setq marked (nthcdr 3 info)))
3028 (setcdr (nthcdr 2 info)
3029 (list (list (cons type (gnus-compress-sequence
3031 (and (not (setq m (assq type (car marked))))
3034 (cons (cons type (gnus-compress-sequence articles t) )
3038 (setcar (nthcdr 3 info)
3039 (delq (assq type (car marked)) (car marked)))
3040 (setcdr m (gnus-compress-sequence articles t)))
3041 (setcdr m (gnus-compress-sequence
3042 (sort (nconc (gnus-uncompress-range (cdr m))
3043 (copy-sequence articles)) '<) t))))))
3045 (provide 'gnus-group)
3047 ;;; gnus-group.el ends here