1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
37 (defvar gnus-group-archive-directory
38 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
39 "*The address of the (ding) archives.")
41 (defvar gnus-group-recent-archive-directory
42 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
43 "*The address of the most recent (ding) articles.")
45 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
46 (defvar gnus-no-groups-message "No news is horrible news"
47 "*Message displayed by Gnus when no groups are available.")
49 (defvar gnus-keep-same-level nil
50 "*Non-nil means that the next newsgroup after the current will be on the same level.
51 When you type, for instance, `n' after reading the last article in the
52 current newsgroup, you will go to the next newsgroup. If this variable
53 is nil, the next newsgroup will be the next from the group
55 If this variable is non-nil, Gnus will either put you in the
56 next newsgroup with the same level, or, if no such newsgroup is
57 available, the next newsgroup with the lowest possible level higher
58 than the current level.
59 If this variable is `best', Gnus will make the next newsgroup the one
60 with the best level.")
62 (defvar gnus-group-goto-unread t
63 "*If non-nil, movement commands will go to the next unread and subscribed group.")
65 (defvar gnus-goto-next-group-when-activating t
66 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
68 (defvar gnus-permanently-visible-groups nil
69 "*Regexp to match groups that should always be listed in the group buffer.
70 This means that they will still be listed when there are no unread
71 articles in the groups.")
73 (defvar gnus-list-groups-with-ticked-articles t
74 "*If non-nil, list groups that have only ticked articles.
75 If nil, only list groups that have unread articles.")
77 (defvar gnus-group-default-list-level gnus-level-subscribed
78 "*Default listing level.
79 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
81 (defvar gnus-group-list-inactive-groups t
82 "*If non-nil, inactive groups will be listed.")
84 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
85 "*Function used for sorting the group buffer.
86 This function will be called with group info entries as the arguments
87 for the groups to be sorted. Pre-made functions include
88 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
89 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
90 `gnus-group-sort-by-score', `gnus-group-sort-by-method', and
91 `gnus-group-sort-by-rank'.
93 This variable can also be a list of sorting functions. In that case,
94 the most significant sort function should be the last function in the
97 (defvar gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
98 "*Format of group lines.
99 It works along the same lines as a normal formatting string,
100 with some simple extensions.
102 %M Only marked articles (character, \"*\" or \" \")
103 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
104 %L Level of subscribedness (integer)
105 %N Number of unread articles (integer)
106 %I Number of dormant articles (integer)
107 %i Number of ticked and dormant (integer)
108 %T Number of ticked articles (integer)
109 %R Number of read articles (integer)
110 %t Estimated total number of articles (integer)
111 %y Number of unread, unticked articles (integer)
112 %G Group name (string)
113 %g Qualified group name (string)
114 %D Group description (string)
115 %s Select method (string)
116 %o Moderated group (char, \"m\")
117 %p Process mark (char)
118 %O Moderated group (string, \"(m)\" or \"\")
119 %P Topic indentation (string)
120 %l Whether there are GroupLens predictions for this group (string)
121 %n Select from where (string)
122 %z A string that look like `<%s:%n>' if a foreign select method is used
123 %u User defined specifier. The next character in the format string should
124 be a letter. Gnus will call the function gnus-user-format-function-X,
125 where X is the letter following %u. The function will be passed the
126 current header as argument. The function should return a string, which
127 will be inserted into the buffer just like information from any other
130 Text between %( and %) will be highlighted with `gnus-mouse-face' when
131 the mouse point move inside the area. There can only be one such area.
133 Note that this format specification is not always respected. For
134 reasons of efficiency, when listing killed groups, this specification
135 is ignored altogether. If the spec is changed considerably, your
136 output may end up looking strange when listing both alive and killed
139 If you use %o or %O, reading the active file will be slower and quite
140 a bit of extra memory will be used. %D will also worsen performance.
141 Also note that if you change the format specification to include any
142 of these specs, you must probably re-start Gnus to see them go into
145 (defvar gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
146 "*The format specification for the group mode line.
147 It works along the same lines as a normal formatting string,
148 with some simple extensions:
150 %S The native news server.
151 %M The native select method.
152 %: \":\" if %S isn't \"\".")
154 (defvar gnus-group-mode-hook nil
155 "*A hook for Gnus group mode.")
157 (defvar gnus-group-menu-hook nil
158 "*Hook run after the creation of the group mode menu.")
160 (defvar gnus-group-catchup-group-hook nil
161 "*A hook run when catching up a group from the group buffer.")
163 (defvar gnus-group-update-group-hook nil
164 "*A hook called when updating group lines.")
166 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
167 "*A function that is called to generate the group buffer.
168 The function is called with three arguments: The first is a number;
169 all group with a level less or equal to that number should be listed,
170 if the second is non-nil, empty groups should also be displayed. If
171 the third is non-nil, it is a number. No groups with a level lower
172 than this number should be displayed.
174 The only current function implemented is `gnus-group-prepare-flat'.")
176 (defvar gnus-group-prepare-hook nil
177 "*A hook called after the group buffer has been generated.
178 If you want to modify the group buffer, you can use this hook.")
180 (defvar gnus-suspend-gnus-hook nil
181 "*A hook called when suspending (not exiting) Gnus.")
183 (defvar gnus-exit-gnus-hook nil
184 "*A hook called when exiting Gnus.")
186 (defvar gnus-after-exiting-gnus-hook nil
187 "*A hook called after exiting Gnus.")
189 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
190 "*A hook called when a group line is changed.
191 The hook will not be called if `gnus-visual' is nil.
193 The default function `gnus-group-highlight-line' will
194 highlight the line according to the `gnus-group-highlight'
197 (defvar gnus-useful-groups
198 `(("(ding) mailing list mirrored at sunsite.auc.dk"
200 (nntp "sunsite.auc.dk"
201 (nntp-address "sunsite.auc.dk")))
205 (nndoc-article-type mbox)
206 (eval `(nndoc-address
207 ,(let ((file (nnheader-find-etc-directory
210 (error "Couldn't find doc group"))
212 "Alist of useful group-server pairs.")
214 (defvar gnus-group-highlight
216 ((not (eq gnus-display-type 'color))
218 ((= unread 0) . italic)))
219 ((eq gnus-background-mode 'dark)
220 `(((and (not mailp) (eq level 1)) .
221 ,(custom-face-lookup "PaleTurquoise" nil nil t))
222 ((and (not mailp) (eq level 2)) .
223 ,(custom-face-lookup "turquoise" nil nil t))
224 ((and (not mailp) (eq level 3)) .
225 ,(custom-face-lookup "MediumTurquoise" nil nil t))
226 ((and (not mailp) (>= level 4)) .
227 ,(custom-face-lookup "DarkTurquoise" nil nil t))
228 ((and mailp (eq level 1)) .
229 ,(custom-face-lookup "aquamarine1" nil nil t))
230 ((and mailp (eq level 2)) .
231 ,(custom-face-lookup "aquamarine2" nil nil t))
232 ((and mailp (eq level 3)) .
233 ,(custom-face-lookup "aquamarine3" nil nil t))
234 ((and mailp (>= level 4)) .
235 ,(custom-face-lookup "aquamarine4" nil nil t))
238 `(((and (not mailp) (<= level 3)) .
239 ,(custom-face-lookup "ForestGreen" nil nil t))
240 ((and (not mailp) (eq level 4)) .
241 ,(custom-face-lookup "DarkGreen" nil nil t))
242 ((and (not mailp) (eq level 5)) .
243 ,(custom-face-lookup "CadetBlue4" nil nil t))
244 ((and mailp (eq level 1)) .
245 ,(custom-face-lookup "DeepPink3" nil nil t))
246 ((and mailp (eq level 2)) .
247 ,(custom-face-lookup "HotPink3" nil nil t))
248 ((and mailp (eq level 3)) .
249 ,(custom-face-lookup "dark magenta" nil nil t))
250 ((and mailp (eq level 4)) .
251 ,(custom-face-lookup "DeepPink4" nil nil t))
252 ((and mailp (> level 4)) .
253 ,(custom-face-lookup "DarkOrchid4" nil nil t))
255 "Controls the highlighting of group buffer lines.
257 Below is a list of `Form'/`Face' pairs. When deciding how a a
258 particular group line should be displayed, each form is
259 evaluated. The content of the face field after the first true form is
260 used. You can change how those group lines are displayed by
261 editing the face field.
263 It is also possible to change and add form fields, but currently that
264 requires an understanding of Lisp expressions. Hopefully this will
265 change in a future release. For now, you can use the following
266 variables in the Lisp expression:
268 group: The name of the group.
269 unread: The number of unread articles in the group.
270 method: The select method used.
271 mailp: Whether it's a mail group or not.
272 level: The level of the group.
273 score: The score of the group.
274 ticked: The number of ticked articles.")
277 ;;; Internal variables
279 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
280 "Function for sorting the group buffer.")
282 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
283 "Function for sorting the selected groups in the group buffer.")
285 (defvar gnus-group-indentation-function nil)
286 (defvar gnus-goto-missing-group-function nil)
287 (defvar gnus-group-update-group-function nil)
288 (defvar gnus-group-goto-next-group-function nil
289 "Function to override finding the next group after listing groups.")
291 (defvar gnus-group-edit-buffer nil)
293 (defvar gnus-group-line-format-alist
294 `((?M gnus-tmp-marked-mark ?c)
295 (?S gnus-tmp-subscribed ?c)
296 (?L gnus-tmp-level ?d)
297 (?N (cond ((eq number t) "*" )
301 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
302 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
304 (?R gnus-tmp-number-of-read ?s)
305 (?t gnus-tmp-number-total ?d)
306 (?y gnus-tmp-number-of-unread ?s)
307 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
308 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
309 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
310 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
311 (?g gnus-tmp-group ?s)
312 (?G gnus-tmp-qualified-group ?s)
313 (?c (gnus-short-group-name gnus-tmp-group) ?s)
314 (?D gnus-tmp-newsgroup-description ?s)
315 (?o gnus-tmp-moderated ?c)
316 (?O gnus-tmp-moderated-string ?s)
317 (?p gnus-tmp-process-marked ?c)
318 (?s gnus-tmp-news-server ?s)
319 (?n gnus-tmp-news-method ?s)
320 (?P gnus-group-indentation ?s)
321 (?l gnus-tmp-grouplens ?s)
322 (?z gnus-tmp-news-method-string ?s)
323 (?u gnus-tmp-user-defined ?s)))
325 (defvar gnus-group-mode-line-format-alist
326 `((?S gnus-tmp-news-server ?s)
327 (?M gnus-tmp-news-method ?s)
328 (?u gnus-tmp-user-defined ?s)
329 (?: gnus-tmp-colon ?s)))
331 (defvar gnus-topic-topology nil
332 "The complete topic hierarchy.")
334 (defvar gnus-topic-alist nil
335 "The complete topic-group alist.")
337 (defvar gnus-group-marked nil)
339 (defvar gnus-group-list-mode nil)
345 (put 'gnus-group-mode 'mode-class 'special)
348 (gnus-define-keys gnus-group-mode-map
349 " " gnus-group-read-group
350 "=" gnus-group-select-group
351 "\r" gnus-group-select-group
352 "\M-\r" gnus-group-quick-select-group
353 "j" gnus-group-jump-to-group
354 "n" gnus-group-next-unread-group
355 "p" gnus-group-prev-unread-group
356 "\177" gnus-group-prev-unread-group
357 [delete] gnus-group-prev-unread-group
358 "N" gnus-group-next-group
359 "P" gnus-group-prev-group
360 "\M-n" gnus-group-next-unread-group-same-level
361 "\M-p" gnus-group-prev-unread-group-same-level
362 "," gnus-group-best-unread-group
363 "." gnus-group-first-unread-group
364 "u" gnus-group-unsubscribe-current-group
365 "U" gnus-group-unsubscribe-group
366 "c" gnus-group-catchup-current
367 "C" gnus-group-catchup-current-all
368 "\M-c" gnus-group-clear-data
369 "l" gnus-group-list-groups
370 "L" gnus-group-list-all-groups
372 "g" gnus-group-get-new-news
373 "\M-g" gnus-group-get-new-news-this-group
374 "R" gnus-group-restart
375 "r" gnus-group-read-init-file
376 "B" gnus-group-browse-foreign-server
377 "b" gnus-group-check-bogus-groups
378 "F" gnus-find-new-newsgroups
379 "\C-c\C-d" gnus-group-describe-group
380 "\M-d" gnus-group-describe-all-groups
381 "\C-c\C-a" gnus-group-apropos
382 "\C-c\M-\C-a" gnus-group-description-apropos
383 "a" gnus-group-post-news
384 "\ek" gnus-group-edit-local-kill
385 "\eK" gnus-group-edit-global-kill
386 "\C-k" gnus-group-kill-group
387 "\C-y" gnus-group-yank-group
388 "\C-w" gnus-group-kill-region
389 "\C-x\C-t" gnus-group-transpose-groups
390 "\C-c\C-l" gnus-group-list-killed
391 "\C-c\C-x" gnus-group-expire-articles
392 "\C-c\M-\C-x" gnus-group-expire-all-groups
394 "s" gnus-group-save-newsrc
395 "z" gnus-group-suspend
398 "?" gnus-group-describe-briefly
399 "\C-c\C-i" gnus-info-find-node
400 "\M-e" gnus-group-edit-group-method
401 "^" gnus-group-enter-server-mode
402 gnus-mouse-2 gnus-mouse-pick-group
403 "<" beginning-of-buffer
406 "\C-c\C-s" gnus-group-sort-groups
408 "\C-c\M-g" gnus-activate-all-groups
409 "\M-&" gnus-group-universal-argument
410 "#" gnus-group-mark-group
411 "\M-#" gnus-group-unmark-group)
413 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
414 "m" gnus-group-mark-group
415 "u" gnus-group-unmark-group
416 "w" gnus-group-mark-region
417 "m" gnus-group-mark-buffer
418 "r" gnus-group-mark-regexp
419 "U" gnus-group-unmark-all-groups)
421 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
422 "d" gnus-group-make-directory-group
423 "h" gnus-group-make-help-group
424 "u" gnus-group-make-useful-group
425 "a" gnus-group-make-archive-group
426 "k" gnus-group-make-kiboze-group
427 "m" gnus-group-make-group
428 "E" gnus-group-edit-group
429 "e" gnus-group-edit-group-method
430 "p" gnus-group-edit-group-parameters
431 "v" gnus-group-add-to-virtual
432 "V" gnus-group-make-empty-virtual
433 "D" gnus-group-enter-directory
434 "f" gnus-group-make-doc-group
435 "w" gnus-group-make-web-group
436 "r" gnus-group-rename-group
437 "c" gnus-group-customize
438 "\177" gnus-group-delete-group
439 [delete] gnus-group-delete-group)
441 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
442 "b" gnus-group-brew-soup
443 "w" gnus-soup-save-areas
444 "s" gnus-soup-send-replies
445 "p" gnus-soup-pack-packet
446 "r" nnsoup-pack-replies)
448 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
449 "s" gnus-group-sort-groups
450 "a" gnus-group-sort-groups-by-alphabet
451 "u" gnus-group-sort-groups-by-unread
452 "l" gnus-group-sort-groups-by-level
453 "v" gnus-group-sort-groups-by-score
454 "r" gnus-group-sort-groups-by-rank
455 "m" gnus-group-sort-groups-by-method)
457 (gnus-define-keys (gnus-group-sort-map "P" gnus-group-group-map)
458 "s" gnus-group-sort-selected-groups
459 "a" gnus-group-sort-selected-groups-by-alphabet
460 "u" gnus-group-sort-selected-groups-by-unread
461 "l" gnus-group-sort-selected-groups-by-level
462 "v" gnus-group-sort-selected-groups-by-score
463 "r" gnus-group-sort-selected-groups-by-rank
464 "m" gnus-group-sort-selected-groups-by-method)
466 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
467 "k" gnus-group-list-killed
468 "z" gnus-group-list-zombies
469 "s" gnus-group-list-groups
470 "u" gnus-group-list-all-groups
471 "A" gnus-group-list-active
472 "a" gnus-group-apropos
473 "d" gnus-group-description-apropos
474 "m" gnus-group-list-matching
475 "M" gnus-group-list-all-matching
476 "l" gnus-group-list-level)
478 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
479 "f" gnus-score-flush-cache)
481 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
482 "d" gnus-group-describe-group
483 "f" gnus-group-fetch-faq)
485 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
486 "l" gnus-group-set-current-level
487 "t" gnus-group-unsubscribe-current-group
488 "s" gnus-group-unsubscribe-group
489 "k" gnus-group-kill-group
490 "y" gnus-group-yank-group
491 "w" gnus-group-kill-region
492 "\C-k" gnus-group-kill-level
493 "z" gnus-group-kill-all-zombies))
495 (defun gnus-group-make-menu-bar ()
496 (gnus-turn-off-edit-menu 'group)
497 (unless (boundp 'gnus-group-reading-menu)
500 gnus-group-reading-menu gnus-group-mode-map ""
502 ["Read" gnus-group-read-group (gnus-group-group-name)]
503 ["Select" gnus-group-select-group (gnus-group-group-name)]
504 ["See old articles" (gnus-group-select-group 'all)
505 :keys "C-u SPC" :active (gnus-group-group-name)]
506 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
507 ["Catch up all articles" gnus-group-catchup-current-all
508 (gnus-group-group-name)]
509 ["Check for new articles" gnus-group-get-new-news-this-group
510 (gnus-group-group-name)]
511 ["Toggle subscription" gnus-group-unsubscribe-current-group
512 (gnus-group-group-name)]
513 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
514 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
515 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
516 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
517 ["Edit kill file" gnus-group-edit-local-kill
518 (gnus-group-group-name)]
519 ;; Actually one should check, if any of the marked groups gives t for
520 ;; (gnus-check-backend-function 'request-expire-articles ...)
521 ["Expire articles" gnus-group-expire-articles
522 (or (and (gnus-group-group-name)
523 (gnus-check-backend-function
524 'request-expire-articles
525 (gnus-group-group-name))) gnus-group-marked)]
526 ["Set group level" gnus-group-set-current-level
527 (gnus-group-group-name)]
528 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
532 gnus-group-group-menu gnus-group-mode-map ""
535 ["List unread subscribed groups" gnus-group-list-groups t]
536 ["List (un)subscribed groups" gnus-group-list-all-groups t]
537 ["List killed groups" gnus-group-list-killed gnus-killed-list]
538 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
539 ["List level..." gnus-group-list-level t]
540 ["Describe all groups" gnus-group-describe-all-groups t]
541 ["Group apropos..." gnus-group-apropos t]
542 ["Group and description apropos..." gnus-group-description-apropos t]
543 ["List groups matching..." gnus-group-list-matching t]
544 ["List all groups matching..." gnus-group-list-all-matching t]
545 ["List active file" gnus-group-list-active t])
547 ["Default sort" gnus-group-sort-groups t]
548 ["Sort by method" gnus-group-sort-groups-by-method t]
549 ["Sort by rank" gnus-group-sort-groups-by-rank t]
550 ["Sort by score" gnus-group-sort-groups-by-score t]
551 ["Sort by level" gnus-group-sort-groups-by-level t]
552 ["Sort by unread" gnus-group-sort-groups-by-unread t]
553 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
554 ("Sort process/prefixed"
555 ["Default sort" gnus-group-sort-selected-groups
556 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
557 ["Sort by method" gnus-group-sort-selected-groups-by-method
558 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
559 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
560 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
561 ["Sort by score" gnus-group-sort-selected-groups-by-score
562 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
563 ["Sort by level" gnus-group-sort-selected-groups-by-level
564 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
565 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
566 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
567 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
568 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
570 ["Mark group" gnus-group-mark-group
571 (and (gnus-group-group-name)
572 (not (memq (gnus-group-group-name) gnus-group-marked)))]
573 ["Unmark group" gnus-group-unmark-group
574 (and (gnus-group-group-name)
575 (memq (gnus-group-group-name) gnus-group-marked))]
576 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
577 ["Mark regexp..." gnus-group-mark-regexp t]
578 ["Mark region" gnus-group-mark-region t]
579 ["Mark buffer" gnus-group-mark-buffer t]
580 ["Execute command" gnus-group-universal-argument
581 (or gnus-group-marked (gnus-group-group-name))])
583 ["Subscribe to a group" gnus-group-unsubscribe-group t]
584 ["Kill all newsgroups in region" gnus-group-kill-region t]
585 ["Kill all zombie groups" gnus-group-kill-all-zombies
587 ["Kill all groups on level..." gnus-group-kill-level t])
589 ["Make a foreign group" gnus-group-make-group t]
590 ["Add a directory group" gnus-group-make-directory-group t]
591 ["Add the help group" gnus-group-make-help-group t]
592 ["Add the archive group" gnus-group-make-archive-group t]
593 ["Make a doc group" gnus-group-make-doc-group t]
594 ["Make a web group" gnus-group-make-web-group t]
595 ["Make a kiboze group" gnus-group-make-kiboze-group t]
596 ["Make a virtual group" gnus-group-make-empty-virtual t]
597 ["Add a group to a virtual" gnus-group-add-to-virtual t]
598 ["Rename group" gnus-group-rename-group
599 (gnus-check-backend-function
600 'request-rename-group (gnus-group-group-name))]
601 ["Delete group" gnus-group-delete-group
602 (gnus-check-backend-function
603 'request-delete-group (gnus-group-group-name))])
605 ["Parameters" gnus-group-edit-group-parameters
606 (gnus-group-group-name)]
607 ["Select method" gnus-group-edit-group-method
608 (gnus-group-group-name)]
609 ["Info" gnus-group-edit-group (gnus-group-group-name)])
611 ["Flush cache" gnus-score-flush-cache t])
613 ["Next" gnus-group-next-group t]
614 ["Previous" gnus-group-prev-group t]
615 ["Next unread" gnus-group-next-unread-group t]
616 ["Previous unread" gnus-group-prev-unread-group t]
617 ["Next unread same level" gnus-group-next-unread-group-same-level t]
618 ["Previous unread same level"
619 gnus-group-prev-unread-group-same-level t]
620 ["Jump to group" gnus-group-jump-to-group t]
621 ["First unread group" gnus-group-first-unread-group t]
622 ["Best unread group" gnus-group-best-unread-group t])
623 ["Transpose" gnus-group-transpose-groups
624 (gnus-group-group-name)]
625 ["Read a directory as a group..." gnus-group-enter-directory t]
629 gnus-group-misc-menu gnus-group-mode-map ""
631 ["Send a bug report" gnus-bug t]
632 ["Send a mail" gnus-group-mail t]
633 ["Post an article..." gnus-group-post-news t]
634 ["Check for new news" gnus-group-get-new-news t]
635 ["Activate all groups" gnus-activate-all-groups t]
636 ["Delete bogus groups" gnus-group-check-bogus-groups t]
637 ["Find new newsgroups" gnus-find-new-newsgroups t]
638 ["Restart Gnus" gnus-group-restart t]
639 ["Read init file" gnus-group-read-init-file t]
640 ["Browse foreign server" gnus-group-browse-foreign-server t]
641 ["Enter server buffer" gnus-group-enter-server-mode t]
642 ["Expire all expirable articles" gnus-group-expire-all-groups t]
643 ["Generate any kiboze groups" nnkiboze-generate-groups t]
644 ["Gnus version" gnus-version t]
645 ["Save .newsrc files" gnus-group-save-newsrc t]
646 ["Suspend Gnus" gnus-group-suspend t]
647 ["Clear dribble buffer" gnus-group-clear-dribble t]
648 ["Edit global kill file" gnus-group-edit-global-kill t]
649 ["Read manual" gnus-info-find-node t]
650 ["Toggle topics" gnus-topic-mode t]
652 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
653 ["Send replies" gnus-soup-send-replies
654 (fboundp 'gnus-soup-pack-packet)]
655 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
656 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
657 ["Brew SOUP" gnus-soup-brew-soup (fboundp 'gnus-soup-pack-packet)])
658 ["Exit from Gnus" gnus-group-exit t]
659 ["Exit without saving" gnus-group-quit t]
662 (run-hooks 'gnus-group-menu-hook)
665 (defun gnus-group-mode ()
666 "Major mode for reading news.
668 All normal editing commands are switched off.
669 \\<gnus-group-mode-map>
670 The group buffer lists (some of) the groups available. For instance,
671 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
672 lists all zombie groups.
674 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
675 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
677 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
679 The following commands are available:
681 \\{gnus-group-mode-map}"
683 (when (and menu-bar-mode
684 (gnus-visual-p 'group-menu 'menu))
685 (gnus-group-make-menu-bar))
686 (kill-all-local-variables)
687 (gnus-simplify-mode-line)
688 (setq major-mode 'gnus-group-mode)
689 (setq mode-name "Group")
690 (gnus-group-set-mode-line)
691 (setq mode-line-process nil)
692 (use-local-map gnus-group-mode-map)
693 (buffer-disable-undo (current-buffer))
694 (setq truncate-lines t)
695 (setq buffer-read-only t)
696 (gnus-set-default-directory)
697 (gnus-update-format-specifications nil 'group 'group-mode)
698 (gnus-update-group-mark-positions)
699 (gnus-make-local-hook 'post-command-hook)
700 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
703 (run-hooks 'gnus-group-mode-hook))
705 (defun gnus-update-group-mark-positions ()
707 (let ((gnus-process-mark 128)
708 (gnus-group-marked '("dummy.group"))
709 (gnus-active-hashtb (make-vector 10 0)))
710 (gnus-set-active "dummy.group" '(0 . 0))
711 (gnus-set-work-buffer)
712 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
713 (goto-char (point-min))
714 (setq gnus-group-mark-positions
715 (list (cons 'process (and (search-forward "\200" nil t)
718 (defun gnus-clear-inboxes-moved ()
719 (setq nnmail-moved-inboxes nil))
721 (defun gnus-mouse-pick-group (e)
722 "Enter the group under the mouse pointer."
725 (gnus-group-read-group nil))
727 ;; Look at LEVEL and find out what the level is really supposed to be.
728 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
729 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
730 (defun gnus-group-default-level (&optional level number-or-nil)
732 (gnus-group-use-permanent-levels
733 (or (setq gnus-group-use-permanent-levels
734 (or level (if (numberp gnus-group-use-permanent-levels)
735 gnus-group-use-permanent-levels
736 (or gnus-group-default-list-level
737 gnus-level-subscribed))))
738 gnus-group-default-list-level gnus-level-subscribed))
742 (or level gnus-group-default-list-level gnus-level-subscribed))))
744 (defun gnus-group-setup-buffer ()
745 (switch-to-buffer gnus-group-buffer)
746 (unless (eq major-mode 'gnus-group-mode)
747 (gnus-add-current-to-buffer-list)
750 (gnus-carpal-setup-buffer 'group))))
752 (defun gnus-group-list-groups (&optional level unread lowest)
753 "List newsgroups with level LEVEL or lower that have unread articles.
754 Default is all subscribed groups.
755 If argument UNREAD is non-nil, groups with no unread articles are also
758 (list (if current-prefix-arg
759 (prefix-numeric-value current-prefix-arg)
761 (gnus-group-default-level nil t)
762 gnus-group-default-list-level
763 gnus-level-subscribed))))
765 (setq level (car gnus-group-list-mode)
766 unread (cdr gnus-group-list-mode)))
767 (setq level (gnus-group-default-level level))
768 (gnus-group-setup-buffer) ;May call from out of group buffer
769 (gnus-update-format-specifications nil 'group 'group-mode)
770 (let ((case-fold-search nil)
771 (props (text-properties-at (gnus-point-at-bol)))
772 (group (gnus-group-group-name)))
773 (set-buffer gnus-group-buffer)
774 (funcall gnus-group-prepare-function level unread lowest)
775 (if (zerop (buffer-size))
776 (gnus-message 5 gnus-no-groups-message)
777 (goto-char (point-max))
778 (when (or (not gnus-group-goto-next-group-function)
779 (not (funcall gnus-group-goto-next-group-function
782 ;; Go to the first group with unread articles.
783 (gnus-group-search-forward t)
784 ;; Find the right group to put point on. If the current group
785 ;; has disappeared in the new listing, try to find the next
786 ;; one. If no next one can be found, just leave point at the
787 ;; first newsgroup in the buffer.
788 (when (not (gnus-goto-char
790 (point-min) (point-max)
791 'gnus-group (gnus-intern-safe
792 group gnus-active-hashtb))))
793 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
797 (point-min) (point-max) 'gnus-group
799 (caar newsrc) gnus-active-hashtb)))))
800 (setq newsrc (cdr newsrc)))
802 (goto-char (point-max))
803 (forward-line -1))))))
804 ;; Adjust cursor point.
805 (gnus-group-position-point))))
807 (defun gnus-group-list-level (level &optional all)
808 "List groups on LEVEL.
809 If ALL (the prefix), also list groups that have no unread articles."
810 (interactive "nList groups on level: \nP")
811 (gnus-group-list-groups level all level))
813 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
814 "List all newsgroups with unread articles of level LEVEL or lower.
815 If ALL is non-nil, list groups that have no unread articles.
816 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
817 If REGEXP, only list groups matching REGEXP."
818 (set-buffer gnus-group-buffer)
819 (let ((buffer-read-only nil)
820 (newsrc (cdr gnus-newsrc-alist))
821 (lowest (or lowest 1))
822 info clevel unread group params)
824 (if (< lowest gnus-level-zombie)
825 ;; List living groups.
827 (setq info (car newsrc)
828 group (gnus-info-group info)
829 params (gnus-info-params info)
831 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
832 (and unread ; This group might be bogus
834 (string-match regexp group))
835 (<= (setq clevel (gnus-info-level info)) level)
837 (or all ; We list all groups?
838 (if (eq unread t) ; Unactivated?
839 gnus-group-list-inactive-groups ; We list unactivated
840 (> unread 0)) ; We list groups with unread articles
841 (and gnus-list-groups-with-ticked-articles
842 (cdr (assq 'tick (gnus-info-marks info))))
843 ; And groups with tickeds
844 ;; Check for permanent visibility.
845 (and gnus-permanently-visible-groups
846 (string-match gnus-permanently-visible-groups
848 (memq 'visible params)
849 (cdr (assq 'visible params)))
850 (gnus-group-insert-group-line
851 group (gnus-info-level info)
852 (gnus-info-marks info) unread (gnus-info-method info)))))
855 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
856 (gnus-group-prepare-flat-list-dead
857 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
860 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
861 (gnus-group-prepare-flat-list-dead
862 (setq gnus-killed-list (sort gnus-killed-list 'string<))
863 gnus-level-killed ?K regexp))
865 (gnus-group-set-mode-line)
866 (setq gnus-group-list-mode (cons level all))
867 (run-hooks 'gnus-group-prepare-hook)))
869 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
870 ;; List zombies and killed lists somewhat faster, which was
871 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
872 ;; this by ignoring the group format specification altogether.
875 ;; This loop is used when listing groups that match some
878 (setq group (pop groups))
879 (when (string-match regexp group)
880 (gnus-add-text-properties
881 (point) (prog1 (1+ (point))
882 (insert " " mark " *: " group "\n"))
883 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
885 'gnus-level level))))
886 ;; This loop is used when listing all groups.
888 (gnus-add-text-properties
889 (point) (prog1 (1+ (point))
890 (insert " " mark " *: "
891 (setq group (pop groups)) "\n"))
892 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
894 'gnus-level level))))))
896 (defun gnus-group-update-group-line ()
897 "Update the current line in the group buffer."
898 (let* ((buffer-read-only nil)
899 (group (gnus-group-group-name))
900 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
901 gnus-group-indentation)
904 (not (gnus-ephemeral-group-p group))
906 (concat "(gnus-group-set-info '"
907 (gnus-prin1-to-string (nth 2 entry)) ")")))
908 (setq gnus-group-indentation (gnus-group-group-indentation))
910 (gnus-group-insert-group-line-info group)
912 (gnus-group-position-point))))
914 (defun gnus-group-insert-group-line-info (group)
915 "Insert GROUP on the current line."
916 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
917 (gnus-group-indentation (gnus-group-group-indentation))
921 ;; (Un)subscribed group.
922 (setq info (nth 2 entry))
923 (gnus-group-insert-group-line
924 group (gnus-info-level info) (gnus-info-marks info)
925 (or (car entry) t) (gnus-info-method info)))
926 ;; This group is dead.
927 (gnus-group-insert-group-line
929 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
931 (if (setq active (gnus-active group))
932 (- (1+ (cdr active)) (car active)) 0)
935 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
936 gnus-tmp-marked number
938 "Insert a group line in the group buffer."
939 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
940 (gnus-tmp-number-total
942 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
944 (gnus-tmp-number-of-unread
945 (if (numberp number) (int-to-string (max 0 number))
947 (gnus-tmp-number-of-read
949 (int-to-string (max 0 (- gnus-tmp-number-total number)))
952 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
953 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
954 ((= gnus-tmp-level gnus-level-zombie) ?Z)
956 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
957 (gnus-tmp-newsgroup-description
958 (if gnus-description-hashtb
959 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
962 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
963 (gnus-tmp-moderated-string
964 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
966 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
967 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
968 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
969 (gnus-tmp-news-method-string
971 (format "(%s:%s)" (car gnus-tmp-method)
972 (cadr gnus-tmp-method)) ""))
973 (gnus-tmp-marked-mark
974 (if (and (numberp number)
976 (cdr (assq 'tick gnus-tmp-marked)))
978 (gnus-tmp-process-marked
979 (if (member gnus-tmp-group gnus-group-marked)
980 gnus-process-mark ? ))
982 (or (and gnus-use-grouplens
983 (bbb-grouplens-group-p gnus-tmp-group))
985 (buffer-read-only nil)
986 header gnus-tmp-header) ; passed as parameter to user-funcs.
988 (gnus-add-text-properties
992 (eval gnus-group-line-format-spec))
993 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
994 gnus-unread ,(if (numberp number)
995 (string-to-int gnus-tmp-number-of-unread)
997 gnus-marked ,gnus-tmp-marked-mark
998 gnus-indentation ,gnus-group-indentation
999 gnus-level ,gnus-tmp-level))
1000 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1002 (run-hooks 'gnus-group-update-hook)
1004 ;; Allow XEmacs to remove front-sticky text properties.
1005 (gnus-group-remove-excess-properties)))
1007 (defun gnus-group-highlight-line ()
1008 "Highlight the current line according to `gnus-group-highlight'."
1009 (let* ((list gnus-group-highlight)
1011 (end (progn (end-of-line) (point)))
1012 ;; now find out where the line starts and leave point there.
1013 (beg (progn (beginning-of-line) (point)))
1014 (group (gnus-group-group-name))
1015 (entry (gnus-group-entry group))
1016 (unread (if (numberp (car entry)) (car entry) 0))
1017 (active (gnus-active group))
1018 (total (if active (1+ (- (cdr active) (car active))) 0))
1019 (info (nth 2 entry))
1020 (method (gnus-server-get-method group (gnus-info-method info)))
1021 (marked (gnus-info-marks info))
1022 (mailp (memq 'mail (assoc (symbol-name
1023 (car (or method gnus-select-method)))
1024 gnus-valid-select-methods)))
1025 (level (or (gnus-info-level info) 9))
1026 (score (or (gnus-info-score info) 0))
1027 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1028 (inhibit-read-only t))
1029 ;; Eval the cars of the lists until we find a match.
1031 (not (eval (caar list))))
1032 (setq list (cdr list)))
1033 (let ((face (cdar list)))
1034 (unless (eq face (get-text-property beg 'face))
1035 (gnus-put-text-property
1037 (setq face (if (boundp face) (symbol-value face) face)))
1038 (gnus-extent-start-open beg)))
1041 (defun gnus-group-update-group (group &optional visible-only)
1042 "Update all lines where GROUP appear.
1043 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1046 (set-buffer gnus-group-buffer)
1047 ;; The buffer may be narrowed.
1050 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1052 found buffer-read-only)
1053 ;; Enter the current status into the dribble buffer.
1054 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1055 (if (and entry (not (gnus-ephemeral-group-p group)))
1057 (concat "(gnus-group-set-info '"
1058 (gnus-prin1-to-string (nth 2 entry))
1060 ;; Find all group instances. If topics are in use, each group
1061 ;; may be listed in more than once.
1062 (while (setq loc (text-property-any
1063 loc (point-max) 'gnus-group ident))
1066 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1068 (gnus-group-insert-group-line-info group)
1071 (run-hooks 'gnus-group-update-group-hook)))
1072 (setq loc (1+ loc)))
1073 (unless (or found visible-only)
1074 ;; No such line in the buffer, find out where it's supposed to
1075 ;; go, and insert it there (or at the end of the buffer).
1076 (if gnus-goto-missing-group-function
1077 (funcall gnus-goto-missing-group-function group)
1078 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1079 (while (and entry (car entry)
1083 (point-min) (point-max)
1084 'gnus-group (gnus-intern-safe
1085 (caar entry) gnus-active-hashtb)))))
1086 (setq entry (cdr entry)))
1087 (or entry (goto-char (point-max)))))
1088 ;; Finally insert the line.
1089 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1090 (gnus-group-insert-group-line-info group)
1093 (run-hooks 'gnus-group-update-group-hook))))
1094 (when gnus-group-update-group-function
1095 (funcall gnus-group-update-group-function group))
1096 (gnus-group-set-mode-line)))))
1098 (defun gnus-group-set-mode-line ()
1099 "Update the mode line in the group buffer."
1100 (when (memq 'group gnus-updated-mode-lines)
1101 ;; Yes, we want to keep this mode line updated.
1103 (set-buffer gnus-group-buffer)
1104 (let* ((gformat (or gnus-group-mode-line-format-spec
1105 (setq gnus-group-mode-line-format-spec
1107 gnus-group-mode-line-format
1108 gnus-group-mode-line-format-alist))))
1109 (gnus-tmp-news-server (cadr gnus-select-method))
1110 (gnus-tmp-news-method (car gnus-select-method))
1111 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1113 gnus-tmp-header ;Dummy binding for user-defined formats
1114 ;; Get the resulting string.
1116 (and gnus-dribble-buffer
1117 (buffer-name gnus-dribble-buffer)
1118 (buffer-modified-p gnus-dribble-buffer)
1120 (set-buffer gnus-dribble-buffer)
1121 (not (zerop (buffer-size))))))
1122 (mode-string (eval gformat)))
1123 ;; Say whether the dribble buffer has been modified.
1124 (setq mode-line-modified
1125 (if modified "---*- " "----- "))
1126 ;; If the line is too long, we chop it off.
1127 (when (> (length mode-string) max-len)
1128 (setq mode-string (substring mode-string 0 (- max-len 4))))
1130 (setq mode-line-buffer-identification
1131 (gnus-mode-line-buffer-identification
1132 (list mode-string)))
1133 (set-buffer-modified-p modified))))))
1135 (defun gnus-group-group-name ()
1136 "Get the name of the newsgroup on the current line."
1137 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1138 (and group (symbol-name group))))
1140 (defun gnus-group-group-level ()
1141 "Get the level of the newsgroup on the current line."
1142 (get-text-property (gnus-point-at-bol) 'gnus-level))
1144 (defun gnus-group-group-indentation ()
1145 "Get the indentation of the newsgroup on the current line."
1146 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1147 (and gnus-group-indentation-function
1148 (funcall gnus-group-indentation-function))
1151 (defun gnus-group-group-unread ()
1152 "Get the number of unread articles of the newsgroup on the current line."
1153 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1155 (defun gnus-group-search-forward (&optional backward all level first-too)
1156 "Find the next newsgroup with unread articles.
1157 If BACKWARD is non-nil, find the previous newsgroup instead.
1158 If ALL is non-nil, just find any newsgroup.
1159 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1161 If FIRST-TOO, the current line is also eligible as a target."
1162 (let ((way (if backward -1 1))
1163 (low gnus-level-killed)
1166 (if (and backward (progn (beginning-of-line)) (bobp))
1168 (or first-too (forward-line way))
1176 (get-text-property (point) 'gnus-unread)))
1177 (and (numberp unread) (> unread 0)))
1178 (setq lev (get-text-property (point)
1180 (<= lev gnus-level-subscribed)))
1182 (and (setq lev (get-text-property (point)
1191 (zerop (forward-line way)))))
1193 (progn (gnus-group-position-point) t)
1194 (goto-char (or pos beg))
1197 ;;; Gnus group mode commands
1201 (defun gnus-group-mark-group (n &optional unmark no-advance)
1202 "Mark the current group."
1204 (let ((buffer-read-only nil)
1208 (when (setq group (gnus-group-group-name))
1209 ;; Go to the mark position.
1211 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1212 (subst-char-in-region
1213 (point) (1+ (point)) (following-char)
1216 (setq gnus-group-marked (delete group gnus-group-marked))
1218 (setq gnus-group-marked
1219 (cons group (delete group gnus-group-marked)))
1220 gnus-process-mark)))
1222 (gnus-group-next-group 1))
1224 (gnus-summary-position-point)
1227 (defun gnus-group-unmark-group (n)
1228 "Remove the mark from the current group."
1230 (gnus-group-mark-group n 'unmark)
1231 (gnus-group-position-point))
1233 (defun gnus-group-unmark-all-groups ()
1234 "Unmark all groups."
1236 (let ((groups gnus-group-marked))
1239 (gnus-group-remove-mark (pop groups)))))
1240 (gnus-group-position-point))
1242 (defun gnus-group-mark-region (unmark beg end)
1243 "Mark all groups between point and mark.
1244 If UNMARK, remove the mark instead."
1245 (interactive "P\nr")
1246 (let ((num (count-lines beg end)))
1249 (- num (gnus-group-mark-group num unmark)))))
1251 (defun gnus-group-mark-buffer (&optional unmark)
1252 "Mark all groups in the buffer.
1253 If UNMARK, remove the mark instead."
1255 (gnus-group-mark-region unmark (point-min) (point-max)))
1257 (defun gnus-group-mark-regexp (regexp)
1258 "Mark all groups that match some regexp."
1259 (interactive "sMark (regexp): ")
1260 (let ((alist (cdr gnus-newsrc-alist))
1263 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1264 (gnus-group-set-mark group))))
1265 (gnus-group-position-point))
1267 (defun gnus-group-remove-mark (group)
1268 "Remove the process mark from GROUP and move point there.
1269 Return nil if the group isn't displayed."
1270 (if (gnus-group-goto-group group)
1272 (gnus-group-mark-group 1 'unmark t)
1274 (setq gnus-group-marked
1275 (delete group gnus-group-marked))
1278 (defun gnus-group-set-mark (group)
1279 "Set the process mark on GROUP."
1280 (if (gnus-group-goto-group group)
1282 (gnus-group-mark-group 1 nil t))
1283 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1285 (defun gnus-group-universal-argument (arg &optional groups func)
1286 "Perform any command on all groups according to the process/prefix convention."
1288 (let ((groups (or groups (gnus-group-process-prefix arg))))
1289 (if (eq (setq func (or func
1292 (substitute-command-keys
1293 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1295 (gnus-error 1 "Undefined key")
1297 (gnus-group-remove-mark (pop groups))
1298 (command-execute func))))
1299 (gnus-group-position-point))
1301 (defun gnus-group-process-prefix (n)
1302 "Return a list of groups to work on.
1303 Take into consideration N (the prefix) and the list of marked groups."
1306 (setq n (prefix-numeric-value n))
1307 ;; There is a prefix, so we return a list of the N next
1309 (let ((way (if (< n 0) -1 1))
1314 (setq group (gnus-group-group-name)))
1315 (setq groups (cons group groups))
1317 (gnus-group-next-group way)))
1319 ((and (boundp 'transient-mark-mode)
1321 (boundp 'mark-active)
1323 ;; Work on the region between point and mark.
1324 (let ((max (max (point) (mark)))
1327 (goto-char (min (point) (mark)))
1330 (push (gnus-group-group-name) groups)
1331 (zerop (gnus-group-next-group 1))
1333 (nreverse groups))))
1335 ;; No prefix, but a list of marked articles.
1336 (reverse gnus-group-marked))
1338 ;; Neither marked articles or a prefix, so we return the
1340 (let ((group (gnus-group-group-name)))
1341 (and group (list group))))))
1343 ;; Selecting groups.
1345 (defun gnus-group-read-group (&optional all no-article group)
1346 "Read news in this newsgroup.
1347 If the prefix argument ALL is non-nil, already read articles become
1348 readable. IF ALL is a number, fetch this number of articles. If the
1349 optional argument NO-ARTICLE is non-nil, no article will be
1350 auto-selected upon group entry. If GROUP is non-nil, fetch that
1353 (let ((no-display (eq all 0))
1354 (group (or group (gnus-group-group-name)))
1355 number active marked entry)
1359 (error "No group on current line"))
1360 (setq marked (gnus-info-marks
1361 (nth 2 (setq entry (gnus-gethash
1362 group gnus-newsrc-hashtb)))))
1363 ;; This group might be a dead group. In that case we have to get
1364 ;; the number of unread articles from `gnus-active-hashtb'.
1366 (cond ((numberp all) all)
1368 ((setq active (gnus-active group))
1369 (- (1+ (cdr active)) (car active)))))
1370 (gnus-summary-read-group
1371 group (or all (and (numberp number)
1372 (zerop (+ number (gnus-range-length
1373 (cdr (assq 'tick marked)))
1375 (cdr (assq 'dormant marked)))))))
1376 no-article nil no-display)))
1378 (defun gnus-group-select-group (&optional all)
1379 "Select this newsgroup.
1380 No article is selected automatically.
1381 If ALL is non-nil, already read articles become readable.
1382 If ALL is a number, fetch this number of articles."
1384 (gnus-group-read-group all t))
1386 (defun gnus-group-quick-select-group (&optional all)
1387 "Select the current group \"quickly\".
1388 This means that no highlighting or scoring will be performed.
1389 If ALL (the prefix argument) is 0, don't even generate the summary
1392 (require 'gnus-score)
1394 gnus-score-find-score-files-function
1395 gnus-apply-kill-hook
1396 gnus-summary-expunge-below)
1397 (gnus-group-read-group all t)))
1399 (defun gnus-group-visible-select-group (&optional all)
1400 "Select the current group without hiding any articles."
1402 (let ((gnus-inhibit-limiting t))
1403 (gnus-group-read-group all t)))
1406 (defun gnus-fetch-group (group)
1407 "Start Gnus if necessary and enter GROUP.
1408 Returns whether the fetching was successful or not."
1409 (interactive "sGroup name: ")
1410 (or (get-buffer gnus-group-buffer)
1412 (gnus-group-read-group nil nil group))
1414 ;; Enter a group that is not in the group buffer. Non-nil is returned
1415 ;; if selection was successful.
1416 (defun gnus-group-read-ephemeral-group (group method &optional activate
1417 quit-config request-only)
1418 "Read GROUP from METHOD as an ephemeral group.
1419 If ACTIVATE, request the group first.
1420 If QUIT-CONFIG, use that window configuration when exiting from the
1422 If REQUEST-ONLY, don't actually read the group; just request it.
1424 Return the name of the group is selection was successful."
1425 (let ((group (if (gnus-group-foreign-p group) group
1426 (gnus-group-prefixed-name group method))))
1430 ,gnus-level-default-subscribed nil nil ,method
1432 ,(if quit-config quit-config
1433 (cons gnus-summary-buffer
1434 gnus-current-window-configuration))))))
1436 (set-buffer gnus-group-buffer)
1437 (unless (gnus-check-server method)
1438 (error "Unable to contact server: %s" (gnus-status-message method)))
1440 (gnus-activate-group group 'scan)
1441 (unless (gnus-request-group group)
1442 (error "Couldn't request group: %s"
1443 (nnheader-get-report (car method)))))
1447 (when (gnus-group-read-group t t group)
1452 (defun gnus-group-jump-to-group (group)
1453 "Jump to newsgroup GROUP."
1455 (list (completing-read
1456 "Group: " gnus-active-hashtb nil
1457 (gnus-read-active-file-p)
1459 'gnus-group-history)))
1461 (when (equal group "")
1462 (error "Empty group name"))
1464 (unless (gnus-ephemeral-group-p group)
1465 ;; Either go to the line in the group buffer...
1466 (unless (gnus-group-goto-group group)
1467 ;; ... or insert the line.
1468 (gnus-group-update-group group)
1469 (gnus-group-goto-group group)))
1470 ;; Adjust cursor point.
1471 (gnus-group-position-point))
1473 (defun gnus-group-goto-group (group &optional far)
1474 "Goto to newsgroup GROUP.
1475 If FAR, it is likely that the group is not on the current line."
1480 (point-min) (point-max)
1481 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
1484 ;; It's quite likely that we are on the right line, so
1485 ;; we check the current line first.
1486 ((eq (get-text-property (point) 'gnus-group)
1487 (gnus-intern-safe group gnus-active-hashtb))
1489 ;; Previous and next line are also likely, so we check them as well.
1492 (eq (get-text-property (point) 'gnus-group)
1493 (gnus-intern-safe group gnus-active-hashtb)))
1498 (eq (get-text-property (point) 'gnus-group)
1499 (gnus-intern-safe group gnus-active-hashtb)))
1503 ;; Search through the entire buffer.
1506 (point-min) (point-max)
1507 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
1509 (defun gnus-group-next-group (n &optional silent)
1510 "Go to next N'th newsgroup.
1511 If N is negative, search backward instead.
1512 Returns the difference between N and the number of skips actually
1515 (gnus-group-next-unread-group n t nil silent))
1517 (defun gnus-group-next-unread-group (n &optional all level silent)
1518 "Go to next N'th unread newsgroup.
1519 If N is negative, search backward instead.
1520 If ALL is non-nil, choose any newsgroup, unread or not.
1521 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1522 such group can be found, the next group with a level higher than
1524 Returns the difference between N and the number of skips actually
1527 (let ((backward (< n 0))
1530 (gnus-group-search-forward
1531 backward (or (not gnus-group-goto-unread) all) level))
1535 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1536 (if level " on this level or higher" "")))
1539 (defun gnus-group-prev-group (n)
1540 "Go to previous N'th newsgroup.
1541 Returns the difference between N and the number of skips actually
1544 (gnus-group-next-unread-group (- n) t))
1546 (defun gnus-group-prev-unread-group (n)
1547 "Go to previous N'th unread newsgroup.
1548 Returns the difference between N and the number of skips actually
1551 (gnus-group-next-unread-group (- n)))
1553 (defun gnus-group-next-unread-group-same-level (n)
1554 "Go to next N'th unread newsgroup on the same level.
1555 If N is negative, search backward instead.
1556 Returns the difference between N and the number of skips actually
1559 (gnus-group-next-unread-group n t (gnus-group-group-level))
1560 (gnus-group-position-point))
1562 (defun gnus-group-prev-unread-group-same-level (n)
1563 "Go to next N'th unread newsgroup on the same level.
1564 Returns the difference between N and the number of skips actually
1567 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1568 (gnus-group-position-point))
1570 (defun gnus-group-best-unread-group (&optional exclude-group)
1571 "Go to the group with the highest level.
1572 If EXCLUDE-GROUP, do not go to that group."
1574 (goto-char (point-min))
1578 (setq unread (get-text-property (point) 'gnus-unread))
1579 (if (and (numberp unread) (> unread 0))
1581 (if (and (get-text-property (point) 'gnus-level)
1582 (< (get-text-property (point) 'gnus-level) best)
1583 (or (not exclude-group)
1584 (not (equal exclude-group (gnus-group-group-name)))))
1586 (setq best (get-text-property (point) 'gnus-level))
1587 (setq best-point (point))))))
1589 (if best-point (goto-char best-point))
1590 (gnus-summary-position-point)
1591 (and best-point (gnus-group-group-name))))
1593 (defun gnus-group-first-unread-group ()
1594 "Go to the first group with unread articles."
1597 (let ((opoint (point))
1599 (goto-char (point-min))
1600 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1601 (and (numberp unread) ; Not a topic.
1602 (not (zerop unread))) ; Has unread articles.
1603 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1606 nil)) ; Not success.
1607 (gnus-group-position-point)))
1609 (defun gnus-group-enter-server-mode ()
1610 "Jump to the server buffer."
1612 (gnus-enter-server-buffer))
1614 (defun gnus-group-make-group (name &optional method address args)
1615 "Add a new newsgroup.
1616 The user will be prompted for a NAME, for a select METHOD, and an
1620 (read-string "Group name: ")
1621 (gnus-read-method "From method: ")))
1623 (let* ((meth (when (and method
1624 (not (gnus-server-equal method gnus-select-method)))
1625 (if address (list (intern method) address)
1627 (nname (if method (gnus-group-prefixed-name name meth) name))
1629 (when (gnus-gethash nname gnus-newsrc-hashtb)
1630 (error "Group %s already exists" nname))
1631 ;; Subscribe to the new group.
1632 (gnus-group-change-level
1633 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1634 gnus-level-default-subscribed gnus-level-killed
1635 (and (gnus-group-group-name)
1636 (gnus-gethash (gnus-group-group-name)
1637 gnus-newsrc-hashtb))
1640 (gnus-set-active nname (cons 1 0))
1641 (or (gnus-ephemeral-group-p name)
1643 (concat "(gnus-group-set-info '"
1644 (gnus-prin1-to-string (cdr info)) ")")))
1646 (gnus-group-insert-group-line-info nname)
1648 (gnus-group-position-point)
1650 ;; Load the backend and try to make the backend create
1651 ;; the group as well.
1652 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1654 gnus-valid-select-methods)
1656 (gnus-check-server meth)
1657 (and (gnus-check-backend-function 'request-create-group nname)
1658 (gnus-request-create-group nname nil args))
1661 (defun gnus-group-delete-group (group &optional force)
1662 "Delete the current group. Only meaningful with mail groups.
1663 If FORCE (the prefix) is non-nil, all the articles in the group will
1664 be deleted. This is \"deleted\" as in \"removed forever from the face
1665 of the Earth\". There is no undo. The user will be prompted before
1666 doing the deletion."
1668 (list (gnus-group-group-name)
1669 current-prefix-arg))
1670 (or group (error "No group to rename"))
1671 (or (gnus-check-backend-function 'request-delete-group group)
1672 (error "This backend does not support group deletion"))
1674 (if (not (gnus-yes-or-no-p
1676 "Do you really want to delete %s%s? "
1677 group (if force " and all its contents" ""))))
1679 (gnus-message 6 "Deleting group %s..." group)
1680 (if (not (gnus-request-delete-group group force))
1681 (gnus-error 3 "Couldn't delete group %s" group)
1682 (gnus-message 6 "Deleting group %s...done" group)
1683 (gnus-group-goto-group group)
1684 (gnus-group-kill-group 1 t)
1685 (gnus-sethash group nil gnus-active-hashtb)
1687 (gnus-group-position-point)))
1689 (defun gnus-group-rename-group (group new-name)
1690 "Rename group from GROUP to NEW-NAME.
1691 When used interactively, GROUP is the group under point
1692 and NEW-NAME will be prompted for."
1695 (gnus-group-group-name)
1697 (unless (gnus-check-backend-function
1698 'request-rename-group (gnus-group-group-name))
1699 (error "This backend does not support renaming groups"))
1700 (read-string "New group name: " (gnus-group-group-name)))))
1702 (unless (gnus-check-backend-function 'request-rename-group group)
1703 (error "This backend does not support renaming groups"))
1705 (error "No group to rename"))
1706 (when (string-match "^[ \t]*$" new-name)
1707 (error "Not a valid group name"))
1708 (when (equal group new-name)
1709 (error "Can't rename to the same name"))
1711 ;; We find the proper prefixed name.
1713 (if (equal (gnus-group-real-name new-name) new-name)
1717 (gnus-group-prefixed-name
1718 (gnus-group-real-name new-name)
1719 (gnus-info-method (gnus-get-info group)))))
1721 (gnus-message 6 "Renaming group %s to %s..." group new-name)
1723 (if (not (gnus-request-rename-group group new-name))
1724 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
1725 ;; We rename the group internally by killing it...
1726 (gnus-group-goto-group group)
1727 (gnus-group-kill-group)
1728 ;; ... changing its name ...
1729 (setcar (cdar gnus-list-of-killed-groups) new-name)
1730 ;; ... and then yanking it. Magic!
1731 (gnus-group-yank-group)
1732 (gnus-set-active new-name (gnus-active group))
1733 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
1735 (gnus-group-position-point)))
1737 (defun gnus-group-edit-group (group &optional part)
1738 "Edit the group on the current line."
1739 (interactive (list (gnus-group-group-name)))
1740 (let ((part (or part 'info))
1743 (error "No group on current line"))
1744 (unless (setq info (gnus-get-info group))
1745 (error "Killed group; can't be edited"))
1747 ;; Find the proper form to edit.
1748 (cond ((eq part 'method)
1749 (or (gnus-info-method info) "native"))
1751 (gnus-info-params info))
1753 ;; The proper documentation.
1757 ((eq part 'method) "select method")
1758 ((eq part 'params) "group parameters")
1761 (gnus-group-edit-group-done ',part ,group form)))))
1763 (defun gnus-group-edit-group-method (group)
1764 "Edit the select method of GROUP."
1765 (interactive (list (gnus-group-group-name)))
1766 (gnus-group-edit-group group 'method))
1768 (defun gnus-group-edit-group-parameters (group)
1769 "Edit the group parameters of GROUP."
1770 (interactive (list (gnus-group-group-name)))
1771 (gnus-group-edit-group group 'params))
1773 (defun gnus-group-edit-group-done (part group form)
1775 (let* ((method (cond ((eq part 'info) (nth 4 form))
1776 ((eq part 'method) form)
1778 (info (cond ((eq part 'info) form)
1779 ((eq part 'method) (gnus-get-info group))
1782 (if (or (not method)
1784 gnus-select-method method))
1785 (gnus-group-real-name (car info))
1786 (gnus-group-prefixed-name
1787 (gnus-group-real-name (car info)) method))
1789 (when (and new-group
1790 (not (equal new-group group)))
1791 (when (gnus-group-goto-group group)
1792 (gnus-group-kill-group 1))
1793 (gnus-activate-group new-group))
1795 (if (not (and info new-group))
1796 (gnus-group-set-info form (or new-group group) part)
1797 (setq info (gnus-copy-sequence info))
1798 (setcar info new-group)
1799 (unless (gnus-server-equal method "native")
1800 (unless (nthcdr 3 info)
1801 (nconc info (list nil nil)))
1802 (unless (nthcdr 4 info)
1803 (nconc info (list nil)))
1804 (gnus-info-set-method info method))
1805 (gnus-group-set-info info))
1806 (gnus-group-update-group (or new-group group))
1807 (gnus-group-position-point)))
1809 (defun gnus-group-make-useful-group (group method)
1811 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
1813 gnus-useful-groups)))
1814 (list (cadr entry) (caddr entry))))
1815 (setq method (gnus-copy-sequence method))
1817 (while (setq entry (memq (assq 'eval method) method))
1818 (setcar entry (eval (cadar entry)))))
1819 (gnus-group-make-group group method))
1821 (defun gnus-group-make-help-group ()
1822 "Create the Gnus documentation group."
1824 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
1825 (file (nnheader-find-etc-directory "gnus-tut.txt" t))
1827 (when (gnus-gethash name gnus-newsrc-hashtb)
1828 (error "Documentation group already exists"))
1830 (gnus-message 1 "Couldn't find doc group")
1831 (gnus-group-make-group
1832 (gnus-group-real-name name)
1833 (list 'nndoc "gnus-help"
1834 (list 'nndoc-address file)
1835 (list 'nndoc-article-type 'mbox)))))
1836 (gnus-group-position-point))
1838 (defun gnus-group-make-doc-group (file type)
1839 "Create a group that uses a single file as the source."
1841 (list (read-file-name "File name: ")
1842 (and current-prefix-arg 'ask)))
1843 (when (eq type 'ask)
1848 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
1850 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
1851 ((= char ?b) 'babyl)
1852 ((= char ?d) 'digest)
1853 ((= char ?f) 'forward)
1855 (t (setq err (format "%c unknown. " char))
1858 (let* ((file (expand-file-name file))
1859 (name (gnus-generate-new-group-name
1860 (gnus-group-prefixed-name
1861 (file-name-nondirectory file) '(nndoc "")))))
1862 (gnus-group-make-group
1863 (gnus-group-real-name name)
1865 (list 'nndoc-address file)
1866 (list 'nndoc-article-type (or type 'guess))))))
1868 (defvar nnweb-type-definition)
1869 (defvar gnus-group-web-type-history nil)
1870 (defvar gnus-group-web-search-history nil)
1871 (defun gnus-group-make-web-group (&optional solid)
1872 "Create an ephemeral nnweb group.
1873 If SOLID (the prefix), create a solid group."
1877 (if solid (read-string "Group name: ") (message-unique-id)))
1880 "Search engine type: "
1881 (mapcar (lambda (elem) (list (symbol-name (car elem))))
1882 nnweb-type-definition)
1883 nil t (cons (or (car gnus-group-web-type-history)
1884 (symbol-name (caar nnweb-type-definition)))
1886 'gnus-group-web-type-history))
1890 (cons (or (car gnus-group-web-search-history) "") 0)
1891 'gnus-group-web-search-history))
1893 `(nnweb ,group (nnweb-search ,search)
1894 (nnweb-type ,(intern type))
1895 (nnweb-ephemeral-p t))))
1897 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
1898 (gnus-group-read-ephemeral-group
1900 (cons (current-buffer)
1901 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
1903 (defun gnus-group-make-archive-group (&optional all)
1904 "Create the (ding) Gnus archive group of the most recent articles.
1905 Given a prefix, create a full group."
1907 (let ((group (gnus-group-prefixed-name
1908 (if all "ding.archives" "ding.recent") '(nndir ""))))
1909 (when (gnus-gethash group gnus-newsrc-hashtb)
1910 (error "Archive group already exists"))
1911 (gnus-group-make-group
1912 (gnus-group-real-name group)
1913 (list 'nndir (if all "hpc" "edu")
1914 (list 'nndir-directory
1915 (if all gnus-group-archive-directory
1916 gnus-group-recent-archive-directory))))
1917 (gnus-group-add-parameter group (cons 'to-address "ding@ifi.uio.no"))))
1919 (defun gnus-group-make-directory-group (dir)
1920 "Create an nndir group.
1921 The user will be prompted for a directory. The contents of this
1922 directory will be used as a newsgroup. The directory should contain
1923 mail messages or news articles in files that have numeric names."
1925 (list (read-file-name "Create group from directory: ")))
1926 (or (file-exists-p dir) (error "No such directory"))
1927 (or (file-directory-p dir) (error "Not a directory"))
1931 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
1933 (gnus-group-prefixed-name
1934 (concat (file-name-as-directory (directory-file-name dir))
1937 (setq ext (format "<%d>" (setq i (1+ i)))))
1938 (gnus-group-make-group
1939 (gnus-group-real-name group)
1940 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
1942 (defun gnus-group-make-kiboze-group (group address scores)
1943 "Create an nnkiboze group.
1944 The user will be prompted for a name, a regexp to match groups, and
1945 score file entries for articles to include in the group."
1948 (read-string "nnkiboze group name: ")
1949 (read-string "Source groups (regexp): ")
1950 (let ((headers (mapcar (lambda (group) (list group))
1951 '("subject" "from" "number" "date" "message-id"
1952 "references" "chars" "lines" "xref"
1953 "followup" "all" "body" "head")))
1954 scores header regexp regexps)
1955 (while (not (equal "" (setq header (completing-read
1956 "Match on header: " headers nil t))))
1958 (while (not (equal "" (setq regexp (read-string
1959 (format "Match on %s (string): "
1961 (setq regexps (cons (list regexp nil nil 'r) regexps)))
1962 (setq scores (cons (cons header regexps) scores)))
1964 (gnus-group-make-group group "nnkiboze" address)
1965 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
1966 (let (emacs-lisp-mode-hook)
1967 (pp scores (current-buffer)))))
1969 (defun gnus-group-add-to-virtual (n vgroup)
1970 "Add the current group to a virtual group."
1972 (list current-prefix-arg
1973 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
1975 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
1976 (error "%s is not an nnvirtual group" vgroup))
1977 (let* ((groups (gnus-group-process-prefix n))
1978 (method (gnus-info-method (gnus-get-info vgroup))))
1979 (setcar (cdr method)
1981 (nth 1 method) "\\|"
1984 (gnus-group-remove-mark s)
1985 (concat "\\(^" (regexp-quote s) "$\\)"))
1987 (gnus-group-position-point))
1989 (defun gnus-group-make-empty-virtual (group)
1990 "Create a new, fresh, empty virtual group."
1991 (interactive "sCreate new, empty virtual group: ")
1992 (let* ((method (list 'nnvirtual "^$"))
1993 (pgroup (gnus-group-prefixed-name group method)))
1994 ;; Check whether it exists already.
1995 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
1996 (error "Group %s already exists." pgroup))
1997 ;; Subscribe the new group after the group on the current line.
1998 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
1999 (gnus-group-update-group pgroup)
2001 (gnus-group-position-point)))
2003 (defun gnus-group-enter-directory (dir)
2004 "Enter an ephemeral nneething group."
2005 (interactive "DDirectory to read: ")
2006 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2007 (leaf (gnus-group-prefixed-name
2008 (file-name-nondirectory (directory-file-name dir))
2010 (name (gnus-generate-new-group-name leaf)))
2011 (unless (gnus-group-read-ephemeral-group
2013 (cons (current-buffer)
2014 (if (eq major-mode 'gnus-summary-mode)
2016 (error "Couldn't enter %s" dir))))
2018 ;; Group sorting commands
2019 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2021 (defun gnus-group-sort-groups (func &optional reverse)
2022 "Sort the group buffer according to FUNC.
2023 If REVERSE, reverse the sorting order."
2024 (interactive (list gnus-group-sort-function current-prefix-arg))
2025 (funcall gnus-group-sort-alist-function
2026 (gnus-make-sort-function func) reverse)
2027 (gnus-group-list-groups))
2029 (defun gnus-group-sort-flat (func reverse)
2030 ;; We peel off the dummy group from the alist.
2032 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
2033 (pop gnus-newsrc-alist))
2035 (setq gnus-newsrc-alist
2036 (sort gnus-newsrc-alist func))
2038 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2039 ;; Regenerate the hash table.
2040 (gnus-make-hashtable-from-newsrc-alist)))
2042 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2043 "Sort the group buffer alphabetically by group name.
2044 If REVERSE, sort in reverse order."
2046 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2048 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2049 "Sort the group buffer by number of unread articles.
2050 If REVERSE, sort in reverse order."
2052 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2054 (defun gnus-group-sort-groups-by-level (&optional reverse)
2055 "Sort the group buffer by group level.
2056 If REVERSE, sort in reverse order."
2058 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2060 (defun gnus-group-sort-groups-by-score (&optional reverse)
2061 "Sort the group buffer by group score.
2062 If REVERSE, sort in reverse order."
2064 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2066 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2067 "Sort the group buffer by group rank.
2068 If REVERSE, sort in reverse order."
2070 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2072 (defun gnus-group-sort-groups-by-method (&optional reverse)
2073 "Sort the group buffer alphabetically by backend name.
2074 If REVERSE, sort in reverse order."
2076 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2078 ;;; Selected group sorting.
2080 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2081 "Sort the process/prefixed groups."
2082 (interactive (list current-prefix-arg gnus-group-sort-function))
2083 (let ((groups (gnus-group-process-prefix n)))
2084 (funcall gnus-group-sort-selected-function
2085 groups (gnus-make-sort-function func) reverse)
2086 (gnus-group-list-groups)))
2088 (defun gnus-group-sort-selected-flat (groups func reverse)
2089 (let (entries infos)
2090 ;; First find all the group entries for these groups.
2092 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2094 ;; Then sort the infos.
2098 (lambda (entry) (car entry))
2099 (setq entries (nreverse entries)))
2102 (setq infos (nreverse infos)))
2103 ;; Go through all the infos and replace the old entries
2104 ;; with the new infos.
2106 (setcar entries (pop infos))
2108 ;; Update the hashtable.
2109 (gnus-make-hashtable-from-newsrc-alist)))
2111 (defun gnus-group-sort-selected-groups-by-alphabet (&optional reverse)
2112 "Sort the group buffer alphabetically by group name.
2113 If REVERSE, sort in reverse order."
2115 (gnus-group-sort-selected-groups 'gnus-group-sort-by-alphabet reverse))
2117 (defun gnus-group-sort-selected-groups-by-unread (&optional reverse)
2118 "Sort the group buffer by number of unread articles.
2119 If REVERSE, sort in reverse order."
2121 (gnus-group-sort-selected-groups 'gnus-group-sort-by-unread reverse))
2123 (defun gnus-group-sort-selected-groups-by-level (&optional reverse)
2124 "Sort the group buffer by group level.
2125 If REVERSE, sort in reverse order."
2127 (gnus-group-sort-selected-groups 'gnus-group-sort-by-level reverse))
2129 (defun gnus-group-sort-selected-groups-by-score (&optional reverse)
2130 "Sort the group buffer by group score.
2131 If REVERSE, sort in reverse order."
2133 (gnus-group-sort-selected-groups 'gnus-group-sort-by-score reverse))
2135 (defun gnus-group-sort-selected-groups-by-rank (&optional reverse)
2136 "Sort the group buffer by group rank.
2137 If REVERSE, sort in reverse order."
2139 (gnus-group-sort-selected-groups 'gnus-group-sort-by-rank reverse))
2141 (defun gnus-group-sort-selected-groups-by-method (&optional reverse)
2142 "Sort the group buffer alphabetically by backend name.
2143 If REVERSE, sort in reverse order."
2145 (gnus-group-sort-selected-groups 'gnus-group-sort-by-method reverse))
2147 ;;; Sorting predicates.
2149 (defun gnus-group-sort-by-alphabet (info1 info2)
2150 "Sort alphabetically."
2151 (string< (gnus-info-group info1) (gnus-info-group info2)))
2153 (defun gnus-group-sort-by-real-name (info1 info2)
2154 "Sort alphabetically on real (unprefixed) names."
2155 (string< (gnus-group-real-name (gnus-info-group info1))
2156 (gnus-group-real-name (gnus-info-group info2))))
2158 (defun gnus-group-sort-by-unread (info1 info2)
2159 "Sort by number of unread articles."
2160 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2161 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2162 (< (or (and (numberp n1) n1) 0)
2163 (or (and (numberp n2) n2) 0))))
2165 (defun gnus-group-sort-by-level (info1 info2)
2167 (< (gnus-info-level info1) (gnus-info-level info2)))
2169 (defun gnus-group-sort-by-method (info1 info2)
2170 "Sort alphabetically by backend name."
2171 (string< (symbol-name (car (gnus-find-method-for-group
2172 (gnus-info-group info1) info1)))
2173 (symbol-name (car (gnus-find-method-for-group
2174 (gnus-info-group info2) info2)))))
2176 (defun gnus-group-sort-by-score (info1 info2)
2177 "Sort by group score."
2178 (< (gnus-info-score info1) (gnus-info-score info2)))
2180 (defun gnus-group-sort-by-rank (info1 info2)
2181 "Sort by level and score."
2182 (let ((level1 (gnus-info-level info1))
2183 (level2 (gnus-info-level info2)))
2184 (or (< level1 level2)
2185 (and (= level1 level2)
2186 (> (gnus-info-score info1) (gnus-info-score info2))))))
2190 (defun gnus-group-clear-data (n)
2191 "Clear all marks and read ranges from the current group."
2193 (let ((groups (gnus-group-process-prefix n))
2195 (while (setq group (pop groups))
2196 (gnus-info-clear-data (setq info (gnus-get-info group)))
2197 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2198 (when (gnus-group-goto-group group)
2199 (gnus-group-remove-mark group)
2200 (gnus-group-update-group-line)))))
2202 (defun gnus-group-clear-data-on-native-groups ()
2203 "Clear all marks and read ranges from all native groups."
2205 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2206 (let ((alist (cdr gnus-newsrc-alist))
2208 (while (setq info (pop alist))
2209 (gnus-info-clear-data info))
2210 (gnus-get-unread-articles))))
2212 (defun gnus-info-clear-data (info)
2213 "Clear all marks and read ranges from INFO."
2214 (let ((group (gnus-info-group info)))
2217 (gnus-info-set-marks ,info ,(gnus-info-marks info))
2218 (gnus-info-set-read ,info ,(gnus-info-read info))
2219 (when (gnus-group-goto-group ,group)
2220 (gnus-group-update-group-line))))
2221 (gnus-info-set-read info nil)
2222 (when (gnus-info-marks info)
2223 (gnus-info-set-marks info nil))))
2225 ;; Group catching up.
2227 (defun gnus-group-catchup-current (&optional n all)
2228 "Mark all articles not marked as unread in current newsgroup as read.
2229 If prefix argument N is numeric, the ARG next newsgroups will be
2230 caught up. If ALL is non-nil, marked articles will also be marked as
2231 read. Cross references (Xref: header) of articles are ignored.
2232 The difference between N and actual number of newsgroups that were
2233 caught up is returned."
2235 (unless (gnus-group-group-name)
2236 (error "No group on the current line"))
2237 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
2241 "Do you really want to mark all articles as read? "
2242 "Mark all unread articles as read? "))))
2244 (let ((groups (gnus-group-process-prefix n))
2247 ;; Virtual groups have to be given special treatment.
2248 (let ((method (gnus-find-method-for-group (car groups))))
2249 (if (eq 'nnvirtual (car method))
2250 (nnvirtual-catchup-group
2251 (gnus-group-real-name (car groups)) (nth 1 method) all)))
2252 (gnus-group-remove-mark (car groups))
2253 (if (>= (gnus-group-group-level) gnus-level-zombie)
2254 (gnus-message 2 "Dead groups can't be caught up")
2256 (gnus-group-goto-group (car groups))
2257 (gnus-group-catchup (car groups) all))
2258 (gnus-group-update-group-line)
2259 (setq ret (1+ ret))))
2260 (setq groups (cdr groups)))
2261 (gnus-group-next-unread-group 1)
2264 (defun gnus-group-catchup-current-all (&optional n)
2265 "Mark all articles in current newsgroup as read.
2266 Cross references (Xref: header) of articles are ignored."
2268 (gnus-group-catchup-current n 'all))
2270 (defun gnus-group-catchup (group &optional all)
2271 "Mark all articles in GROUP as read.
2272 If ALL is non-nil, all articles are marked as read.
2273 The return value is the number of articles that were marked as read,
2274 or nil if no action could be taken."
2275 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2277 ;; Do the updating only if the newsgroup isn't killed.
2278 (if (not (numberp (car entry)))
2279 (gnus-message 1 "Can't catch up; non-active group")
2280 ;; Do auto-expirable marks if that's required.
2281 (when (gnus-group-auto-expirable-p group)
2282 (gnus-add-marked-articles
2283 group 'expire (gnus-list-of-unread-articles group))
2285 (let ((marks (nth 3 (nth 2 entry))))
2286 (gnus-add-marked-articles
2287 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2288 (gnus-add-marked-articles
2289 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2291 (gnus-update-read-articles group nil)
2292 ;; Also nix out the lists of marks and dormants.
2294 (gnus-add-marked-articles group 'tick nil nil 'force)
2295 (gnus-add-marked-articles group 'dormant nil nil 'force))
2296 (run-hooks 'gnus-group-catchup-group-hook)
2299 (defun gnus-group-expire-articles (&optional n)
2300 "Expire all expirable articles in the current newsgroup."
2302 (let ((groups (gnus-group-process-prefix n))
2305 (error "No groups to expire"))
2306 (while (setq group (pop groups))
2307 (gnus-group-remove-mark group)
2308 (when (gnus-check-backend-function 'request-expire-articles group)
2309 (gnus-message 6 "Expiring articles in %s..." group)
2310 (let* ((info (gnus-get-info group))
2311 (expirable (if (gnus-group-total-expirable-p group)
2312 (cons nil (gnus-list-of-read-articles group))
2313 (assq 'expire (gnus-info-marks info))))
2314 (expiry-wait (gnus-group-find-parameter group 'expiry-wait)))
2318 (gnus-compress-sequence
2320 ;; We set the expiry variables to the group
2322 (let ((nnmail-expiry-wait-function nil)
2323 (nnmail-expiry-wait expiry-wait))
2324 (gnus-request-expire-articles
2325 (gnus-uncompress-sequence (cdr expirable)) group))
2326 ;; Just expire using the normal expiry values.
2327 (gnus-request-expire-articles
2328 (gnus-uncompress-sequence (cdr expirable)) group))))
2329 (gnus-close-group group))
2330 (gnus-message 6 "Expiring articles in %s...done" group)))
2331 (gnus-group-position-point))))
2333 (defun gnus-group-expire-all-groups ()
2334 "Expire all expirable articles in all newsgroups."
2337 (gnus-message 5 "Expiring...")
2338 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2339 (cdr gnus-newsrc-alist))))
2340 (gnus-group-expire-articles nil)))
2341 (gnus-group-position-point)
2342 (gnus-message 5 "Expiring...done"))
2344 (defun gnus-group-set-current-level (n level)
2345 "Set the level of the next N groups to LEVEL."
2350 (let ((s (read-string
2351 (format "Level (default %s): "
2352 (or (gnus-group-group-level)
2353 gnus-level-default-subscribed)))))
2354 (if (string-match "^\\s-*$" s)
2355 (int-to-string (or (gnus-group-group-level)
2356 gnus-level-default-subscribed))
2358 (or (and (>= level 1) (<= level gnus-level-killed))
2359 (error "Illegal level: %d" level))
2360 (let ((groups (gnus-group-process-prefix n))
2362 (while (setq group (pop groups))
2363 (gnus-group-remove-mark group)
2364 (gnus-message 6 "Changed level of %s from %d to %d"
2365 group (or (gnus-group-group-level) gnus-level-killed)
2367 (gnus-group-change-level
2368 group level (or (gnus-group-group-level) gnus-level-killed))
2369 (gnus-group-update-group-line)))
2370 (gnus-group-position-point))
2372 (defun gnus-group-unsubscribe (&optional n)
2373 "Unsubscribe the current group."
2375 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2377 (defun gnus-group-subscribe (&optional n)
2378 "Unsubscribe the current group."
2380 (gnus-group-unsubscribe-current-group n 'subscribe))
2382 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2383 "Toggle subscription of the current group.
2384 If given numerical prefix, toggle the N next groups."
2386 (let ((groups (gnus-group-process-prefix n))
2389 (setq group (car groups)
2390 groups (cdr groups))
2391 (gnus-group-remove-mark group)
2392 (gnus-group-unsubscribe-group
2395 ((eq do-sub 'unsubscribe)
2396 gnus-level-default-unsubscribed)
2397 ((eq do-sub 'subscribe)
2398 gnus-level-default-subscribed)
2399 ((<= (gnus-group-group-level) gnus-level-subscribed)
2400 gnus-level-default-unsubscribed)
2402 gnus-level-default-subscribed))
2404 (gnus-group-update-group-line))
2405 (gnus-group-next-group 1)))
2407 (defun gnus-group-unsubscribe-group (group &optional level silent)
2408 "Toggle subscription to GROUP.
2409 Killed newsgroups are subscribed. If SILENT, don't try to update the
2412 (list (completing-read
2413 "Group: " gnus-active-hashtb nil
2414 (gnus-read-active-file-p)
2416 'gnus-group-history)))
2417 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2419 ((string-match "^[ \t]$" group)
2420 (error "Empty group name"))
2422 ;; Toggle subscription flag.
2423 (gnus-group-change-level
2424 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
2425 gnus-level-subscribed)
2426 (1+ gnus-level-subscribed)
2427 gnus-level-default-subscribed)))
2429 (gnus-group-update-group group)))
2430 ((and (stringp group)
2431 (or (not (gnus-read-active-file-p))
2432 (gnus-active group)))
2433 ;; Add new newsgroup.
2434 (gnus-group-change-level
2436 (if level level gnus-level-default-subscribed)
2437 (or (and (member group gnus-zombie-list)
2440 (and (gnus-group-group-name)
2441 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2443 (gnus-group-update-group group)))
2444 (t (error "No such newsgroup: %s" group)))
2445 (gnus-group-position-point)))
2447 (defun gnus-group-transpose-groups (n)
2448 "Move the current newsgroup up N places.
2449 If given a negative prefix, move down instead. The difference between
2450 N and the number of steps taken is returned."
2452 (or (gnus-group-group-name)
2453 (error "No group on current line"))
2454 (gnus-group-kill-group 1)
2456 (forward-line (- n))
2457 (gnus-group-yank-group)
2458 (gnus-group-position-point)))
2460 (defun gnus-group-kill-all-zombies ()
2461 "Kill all zombie newsgroups."
2463 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2464 (setq gnus-zombie-list nil)
2465 (gnus-group-list-groups))
2467 (defun gnus-group-kill-region (begin end)
2468 "Kill newsgroups in current region (excluding current point).
2469 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2484 (beginning-of-line) ;Important when LINES < 1
2485 (gnus-group-kill-group lines)))
2487 (defun gnus-group-kill-group (&optional n discard)
2488 "Kill the next N groups.
2489 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2490 However, only groups that were alive can be yanked; already killed
2491 groups or zombie groups can't be yanked.
2492 The return value is the name of the group that was killed, or a list
2495 (let ((buffer-read-only nil)
2496 (groups (gnus-group-process-prefix n))
2497 group entry level out)
2498 (if (< (length groups) 10)
2499 ;; This is faster when there are few groups.
2501 (push (setq group (pop groups)) out)
2502 (gnus-group-remove-mark group)
2503 (setq level (gnus-group-group-level))
2505 (when (and (not discard)
2506 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2509 (gnus-group-goto-group ,(gnus-group-group-name))
2510 (gnus-group-yank-group)))
2511 (push (cons (car entry) (nth 2 entry))
2512 gnus-list-of-killed-groups))
2513 (gnus-group-change-level
2514 (if entry entry group) gnus-level-killed (if entry nil level)))
2515 ;; If there are lots and lots of groups to be killed, we use
2516 ;; this thing instead.
2518 (setq groups (nreverse groups))
2520 (gnus-group-remove-mark (setq group (pop groups)))
2522 (push group gnus-killed-list)
2523 (setq gnus-newsrc-alist
2524 (delq (assoc group gnus-newsrc-alist)
2526 (when gnus-group-change-level-function
2527 (funcall gnus-group-change-level-function group 9 3))
2529 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2530 (push (cons (car entry) (nth 2 entry))
2531 gnus-list-of-killed-groups)
2532 (setcdr (cdr entry) (cdddr entry)))
2533 ((member group gnus-zombie-list)
2534 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
2535 (gnus-make-hashtable-from-newsrc-alist)))
2537 (gnus-group-position-point)
2538 (if (< (length out) 2) (car out) (nreverse out))))
2540 (defun gnus-group-yank-group (&optional arg)
2541 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
2542 inserting it before the current newsgroup. The numeric ARG specifies
2543 how many newsgroups are to be yanked. The name of the newsgroup yanked
2544 is returned, or (if several groups are yanked) a list of yanked groups
2547 (setq arg (or arg 1))
2548 (let (info group prev out)
2549 (while (>= (decf arg) 0)
2550 (if (not (setq info (pop gnus-list-of-killed-groups)))
2551 (error "No more newsgroups to yank"))
2552 (push (setq group (nth 1 info)) out)
2553 ;; Find which newsgroup to insert this one before - search
2554 ;; backward until something suitable is found. If there are no
2555 ;; other newsgroups in this buffer, just make this newsgroup the
2557 (setq prev (gnus-group-group-name))
2558 (gnus-group-change-level
2559 info (gnus-info-level (cdr info)) gnus-level-killed
2560 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
2562 (gnus-group-insert-group-line-info group)
2564 `(when (gnus-group-goto-group ,group)
2565 (gnus-group-kill-group 1))))
2567 (gnus-group-position-point)
2568 (if (< (length out) 2) (car out) (nreverse out))))
2570 (defun gnus-group-kill-level (level)
2571 "Kill all groups that is on a certain LEVEL."
2572 (interactive "nKill all groups on level: ")
2574 ((= level gnus-level-zombie)
2575 (setq gnus-killed-list
2576 (nconc gnus-zombie-list gnus-killed-list))
2577 (setq gnus-zombie-list nil))
2578 ((and (< level gnus-level-zombie)
2580 (or gnus-expert-user
2583 "Do you really want to kill all groups on level %d? "
2585 (let* ((prev gnus-newsrc-alist)
2588 (if (= (gnus-info-level (car alist)) level)
2590 (push (gnus-info-group (car alist)) gnus-killed-list)
2591 (setcdr prev (cdr alist)))
2593 (setq alist (cdr alist)))
2594 (gnus-make-hashtable-from-newsrc-alist)
2595 (gnus-group-list-groups)))
2597 (error "Can't kill; illegal level: %d" level))))
2599 (defun gnus-group-list-all-groups (&optional arg)
2600 "List all newsgroups with level ARG or lower.
2601 Default is gnus-level-unsubscribed, which lists all subscribed and most
2602 unsubscribed groups."
2604 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
2606 ;; Redefine this to list ALL killed groups if prefix arg used.
2607 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
2608 (defun gnus-group-list-killed (&optional arg)
2609 "List all killed newsgroups in the group buffer.
2610 If ARG is non-nil, list ALL killed groups known to Gnus. This may
2611 entail asking the server for the groups."
2613 ;; Find all possible killed newsgroups if arg.
2615 (gnus-get-killed-groups))
2616 (if (not gnus-killed-list)
2617 (gnus-message 6 "No killed groups")
2618 (let (gnus-group-list-mode)
2619 (funcall gnus-group-prepare-function
2620 gnus-level-killed t gnus-level-killed))
2621 (goto-char (point-min)))
2622 (gnus-group-position-point))
2624 (defun gnus-group-list-zombies ()
2625 "List all zombie newsgroups in the group buffer."
2627 (if (not gnus-zombie-list)
2628 (gnus-message 6 "No zombie groups")
2629 (let (gnus-group-list-mode)
2630 (funcall gnus-group-prepare-function
2631 gnus-level-zombie t gnus-level-zombie))
2632 (goto-char (point-min)))
2633 (gnus-group-position-point))
2635 (defun gnus-group-list-active ()
2636 "List all groups that are available from the server(s)."
2638 ;; First we make sure that we have really read the active file.
2639 (unless (gnus-read-active-file-p)
2640 (let ((gnus-read-active-file t))
2641 (gnus-read-active-file)))
2642 ;; Find all groups and sort them.
2650 (setq list (cons (symbol-name sym) list))))
2654 (buffer-read-only nil))
2657 (gnus-group-insert-group-line-info (pop groups)))
2658 (goto-char (point-min))))
2660 (defun gnus-activate-all-groups (level)
2661 "Activate absolutely all groups."
2662 (interactive (list 7))
2663 (let ((gnus-activate-level level)
2664 (gnus-activate-foreign-newsgroups level))
2665 (gnus-group-get-new-news)))
2667 (defun gnus-group-get-new-news (&optional arg)
2668 "Get newly arrived articles.
2669 If ARG is a number, it specifies which levels you are interested in
2670 re-scanning. If ARG is non-nil and not a number, this will force
2671 \"hard\" re-reading of the active files from all servers."
2673 (run-hooks 'gnus-get-new-news-hook)
2675 ;; Read any slave files.
2677 (gnus-master-read-slave-newsrc))
2679 ;; We might read in new NoCeM messages here.
2680 (when (and gnus-use-nocem
2682 (gnus-nocem-scan-groups))
2683 ;; If ARG is not a number, then we read the active file.
2684 (when (and arg (not (numberp arg)))
2685 (let ((gnus-read-active-file t))
2686 (gnus-read-active-file))
2689 (setq arg (gnus-group-default-level arg t))
2690 (if (and gnus-read-active-file (not arg))
2692 (gnus-read-active-file)
2693 (gnus-get-unread-articles arg))
2694 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
2695 (gnus-get-unread-articles arg)))
2696 (run-hooks 'gnus-after-getting-new-news-hook)
2697 (gnus-group-list-groups))
2699 (defun gnus-group-get-new-news-this-group (&optional n)
2700 "Check for newly arrived news in the current group (and the N-1 next groups).
2701 The difference between N and the number of newsgroup checked is returned.
2702 If N is negative, this group and the N-1 previous groups will be checked."
2704 (let* ((groups (gnus-group-process-prefix n))
2705 (ret (if (numberp n) (- n (length groups)) 0))
2706 (beg (unless n (point)))
2708 (while (setq group (pop groups))
2709 (gnus-group-remove-mark group)
2710 ;; Bypass any previous denials from the server.
2711 (gnus-remove-denial (gnus-find-method-for-group group))
2712 (if (gnus-activate-group group 'scan)
2714 (gnus-get-unread-articles-in-group
2715 (gnus-get-info group) (gnus-active group) t)
2716 (unless (gnus-virtual-group-p group)
2717 (gnus-close-group group))
2718 (gnus-group-update-group group))
2719 (if (eq (gnus-server-status (gnus-find-method-for-group group))
2721 (gnus-error 3 "Server denied access")
2722 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
2723 (when beg (goto-char beg))
2724 (when gnus-goto-next-group-when-activating
2725 (gnus-group-next-unread-group 1 t))
2726 (gnus-summary-position-point)
2729 (defun gnus-group-fetch-faq (group &optional faq-dir)
2730 "Fetch the FAQ for the current group.
2731 If given a prefix argument, prompt for the FAQ dir
2735 (gnus-group-group-name)
2736 (cond (current-prefix-arg
2738 "Faq dir: " (and (listp gnus-group-faq-directory)
2739 (mapcar (lambda (file) (list file))
2740 gnus-group-faq-directory)))))))
2742 (error "No group name given"))
2743 (let ((dirs (or faq-dir gnus-group-faq-directory))
2745 (unless (listp dirs)
2746 (setq dirs (list dirs)))
2747 (while (and (not found)
2748 (setq dir (pop dirs)))
2749 (setq file (concat (file-name-as-directory dir)
2750 (gnus-group-real-name group)))
2751 (if (not (file-exists-p file))
2752 (gnus-message 1 "No such file: %s" file)
2756 (defun gnus-group-describe-group (force &optional group)
2757 "Display a description of the current newsgroup."
2758 (interactive (list current-prefix-arg (gnus-group-group-name)))
2759 (let* ((method (gnus-find-method-for-group group))
2760 (mname (gnus-group-prefixed-name "" method))
2763 gnus-description-hashtb)
2764 (gnus-sethash mname nil gnus-description-hashtb))
2765 (or group (error "No group name given"))
2766 (and (or (and gnus-description-hashtb
2767 ;; We check whether this group's method has been
2768 ;; queried for a description file.
2769 (gnus-gethash mname gnus-description-hashtb))
2770 (setq desc (gnus-group-get-description group))
2771 (gnus-read-descriptions-file method))
2773 (or desc (gnus-gethash group gnus-description-hashtb)
2774 "No description available")))))
2776 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
2777 (defun gnus-group-describe-all-groups (&optional force)
2778 "Pop up a buffer with descriptions of all newsgroups."
2780 (and force (setq gnus-description-hashtb nil))
2781 (if (not (or gnus-description-hashtb
2782 (gnus-read-all-descriptions-files)))
2783 (error "Couldn't request descriptions file"))
2784 (let ((buffer-read-only nil)
2790 (insert (format " *: %-20s %s\n" (symbol-name group)
2791 (symbol-value group)))
2792 (gnus-add-text-properties
2793 b (1+ b) (list 'gnus-group group
2794 'gnus-unread t 'gnus-marked nil
2795 'gnus-level (1+ gnus-level-subscribed))))
2796 gnus-description-hashtb)
2797 (goto-char (point-min))
2798 (gnus-group-position-point)))
2800 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
2801 (defun gnus-group-apropos (regexp &optional search-description)
2802 "List all newsgroups that have names that match a regexp."
2803 (interactive "sGnus apropos (regexp): ")
2805 (obuf (current-buffer))
2807 ;; Go through all newsgroups that are known to Gnus.
2810 (and (symbol-name group)
2811 (string-match regexp (symbol-name group))
2812 (setq groups (cons (symbol-name group) groups))))
2814 ;; Also go through all descriptions that are known to Gnus.
2815 (when search-description
2818 (and (string-match regexp (symbol-value group))
2819 (gnus-active (symbol-name group))
2820 (setq groups (cons (symbol-name group) groups))))
2821 gnus-description-hashtb))
2823 (gnus-message 3 "No groups matched \"%s\"." regexp)
2824 ;; Print out all the groups.
2826 (pop-to-buffer "*Gnus Help*")
2827 (buffer-disable-undo (current-buffer))
2829 (setq groups (sort groups 'string<))
2831 ;; Groups may be entered twice into the list of groups.
2832 (if (not (string= (car groups) prev))
2834 (insert (setq prev (car groups)) "\n")
2835 (if (and gnus-description-hashtb
2836 (setq des (gnus-gethash (car groups)
2837 gnus-description-hashtb)))
2838 (insert " " des "\n"))))
2839 (setq groups (cdr groups)))
2840 (goto-char (point-min))))
2841 (pop-to-buffer obuf)))
2843 (defun gnus-group-description-apropos (regexp)
2844 "List all newsgroups that have names or descriptions that match a regexp."
2845 (interactive "sGnus description apropos (regexp): ")
2846 (if (not (or gnus-description-hashtb
2847 (gnus-read-all-descriptions-files)))
2848 (error "Couldn't request descriptions file"))
2849 (gnus-group-apropos regexp t))
2851 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
2852 (defun gnus-group-list-matching (level regexp &optional all lowest)
2853 "List all groups with unread articles that match REGEXP.
2854 If the prefix LEVEL is non-nil, it should be a number that says which
2855 level to cut off listing groups.
2856 If ALL, also list groups with no unread articles.
2857 If LOWEST, don't list groups with level lower than LOWEST.
2859 This command may read the active file."
2860 (interactive "P\nsList newsgroups matching: ")
2861 ;; First make sure active file has been read.
2863 (> (prefix-numeric-value level) gnus-level-killed))
2864 (gnus-get-killed-groups))
2865 (gnus-group-prepare-flat (or level gnus-level-subscribed)
2866 all (or lowest 1) regexp)
2867 (goto-char (point-min))
2868 (gnus-group-position-point))
2870 (defun gnus-group-list-all-matching (level regexp &optional lowest)
2871 "List all groups that match REGEXP.
2872 If the prefix LEVEL is non-nil, it should be a number that says which
2873 level to cut off listing groups.
2874 If LOWEST, don't list groups with level lower than LOWEST."
2875 (interactive "P\nsList newsgroups matching: ")
2876 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
2878 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
2879 (defun gnus-group-save-newsrc (&optional force)
2880 "Save the Gnus startup files.
2881 If FORCE, force saving whether it is necessary or not."
2883 (gnus-save-newsrc-file force))
2885 (defun gnus-group-restart (&optional arg)
2886 "Force Gnus to read the .newsrc file."
2888 (when (gnus-yes-or-no-p
2889 (format "Are you sure you want to restart Gnus? "))
2890 (gnus-save-newsrc-file)
2891 (gnus-setup-news 'force)
2892 (gnus-group-list-groups arg)))
2894 (defun gnus-group-read-init-file ()
2895 "Read the Gnus elisp init file."
2897 (gnus-read-init-file))
2899 (defun gnus-group-check-bogus-groups (&optional silent)
2900 "Check bogus newsgroups.
2901 If given a prefix, don't ask for confirmation before removing a bogus
2904 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
2905 (gnus-group-list-groups))
2907 (defun gnus-group-edit-global-kill (&optional article group)
2908 "Edit the global kill file.
2909 If GROUP, edit that local kill file instead."
2911 (setq gnus-current-kill-article article)
2912 (gnus-kill-file-edit-file group)
2915 (substitute-command-keys
2916 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
2917 (if group "local" "global")))))
2919 (defun gnus-group-edit-local-kill (article group)
2920 "Edit a local kill file."
2921 (interactive (list nil (gnus-group-group-name)))
2922 (gnus-group-edit-global-kill article group))
2924 (defun gnus-group-force-update ()
2925 "Update `.newsrc' file."
2927 (gnus-save-newsrc-file))
2929 (defun gnus-group-suspend ()
2930 "Suspend the current Gnus session.
2931 In fact, cleanup buffers except for group mode buffer.
2932 The hook gnus-suspend-gnus-hook is called before actually suspending."
2934 (run-hooks 'gnus-suspend-gnus-hook)
2935 ;; Kill Gnus buffers except for group mode buffer.
2936 (let* ((group-buf (get-buffer gnus-group-buffer))
2937 ;; Do this on a separate list in case the user does a ^G before we finish
2939 (delete group-buf (delete gnus-dribble-buffer
2940 (append gnus-buffer-list nil)))))
2941 (while gnus-buffer-list
2942 (gnus-kill-buffer (pop gnus-buffer-list)))
2943 (gnus-kill-gnus-frames)
2945 (setq gnus-buffer-list (list group-buf))
2946 (bury-buffer group-buf)
2947 (delete-windows-on group-buf t))))
2949 (defun gnus-group-clear-dribble ()
2950 "Clear all information from the dribble buffer."
2952 (gnus-dribble-clear)
2953 (gnus-message 7 "Cleared dribble buffer"))
2955 (defun gnus-group-exit ()
2956 "Quit reading news after updating .newsrc.eld and .newsrc.
2957 The hook `gnus-exit-gnus-hook' is called before actually exiting."
2960 (or noninteractive ;For gnus-batch-kill
2961 (not gnus-interactive-exit) ;Without confirmation
2963 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
2964 (run-hooks 'gnus-exit-gnus-hook)
2965 ;; Offer to save data from non-quitted summary buffers.
2966 (gnus-offer-save-summaries)
2967 ;; Save the newsrc file(s).
2968 (gnus-save-newsrc-file)
2970 (gnus-close-backends)
2971 ;; Reset everything.
2973 ;; Allow the user to do things after cleaning up.
2974 (run-hooks 'gnus-after-exiting-gnus-hook)))
2976 (defun gnus-group-quit ()
2977 "Quit reading news without updating .newsrc.eld or .newsrc.
2978 The hook `gnus-exit-gnus-hook' is called before actually exiting."
2980 (when (or noninteractive ;For gnus-batch-kill
2981 (zerop (buffer-size))
2982 (not (gnus-server-opened gnus-select-method))
2984 (not gnus-current-startup-file)
2986 (format "Quit reading news without saving %s? "
2987 (file-name-nondirectory gnus-current-startup-file))))
2988 (run-hooks 'gnus-exit-gnus-hook)
2989 (gnus-configure-windows 'group t)
2991 (gnus-close-backends)
2993 (gnus-kill-buffer gnus-group-buffer)
2994 ;; Allow the user to do things after cleaning up.
2995 (run-hooks 'gnus-after-exiting-gnus-hook)))
2997 (defun gnus-group-describe-briefly ()
2998 "Give a one line description of the group mode commands."
3000 (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")))
3002 (defun gnus-group-browse-foreign-server (method)
3003 "Browse a foreign news server.
3004 If called interactively, this function will ask for a select method
3005 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3006 If not, METHOD should be a list where the first element is the method
3007 and the second element is the address."
3009 (list (let ((how (completing-read
3011 (append gnus-valid-select-methods gnus-server-alist)
3012 nil t (cons "nntp" 0) 'gnus-method-history)))
3013 ;; We either got a backend name or a virtual server name.
3014 ;; If the first, we also need an address.
3015 (if (assoc how gnus-valid-select-methods)
3017 ;; Suggested by mapjph@bath.ac.uk.
3020 (mapcar (lambda (server) (list server))
3021 gnus-secondary-servers)))
3022 ;; We got a server name, so we find the method.
3023 (gnus-server-to-method how)))))
3024 (gnus-browse-foreign-server method))
3026 (defun gnus-group-set-info (info &optional method-only-group part)
3027 (let* ((entry (gnus-gethash
3028 (or method-only-group (gnus-info-group info))
3029 gnus-newsrc-hashtb))
3031 (info (if method-only-group (nth 2 entry) info))
3033 (when method-only-group
3035 (error "Trying to change non-existent group %s" method-only-group))
3036 ;; We have received parts of the actual group info - either the
3037 ;; select method or the group parameters. We first check
3038 ;; whether we have to extend the info, and if so, do that.
3039 (let ((len (length info))
3040 (total (if (eq part 'method) 5 6)))
3042 (setcdr (nthcdr (1- len) info)
3043 (make-list (- total len) nil)))
3044 ;; Then we enter the new info.
3045 (setcar (nthcdr (1- total) info) part-info)))
3047 ;; This is a new group, so we just create it.
3049 (set-buffer gnus-group-buffer)
3050 (setq method (gnus-info-method info))
3051 (when (gnus-server-equal method "native")
3054 (set-buffer gnus-group-buffer)
3056 ;; It's a foreign group...
3057 (gnus-group-make-group
3058 (gnus-group-real-name (gnus-info-group info))
3059 (if (stringp method) method
3060 (prin1-to-string (car method)))
3062 (nth 1 (gnus-info-method info))))
3063 ;; It's a native group.
3064 (gnus-group-make-group (gnus-info-group info))))
3065 (gnus-message 6 "Note: New group created")
3067 (gnus-gethash (gnus-group-prefixed-name
3068 (gnus-group-real-name (gnus-info-group info))
3069 (or (gnus-info-method info) gnus-select-method))
3070 gnus-newsrc-hashtb))))
3071 ;; Whether it was a new group or not, we now have the entry, so we
3072 ;; can do the update.
3075 (setcar (nthcdr 2 entry) info)
3076 (when (and (not (eq (car entry) t))
3077 (gnus-active (gnus-info-group info)))
3078 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3079 (error "No such group: %s" (gnus-info-group info)))))
3081 (defun gnus-group-set-method-info (group select-method)
3082 (gnus-group-set-info select-method group 'method))
3084 (defun gnus-group-set-params-info (group params)
3085 (gnus-group-set-info params group 'params))
3087 (defun gnus-add-marked-articles (group type articles &optional info force)
3088 ;; Add ARTICLES of TYPE to the info of GROUP.
3089 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3090 ;; add, but replace marked articles of TYPE with ARTICLES.
3091 (let ((info (or info (gnus-get-info group)))
3092 (uncompressed '(score bookmark killed))
3095 (and (not (setq marked (nthcdr 3 info)))
3097 (setcdr (nthcdr 2 info)
3098 (list (list (cons type (gnus-compress-sequence
3100 (and (not (setq m (assq type (car marked))))
3103 (cons (cons type (gnus-compress-sequence articles t) )
3107 (setcar (nthcdr 3 info)
3108 (delq (assq type (car marked)) (car marked)))
3109 (setcdr m (gnus-compress-sequence articles t)))
3110 (setcdr m (gnus-compress-sequence
3111 (sort (nconc (gnus-uncompress-range (cdr m))
3112 (copy-sequence articles)) '<) t))))))
3114 (provide 'gnus-group)
3116 ;;; gnus-group.el ends here