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 %m Whether there is new(ish) mail in the group (char, \"%\")
121 %l Whether there are GroupLens predictions for this group (string)
122 %n Select from where (string)
123 %z A string that look like `<%s:%n>' if a foreign select method is used
124 %u User defined specifier. The next character in the format string should
125 be a letter. Gnus will call the function gnus-user-format-function-X,
126 where X is the letter following %u. The function will be passed the
127 current header as argument. The function should return a string, which
128 will be inserted into the buffer just like information from any other
131 Text between %( and %) will be highlighted with `gnus-mouse-face' when
132 the mouse point move inside the area. There can only be one such area.
134 Note that this format specification is not always respected. For
135 reasons of efficiency, when listing killed groups, this specification
136 is ignored altogether. If the spec is changed considerably, your
137 output may end up looking strange when listing both alive and killed
140 If you use %o or %O, reading the active file will be slower and quite
141 a bit of extra memory will be used. %D will also worsen performance.
142 Also note that if you change the format specification to include any
143 of these specs, you must probably re-start Gnus to see them go into
146 (defvar gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
147 "*The format specification for the group mode line.
148 It works along the same lines as a normal formatting string,
149 with some simple extensions:
151 %S The native news server.
152 %M The native select method.
153 %: \":\" if %S isn't \"\".")
155 (defvar gnus-group-mode-hook nil
156 "*A hook for Gnus group mode.")
158 (defvar gnus-group-menu-hook nil
159 "*Hook run after the creation of the group mode menu.")
161 (defvar gnus-group-catchup-group-hook nil
162 "*A hook run when catching up a group from the group buffer.")
164 (defvar gnus-group-update-group-hook nil
165 "*A hook called when updating group lines.")
167 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
168 "*A function that is called to generate the group buffer.
169 The function is called with three arguments: The first is a number;
170 all group with a level less or equal to that number should be listed,
171 if the second is non-nil, empty groups should also be displayed. If
172 the third is non-nil, it is a number. No groups with a level lower
173 than this number should be displayed.
175 The only current function implemented is `gnus-group-prepare-flat'.")
177 (defvar gnus-group-prepare-hook nil
178 "*A hook called after the group buffer has been generated.
179 If you want to modify the group buffer, you can use this hook.")
181 (defvar gnus-suspend-gnus-hook nil
182 "*A hook called when suspending (not exiting) Gnus.")
184 (defvar gnus-exit-gnus-hook nil
185 "*A hook called when exiting Gnus.")
187 (defvar gnus-after-exiting-gnus-hook nil
188 "*A hook called after exiting Gnus.")
190 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
191 "*A hook called when a group line is changed.
192 The hook will not be called if `gnus-visual' is nil.
194 The default function `gnus-group-highlight-line' will
195 highlight the line according to the `gnus-group-highlight'
198 (defvar gnus-useful-groups
199 `(("(ding) mailing list mirrored at sunsite.auc.dk"
201 (nntp "sunsite.auc.dk"
202 (nntp-address "sunsite.auc.dk")))
206 (nndoc-article-type mbox)
207 (eval `(nndoc-address
208 ,(let ((file (nnheader-find-etc-directory
211 (error "Couldn't find doc group"))
213 "Alist of useful group-server pairs.")
215 (defvar gnus-group-highlight
217 ((not (eq gnus-display-type 'color))
219 ((= unread 0) . italic)))
220 ((eq gnus-background-mode 'dark)
221 `(((and (not mailp) (eq level 1)) .
222 ,(custom-face-lookup "PaleTurquoise" nil nil t))
223 ((and (not mailp) (eq level 2)) .
224 ,(custom-face-lookup "turquoise" nil nil t))
225 ((and (not mailp) (eq level 3)) .
226 ,(custom-face-lookup "MediumTurquoise" nil nil t))
227 ((and (not mailp) (>= level 4)) .
228 ,(custom-face-lookup "DarkTurquoise" nil nil t))
229 ((and mailp (eq level 1)) .
230 ,(custom-face-lookup "aquamarine1" nil nil t))
231 ((and mailp (eq level 2)) .
232 ,(custom-face-lookup "aquamarine2" nil nil t))
233 ((and mailp (eq level 3)) .
234 ,(custom-face-lookup "aquamarine3" nil nil t))
235 ((and mailp (>= level 4)) .
236 ,(custom-face-lookup "aquamarine4" nil nil t))
239 `(((and (not mailp) (<= level 3)) .
240 ,(custom-face-lookup "ForestGreen" nil nil t))
241 ((and (not mailp) (eq level 4)) .
242 ,(custom-face-lookup "DarkGreen" nil nil t))
243 ((and (not mailp) (eq level 5)) .
244 ,(custom-face-lookup "CadetBlue4" nil nil t))
245 ((and mailp (eq level 1)) .
246 ,(custom-face-lookup "DeepPink3" nil nil t))
247 ((and mailp (eq level 2)) .
248 ,(custom-face-lookup "HotPink3" nil nil t))
249 ((and mailp (eq level 3)) .
250 ,(custom-face-lookup "dark magenta" nil nil t))
251 ((and mailp (eq level 4)) .
252 ,(custom-face-lookup "DeepPink4" nil nil t))
253 ((and mailp (> level 4)) .
254 ,(custom-face-lookup "DarkOrchid4" nil nil t))
256 "Controls the highlighting of group buffer lines.
258 Below is a list of `Form'/`Face' pairs. When deciding how a a
259 particular group line should be displayed, each form is
260 evaluated. The content of the face field after the first true form is
261 used. You can change how those group lines are displayed by
262 editing the face field.
264 It is also possible to change and add form fields, but currently that
265 requires an understanding of Lisp expressions. Hopefully this will
266 change in a future release. For now, you can use the following
267 variables in the Lisp expression:
269 group: The name of the group.
270 unread: The number of unread articles in the group.
271 method: The select method used.
272 mailp: Whether it's a mail group or not.
273 level: The level of the group.
274 score: The score of the group.
275 ticked: The number of ticked articles.")
277 (defvar gnus-new-mail-mark ?%
278 "Mark used for groups with new mail.")
280 ;;; Internal variables
282 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
283 "Function for sorting the group buffer.")
285 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
286 "Function for sorting the selected groups in the group buffer.")
288 (defvar gnus-group-indentation-function nil)
289 (defvar gnus-goto-missing-group-function nil)
290 (defvar gnus-group-update-group-function nil)
291 (defvar gnus-group-goto-next-group-function nil
292 "Function to override finding the next group after listing groups.")
294 (defvar gnus-group-edit-buffer nil)
296 (defvar gnus-group-line-format-alist
297 `((?M gnus-tmp-marked-mark ?c)
298 (?S gnus-tmp-subscribed ?c)
299 (?L gnus-tmp-level ?d)
300 (?N (cond ((eq number t) "*" )
304 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
305 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
307 (?R gnus-tmp-number-of-read ?s)
308 (?t gnus-tmp-number-total ?d)
309 (?y gnus-tmp-number-of-unread ?s)
310 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
311 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
312 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
313 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
314 (?g gnus-tmp-group ?s)
315 (?G gnus-tmp-qualified-group ?s)
316 (?c (gnus-short-group-name gnus-tmp-group) ?s)
317 (?D gnus-tmp-newsgroup-description ?s)
318 (?o gnus-tmp-moderated ?c)
319 (?O gnus-tmp-moderated-string ?s)
320 (?p gnus-tmp-process-marked ?c)
321 (?s gnus-tmp-news-server ?s)
322 (?n gnus-tmp-news-method ?s)
323 (?P gnus-group-indentation ?s)
324 (?l gnus-tmp-grouplens ?s)
325 (?z gnus-tmp-news-method-string ?s)
326 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
327 (?u gnus-tmp-user-defined ?s)))
329 (defvar gnus-group-mode-line-format-alist
330 `((?S gnus-tmp-news-server ?s)
331 (?M gnus-tmp-news-method ?s)
332 (?u gnus-tmp-user-defined ?s)
333 (?: gnus-tmp-colon ?s)))
335 (defvar gnus-topic-topology nil
336 "The complete topic hierarchy.")
338 (defvar gnus-topic-alist nil
339 "The complete topic-group alist.")
341 (defvar gnus-group-marked nil)
343 (defvar gnus-group-list-mode nil)
349 (put 'gnus-group-mode 'mode-class 'special)
352 (gnus-define-keys gnus-group-mode-map
353 " " gnus-group-read-group
354 "=" gnus-group-select-group
355 "\r" gnus-group-select-group
356 "\M-\r" gnus-group-quick-select-group
357 "j" gnus-group-jump-to-group
358 "n" gnus-group-next-unread-group
359 "p" gnus-group-prev-unread-group
360 "\177" gnus-group-prev-unread-group
361 [delete] gnus-group-prev-unread-group
362 "N" gnus-group-next-group
363 "P" gnus-group-prev-group
364 "\M-n" gnus-group-next-unread-group-same-level
365 "\M-p" gnus-group-prev-unread-group-same-level
366 "," gnus-group-best-unread-group
367 "." gnus-group-first-unread-group
368 "u" gnus-group-unsubscribe-current-group
369 "U" gnus-group-unsubscribe-group
370 "c" gnus-group-catchup-current
371 "C" gnus-group-catchup-current-all
372 "\M-c" gnus-group-clear-data
373 "l" gnus-group-list-groups
374 "L" gnus-group-list-all-groups
376 "g" gnus-group-get-new-news
377 "\M-g" gnus-group-get-new-news-this-group
378 "R" gnus-group-restart
379 "r" gnus-group-read-init-file
380 "B" gnus-group-browse-foreign-server
381 "b" gnus-group-check-bogus-groups
382 "F" gnus-find-new-newsgroups
383 "\C-c\C-d" gnus-group-describe-group
384 "\M-d" gnus-group-describe-all-groups
385 "\C-c\C-a" gnus-group-apropos
386 "\C-c\M-\C-a" gnus-group-description-apropos
387 "a" gnus-group-post-news
388 "\ek" gnus-group-edit-local-kill
389 "\eK" gnus-group-edit-global-kill
390 "\C-k" gnus-group-kill-group
391 "\C-y" gnus-group-yank-group
392 "\C-w" gnus-group-kill-region
393 "\C-x\C-t" gnus-group-transpose-groups
394 "\C-c\C-l" gnus-group-list-killed
395 "\C-c\C-x" gnus-group-expire-articles
396 "\C-c\M-\C-x" gnus-group-expire-all-groups
398 "s" gnus-group-save-newsrc
399 "z" gnus-group-suspend
402 "?" gnus-group-describe-briefly
403 "\C-c\C-i" gnus-info-find-node
404 "\M-e" gnus-group-edit-group-method
405 "^" gnus-group-enter-server-mode
406 gnus-mouse-2 gnus-mouse-pick-group
407 "<" beginning-of-buffer
410 "\C-c\C-s" gnus-group-sort-groups
412 "\C-c\M-g" gnus-activate-all-groups
413 "\M-&" gnus-group-universal-argument
414 "#" gnus-group-mark-group
415 "\M-#" gnus-group-unmark-group)
417 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
418 "m" gnus-group-mark-group
419 "u" gnus-group-unmark-group
420 "w" gnus-group-mark-region
421 "m" gnus-group-mark-buffer
422 "r" gnus-group-mark-regexp
423 "U" gnus-group-unmark-all-groups)
425 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
426 "d" gnus-group-make-directory-group
427 "h" gnus-group-make-help-group
428 "u" gnus-group-make-useful-group
429 "a" gnus-group-make-archive-group
430 "k" gnus-group-make-kiboze-group
431 "m" gnus-group-make-group
432 "E" gnus-group-edit-group
433 "e" gnus-group-edit-group-method
434 "p" gnus-group-edit-group-parameters
435 "v" gnus-group-add-to-virtual
436 "V" gnus-group-make-empty-virtual
437 "D" gnus-group-enter-directory
438 "f" gnus-group-make-doc-group
439 "w" gnus-group-make-web-group
440 "r" gnus-group-rename-group
441 "c" gnus-group-customize
442 "\177" gnus-group-delete-group
443 [delete] gnus-group-delete-group)
445 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
446 "b" gnus-group-brew-soup
447 "w" gnus-soup-save-areas
448 "s" gnus-soup-send-replies
449 "p" gnus-soup-pack-packet
450 "r" nnsoup-pack-replies)
452 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
453 "s" gnus-group-sort-groups
454 "a" gnus-group-sort-groups-by-alphabet
455 "u" gnus-group-sort-groups-by-unread
456 "l" gnus-group-sort-groups-by-level
457 "v" gnus-group-sort-groups-by-score
458 "r" gnus-group-sort-groups-by-rank
459 "m" gnus-group-sort-groups-by-method)
461 (gnus-define-keys (gnus-group-sort-map "P" gnus-group-group-map)
462 "s" gnus-group-sort-selected-groups
463 "a" gnus-group-sort-selected-groups-by-alphabet
464 "u" gnus-group-sort-selected-groups-by-unread
465 "l" gnus-group-sort-selected-groups-by-level
466 "v" gnus-group-sort-selected-groups-by-score
467 "r" gnus-group-sort-selected-groups-by-rank
468 "m" gnus-group-sort-selected-groups-by-method)
470 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
471 "k" gnus-group-list-killed
472 "z" gnus-group-list-zombies
473 "s" gnus-group-list-groups
474 "u" gnus-group-list-all-groups
475 "A" gnus-group-list-active
476 "a" gnus-group-apropos
477 "d" gnus-group-description-apropos
478 "m" gnus-group-list-matching
479 "M" gnus-group-list-all-matching
480 "l" gnus-group-list-level)
482 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
483 "f" gnus-score-flush-cache)
485 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
486 "d" gnus-group-describe-group
487 "f" gnus-group-fetch-faq)
489 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
490 "l" gnus-group-set-current-level
491 "t" gnus-group-unsubscribe-current-group
492 "s" gnus-group-unsubscribe-group
493 "k" gnus-group-kill-group
494 "y" gnus-group-yank-group
495 "w" gnus-group-kill-region
496 "\C-k" gnus-group-kill-level
497 "z" gnus-group-kill-all-zombies))
499 (defun gnus-group-make-menu-bar ()
500 (gnus-turn-off-edit-menu 'group)
501 (unless (boundp 'gnus-group-reading-menu)
504 gnus-group-reading-menu gnus-group-mode-map ""
506 ["Read" gnus-group-read-group (gnus-group-group-name)]
507 ["Select" gnus-group-select-group (gnus-group-group-name)]
508 ["See old articles" (gnus-group-select-group 'all)
509 :keys "C-u SPC" :active (gnus-group-group-name)]
510 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
511 ["Catch up all articles" gnus-group-catchup-current-all
512 (gnus-group-group-name)]
513 ["Check for new articles" gnus-group-get-new-news-this-group
514 (gnus-group-group-name)]
515 ["Toggle subscription" gnus-group-unsubscribe-current-group
516 (gnus-group-group-name)]
517 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
518 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
519 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
520 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
521 ["Edit kill file" gnus-group-edit-local-kill
522 (gnus-group-group-name)]
523 ;; Actually one should check, if any of the marked groups gives t for
524 ;; (gnus-check-backend-function 'request-expire-articles ...)
525 ["Expire articles" gnus-group-expire-articles
526 (or (and (gnus-group-group-name)
527 (gnus-check-backend-function
528 'request-expire-articles
529 (gnus-group-group-name))) gnus-group-marked)]
530 ["Set group level" gnus-group-set-current-level
531 (gnus-group-group-name)]
532 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
536 gnus-group-group-menu gnus-group-mode-map ""
539 ["List unread subscribed groups" gnus-group-list-groups t]
540 ["List (un)subscribed groups" gnus-group-list-all-groups t]
541 ["List killed groups" gnus-group-list-killed gnus-killed-list]
542 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
543 ["List level..." gnus-group-list-level t]
544 ["Describe all groups" gnus-group-describe-all-groups t]
545 ["Group apropos..." gnus-group-apropos t]
546 ["Group and description apropos..." gnus-group-description-apropos t]
547 ["List groups matching..." gnus-group-list-matching t]
548 ["List all groups matching..." gnus-group-list-all-matching t]
549 ["List active file" gnus-group-list-active t])
551 ["Default sort" gnus-group-sort-groups t]
552 ["Sort by method" gnus-group-sort-groups-by-method t]
553 ["Sort by rank" gnus-group-sort-groups-by-rank t]
554 ["Sort by score" gnus-group-sort-groups-by-score t]
555 ["Sort by level" gnus-group-sort-groups-by-level t]
556 ["Sort by unread" gnus-group-sort-groups-by-unread t]
557 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
558 ("Sort process/prefixed"
559 ["Default sort" gnus-group-sort-selected-groups
560 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
561 ["Sort by method" gnus-group-sort-selected-groups-by-method
562 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
563 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
564 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
565 ["Sort by score" gnus-group-sort-selected-groups-by-score
566 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
567 ["Sort by level" gnus-group-sort-selected-groups-by-level
568 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
569 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
570 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
571 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
572 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
574 ["Mark group" gnus-group-mark-group
575 (and (gnus-group-group-name)
576 (not (memq (gnus-group-group-name) gnus-group-marked)))]
577 ["Unmark group" gnus-group-unmark-group
578 (and (gnus-group-group-name)
579 (memq (gnus-group-group-name) gnus-group-marked))]
580 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
581 ["Mark regexp..." gnus-group-mark-regexp t]
582 ["Mark region" gnus-group-mark-region t]
583 ["Mark buffer" gnus-group-mark-buffer t]
584 ["Execute command" gnus-group-universal-argument
585 (or gnus-group-marked (gnus-group-group-name))])
587 ["Subscribe to a group" gnus-group-unsubscribe-group t]
588 ["Kill all newsgroups in region" gnus-group-kill-region t]
589 ["Kill all zombie groups" gnus-group-kill-all-zombies
591 ["Kill all groups on level..." gnus-group-kill-level t])
593 ["Make a foreign group" gnus-group-make-group t]
594 ["Add a directory group" gnus-group-make-directory-group t]
595 ["Add the help group" gnus-group-make-help-group t]
596 ["Add the archive group" gnus-group-make-archive-group t]
597 ["Make a doc group" gnus-group-make-doc-group t]
598 ["Make a web group" gnus-group-make-web-group t]
599 ["Make a kiboze group" gnus-group-make-kiboze-group t]
600 ["Make a virtual group" gnus-group-make-empty-virtual t]
601 ["Add a group to a virtual" gnus-group-add-to-virtual t]
602 ["Rename group" gnus-group-rename-group
603 (gnus-check-backend-function
604 'request-rename-group (gnus-group-group-name))]
605 ["Delete group" gnus-group-delete-group
606 (gnus-check-backend-function
607 'request-delete-group (gnus-group-group-name))])
609 ["Parameters" gnus-group-edit-group-parameters
610 (gnus-group-group-name)]
611 ["Select method" gnus-group-edit-group-method
612 (gnus-group-group-name)]
613 ["Info" gnus-group-edit-group (gnus-group-group-name)])
615 ["Flush cache" gnus-score-flush-cache t])
617 ["Next" gnus-group-next-group t]
618 ["Previous" gnus-group-prev-group t]
619 ["Next unread" gnus-group-next-unread-group t]
620 ["Previous unread" gnus-group-prev-unread-group t]
621 ["Next unread same level" gnus-group-next-unread-group-same-level t]
622 ["Previous unread same level"
623 gnus-group-prev-unread-group-same-level t]
624 ["Jump to group" gnus-group-jump-to-group t]
625 ["First unread group" gnus-group-first-unread-group t]
626 ["Best unread group" gnus-group-best-unread-group t])
627 ["Transpose" gnus-group-transpose-groups
628 (gnus-group-group-name)]
629 ["Read a directory as a group..." gnus-group-enter-directory t]
633 gnus-group-misc-menu gnus-group-mode-map ""
635 ["Send a bug report" gnus-bug t]
636 ["Send a mail" gnus-group-mail t]
637 ["Post an article..." gnus-group-post-news t]
638 ["Check for new news" gnus-group-get-new-news t]
639 ["Activate all groups" gnus-activate-all-groups t]
640 ["Delete bogus groups" gnus-group-check-bogus-groups t]
641 ["Find new newsgroups" gnus-find-new-newsgroups t]
642 ["Restart Gnus" gnus-group-restart t]
643 ["Read init file" gnus-group-read-init-file t]
644 ["Browse foreign server" gnus-group-browse-foreign-server t]
645 ["Enter server buffer" gnus-group-enter-server-mode t]
646 ["Expire all expirable articles" gnus-group-expire-all-groups t]
647 ["Generate any kiboze groups" nnkiboze-generate-groups t]
648 ["Gnus version" gnus-version t]
649 ["Save .newsrc files" gnus-group-save-newsrc t]
650 ["Suspend Gnus" gnus-group-suspend t]
651 ["Clear dribble buffer" gnus-group-clear-dribble t]
652 ["Edit global kill file" gnus-group-edit-global-kill t]
653 ["Read manual" gnus-info-find-node t]
654 ["Toggle topics" gnus-topic-mode t]
656 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
657 ["Send replies" gnus-soup-send-replies
658 (fboundp 'gnus-soup-pack-packet)]
659 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
660 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
661 ["Brew SOUP" gnus-soup-brew-soup (fboundp 'gnus-soup-pack-packet)])
662 ["Exit from Gnus" gnus-group-exit t]
663 ["Exit without saving" gnus-group-quit t]
666 (run-hooks 'gnus-group-menu-hook)
669 (defun gnus-group-mode ()
670 "Major mode for reading news.
672 All normal editing commands are switched off.
673 \\<gnus-group-mode-map>
674 The group buffer lists (some of) the groups available. For instance,
675 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
676 lists all zombie groups.
678 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
679 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
681 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
683 The following commands are available:
685 \\{gnus-group-mode-map}"
687 (when (and menu-bar-mode
688 (gnus-visual-p 'group-menu 'menu))
689 (gnus-group-make-menu-bar))
690 (kill-all-local-variables)
691 (gnus-simplify-mode-line)
692 (setq major-mode 'gnus-group-mode)
693 (setq mode-name "Group")
694 (gnus-group-set-mode-line)
695 (setq mode-line-process nil)
696 (use-local-map gnus-group-mode-map)
697 (buffer-disable-undo (current-buffer))
698 (setq truncate-lines t)
699 (setq buffer-read-only t)
700 (gnus-set-default-directory)
701 (gnus-update-format-specifications nil 'group 'group-mode)
702 (gnus-update-group-mark-positions)
703 (gnus-make-local-hook 'post-command-hook)
704 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
707 (run-hooks 'gnus-group-mode-hook))
709 (defun gnus-update-group-mark-positions ()
711 (let ((gnus-process-mark 128)
712 (gnus-group-marked '("dummy.group"))
713 (gnus-active-hashtb (make-vector 10 0)))
714 (gnus-set-active "dummy.group" '(0 . 0))
715 (gnus-set-work-buffer)
716 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
717 (goto-char (point-min))
718 (setq gnus-group-mark-positions
719 (list (cons 'process (and (search-forward "\200" nil t)
722 (defun gnus-clear-inboxes-moved ()
723 (setq nnmail-moved-inboxes nil))
725 (defun gnus-mouse-pick-group (e)
726 "Enter the group under the mouse pointer."
729 (gnus-group-read-group nil))
731 ;; Look at LEVEL and find out what the level is really supposed to be.
732 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
733 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
734 (defun gnus-group-default-level (&optional level number-or-nil)
736 (gnus-group-use-permanent-levels
737 (or (setq gnus-group-use-permanent-levels
738 (or level (if (numberp gnus-group-use-permanent-levels)
739 gnus-group-use-permanent-levels
740 (or gnus-group-default-list-level
741 gnus-level-subscribed))))
742 gnus-group-default-list-level gnus-level-subscribed))
746 (or level gnus-group-default-list-level gnus-level-subscribed))))
748 (defun gnus-group-setup-buffer ()
749 (switch-to-buffer gnus-group-buffer)
750 (unless (eq major-mode 'gnus-group-mode)
751 (gnus-add-current-to-buffer-list)
754 (gnus-carpal-setup-buffer 'group))))
756 (defun gnus-group-list-groups (&optional level unread lowest)
757 "List newsgroups with level LEVEL or lower that have unread articles.
758 Default is all subscribed groups.
759 If argument UNREAD is non-nil, groups with no unread articles are also
762 (list (if current-prefix-arg
763 (prefix-numeric-value current-prefix-arg)
765 (gnus-group-default-level nil t)
766 gnus-group-default-list-level
767 gnus-level-subscribed))))
769 (setq level (car gnus-group-list-mode)
770 unread (cdr gnus-group-list-mode)))
771 (setq level (gnus-group-default-level level))
772 (gnus-group-setup-buffer) ;May call from out of group buffer
773 (gnus-update-format-specifications nil 'group 'group-mode)
774 (let ((case-fold-search nil)
775 (props (text-properties-at (gnus-point-at-bol)))
776 (group (gnus-group-group-name)))
777 (set-buffer gnus-group-buffer)
778 (funcall gnus-group-prepare-function level unread lowest)
779 (if (zerop (buffer-size))
780 (gnus-message 5 gnus-no-groups-message)
781 (goto-char (point-max))
782 (when (or (not gnus-group-goto-next-group-function)
783 (not (funcall gnus-group-goto-next-group-function
786 ;; Go to the first group with unread articles.
787 (gnus-group-search-forward t)
788 ;; Find the right group to put point on. If the current group
789 ;; has disappeared in the new listing, try to find the next
790 ;; one. If no next one can be found, just leave point at the
791 ;; first newsgroup in the buffer.
792 (when (not (gnus-goto-char
794 (point-min) (point-max)
795 'gnus-group (gnus-intern-safe
796 group gnus-active-hashtb))))
797 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
801 (point-min) (point-max) 'gnus-group
803 (caar newsrc) gnus-active-hashtb)))))
804 (setq newsrc (cdr newsrc)))
806 (goto-char (point-max))
807 (forward-line -1))))))
808 ;; Adjust cursor point.
809 (gnus-group-position-point))))
811 (defun gnus-group-list-level (level &optional all)
812 "List groups on LEVEL.
813 If ALL (the prefix), also list groups that have no unread articles."
814 (interactive "nList groups on level: \nP")
815 (gnus-group-list-groups level all level))
817 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
818 "List all newsgroups with unread articles of level LEVEL or lower.
819 If ALL is non-nil, list groups that have no unread articles.
820 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
821 If REGEXP, only list groups matching REGEXP."
822 (set-buffer gnus-group-buffer)
823 (let ((buffer-read-only nil)
824 (newsrc (cdr gnus-newsrc-alist))
825 (lowest (or lowest 1))
826 info clevel unread group params)
828 (when (< lowest gnus-level-zombie)
829 ;; List living groups.
831 (setq info (car newsrc)
832 group (gnus-info-group info)
833 params (gnus-info-params info)
835 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
836 (and unread ; This group might be bogus
838 (string-match regexp group))
839 (<= (setq clevel (gnus-info-level info)) level)
841 (or all ; We list all groups?
842 (if (eq unread t) ; Unactivated?
843 gnus-group-list-inactive-groups ; We list unactivated
844 (> unread 0)) ; We list groups with unread articles
845 (and gnus-list-groups-with-ticked-articles
846 (cdr (assq 'tick (gnus-info-marks info))))
847 ; And groups with tickeds
848 ;; Check for permanent visibility.
849 (and gnus-permanently-visible-groups
850 (string-match gnus-permanently-visible-groups
852 (memq 'visible params)
853 (cdr (assq 'visible params)))
854 (gnus-group-insert-group-line
855 group (gnus-info-level info)
856 (gnus-info-marks info) unread (gnus-info-method info)))))
859 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
860 (gnus-group-prepare-flat-list-dead
861 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
864 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
865 (gnus-group-prepare-flat-list-dead
866 (setq gnus-killed-list (sort gnus-killed-list 'string<))
867 gnus-level-killed ?K regexp))
869 (gnus-group-set-mode-line)
870 (setq gnus-group-list-mode (cons level all))
871 (run-hooks 'gnus-group-prepare-hook)))
873 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
874 ;; List zombies and killed lists somewhat faster, which was
875 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
876 ;; this by ignoring the group format specification altogether.
879 ;; This loop is used when listing groups that match some
882 (setq group (pop groups))
883 (when (string-match regexp group)
884 (gnus-add-text-properties
885 (point) (prog1 (1+ (point))
886 (insert " " mark " *: " group "\n"))
887 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
889 'gnus-level level))))
890 ;; This loop is used when listing all groups.
892 (gnus-add-text-properties
893 (point) (prog1 (1+ (point))
894 (insert " " mark " *: "
895 (setq group (pop groups)) "\n"))
896 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
898 'gnus-level level))))))
900 (defun gnus-group-update-group-line ()
901 "Update the current line in the group buffer."
902 (let* ((buffer-read-only nil)
903 (group (gnus-group-group-name))
904 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
905 gnus-group-indentation)
908 (not (gnus-ephemeral-group-p group))
910 (concat "(gnus-group-set-info '"
911 (gnus-prin1-to-string (nth 2 entry))
913 (setq gnus-group-indentation (gnus-group-group-indentation))
915 (gnus-group-insert-group-line-info group)
917 (gnus-group-position-point))))
919 (defun gnus-group-insert-group-line-info (group)
920 "Insert GROUP on the current line."
921 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
922 (gnus-group-indentation (gnus-group-group-indentation))
926 ;; (Un)subscribed group.
927 (setq info (nth 2 entry))
928 (gnus-group-insert-group-line
929 group (gnus-info-level info) (gnus-info-marks info)
930 (or (car entry) t) (gnus-info-method info)))
931 ;; This group is dead.
932 (gnus-group-insert-group-line
934 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
936 (if (setq active (gnus-active group))
937 (- (1+ (cdr active)) (car active)) 0)
940 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
941 gnus-tmp-marked number
943 "Insert a group line in the group buffer."
944 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
945 (gnus-tmp-number-total
947 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
949 (gnus-tmp-number-of-unread
950 (if (numberp number) (int-to-string (max 0 number))
952 (gnus-tmp-number-of-read
954 (int-to-string (max 0 (- gnus-tmp-number-total number)))
957 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
958 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
959 ((= gnus-tmp-level gnus-level-zombie) ?Z)
961 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
962 (gnus-tmp-newsgroup-description
963 (if gnus-description-hashtb
964 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
967 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
968 (gnus-tmp-moderated-string
969 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
971 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
972 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
973 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
974 (gnus-tmp-news-method-string
976 (format "(%s:%s)" (car gnus-tmp-method)
977 (cadr gnus-tmp-method)) ""))
978 (gnus-tmp-marked-mark
979 (if (and (numberp number)
981 (cdr (assq 'tick gnus-tmp-marked)))
983 (gnus-tmp-process-marked
984 (if (member gnus-tmp-group gnus-group-marked)
985 gnus-process-mark ? ))
987 (or (and gnus-use-grouplens
988 (bbb-grouplens-group-p gnus-tmp-group))
990 (buffer-read-only nil)
991 header gnus-tmp-header) ; passed as parameter to user-funcs.
993 (gnus-add-text-properties
997 (eval gnus-group-line-format-spec))
998 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
999 gnus-unread ,(if (numberp number)
1000 (string-to-int gnus-tmp-number-of-unread)
1002 gnus-marked ,gnus-tmp-marked-mark
1003 gnus-indentation ,gnus-group-indentation
1004 gnus-level ,gnus-tmp-level))
1005 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1007 (run-hooks 'gnus-group-update-hook)
1009 ;; Allow XEmacs to remove front-sticky text properties.
1010 (gnus-group-remove-excess-properties)))
1012 (defun gnus-group-highlight-line ()
1013 "Highlight the current line according to `gnus-group-highlight'."
1014 (let* ((list gnus-group-highlight)
1016 (end (progn (end-of-line) (point)))
1017 ;; now find out where the line starts and leave point there.
1018 (beg (progn (beginning-of-line) (point)))
1019 (group (gnus-group-group-name))
1020 (entry (gnus-group-entry group))
1021 (unread (if (numberp (car entry)) (car entry) 0))
1022 (active (gnus-active group))
1023 (total (if active (1+ (- (cdr active) (car active))) 0))
1024 (info (nth 2 entry))
1025 (method (gnus-server-get-method group (gnus-info-method info)))
1026 (marked (gnus-info-marks info))
1027 (mailp (memq 'mail (assoc (symbol-name
1028 (car (or method gnus-select-method)))
1029 gnus-valid-select-methods)))
1030 (level (or (gnus-info-level info) 9))
1031 (score (or (gnus-info-score info) 0))
1032 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1033 (inhibit-read-only t))
1034 ;; Eval the cars of the lists until we find a match.
1036 (not (eval (caar list))))
1037 (setq list (cdr list)))
1038 (let ((face (cdar list)))
1039 (unless (eq face (get-text-property beg 'face))
1040 (gnus-put-text-property
1042 (setq face (if (boundp face) (symbol-value face) face)))
1043 (gnus-extent-start-open beg)))
1046 (defun gnus-group-update-group (group &optional visible-only)
1047 "Update all lines where GROUP appear.
1048 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1051 (set-buffer gnus-group-buffer)
1052 ;; The buffer may be narrowed.
1055 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1057 found buffer-read-only)
1058 ;; Enter the current status into the dribble buffer.
1059 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1060 (when (and entry (not (gnus-ephemeral-group-p group)))
1062 (concat "(gnus-group-set-info '"
1063 (gnus-prin1-to-string (nth 2 entry))
1065 ;; Find all group instances. If topics are in use, each group
1066 ;; may be listed in more than once.
1067 (while (setq loc (text-property-any
1068 loc (point-max) 'gnus-group ident))
1071 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1073 (gnus-group-insert-group-line-info group)
1076 (run-hooks 'gnus-group-update-group-hook)))
1077 (setq loc (1+ loc)))
1078 (unless (or found visible-only)
1079 ;; No such line in the buffer, find out where it's supposed to
1080 ;; go, and insert it there (or at the end of the buffer).
1081 (if gnus-goto-missing-group-function
1082 (funcall gnus-goto-missing-group-function group)
1083 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1084 (while (and entry (car entry)
1088 (point-min) (point-max)
1089 'gnus-group (gnus-intern-safe
1090 (caar entry) gnus-active-hashtb)))))
1091 (setq entry (cdr entry)))
1092 (or entry (goto-char (point-max)))))
1093 ;; Finally insert the line.
1094 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1095 (gnus-group-insert-group-line-info group)
1098 (run-hooks 'gnus-group-update-group-hook))))
1099 (when gnus-group-update-group-function
1100 (funcall gnus-group-update-group-function group))
1101 (gnus-group-set-mode-line)))))
1103 (defun gnus-group-set-mode-line ()
1104 "Update the mode line in the group buffer."
1105 (when (memq 'group gnus-updated-mode-lines)
1106 ;; Yes, we want to keep this mode line updated.
1108 (set-buffer gnus-group-buffer)
1109 (let* ((gformat (or gnus-group-mode-line-format-spec
1110 (setq gnus-group-mode-line-format-spec
1112 gnus-group-mode-line-format
1113 gnus-group-mode-line-format-alist))))
1114 (gnus-tmp-news-server (cadr gnus-select-method))
1115 (gnus-tmp-news-method (car gnus-select-method))
1116 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1118 gnus-tmp-header ;Dummy binding for user-defined formats
1119 ;; Get the resulting string.
1121 (and gnus-dribble-buffer
1122 (buffer-name gnus-dribble-buffer)
1123 (buffer-modified-p gnus-dribble-buffer)
1125 (set-buffer gnus-dribble-buffer)
1126 (not (zerop (buffer-size))))))
1127 (mode-string (eval gformat)))
1128 ;; Say whether the dribble buffer has been modified.
1129 (setq mode-line-modified
1130 (if modified "---*- " "----- "))
1131 ;; If the line is too long, we chop it off.
1132 (when (> (length mode-string) max-len)
1133 (setq mode-string (substring mode-string 0 (- max-len 4))))
1135 (setq mode-line-buffer-identification
1136 (gnus-mode-line-buffer-identification
1137 (list mode-string)))
1138 (set-buffer-modified-p modified))))))
1140 (defun gnus-group-group-name ()
1141 "Get the name of the newsgroup on the current line."
1142 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1143 (and group (symbol-name group))))
1145 (defun gnus-group-group-level ()
1146 "Get the level of the newsgroup on the current line."
1147 (get-text-property (gnus-point-at-bol) 'gnus-level))
1149 (defun gnus-group-group-indentation ()
1150 "Get the indentation of the newsgroup on the current line."
1151 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1152 (and gnus-group-indentation-function
1153 (funcall gnus-group-indentation-function))
1156 (defun gnus-group-group-unread ()
1157 "Get the number of unread articles of the newsgroup on the current line."
1158 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1160 (defun gnus-group-new-mail (group)
1161 (if (nnmail-new-mail-p group)
1165 (defun gnus-group-search-forward (&optional backward all level first-too)
1166 "Find the next newsgroup with unread articles.
1167 If BACKWARD is non-nil, find the previous newsgroup instead.
1168 If ALL is non-nil, just find any newsgroup.
1169 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1171 If FIRST-TOO, the current line is also eligible as a target."
1172 (let ((way (if backward -1 1))
1173 (low gnus-level-killed)
1176 (if (and backward (progn (beginning-of-line)) (bobp))
1187 (get-text-property (point) 'gnus-unread)))
1188 (and (numberp unread) (> unread 0)))
1189 (setq lev (get-text-property (point)
1191 (<= lev gnus-level-subscribed)))
1193 (and (setq lev (get-text-property (point)
1202 (zerop (forward-line way)))))
1204 (progn (gnus-group-position-point) t)
1205 (goto-char (or pos beg))
1208 ;;; Gnus group mode commands
1212 (defun gnus-group-mark-group (n &optional unmark no-advance)
1213 "Mark the current group."
1215 (let ((buffer-read-only nil)
1219 (when (setq group (gnus-group-group-name))
1220 ;; Go to the mark position.
1222 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1223 (subst-char-in-region
1224 (point) (1+ (point)) (following-char)
1227 (setq gnus-group-marked (delete group gnus-group-marked))
1229 (setq gnus-group-marked
1230 (cons group (delete group gnus-group-marked)))
1231 gnus-process-mark)))
1233 (gnus-group-next-group 1))
1235 (gnus-summary-position-point)
1238 (defun gnus-group-unmark-group (n)
1239 "Remove the mark from the current group."
1241 (gnus-group-mark-group n 'unmark)
1242 (gnus-group-position-point))
1244 (defun gnus-group-unmark-all-groups ()
1245 "Unmark all groups."
1247 (let ((groups gnus-group-marked))
1250 (gnus-group-remove-mark (pop groups)))))
1251 (gnus-group-position-point))
1253 (defun gnus-group-mark-region (unmark beg end)
1254 "Mark all groups between point and mark.
1255 If UNMARK, remove the mark instead."
1256 (interactive "P\nr")
1257 (let ((num (count-lines beg end)))
1260 (- num (gnus-group-mark-group num unmark)))))
1262 (defun gnus-group-mark-buffer (&optional unmark)
1263 "Mark all groups in the buffer.
1264 If UNMARK, remove the mark instead."
1266 (gnus-group-mark-region unmark (point-min) (point-max)))
1268 (defun gnus-group-mark-regexp (regexp)
1269 "Mark all groups that match some regexp."
1270 (interactive "sMark (regexp): ")
1271 (let ((alist (cdr gnus-newsrc-alist))
1274 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1275 (gnus-group-set-mark group))))
1276 (gnus-group-position-point))
1278 (defun gnus-group-remove-mark (group)
1279 "Remove the process mark from GROUP and move point there.
1280 Return nil if the group isn't displayed."
1281 (if (gnus-group-goto-group group)
1283 (gnus-group-mark-group 1 'unmark t)
1285 (setq gnus-group-marked
1286 (delete group gnus-group-marked))
1289 (defun gnus-group-set-mark (group)
1290 "Set the process mark on GROUP."
1291 (if (gnus-group-goto-group group)
1293 (gnus-group-mark-group 1 nil t))
1294 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1296 (defun gnus-group-universal-argument (arg &optional groups func)
1297 "Perform any command on all groups according to the process/prefix convention."
1299 (let ((groups (or groups (gnus-group-process-prefix arg))))
1300 (if (eq (setq func (or func
1303 (substitute-command-keys
1304 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1306 (gnus-error 1 "Undefined key")
1308 (gnus-group-remove-mark (pop groups))
1309 (command-execute func))))
1310 (gnus-group-position-point))
1312 (defun gnus-group-process-prefix (n)
1313 "Return a list of groups to work on.
1314 Take into consideration N (the prefix) and the list of marked groups."
1317 (setq n (prefix-numeric-value n))
1318 ;; There is a prefix, so we return a list of the N next
1320 (let ((way (if (< n 0) -1 1))
1325 (setq group (gnus-group-group-name)))
1328 (gnus-group-next-group way)))
1330 ((and (boundp 'transient-mark-mode)
1332 (boundp 'mark-active)
1334 ;; Work on the region between point and mark.
1335 (let ((max (max (point) (mark)))
1338 (goto-char (min (point) (mark)))
1341 (push (gnus-group-group-name) groups)
1342 (zerop (gnus-group-next-group 1))
1344 (nreverse groups))))
1346 ;; No prefix, but a list of marked articles.
1347 (reverse gnus-group-marked))
1349 ;; Neither marked articles or a prefix, so we return the
1351 (let ((group (gnus-group-group-name)))
1352 (and group (list group))))))
1354 ;; Selecting groups.
1356 (defun gnus-group-read-group (&optional all no-article group)
1357 "Read news in this newsgroup.
1358 If the prefix argument ALL is non-nil, already read articles become
1359 readable. IF ALL is a number, fetch this number of articles. If the
1360 optional argument NO-ARTICLE is non-nil, no article will be
1361 auto-selected upon group entry. If GROUP is non-nil, fetch that
1364 (let ((no-display (eq all 0))
1365 (group (or group (gnus-group-group-name)))
1366 number active marked entry)
1370 (error "No group on current line"))
1371 (setq marked (gnus-info-marks
1372 (nth 2 (setq entry (gnus-gethash
1373 group gnus-newsrc-hashtb)))))
1374 ;; This group might be a dead group. In that case we have to get
1375 ;; the number of unread articles from `gnus-active-hashtb'.
1377 (cond ((numberp all) all)
1379 ((setq active (gnus-active group))
1380 (- (1+ (cdr active)) (car active)))))
1381 (gnus-summary-read-group
1382 group (or all (and (numberp number)
1383 (zerop (+ number (gnus-range-length
1384 (cdr (assq 'tick marked)))
1386 (cdr (assq 'dormant marked)))))))
1387 no-article nil no-display)))
1389 (defun gnus-group-select-group (&optional all)
1390 "Select this newsgroup.
1391 No article is selected automatically.
1392 If ALL is non-nil, already read articles become readable.
1393 If ALL is a number, fetch this number of articles."
1395 (gnus-group-read-group all t))
1397 (defun gnus-group-quick-select-group (&optional all)
1398 "Select the current group \"quickly\".
1399 This means that no highlighting or scoring will be performed.
1400 If ALL (the prefix argument) is 0, don't even generate the summary
1403 (require 'gnus-score)
1405 gnus-score-find-score-files-function
1406 gnus-apply-kill-hook
1407 gnus-summary-expunge-below)
1408 (gnus-group-read-group all t)))
1410 (defun gnus-group-visible-select-group (&optional all)
1411 "Select the current group without hiding any articles."
1413 (let ((gnus-inhibit-limiting t))
1414 (gnus-group-read-group all t)))
1417 (defun gnus-fetch-group (group)
1418 "Start Gnus if necessary and enter GROUP.
1419 Returns whether the fetching was successful or not."
1420 (interactive "sGroup name: ")
1421 (unless (get-buffer gnus-group-buffer)
1423 (gnus-group-read-group nil nil group))
1425 ;; Enter a group that is not in the group buffer. Non-nil is returned
1426 ;; if selection was successful.
1427 (defun gnus-group-read-ephemeral-group (group method &optional activate
1428 quit-config request-only)
1429 "Read GROUP from METHOD as an ephemeral group.
1430 If ACTIVATE, request the group first.
1431 If QUIT-CONFIG, use that window configuration when exiting from the
1433 If REQUEST-ONLY, don't actually read the group; just request it.
1435 Return the name of the group is selection was successful."
1436 (let ((group (if (gnus-group-foreign-p group) group
1437 (gnus-group-prefixed-name group method))))
1441 ,gnus-level-default-subscribed nil nil ,method
1443 ,(if quit-config quit-config
1444 (cons gnus-summary-buffer
1445 gnus-current-window-configuration))))))
1447 (set-buffer gnus-group-buffer)
1448 (unless (gnus-check-server method)
1449 (error "Unable to contact server: %s" (gnus-status-message method)))
1451 (gnus-activate-group group 'scan)
1452 (unless (gnus-request-group group)
1453 (error "Couldn't request group: %s"
1454 (nnheader-get-report (car method)))))
1458 (when (gnus-group-read-group t t group)
1463 (defun gnus-group-jump-to-group (group)
1464 "Jump to newsgroup GROUP."
1466 (list (completing-read
1467 "Group: " gnus-active-hashtb nil
1468 (gnus-read-active-file-p)
1470 'gnus-group-history)))
1472 (when (equal group "")
1473 (error "Empty group name"))
1475 (unless (gnus-ephemeral-group-p group)
1476 ;; Either go to the line in the group buffer...
1477 (unless (gnus-group-goto-group group)
1478 ;; ... or insert the line.
1479 (gnus-group-update-group group)
1480 (gnus-group-goto-group group)))
1481 ;; Adjust cursor point.
1482 (gnus-group-position-point))
1484 (defun gnus-group-goto-group (group &optional far)
1485 "Goto to newsgroup GROUP.
1486 If FAR, it is likely that the group is not on the current line."
1491 (point-min) (point-max)
1492 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
1495 ;; It's quite likely that we are on the right line, so
1496 ;; we check the current line first.
1497 ((eq (get-text-property (point) 'gnus-group)
1498 (gnus-intern-safe group gnus-active-hashtb))
1500 ;; Previous and next line are also likely, so we check them as well.
1503 (eq (get-text-property (point) 'gnus-group)
1504 (gnus-intern-safe group gnus-active-hashtb)))
1509 (eq (get-text-property (point) 'gnus-group)
1510 (gnus-intern-safe group gnus-active-hashtb)))
1514 ;; Search through the entire buffer.
1517 (point-min) (point-max)
1518 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
1520 (defun gnus-group-next-group (n &optional silent)
1521 "Go to next N'th newsgroup.
1522 If N is negative, search backward instead.
1523 Returns the difference between N and the number of skips actually
1526 (gnus-group-next-unread-group n t nil silent))
1528 (defun gnus-group-next-unread-group (n &optional all level silent)
1529 "Go to next N'th unread newsgroup.
1530 If N is negative, search backward instead.
1531 If ALL is non-nil, choose any newsgroup, unread or not.
1532 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1533 such group can be found, the next group with a level higher than
1535 Returns the difference between N and the number of skips actually
1538 (let ((backward (< n 0))
1541 (gnus-group-search-forward
1542 backward (or (not gnus-group-goto-unread) all) level))
1546 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1547 (if level " on this level or higher" "")))
1550 (defun gnus-group-prev-group (n)
1551 "Go to previous N'th newsgroup.
1552 Returns the difference between N and the number of skips actually
1555 (gnus-group-next-unread-group (- n) t))
1557 (defun gnus-group-prev-unread-group (n)
1558 "Go to previous N'th unread newsgroup.
1559 Returns the difference between N and the number of skips actually
1562 (gnus-group-next-unread-group (- n)))
1564 (defun gnus-group-next-unread-group-same-level (n)
1565 "Go to next N'th unread newsgroup on the same level.
1566 If N is negative, search backward instead.
1567 Returns the difference between N and the number of skips actually
1570 (gnus-group-next-unread-group n t (gnus-group-group-level))
1571 (gnus-group-position-point))
1573 (defun gnus-group-prev-unread-group-same-level (n)
1574 "Go to next N'th unread newsgroup on the same level.
1575 Returns the difference between N and the number of skips actually
1578 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1579 (gnus-group-position-point))
1581 (defun gnus-group-best-unread-group (&optional exclude-group)
1582 "Go to the group with the highest level.
1583 If EXCLUDE-GROUP, do not go to that group."
1585 (goto-char (point-min))
1589 (setq unread (get-text-property (point) 'gnus-unread))
1590 (when (and (numberp unread) (> unread 0))
1591 (when (and (get-text-property (point) 'gnus-level)
1592 (< (get-text-property (point) 'gnus-level) best)
1593 (or (not exclude-group)
1594 (not (equal exclude-group (gnus-group-group-name)))))
1595 (setq best (get-text-property (point) 'gnus-level))
1596 (setq best-point (point))))
1599 (goto-char best-point))
1600 (gnus-summary-position-point)
1601 (and best-point (gnus-group-group-name))))
1603 (defun gnus-group-first-unread-group ()
1604 "Go to the first group with unread articles."
1607 (let ((opoint (point))
1609 (goto-char (point-min))
1610 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1611 (and (numberp unread) ; Not a topic.
1612 (not (zerop unread))) ; Has unread articles.
1613 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1616 nil)) ; Not success.
1617 (gnus-group-position-point)))
1619 (defun gnus-group-enter-server-mode ()
1620 "Jump to the server buffer."
1622 (gnus-enter-server-buffer))
1624 (defun gnus-group-make-group (name &optional method address args)
1625 "Add a new newsgroup.
1626 The user will be prompted for a NAME, for a select METHOD, and an
1630 (read-string "Group name: ")
1631 (gnus-read-method "From method: ")))
1633 (let* ((meth (when (and method
1634 (not (gnus-server-equal method gnus-select-method)))
1635 (if address (list (intern method) address)
1637 (nname (if method (gnus-group-prefixed-name name meth) name))
1639 (when (gnus-gethash nname gnus-newsrc-hashtb)
1640 (error "Group %s already exists" nname))
1641 ;; Subscribe to the new group.
1642 (gnus-group-change-level
1643 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1644 gnus-level-default-subscribed gnus-level-killed
1645 (and (gnus-group-group-name)
1646 (gnus-gethash (gnus-group-group-name)
1647 gnus-newsrc-hashtb))
1650 (gnus-set-active nname (cons 1 0))
1651 (unless (gnus-ephemeral-group-p name)
1653 (concat "(gnus-group-set-info '"
1654 (gnus-prin1-to-string (cdr info)) ")")))
1656 (gnus-group-insert-group-line-info nname)
1658 (gnus-group-position-point)
1660 ;; Load the backend and try to make the backend create
1661 ;; the group as well.
1662 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1664 gnus-valid-select-methods)
1666 (gnus-check-server meth)
1667 (when (gnus-check-backend-function 'request-create-group nname)
1668 (gnus-request-create-group nname nil args))
1671 (defun gnus-group-delete-group (group &optional force)
1672 "Delete the current group. Only meaningful with mail groups.
1673 If FORCE (the prefix) is non-nil, all the articles in the group will
1674 be deleted. This is \"deleted\" as in \"removed forever from the face
1675 of the Earth\". There is no undo. The user will be prompted before
1676 doing the deletion."
1678 (list (gnus-group-group-name)
1679 current-prefix-arg))
1681 (error "No group to rename"))
1682 (unless (gnus-check-backend-function 'request-delete-group group)
1683 (error "This backend does not support group deletion"))
1685 (if (not (gnus-yes-or-no-p
1687 "Do you really want to delete %s%s? "
1688 group (if force " and all its contents" ""))))
1690 (gnus-message 6 "Deleting group %s..." group)
1691 (if (not (gnus-request-delete-group group force))
1692 (gnus-error 3 "Couldn't delete group %s" group)
1693 (gnus-message 6 "Deleting group %s...done" group)
1694 (gnus-group-goto-group group)
1695 (gnus-group-kill-group 1 t)
1696 (gnus-sethash group nil gnus-active-hashtb)
1698 (gnus-group-position-point)))
1700 (defun gnus-group-rename-group (group new-name)
1701 "Rename group from GROUP to NEW-NAME.
1702 When used interactively, GROUP is the group under point
1703 and NEW-NAME will be prompted for."
1706 (gnus-group-group-name)
1708 (unless (gnus-check-backend-function
1709 'request-rename-group (gnus-group-group-name))
1710 (error "This backend does not support renaming groups"))
1711 (read-string "New group name: " (gnus-group-group-name)))))
1713 (unless (gnus-check-backend-function 'request-rename-group group)
1714 (error "This backend does not support renaming groups"))
1716 (error "No group to rename"))
1717 (when (string-match "^[ \t]*$" new-name)
1718 (error "Not a valid group name"))
1719 (when (equal group new-name)
1720 (error "Can't rename to the same name"))
1722 ;; We find the proper prefixed name.
1724 (if (equal (gnus-group-real-name new-name) new-name)
1728 (gnus-group-prefixed-name
1729 (gnus-group-real-name new-name)
1730 (gnus-info-method (gnus-get-info group)))))
1732 (gnus-message 6 "Renaming group %s to %s..." group new-name)
1734 (if (not (gnus-request-rename-group group new-name))
1735 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
1736 ;; We rename the group internally by killing it...
1737 (gnus-group-goto-group group)
1738 (gnus-group-kill-group)
1739 ;; ... changing its name ...
1740 (setcar (cdar gnus-list-of-killed-groups) new-name)
1741 ;; ... and then yanking it. Magic!
1742 (gnus-group-yank-group)
1743 (gnus-set-active new-name (gnus-active group))
1744 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
1746 (gnus-group-position-point)))
1748 (defun gnus-group-edit-group (group &optional part)
1749 "Edit the group on the current line."
1750 (interactive (list (gnus-group-group-name)))
1751 (let ((part (or part 'info))
1754 (error "No group on current line"))
1755 (unless (setq info (gnus-get-info group))
1756 (error "Killed group; can't be edited"))
1758 ;; Find the proper form to edit.
1759 (cond ((eq part 'method)
1760 (or (gnus-info-method info) "native"))
1762 (gnus-info-params info))
1764 ;; The proper documentation.
1768 ((eq part 'method) "select method")
1769 ((eq part 'params) "group parameters")
1772 (gnus-group-edit-group-done ',part ,group form)))))
1774 (defun gnus-group-edit-group-method (group)
1775 "Edit the select method of GROUP."
1776 (interactive (list (gnus-group-group-name)))
1777 (gnus-group-edit-group group 'method))
1779 (defun gnus-group-edit-group-parameters (group)
1780 "Edit the group parameters of GROUP."
1781 (interactive (list (gnus-group-group-name)))
1782 (gnus-group-edit-group group 'params))
1784 (defun gnus-group-edit-group-done (part group form)
1786 (let* ((method (cond ((eq part 'info) (nth 4 form))
1787 ((eq part 'method) form)
1789 (info (cond ((eq part 'info) form)
1790 ((eq part 'method) (gnus-get-info group))
1793 (if (or (not method)
1795 gnus-select-method method))
1796 (gnus-group-real-name (car info))
1797 (gnus-group-prefixed-name
1798 (gnus-group-real-name (car info)) method))
1800 (when (and new-group
1801 (not (equal new-group group)))
1802 (when (gnus-group-goto-group group)
1803 (gnus-group-kill-group 1))
1804 (gnus-activate-group new-group))
1806 (if (not (and info new-group))
1807 (gnus-group-set-info form (or new-group group) part)
1808 (setq info (gnus-copy-sequence info))
1809 (setcar info new-group)
1810 (unless (gnus-server-equal method "native")
1811 (unless (nthcdr 3 info)
1812 (nconc info (list nil nil)))
1813 (unless (nthcdr 4 info)
1814 (nconc info (list nil)))
1815 (gnus-info-set-method info method))
1816 (gnus-group-set-info info))
1817 (gnus-group-update-group (or new-group group))
1818 (gnus-group-position-point)))
1820 (defun gnus-group-make-useful-group (group method)
1822 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
1824 gnus-useful-groups)))
1825 (list (cadr entry) (caddr entry))))
1826 (setq method (gnus-copy-sequence method))
1828 (while (setq entry (memq (assq 'eval method) method))
1829 (setcar entry (eval (cadar entry)))))
1830 (gnus-group-make-group group method))
1832 (defun gnus-group-make-help-group ()
1833 "Create the Gnus documentation group."
1835 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
1836 (file (nnheader-find-etc-directory "gnus-tut.txt" t))
1838 (when (gnus-gethash name gnus-newsrc-hashtb)
1839 (error "Documentation group already exists"))
1841 (gnus-message 1 "Couldn't find doc group")
1842 (gnus-group-make-group
1843 (gnus-group-real-name name)
1844 (list 'nndoc "gnus-help"
1845 (list 'nndoc-address file)
1846 (list 'nndoc-article-type 'mbox)))))
1847 (gnus-group-position-point))
1849 (defun gnus-group-make-doc-group (file type)
1850 "Create a group that uses a single file as the source."
1852 (list (read-file-name "File name: ")
1853 (and current-prefix-arg 'ask)))
1854 (when (eq type 'ask)
1859 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
1861 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
1862 ((= char ?b) 'babyl)
1863 ((= char ?d) 'digest)
1864 ((= char ?f) 'forward)
1866 (t (setq err (format "%c unknown. " char))
1869 (let* ((file (expand-file-name file))
1870 (name (gnus-generate-new-group-name
1871 (gnus-group-prefixed-name
1872 (file-name-nondirectory file) '(nndoc "")))))
1873 (gnus-group-make-group
1874 (gnus-group-real-name name)
1876 (list 'nndoc-address file)
1877 (list 'nndoc-article-type (or type 'guess))))))
1879 (defvar nnweb-type-definition)
1880 (defvar gnus-group-web-type-history nil)
1881 (defvar gnus-group-web-search-history nil)
1882 (defun gnus-group-make-web-group (&optional solid)
1883 "Create an ephemeral nnweb group.
1884 If SOLID (the prefix), create a solid group."
1888 (if solid (read-string "Group name: ") (message-unique-id)))
1891 "Search engine type: "
1892 (mapcar (lambda (elem) (list (symbol-name (car elem))))
1893 nnweb-type-definition)
1894 nil t (cons (or (car gnus-group-web-type-history)
1895 (symbol-name (caar nnweb-type-definition)))
1897 'gnus-group-web-type-history))
1901 (cons (or (car gnus-group-web-search-history) "") 0)
1902 'gnus-group-web-search-history))
1904 `(nnweb ,group (nnweb-search ,search)
1905 (nnweb-type ,(intern type))
1906 (nnweb-ephemeral-p t))))
1908 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
1909 (gnus-group-read-ephemeral-group
1911 (cons (current-buffer)
1912 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
1914 (defun gnus-group-make-archive-group (&optional all)
1915 "Create the (ding) Gnus archive group of the most recent articles.
1916 Given a prefix, create a full group."
1918 (let ((group (gnus-group-prefixed-name
1919 (if all "ding.archives" "ding.recent") '(nndir ""))))
1920 (when (gnus-gethash group gnus-newsrc-hashtb)
1921 (error "Archive group already exists"))
1922 (gnus-group-make-group
1923 (gnus-group-real-name group)
1924 (list 'nndir (if all "hpc" "edu")
1925 (list 'nndir-directory
1926 (if all gnus-group-archive-directory
1927 gnus-group-recent-archive-directory))))
1928 (gnus-group-add-parameter group (cons 'to-address "ding@ifi.uio.no"))))
1930 (defun gnus-group-make-directory-group (dir)
1931 "Create an nndir group.
1932 The user will be prompted for a directory. The contents of this
1933 directory will be used as a newsgroup. The directory should contain
1934 mail messages or news articles in files that have numeric names."
1936 (list (read-file-name "Create group from directory: ")))
1937 (unless (file-exists-p dir)
1938 (error "No such directory"))
1939 (unless (file-directory-p dir)
1940 (error "Not a directory"))
1944 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
1946 (gnus-group-prefixed-name
1947 (concat (file-name-as-directory (directory-file-name dir))
1950 (setq ext (format "<%d>" (setq i (1+ i)))))
1951 (gnus-group-make-group
1952 (gnus-group-real-name group)
1953 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
1955 (defun gnus-group-make-kiboze-group (group address scores)
1956 "Create an nnkiboze group.
1957 The user will be prompted for a name, a regexp to match groups, and
1958 score file entries for articles to include in the group."
1961 (read-string "nnkiboze group name: ")
1962 (read-string "Source groups (regexp): ")
1963 (let ((headers (mapcar (lambda (group) (list group))
1964 '("subject" "from" "number" "date" "message-id"
1965 "references" "chars" "lines" "xref"
1966 "followup" "all" "body" "head")))
1967 scores header regexp regexps)
1968 (while (not (equal "" (setq header (completing-read
1969 "Match on header: " headers nil t))))
1971 (while (not (equal "" (setq regexp (read-string
1972 (format "Match on %s (string): "
1974 (push (list regexp nil nil 'r) regexps))
1975 (push (cons header regexps) scores))
1977 (gnus-group-make-group group "nnkiboze" address)
1978 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
1979 (let (emacs-lisp-mode-hook)
1980 (pp scores (current-buffer)))))
1982 (defun gnus-group-add-to-virtual (n vgroup)
1983 "Add the current group to a virtual group."
1985 (list current-prefix-arg
1986 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
1988 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
1989 (error "%s is not an nnvirtual group" vgroup))
1990 (let* ((groups (gnus-group-process-prefix n))
1991 (method (gnus-info-method (gnus-get-info vgroup))))
1992 (setcar (cdr method)
1994 (nth 1 method) "\\|"
1997 (gnus-group-remove-mark s)
1998 (concat "\\(^" (regexp-quote s) "$\\)"))
2000 (gnus-group-position-point))
2002 (defun gnus-group-make-empty-virtual (group)
2003 "Create a new, fresh, empty virtual group."
2004 (interactive "sCreate new, empty virtual group: ")
2005 (let* ((method (list 'nnvirtual "^$"))
2006 (pgroup (gnus-group-prefixed-name group method)))
2007 ;; Check whether it exists already.
2008 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2009 (error "Group %s already exists." pgroup))
2010 ;; Subscribe the new group after the group on the current line.
2011 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2012 (gnus-group-update-group pgroup)
2014 (gnus-group-position-point)))
2016 (defun gnus-group-enter-directory (dir)
2017 "Enter an ephemeral nneething group."
2018 (interactive "DDirectory to read: ")
2019 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2020 (leaf (gnus-group-prefixed-name
2021 (file-name-nondirectory (directory-file-name dir))
2023 (name (gnus-generate-new-group-name leaf)))
2024 (unless (gnus-group-read-ephemeral-group
2026 (cons (current-buffer)
2027 (if (eq major-mode 'gnus-summary-mode)
2029 (error "Couldn't enter %s" dir))))
2031 ;; Group sorting commands
2032 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2034 (defun gnus-group-sort-groups (func &optional reverse)
2035 "Sort the group buffer according to FUNC.
2036 If REVERSE, reverse the sorting order."
2037 (interactive (list gnus-group-sort-function current-prefix-arg))
2038 (funcall gnus-group-sort-alist-function
2039 (gnus-make-sort-function func) reverse)
2040 (gnus-group-list-groups))
2042 (defun gnus-group-sort-flat (func reverse)
2043 ;; We peel off the dummy group from the alist.
2045 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
2046 (pop gnus-newsrc-alist))
2048 (setq gnus-newsrc-alist
2049 (sort gnus-newsrc-alist func))
2051 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2052 ;; Regenerate the hash table.
2053 (gnus-make-hashtable-from-newsrc-alist)))
2055 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2056 "Sort the group buffer alphabetically by group name.
2057 If REVERSE, sort in reverse order."
2059 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2061 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2062 "Sort the group buffer by number of unread articles.
2063 If REVERSE, sort in reverse order."
2065 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2067 (defun gnus-group-sort-groups-by-level (&optional reverse)
2068 "Sort the group buffer by group level.
2069 If REVERSE, sort in reverse order."
2071 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2073 (defun gnus-group-sort-groups-by-score (&optional reverse)
2074 "Sort the group buffer by group score.
2075 If REVERSE, sort in reverse order."
2077 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2079 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2080 "Sort the group buffer by group rank.
2081 If REVERSE, sort in reverse order."
2083 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2085 (defun gnus-group-sort-groups-by-method (&optional reverse)
2086 "Sort the group buffer alphabetically by backend name.
2087 If REVERSE, sort in reverse order."
2089 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2091 ;;; Selected group sorting.
2093 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2094 "Sort the process/prefixed groups."
2095 (interactive (list current-prefix-arg gnus-group-sort-function))
2096 (let ((groups (gnus-group-process-prefix n)))
2097 (funcall gnus-group-sort-selected-function
2098 groups (gnus-make-sort-function func) reverse)
2099 (gnus-group-list-groups)))
2101 (defun gnus-group-sort-selected-flat (groups func reverse)
2102 (let (entries infos)
2103 ;; First find all the group entries for these groups.
2105 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2107 ;; Then sort the infos.
2111 (lambda (entry) (car entry))
2112 (setq entries (nreverse entries)))
2115 (setq infos (nreverse infos)))
2116 ;; Go through all the infos and replace the old entries
2117 ;; with the new infos.
2119 (setcar entries (pop infos))
2121 ;; Update the hashtable.
2122 (gnus-make-hashtable-from-newsrc-alist)))
2124 (defun gnus-group-sort-selected-groups-by-alphabet (&optional reverse)
2125 "Sort the group buffer alphabetically by group name.
2126 If REVERSE, sort in reverse order."
2128 (gnus-group-sort-selected-groups 'gnus-group-sort-by-alphabet reverse))
2130 (defun gnus-group-sort-selected-groups-by-unread (&optional reverse)
2131 "Sort the group buffer by number of unread articles.
2132 If REVERSE, sort in reverse order."
2134 (gnus-group-sort-selected-groups 'gnus-group-sort-by-unread reverse))
2136 (defun gnus-group-sort-selected-groups-by-level (&optional reverse)
2137 "Sort the group buffer by group level.
2138 If REVERSE, sort in reverse order."
2140 (gnus-group-sort-selected-groups 'gnus-group-sort-by-level reverse))
2142 (defun gnus-group-sort-selected-groups-by-score (&optional reverse)
2143 "Sort the group buffer by group score.
2144 If REVERSE, sort in reverse order."
2146 (gnus-group-sort-selected-groups 'gnus-group-sort-by-score reverse))
2148 (defun gnus-group-sort-selected-groups-by-rank (&optional reverse)
2149 "Sort the group buffer by group rank.
2150 If REVERSE, sort in reverse order."
2152 (gnus-group-sort-selected-groups 'gnus-group-sort-by-rank reverse))
2154 (defun gnus-group-sort-selected-groups-by-method (&optional reverse)
2155 "Sort the group buffer alphabetically by backend name.
2156 If REVERSE, sort in reverse order."
2158 (gnus-group-sort-selected-groups 'gnus-group-sort-by-method reverse))
2160 ;;; Sorting predicates.
2162 (defun gnus-group-sort-by-alphabet (info1 info2)
2163 "Sort alphabetically."
2164 (string< (gnus-info-group info1) (gnus-info-group info2)))
2166 (defun gnus-group-sort-by-real-name (info1 info2)
2167 "Sort alphabetically on real (unprefixed) names."
2168 (string< (gnus-group-real-name (gnus-info-group info1))
2169 (gnus-group-real-name (gnus-info-group info2))))
2171 (defun gnus-group-sort-by-unread (info1 info2)
2172 "Sort by number of unread articles."
2173 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2174 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2175 (< (or (and (numberp n1) n1) 0)
2176 (or (and (numberp n2) n2) 0))))
2178 (defun gnus-group-sort-by-level (info1 info2)
2180 (< (gnus-info-level info1) (gnus-info-level info2)))
2182 (defun gnus-group-sort-by-method (info1 info2)
2183 "Sort alphabetically by backend name."
2184 (string< (symbol-name (car (gnus-find-method-for-group
2185 (gnus-info-group info1) info1)))
2186 (symbol-name (car (gnus-find-method-for-group
2187 (gnus-info-group info2) info2)))))
2189 (defun gnus-group-sort-by-score (info1 info2)
2190 "Sort by group score."
2191 (< (gnus-info-score info1) (gnus-info-score info2)))
2193 (defun gnus-group-sort-by-rank (info1 info2)
2194 "Sort by level and score."
2195 (let ((level1 (gnus-info-level info1))
2196 (level2 (gnus-info-level info2)))
2197 (or (< level1 level2)
2198 (and (= level1 level2)
2199 (> (gnus-info-score info1) (gnus-info-score info2))))))
2203 (defun gnus-group-clear-data (n)
2204 "Clear all marks and read ranges from the current group."
2206 (let ((groups (gnus-group-process-prefix n))
2208 (while (setq group (pop groups))
2209 (gnus-info-clear-data (setq info (gnus-get-info group)))
2210 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2211 (when (gnus-group-goto-group group)
2212 (gnus-group-remove-mark group)
2213 (gnus-group-update-group-line)))))
2215 (defun gnus-group-clear-data-on-native-groups ()
2216 "Clear all marks and read ranges from all native groups."
2218 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2219 (let ((alist (cdr gnus-newsrc-alist))
2221 (while (setq info (pop alist))
2222 (gnus-info-clear-data info))
2223 (gnus-get-unread-articles))))
2225 (defun gnus-info-clear-data (info)
2226 "Clear all marks and read ranges from INFO."
2227 (let ((group (gnus-info-group info)))
2230 (gnus-info-set-marks ,info ,(gnus-info-marks info))
2231 (gnus-info-set-read ,info ,(gnus-info-read info))
2232 (when (gnus-group-goto-group ,group)
2233 (gnus-group-update-group-line))))
2234 (gnus-info-set-read info nil)
2235 (when (gnus-info-marks info)
2236 (gnus-info-set-marks info nil))))
2238 ;; Group catching up.
2240 (defun gnus-group-catchup-current (&optional n all)
2241 "Mark all articles not marked as unread in current newsgroup as read.
2242 If prefix argument N is numeric, the ARG next newsgroups will be
2243 caught up. If ALL is non-nil, marked articles will also be marked as
2244 read. Cross references (Xref: header) of articles are ignored.
2245 The difference between N and actual number of newsgroups that were
2246 caught up is returned."
2248 (unless (gnus-group-group-name)
2249 (error "No group on the current line"))
2250 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
2254 "Do you really want to mark all articles as read? "
2255 "Mark all unread articles as read? "))))
2257 (let ((groups (gnus-group-process-prefix n))
2260 ;; Virtual groups have to be given special treatment.
2261 (let ((method (gnus-find-method-for-group (car groups))))
2262 (when (eq 'nnvirtual (car method))
2263 (nnvirtual-catchup-group
2264 (gnus-group-real-name (car groups)) (nth 1 method) all)))
2265 (gnus-group-remove-mark (car groups))
2266 (if (>= (gnus-group-group-level) gnus-level-zombie)
2267 (gnus-message 2 "Dead groups can't be caught up")
2269 (gnus-group-goto-group (car groups))
2270 (gnus-group-catchup (car groups) all))
2271 (gnus-group-update-group-line)
2272 (setq ret (1+ ret))))
2273 (setq groups (cdr groups)))
2274 (gnus-group-next-unread-group 1)
2277 (defun gnus-group-catchup-current-all (&optional n)
2278 "Mark all articles in current newsgroup as read.
2279 Cross references (Xref: header) of articles are ignored."
2281 (gnus-group-catchup-current n 'all))
2283 (defun gnus-group-catchup (group &optional all)
2284 "Mark all articles in GROUP as read.
2285 If ALL is non-nil, all articles are marked as read.
2286 The return value is the number of articles that were marked as read,
2287 or nil if no action could be taken."
2288 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2290 ;; Do the updating only if the newsgroup isn't killed.
2291 (if (not (numberp (car entry)))
2292 (gnus-message 1 "Can't catch up; non-active group")
2293 ;; Do auto-expirable marks if that's required.
2294 (when (gnus-group-auto-expirable-p group)
2295 (gnus-add-marked-articles
2296 group 'expire (gnus-list-of-unread-articles group))
2298 (let ((marks (nth 3 (nth 2 entry))))
2299 (gnus-add-marked-articles
2300 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2301 (gnus-add-marked-articles
2302 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2304 (gnus-update-read-articles group nil)
2305 ;; Also nix out the lists of marks and dormants.
2307 (gnus-add-marked-articles group 'tick nil nil 'force)
2308 (gnus-add-marked-articles group 'dormant nil nil 'force))
2309 (run-hooks 'gnus-group-catchup-group-hook)
2312 (defun gnus-group-expire-articles (&optional n)
2313 "Expire all expirable articles in the current newsgroup."
2315 (let ((groups (gnus-group-process-prefix n))
2318 (error "No groups to expire"))
2319 (while (setq group (pop groups))
2320 (gnus-group-remove-mark group)
2321 (when (gnus-check-backend-function 'request-expire-articles group)
2322 (gnus-message 6 "Expiring articles in %s..." group)
2323 (let* ((info (gnus-get-info group))
2324 (expirable (if (gnus-group-total-expirable-p group)
2325 (cons nil (gnus-list-of-read-articles group))
2326 (assq 'expire (gnus-info-marks info))))
2327 (expiry-wait (gnus-group-find-parameter group 'expiry-wait)))
2331 (gnus-compress-sequence
2333 ;; We set the expiry variables to the group
2335 (let ((nnmail-expiry-wait-function nil)
2336 (nnmail-expiry-wait expiry-wait))
2337 (gnus-request-expire-articles
2338 (gnus-uncompress-sequence (cdr expirable)) group))
2339 ;; Just expire using the normal expiry values.
2340 (gnus-request-expire-articles
2341 (gnus-uncompress-sequence (cdr expirable)) group))))
2342 (gnus-close-group group))
2343 (gnus-message 6 "Expiring articles in %s...done" group)))
2344 (gnus-group-position-point))))
2346 (defun gnus-group-expire-all-groups ()
2347 "Expire all expirable articles in all newsgroups."
2350 (gnus-message 5 "Expiring...")
2351 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2352 (cdr gnus-newsrc-alist))))
2353 (gnus-group-expire-articles nil)))
2354 (gnus-group-position-point)
2355 (gnus-message 5 "Expiring...done"))
2357 (defun gnus-group-set-current-level (n level)
2358 "Set the level of the next N groups to LEVEL."
2363 (let ((s (read-string
2364 (format "Level (default %s): "
2365 (or (gnus-group-group-level)
2366 gnus-level-default-subscribed)))))
2367 (if (string-match "^\\s-*$" s)
2368 (int-to-string (or (gnus-group-group-level)
2369 gnus-level-default-subscribed))
2371 (unless (and (>= level 1) (<= level gnus-level-killed))
2372 (error "Illegal level: %d" level))
2373 (let ((groups (gnus-group-process-prefix n))
2375 (while (setq group (pop groups))
2376 (gnus-group-remove-mark group)
2377 (gnus-message 6 "Changed level of %s from %d to %d"
2378 group (or (gnus-group-group-level) gnus-level-killed)
2380 (gnus-group-change-level
2381 group level (or (gnus-group-group-level) gnus-level-killed))
2382 (gnus-group-update-group-line)))
2383 (gnus-group-position-point))
2385 (defun gnus-group-unsubscribe (&optional n)
2386 "Unsubscribe the current group."
2388 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2390 (defun gnus-group-subscribe (&optional n)
2391 "Unsubscribe the current group."
2393 (gnus-group-unsubscribe-current-group n 'subscribe))
2395 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2396 "Toggle subscription of the current group.
2397 If given numerical prefix, toggle the N next groups."
2399 (let ((groups (gnus-group-process-prefix n))
2402 (setq group (car groups)
2403 groups (cdr groups))
2404 (gnus-group-remove-mark group)
2405 (gnus-group-unsubscribe-group
2408 ((eq do-sub 'unsubscribe)
2409 gnus-level-default-unsubscribed)
2410 ((eq do-sub 'subscribe)
2411 gnus-level-default-subscribed)
2412 ((<= (gnus-group-group-level) gnus-level-subscribed)
2413 gnus-level-default-unsubscribed)
2415 gnus-level-default-subscribed))
2417 (gnus-group-update-group-line))
2418 (gnus-group-next-group 1)))
2420 (defun gnus-group-unsubscribe-group (group &optional level silent)
2421 "Toggle subscription to GROUP.
2422 Killed newsgroups are subscribed. If SILENT, don't try to update the
2425 (list (completing-read
2426 "Group: " gnus-active-hashtb nil
2427 (gnus-read-active-file-p)
2429 'gnus-group-history)))
2430 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2432 ((string-match "^[ \t]$" group)
2433 (error "Empty group name"))
2435 ;; Toggle subscription flag.
2436 (gnus-group-change-level
2437 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
2438 gnus-level-subscribed)
2439 (1+ gnus-level-subscribed)
2440 gnus-level-default-subscribed)))
2442 (gnus-group-update-group group)))
2443 ((and (stringp group)
2444 (or (not (gnus-read-active-file-p))
2445 (gnus-active group)))
2446 ;; Add new newsgroup.
2447 (gnus-group-change-level
2449 (if level level gnus-level-default-subscribed)
2450 (or (and (member group gnus-zombie-list)
2453 (when (gnus-group-group-name)
2454 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2456 (gnus-group-update-group group)))
2457 (t (error "No such newsgroup: %s" group)))
2458 (gnus-group-position-point)))
2460 (defun gnus-group-transpose-groups (n)
2461 "Move the current newsgroup up N places.
2462 If given a negative prefix, move down instead. The difference between
2463 N and the number of steps taken is returned."
2465 (unless (gnus-group-group-name)
2466 (error "No group on current line"))
2467 (gnus-group-kill-group 1)
2469 (forward-line (- n))
2470 (gnus-group-yank-group)
2471 (gnus-group-position-point)))
2473 (defun gnus-group-kill-all-zombies ()
2474 "Kill all zombie newsgroups."
2476 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2477 (setq gnus-zombie-list nil)
2478 (gnus-group-list-groups))
2480 (defun gnus-group-kill-region (begin end)
2481 "Kill newsgroups in current region (excluding current point).
2482 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2497 (beginning-of-line) ;Important when LINES < 1
2498 (gnus-group-kill-group lines)))
2500 (defun gnus-group-kill-group (&optional n discard)
2501 "Kill the next N groups.
2502 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2503 However, only groups that were alive can be yanked; already killed
2504 groups or zombie groups can't be yanked.
2505 The return value is the name of the group that was killed, or a list
2508 (let ((buffer-read-only nil)
2509 (groups (gnus-group-process-prefix n))
2510 group entry level out)
2511 (if (< (length groups) 10)
2512 ;; This is faster when there are few groups.
2514 (push (setq group (pop groups)) out)
2515 (gnus-group-remove-mark group)
2516 (setq level (gnus-group-group-level))
2518 (when (and (not discard)
2519 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2522 (gnus-group-goto-group ,(gnus-group-group-name))
2523 (gnus-group-yank-group)))
2524 (push (cons (car entry) (nth 2 entry))
2525 gnus-list-of-killed-groups))
2526 (gnus-group-change-level
2527 (if entry entry group) gnus-level-killed (if entry nil level)))
2528 ;; If there are lots and lots of groups to be killed, we use
2529 ;; this thing instead.
2531 (setq groups (nreverse groups))
2533 (gnus-group-remove-mark (setq group (pop groups)))
2535 (push group gnus-killed-list)
2536 (setq gnus-newsrc-alist
2537 (delq (assoc group gnus-newsrc-alist)
2539 (when gnus-group-change-level-function
2540 (funcall gnus-group-change-level-function group 9 3))
2542 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2543 (push (cons (car entry) (nth 2 entry))
2544 gnus-list-of-killed-groups)
2545 (setcdr (cdr entry) (cdddr entry)))
2546 ((member group gnus-zombie-list)
2547 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
2548 (gnus-make-hashtable-from-newsrc-alist)))
2550 (gnus-group-position-point)
2551 (if (< (length out) 2) (car out) (nreverse out))))
2553 (defun gnus-group-yank-group (&optional arg)
2554 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
2555 inserting it before the current newsgroup. The numeric ARG specifies
2556 how many newsgroups are to be yanked. The name of the newsgroup yanked
2557 is returned, or (if several groups are yanked) a list of yanked groups
2560 (setq arg (or arg 1))
2561 (let (info group prev out)
2562 (while (>= (decf arg) 0)
2563 (when (not (setq info (pop gnus-list-of-killed-groups)))
2564 (error "No more newsgroups to yank"))
2565 (push (setq group (nth 1 info)) out)
2566 ;; Find which newsgroup to insert this one before - search
2567 ;; backward until something suitable is found. If there are no
2568 ;; other newsgroups in this buffer, just make this newsgroup the
2570 (setq prev (gnus-group-group-name))
2571 (gnus-group-change-level
2572 info (gnus-info-level (cdr info)) gnus-level-killed
2573 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
2575 (gnus-group-insert-group-line-info group)
2577 `(when (gnus-group-goto-group ,group)
2578 (gnus-group-kill-group 1))))
2580 (gnus-group-position-point)
2581 (if (< (length out) 2) (car out) (nreverse out))))
2583 (defun gnus-group-kill-level (level)
2584 "Kill all groups that is on a certain LEVEL."
2585 (interactive "nKill all groups on level: ")
2587 ((= level gnus-level-zombie)
2588 (setq gnus-killed-list
2589 (nconc gnus-zombie-list gnus-killed-list))
2590 (setq gnus-zombie-list nil))
2591 ((and (< level gnus-level-zombie)
2593 (or gnus-expert-user
2596 "Do you really want to kill all groups on level %d? "
2598 (let* ((prev gnus-newsrc-alist)
2601 (if (= (gnus-info-level (car alist)) level)
2603 (push (gnus-info-group (car alist)) gnus-killed-list)
2604 (setcdr prev (cdr alist)))
2606 (setq alist (cdr alist)))
2607 (gnus-make-hashtable-from-newsrc-alist)
2608 (gnus-group-list-groups)))
2610 (error "Can't kill; illegal level: %d" level))))
2612 (defun gnus-group-list-all-groups (&optional arg)
2613 "List all newsgroups with level ARG or lower.
2614 Default is gnus-level-unsubscribed, which lists all subscribed and most
2615 unsubscribed groups."
2617 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
2619 ;; Redefine this to list ALL killed groups if prefix arg used.
2620 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
2621 (defun gnus-group-list-killed (&optional arg)
2622 "List all killed newsgroups in the group buffer.
2623 If ARG is non-nil, list ALL killed groups known to Gnus. This may
2624 entail asking the server for the groups."
2626 ;; Find all possible killed newsgroups if arg.
2628 (gnus-get-killed-groups))
2629 (if (not gnus-killed-list)
2630 (gnus-message 6 "No killed groups")
2631 (let (gnus-group-list-mode)
2632 (funcall gnus-group-prepare-function
2633 gnus-level-killed t gnus-level-killed))
2634 (goto-char (point-min)))
2635 (gnus-group-position-point))
2637 (defun gnus-group-list-zombies ()
2638 "List all zombie newsgroups in the group buffer."
2640 (if (not gnus-zombie-list)
2641 (gnus-message 6 "No zombie groups")
2642 (let (gnus-group-list-mode)
2643 (funcall gnus-group-prepare-function
2644 gnus-level-zombie t gnus-level-zombie))
2645 (goto-char (point-min)))
2646 (gnus-group-position-point))
2648 (defun gnus-group-list-active ()
2649 "List all groups that are available from the server(s)."
2651 ;; First we make sure that we have really read the active file.
2652 (unless (gnus-read-active-file-p)
2653 (let ((gnus-read-active-file t))
2654 (gnus-read-active-file)))
2655 ;; Find all groups and sort them.
2663 (push (symbol-name sym) list)))
2667 (buffer-read-only nil))
2670 (gnus-group-insert-group-line-info (pop groups)))
2671 (goto-char (point-min))))
2673 (defun gnus-activate-all-groups (level)
2674 "Activate absolutely all groups."
2675 (interactive (list 7))
2676 (let ((gnus-activate-level level)
2677 (gnus-activate-foreign-newsgroups level))
2678 (gnus-group-get-new-news)))
2680 (defun gnus-group-get-new-news (&optional arg)
2681 "Get newly arrived articles.
2682 If ARG is a number, it specifies which levels you are interested in
2683 re-scanning. If ARG is non-nil and not a number, this will force
2684 \"hard\" re-reading of the active files from all servers."
2686 (run-hooks 'gnus-get-new-news-hook)
2688 ;; Read any slave files.
2690 (gnus-master-read-slave-newsrc))
2692 ;; We might read in new NoCeM messages here.
2693 (when (and gnus-use-nocem
2695 (gnus-nocem-scan-groups))
2696 ;; If ARG is not a number, then we read the active file.
2697 (when (and arg (not (numberp arg)))
2698 (let ((gnus-read-active-file t))
2699 (gnus-read-active-file))
2702 (setq arg (gnus-group-default-level arg t))
2703 (if (and gnus-read-active-file (not arg))
2705 (gnus-read-active-file)
2706 (gnus-get-unread-articles arg))
2707 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
2708 (gnus-get-unread-articles arg)))
2709 (run-hooks 'gnus-after-getting-new-news-hook)
2710 (gnus-group-list-groups))
2712 (defun gnus-group-get-new-news-this-group (&optional n)
2713 "Check for newly arrived news in the current group (and the N-1 next groups).
2714 The difference between N and the number of newsgroup checked is returned.
2715 If N is negative, this group and the N-1 previous groups will be checked."
2717 (let* ((groups (gnus-group-process-prefix n))
2718 (ret (if (numberp n) (- n (length groups)) 0))
2722 (while (setq group (pop groups))
2723 (gnus-group-remove-mark group)
2724 ;; Bypass any previous denials from the server.
2725 (gnus-remove-denial (gnus-find-method-for-group group))
2726 (if (gnus-activate-group group 'scan)
2728 (gnus-get-unread-articles-in-group
2729 (gnus-get-info group) (gnus-active group) t)
2730 (unless (gnus-virtual-group-p group)
2731 (gnus-close-group group))
2732 (gnus-group-update-group group))
2733 (if (eq (gnus-server-status (gnus-find-method-for-group group))
2735 (gnus-error 3 "Server denied access")
2736 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
2739 (when gnus-goto-next-group-when-activating
2740 (gnus-group-next-unread-group 1 t))
2741 (gnus-summary-position-point)
2744 (defun gnus-group-fetch-faq (group &optional faq-dir)
2745 "Fetch the FAQ for the current group.
2746 If given a prefix argument, prompt for the FAQ dir
2750 (gnus-group-group-name)
2751 (cond (current-prefix-arg
2753 "Faq dir: " (and (listp gnus-group-faq-directory)
2754 (mapcar (lambda (file) (list file))
2755 gnus-group-faq-directory)))))))
2757 (error "No group name given"))
2758 (let ((dirs (or faq-dir gnus-group-faq-directory))
2760 (unless (listp dirs)
2761 (setq dirs (list dirs)))
2762 (while (and (not found)
2763 (setq dir (pop dirs)))
2764 (setq file (concat (file-name-as-directory dir)
2765 (gnus-group-real-name group)))
2766 (if (not (file-exists-p file))
2767 (gnus-message 1 "No such file: %s" file)
2771 (defun gnus-group-describe-group (force &optional group)
2772 "Display a description of the current newsgroup."
2773 (interactive (list current-prefix-arg (gnus-group-group-name)))
2774 (let* ((method (gnus-find-method-for-group group))
2775 (mname (gnus-group-prefixed-name "" method))
2778 gnus-description-hashtb)
2779 (gnus-sethash mname nil gnus-description-hashtb))
2781 (error "No group name given"))
2782 (when (or (and gnus-description-hashtb
2783 ;; We check whether this group's method has been
2784 ;; queried for a description file.
2785 (gnus-gethash mname gnus-description-hashtb))
2786 (setq desc (gnus-group-get-description group))
2787 (gnus-read-descriptions-file method))
2789 (or desc (gnus-gethash group gnus-description-hashtb)
2790 "No description available")))))
2792 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
2793 (defun gnus-group-describe-all-groups (&optional force)
2794 "Pop up a buffer with descriptions of all newsgroups."
2797 (setq gnus-description-hashtb nil))
2798 (when (not (or gnus-description-hashtb
2799 (gnus-read-all-descriptions-files)))
2800 (error "Couldn't request descriptions file"))
2801 (let ((buffer-read-only nil)
2807 (insert (format " *: %-20s %s\n" (symbol-name group)
2808 (symbol-value group)))
2809 (gnus-add-text-properties
2810 b (1+ b) (list 'gnus-group group
2811 'gnus-unread t 'gnus-marked nil
2812 'gnus-level (1+ gnus-level-subscribed))))
2813 gnus-description-hashtb)
2814 (goto-char (point-min))
2815 (gnus-group-position-point)))
2817 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
2818 (defun gnus-group-apropos (regexp &optional search-description)
2819 "List all newsgroups that have names that match a regexp."
2820 (interactive "sGnus apropos (regexp): ")
2822 (obuf (current-buffer))
2824 ;; Go through all newsgroups that are known to Gnus.
2827 (and (symbol-name group)
2828 (string-match regexp (symbol-name group))
2829 (push (symbol-name group) groups)))
2831 ;; Also go through all descriptions that are known to Gnus.
2832 (when search-description
2835 (and (string-match regexp (symbol-value group))
2836 (gnus-active (symbol-name group))
2837 (push (symbol-name group) groups)))
2838 gnus-description-hashtb))
2840 (gnus-message 3 "No groups matched \"%s\"." regexp)
2841 ;; Print out all the groups.
2843 (pop-to-buffer "*Gnus Help*")
2844 (buffer-disable-undo (current-buffer))
2846 (setq groups (sort groups 'string<))
2848 ;; Groups may be entered twice into the list of groups.
2849 (when (not (string= (car groups) prev))
2850 (insert (setq prev (car groups)) "\n")
2851 (when (and gnus-description-hashtb
2852 (setq des (gnus-gethash (car groups)
2853 gnus-description-hashtb)))
2854 (insert " " des "\n")))
2855 (setq groups (cdr groups)))
2856 (goto-char (point-min))))
2857 (pop-to-buffer obuf)))
2859 (defun gnus-group-description-apropos (regexp)
2860 "List all newsgroups that have names or descriptions that match a regexp."
2861 (interactive "sGnus description apropos (regexp): ")
2862 (when (not (or gnus-description-hashtb
2863 (gnus-read-all-descriptions-files)))
2864 (error "Couldn't request descriptions file"))
2865 (gnus-group-apropos regexp t))
2867 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
2868 (defun gnus-group-list-matching (level regexp &optional all lowest)
2869 "List all groups with unread articles that match REGEXP.
2870 If the prefix LEVEL is non-nil, it should be a number that says which
2871 level to cut off listing groups.
2872 If ALL, also list groups with no unread articles.
2873 If LOWEST, don't list groups with level lower than LOWEST.
2875 This command may read the active file."
2876 (interactive "P\nsList newsgroups matching: ")
2877 ;; First make sure active file has been read.
2879 (> (prefix-numeric-value level) gnus-level-killed))
2880 (gnus-get-killed-groups))
2881 (gnus-group-prepare-flat (or level gnus-level-subscribed)
2882 all (or lowest 1) regexp)
2883 (goto-char (point-min))
2884 (gnus-group-position-point))
2886 (defun gnus-group-list-all-matching (level regexp &optional lowest)
2887 "List all groups that match REGEXP.
2888 If the prefix LEVEL is non-nil, it should be a number that says which
2889 level to cut off listing groups.
2890 If LOWEST, don't list groups with level lower than LOWEST."
2891 (interactive "P\nsList newsgroups matching: ")
2892 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
2894 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
2895 (defun gnus-group-save-newsrc (&optional force)
2896 "Save the Gnus startup files.
2897 If FORCE, force saving whether it is necessary or not."
2899 (gnus-save-newsrc-file force))
2901 (defun gnus-group-restart (&optional arg)
2902 "Force Gnus to read the .newsrc file."
2904 (when (gnus-yes-or-no-p
2905 (format "Are you sure you want to restart Gnus? "))
2906 (gnus-save-newsrc-file)
2907 (gnus-setup-news 'force)
2908 (gnus-group-list-groups arg)))
2910 (defun gnus-group-read-init-file ()
2911 "Read the Gnus elisp init file."
2913 (gnus-read-init-file))
2915 (defun gnus-group-check-bogus-groups (&optional silent)
2916 "Check bogus newsgroups.
2917 If given a prefix, don't ask for confirmation before removing a bogus
2920 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
2921 (gnus-group-list-groups))
2923 (defun gnus-group-edit-global-kill (&optional article group)
2924 "Edit the global kill file.
2925 If GROUP, edit that local kill file instead."
2927 (setq gnus-current-kill-article article)
2928 (gnus-kill-file-edit-file group)
2931 (substitute-command-keys
2932 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
2933 (if group "local" "global")))))
2935 (defun gnus-group-edit-local-kill (article group)
2936 "Edit a local kill file."
2937 (interactive (list nil (gnus-group-group-name)))
2938 (gnus-group-edit-global-kill article group))
2940 (defun gnus-group-force-update ()
2941 "Update `.newsrc' file."
2943 (gnus-save-newsrc-file))
2945 (defun gnus-group-suspend ()
2946 "Suspend the current Gnus session.
2947 In fact, cleanup buffers except for group mode buffer.
2948 The hook gnus-suspend-gnus-hook is called before actually suspending."
2950 (run-hooks 'gnus-suspend-gnus-hook)
2951 ;; Kill Gnus buffers except for group mode buffer.
2952 (let* ((group-buf (get-buffer gnus-group-buffer))
2953 ;; Do this on a separate list in case the user does a ^G before we finish
2955 (delete group-buf (delete gnus-dribble-buffer
2956 (append gnus-buffer-list nil)))))
2957 (while gnus-buffer-list
2958 (gnus-kill-buffer (pop gnus-buffer-list)))
2959 (gnus-kill-gnus-frames)
2961 (setq gnus-buffer-list (list group-buf))
2962 (bury-buffer group-buf)
2963 (delete-windows-on group-buf t))))
2965 (defun gnus-group-clear-dribble ()
2966 "Clear all information from the dribble buffer."
2968 (gnus-dribble-clear)
2969 (gnus-message 7 "Cleared dribble buffer"))
2971 (defun gnus-group-exit ()
2972 "Quit reading news after updating .newsrc.eld and .newsrc.
2973 The hook `gnus-exit-gnus-hook' is called before actually exiting."
2976 (or noninteractive ;For gnus-batch-kill
2977 (not gnus-interactive-exit) ;Without confirmation
2979 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
2980 (run-hooks 'gnus-exit-gnus-hook)
2981 ;; Offer to save data from non-quitted summary buffers.
2982 (gnus-offer-save-summaries)
2983 ;; Save the newsrc file(s).
2984 (gnus-save-newsrc-file)
2986 (gnus-close-backends)
2987 ;; Reset everything.
2989 ;; Allow the user to do things after cleaning up.
2990 (run-hooks 'gnus-after-exiting-gnus-hook)))
2992 (defun gnus-group-quit ()
2993 "Quit reading news without updating .newsrc.eld or .newsrc.
2994 The hook `gnus-exit-gnus-hook' is called before actually exiting."
2996 (when (or noninteractive ;For gnus-batch-kill
2997 (zerop (buffer-size))
2998 (not (gnus-server-opened gnus-select-method))
3000 (not gnus-current-startup-file)
3002 (format "Quit reading news without saving %s? "
3003 (file-name-nondirectory gnus-current-startup-file))))
3004 (run-hooks 'gnus-exit-gnus-hook)
3005 (gnus-configure-windows 'group t)
3007 (gnus-close-backends)
3009 (gnus-kill-buffer gnus-group-buffer)
3010 ;; Allow the user to do things after cleaning up.
3011 (run-hooks 'gnus-after-exiting-gnus-hook)))
3013 (defun gnus-group-describe-briefly ()
3014 "Give a one line description of the group mode commands."
3016 (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")))
3018 (defun gnus-group-browse-foreign-server (method)
3019 "Browse a foreign news server.
3020 If called interactively, this function will ask for a select method
3021 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3022 If not, METHOD should be a list where the first element is the method
3023 and the second element is the address."
3025 (list (let ((how (completing-read
3027 (append gnus-valid-select-methods gnus-server-alist)
3028 nil t (cons "nntp" 0) 'gnus-method-history)))
3029 ;; We either got a backend name or a virtual server name.
3030 ;; If the first, we also need an address.
3031 (if (assoc how gnus-valid-select-methods)
3033 ;; Suggested by mapjph@bath.ac.uk.
3036 (mapcar (lambda (server) (list server))
3037 gnus-secondary-servers)))
3038 ;; We got a server name, so we find the method.
3039 (gnus-server-to-method how)))))
3040 (gnus-browse-foreign-server method))
3042 (defun gnus-group-set-info (info &optional method-only-group part)
3043 (let* ((entry (gnus-gethash
3044 (or method-only-group (gnus-info-group info))
3045 gnus-newsrc-hashtb))
3047 (info (if method-only-group (nth 2 entry) info))
3049 (when method-only-group
3051 (error "Trying to change non-existent group %s" method-only-group))
3052 ;; We have received parts of the actual group info - either the
3053 ;; select method or the group parameters. We first check
3054 ;; whether we have to extend the info, and if so, do that.
3055 (let ((len (length info))
3056 (total (if (eq part 'method) 5 6)))
3058 (setcdr (nthcdr (1- len) info)
3059 (make-list (- total len) nil)))
3060 ;; Then we enter the new info.
3061 (setcar (nthcdr (1- total) info) part-info)))
3063 ;; This is a new group, so we just create it.
3065 (set-buffer gnus-group-buffer)
3066 (setq method (gnus-info-method info))
3067 (when (gnus-server-equal method "native")
3070 (set-buffer gnus-group-buffer)
3072 ;; It's a foreign group...
3073 (gnus-group-make-group
3074 (gnus-group-real-name (gnus-info-group info))
3075 (if (stringp method) method
3076 (prin1-to-string (car method)))
3078 (nth 1 (gnus-info-method info))))
3079 ;; It's a native group.
3080 (gnus-group-make-group (gnus-info-group info))))
3081 (gnus-message 6 "Note: New group created")
3083 (gnus-gethash (gnus-group-prefixed-name
3084 (gnus-group-real-name (gnus-info-group info))
3085 (or (gnus-info-method info) gnus-select-method))
3086 gnus-newsrc-hashtb))))
3087 ;; Whether it was a new group or not, we now have the entry, so we
3088 ;; can do the update.
3091 (setcar (nthcdr 2 entry) info)
3092 (when (and (not (eq (car entry) t))
3093 (gnus-active (gnus-info-group info)))
3094 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3095 (error "No such group: %s" (gnus-info-group info)))))
3097 (defun gnus-group-set-method-info (group select-method)
3098 (gnus-group-set-info select-method group 'method))
3100 (defun gnus-group-set-params-info (group params)
3101 (gnus-group-set-info params group 'params))
3103 (defun gnus-add-marked-articles (group type articles &optional info force)
3104 ;; Add ARTICLES of TYPE to the info of GROUP.
3105 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3106 ;; add, but replace marked articles of TYPE with ARTICLES.
3107 (let ((info (or info (gnus-get-info group)))
3108 (uncompressed '(score bookmark killed))
3111 (and (not (setq marked (nthcdr 3 info)))
3113 (setcdr (nthcdr 2 info)
3114 (list (list (cons type (gnus-compress-sequence
3116 (and (not (setq m (assq type (car marked))))
3119 (cons (cons type (gnus-compress-sequence articles t) )
3123 (setcar (nthcdr 3 info)
3124 (delq (assq type (car marked)) (car marked)))
3125 (setcdr m (gnus-compress-sequence articles t)))
3126 (setcdr m (gnus-compress-sequence
3127 (sort (nconc (gnus-uncompress-range (cdr m))
3128 (copy-sequence articles)) '<) t))))))
3130 (provide 'gnus-group)
3132 ;;; gnus-group.el ends here