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 "\177" gnus-group-delete-group
438 [delete] gnus-group-delete-group)
440 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
441 "b" gnus-group-brew-soup
442 "w" gnus-soup-save-areas
443 "s" gnus-soup-send-replies
444 "p" gnus-soup-pack-packet
445 "r" nnsoup-pack-replies)
447 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
448 "s" gnus-group-sort-groups
449 "a" gnus-group-sort-groups-by-alphabet
450 "u" gnus-group-sort-groups-by-unread
451 "l" gnus-group-sort-groups-by-level
452 "v" gnus-group-sort-groups-by-score
453 "r" gnus-group-sort-groups-by-rank
454 "m" gnus-group-sort-groups-by-method)
456 (gnus-define-keys (gnus-group-sort-map "P" gnus-group-group-map)
457 "s" gnus-group-sort-selected-groups
458 "a" gnus-group-sort-selected-groups-by-alphabet
459 "u" gnus-group-sort-selected-groups-by-unread
460 "l" gnus-group-sort-selected-groups-by-level
461 "v" gnus-group-sort-selected-groups-by-score
462 "r" gnus-group-sort-selected-groups-by-rank
463 "m" gnus-group-sort-selected-groups-by-method)
465 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
466 "k" gnus-group-list-killed
467 "z" gnus-group-list-zombies
468 "s" gnus-group-list-groups
469 "u" gnus-group-list-all-groups
470 "A" gnus-group-list-active
471 "a" gnus-group-apropos
472 "d" gnus-group-description-apropos
473 "m" gnus-group-list-matching
474 "M" gnus-group-list-all-matching
475 "l" gnus-group-list-level)
477 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
478 "f" gnus-score-flush-cache)
480 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
481 "d" gnus-group-describe-group
482 "f" gnus-group-fetch-faq)
484 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
485 "l" gnus-group-set-current-level
486 "t" gnus-group-unsubscribe-current-group
487 "s" gnus-group-unsubscribe-group
488 "k" gnus-group-kill-group
489 "y" gnus-group-yank-group
490 "w" gnus-group-kill-region
491 "\C-k" gnus-group-kill-level
492 "z" gnus-group-kill-all-zombies))
494 (defun gnus-group-make-menu-bar ()
495 (gnus-turn-off-edit-menu 'group)
496 (unless (boundp 'gnus-group-reading-menu)
499 gnus-group-reading-menu gnus-group-mode-map ""
501 ["Read" gnus-group-read-group (gnus-group-group-name)]
502 ["Select" gnus-group-select-group (gnus-group-group-name)]
503 ["See old articles" (gnus-group-select-group 'all)
504 :keys "C-u SPC" :active (gnus-group-group-name)]
505 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
506 ["Catch up all articles" gnus-group-catchup-current-all
507 (gnus-group-group-name)]
508 ["Check for new articles" gnus-group-get-new-news-this-group
509 (gnus-group-group-name)]
510 ["Toggle subscription" gnus-group-unsubscribe-current-group
511 (gnus-group-group-name)]
512 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
513 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
514 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
515 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
516 ["Edit kill file" gnus-group-edit-local-kill
517 (gnus-group-group-name)]
518 ;; Actually one should check, if any of the marked groups gives t for
519 ;; (gnus-check-backend-function 'request-expire-articles ...)
520 ["Expire articles" gnus-group-expire-articles
521 (or (and (gnus-group-group-name)
522 (gnus-check-backend-function
523 'request-expire-articles
524 (gnus-group-group-name))) gnus-group-marked)]
525 ["Set group level" gnus-group-set-current-level
526 (gnus-group-group-name)]
527 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
531 gnus-group-group-menu gnus-group-mode-map ""
534 ["List unread subscribed groups" gnus-group-list-groups t]
535 ["List (un)subscribed groups" gnus-group-list-all-groups t]
536 ["List killed groups" gnus-group-list-killed gnus-killed-list]
537 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
538 ["List level..." gnus-group-list-level t]
539 ["Describe all groups" gnus-group-describe-all-groups t]
540 ["Group apropos..." gnus-group-apropos t]
541 ["Group and description apropos..." gnus-group-description-apropos t]
542 ["List groups matching..." gnus-group-list-matching t]
543 ["List all groups matching..." gnus-group-list-all-matching t]
544 ["List active file" gnus-group-list-active t])
546 ["Default sort" gnus-group-sort-groups t]
547 ["Sort by method" gnus-group-sort-groups-by-method t]
548 ["Sort by rank" gnus-group-sort-groups-by-rank t]
549 ["Sort by score" gnus-group-sort-groups-by-score t]
550 ["Sort by level" gnus-group-sort-groups-by-level t]
551 ["Sort by unread" gnus-group-sort-groups-by-unread t]
552 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
553 ("Sort process/prefixed"
554 ["Default sort" gnus-group-sort-selected-groups
555 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
556 ["Sort by method" gnus-group-sort-selected-groups-by-method
557 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
558 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
559 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
560 ["Sort by score" gnus-group-sort-selected-groups-by-score
561 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
562 ["Sort by level" gnus-group-sort-selected-groups-by-level
563 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
564 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
565 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
566 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
567 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
569 ["Mark group" gnus-group-mark-group
570 (and (gnus-group-group-name)
571 (not (memq (gnus-group-group-name) gnus-group-marked)))]
572 ["Unmark group" gnus-group-unmark-group
573 (and (gnus-group-group-name)
574 (memq (gnus-group-group-name) gnus-group-marked))]
575 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
576 ["Mark regexp..." gnus-group-mark-regexp t]
577 ["Mark region" gnus-group-mark-region t]
578 ["Mark buffer" gnus-group-mark-buffer t]
579 ["Execute command" gnus-group-universal-argument
580 (or gnus-group-marked (gnus-group-group-name))])
582 ["Subscribe to a group" gnus-group-unsubscribe-group t]
583 ["Kill all newsgroups in region" gnus-group-kill-region t]
584 ["Kill all zombie groups" gnus-group-kill-all-zombies
586 ["Kill all groups on level..." gnus-group-kill-level t])
588 ["Make a foreign group" gnus-group-make-group t]
589 ["Add a directory group" gnus-group-make-directory-group t]
590 ["Add the help group" gnus-group-make-help-group t]
591 ["Add the archive group" gnus-group-make-archive-group t]
592 ["Make a doc group" gnus-group-make-doc-group t]
593 ["Make a web group" gnus-group-make-web-group t]
594 ["Make a kiboze group" gnus-group-make-kiboze-group t]
595 ["Make a virtual group" gnus-group-make-empty-virtual t]
596 ["Add a group to a virtual" gnus-group-add-to-virtual t]
597 ["Rename group" gnus-group-rename-group
598 (gnus-check-backend-function
599 'request-rename-group (gnus-group-group-name))]
600 ["Delete group" gnus-group-delete-group
601 (gnus-check-backend-function
602 'request-delete-group (gnus-group-group-name))])
604 ["Parameters" gnus-group-edit-group-parameters
605 (gnus-group-group-name)]
606 ["Select method" gnus-group-edit-group-method
607 (gnus-group-group-name)]
608 ["Info" gnus-group-edit-group (gnus-group-group-name)])
610 ["Flush cache" gnus-score-flush-cache t])
612 ["Next" gnus-group-next-group t]
613 ["Previous" gnus-group-prev-group t]
614 ["Next unread" gnus-group-next-unread-group t]
615 ["Previous unread" gnus-group-prev-unread-group t]
616 ["Next unread same level" gnus-group-next-unread-group-same-level t]
617 ["Previous unread same level"
618 gnus-group-prev-unread-group-same-level t]
619 ["Jump to group" gnus-group-jump-to-group t]
620 ["First unread group" gnus-group-first-unread-group t]
621 ["Best unread group" gnus-group-best-unread-group t])
622 ["Transpose" gnus-group-transpose-groups
623 (gnus-group-group-name)]
624 ["Read a directory as a group..." gnus-group-enter-directory t]
628 gnus-group-misc-menu gnus-group-mode-map ""
630 ["Send a bug report" gnus-bug t]
631 ["Send a mail" gnus-group-mail t]
632 ["Post an article..." gnus-group-post-news t]
633 ["Check for new news" gnus-group-get-new-news t]
634 ["Activate all groups" gnus-activate-all-groups t]
635 ["Delete bogus groups" gnus-group-check-bogus-groups t]
636 ["Find new newsgroups" gnus-find-new-newsgroups t]
637 ["Restart Gnus" gnus-group-restart t]
638 ["Read init file" gnus-group-read-init-file t]
639 ["Browse foreign server" gnus-group-browse-foreign-server t]
640 ["Enter server buffer" gnus-group-enter-server-mode t]
641 ["Expire all expirable articles" gnus-group-expire-all-groups t]
642 ["Generate any kiboze groups" nnkiboze-generate-groups t]
643 ["Gnus version" gnus-version t]
644 ["Save .newsrc files" gnus-group-save-newsrc t]
645 ["Suspend Gnus" gnus-group-suspend t]
646 ["Clear dribble buffer" gnus-group-clear-dribble t]
647 ["Edit global kill file" gnus-group-edit-global-kill t]
648 ["Read manual" gnus-info-find-node t]
649 ["Toggle topics" gnus-topic-mode t]
651 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
652 ["Send replies" gnus-soup-send-replies
653 (fboundp 'gnus-soup-pack-packet)]
654 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
655 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
656 ["Brew SOUP" gnus-soup-brew-soup (fboundp 'gnus-soup-pack-packet)])
657 ["Exit from Gnus" gnus-group-exit t]
658 ["Exit without saving" gnus-group-quit t]
661 (run-hooks 'gnus-group-menu-hook)
664 (defun gnus-group-mode ()
665 "Major mode for reading news.
667 All normal editing commands are switched off.
668 \\<gnus-group-mode-map>
669 The group buffer lists (some of) the groups available. For instance,
670 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
671 lists all zombie groups.
673 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
674 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
676 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
678 The following commands are available:
680 \\{gnus-group-mode-map}"
682 (when (and menu-bar-mode
683 (gnus-visual-p 'group-menu 'menu))
684 (gnus-group-make-menu-bar))
685 (kill-all-local-variables)
686 (gnus-simplify-mode-line)
687 (setq major-mode 'gnus-group-mode)
688 (setq mode-name "Group")
689 (gnus-group-set-mode-line)
690 (setq mode-line-process nil)
691 (use-local-map gnus-group-mode-map)
692 (buffer-disable-undo (current-buffer))
693 (setq truncate-lines t)
694 (setq buffer-read-only t)
695 (gnus-set-default-directory)
696 (gnus-update-format-specifications nil 'group 'group-mode)
697 (gnus-update-group-mark-positions)
698 (gnus-make-local-hook 'post-command-hook)
699 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
702 (run-hooks 'gnus-group-mode-hook))
704 (defun gnus-update-group-mark-positions ()
706 (let ((gnus-process-mark 128)
707 (gnus-group-marked '("dummy.group"))
708 (gnus-active-hashtb (make-vector 10 0)))
709 (gnus-set-active "dummy.group" '(0 . 0))
710 (gnus-set-work-buffer)
711 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
712 (goto-char (point-min))
713 (setq gnus-group-mark-positions
714 (list (cons 'process (and (search-forward "\200" nil t)
717 (defun gnus-clear-inboxes-moved ()
718 (setq nnmail-moved-inboxes nil))
720 (defun gnus-mouse-pick-group (e)
721 "Enter the group under the mouse pointer."
724 (gnus-group-read-group nil))
726 ;; Look at LEVEL and find out what the level is really supposed to be.
727 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
728 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
729 (defun gnus-group-default-level (&optional level number-or-nil)
731 (gnus-group-use-permanent-levels
732 (or (setq gnus-group-use-permanent-levels
733 (or level (if (numberp gnus-group-use-permanent-levels)
734 gnus-group-use-permanent-levels
735 (or gnus-group-default-list-level
736 gnus-level-subscribed))))
737 gnus-group-default-list-level gnus-level-subscribed))
741 (or level gnus-group-default-list-level gnus-level-subscribed))))
743 (defun gnus-group-setup-buffer ()
744 (switch-to-buffer gnus-group-buffer)
745 (unless (eq major-mode 'gnus-group-mode)
746 (gnus-add-current-to-buffer-list)
749 (gnus-carpal-setup-buffer 'group))))
751 (defun gnus-group-list-groups (&optional level unread lowest)
752 "List newsgroups with level LEVEL or lower that have unread articles.
753 Default is all subscribed groups.
754 If argument UNREAD is non-nil, groups with no unread articles are also
757 (list (if current-prefix-arg
758 (prefix-numeric-value current-prefix-arg)
760 (gnus-group-default-level nil t)
761 gnus-group-default-list-level
762 gnus-level-subscribed))))
764 (setq level (car gnus-group-list-mode)
765 unread (cdr gnus-group-list-mode)))
766 (setq level (gnus-group-default-level level))
767 (gnus-group-setup-buffer) ;May call from out of group buffer
768 (gnus-update-format-specifications nil 'group 'group-mode)
769 (let ((case-fold-search nil)
770 (props (text-properties-at (gnus-point-at-bol)))
771 (group (gnus-group-group-name)))
772 (set-buffer gnus-group-buffer)
773 (funcall gnus-group-prepare-function level unread lowest)
774 (if (zerop (buffer-size))
775 (gnus-message 5 gnus-no-groups-message)
776 (goto-char (point-max))
777 (when (or (not gnus-group-goto-next-group-function)
778 (not (funcall gnus-group-goto-next-group-function
781 ;; Go to the first group with unread articles.
782 (gnus-group-search-forward t)
783 ;; Find the right group to put point on. If the current group
784 ;; has disappeared in the new listing, try to find the next
785 ;; one. If no next one can be found, just leave point at the
786 ;; first newsgroup in the buffer.
787 (when (not (gnus-goto-char
789 (point-min) (point-max)
790 'gnus-group (gnus-intern-safe
791 group gnus-active-hashtb))))
792 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
796 (point-min) (point-max) 'gnus-group
798 (caar newsrc) gnus-active-hashtb)))))
799 (setq newsrc (cdr newsrc)))
801 (goto-char (point-max))
802 (forward-line -1))))))
803 ;; Adjust cursor point.
804 (gnus-group-position-point))))
806 (defun gnus-group-list-level (level &optional all)
807 "List groups on LEVEL.
808 If ALL (the prefix), also list groups that have no unread articles."
809 (interactive "nList groups on level: \nP")
810 (gnus-group-list-groups level all level))
812 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
813 "List all newsgroups with unread articles of level LEVEL or lower.
814 If ALL is non-nil, list groups that have no unread articles.
815 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
816 If REGEXP, only list groups matching REGEXP."
817 (set-buffer gnus-group-buffer)
818 (let ((buffer-read-only nil)
819 (newsrc (cdr gnus-newsrc-alist))
820 (lowest (or lowest 1))
821 info clevel unread group params)
823 (if (< lowest gnus-level-zombie)
824 ;; List living groups.
826 (setq info (car newsrc)
827 group (gnus-info-group info)
828 params (gnus-info-params info)
830 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
831 (and unread ; This group might be bogus
833 (string-match regexp group))
834 (<= (setq clevel (gnus-info-level info)) level)
836 (or all ; We list all groups?
837 (if (eq unread t) ; Unactivated?
838 gnus-group-list-inactive-groups ; We list unactivated
839 (> unread 0)) ; We list groups with unread articles
840 (and gnus-list-groups-with-ticked-articles
841 (cdr (assq 'tick (gnus-info-marks info))))
842 ; And groups with tickeds
843 ;; Check for permanent visibility.
844 (and gnus-permanently-visible-groups
845 (string-match gnus-permanently-visible-groups
847 (memq 'visible params)
848 (cdr (assq 'visible params)))
849 (gnus-group-insert-group-line
850 group (gnus-info-level info)
851 (gnus-info-marks info) unread (gnus-info-method info)))))
854 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
855 (gnus-group-prepare-flat-list-dead
856 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
859 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
860 (gnus-group-prepare-flat-list-dead
861 (setq gnus-killed-list (sort gnus-killed-list 'string<))
862 gnus-level-killed ?K regexp))
864 (gnus-group-set-mode-line)
865 (setq gnus-group-list-mode (cons level all))
866 (run-hooks 'gnus-group-prepare-hook)))
868 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
869 ;; List zombies and killed lists somewhat faster, which was
870 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
871 ;; this by ignoring the group format specification altogether.
874 ;; This loop is used when listing groups that match some
877 (setq group (pop groups))
878 (when (string-match regexp group)
879 (gnus-add-text-properties
880 (point) (prog1 (1+ (point))
881 (insert " " mark " *: " group "\n"))
882 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
884 'gnus-level level))))
885 ;; This loop is used when listing all groups.
887 (gnus-add-text-properties
888 (point) (prog1 (1+ (point))
889 (insert " " mark " *: "
890 (setq group (pop groups)) "\n"))
891 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
893 'gnus-level level))))))
895 (defun gnus-group-update-group-line ()
896 "Update the current line in the group buffer."
897 (let* ((buffer-read-only nil)
898 (group (gnus-group-group-name))
899 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
900 gnus-group-indentation)
903 (not (gnus-ephemeral-group-p group))
905 (concat "(gnus-group-set-info '"
906 (gnus-prin1-to-string (nth 2 entry)) ")")))
907 (setq gnus-group-indentation (gnus-group-group-indentation))
909 (gnus-group-insert-group-line-info group)
911 (gnus-group-position-point))))
913 (defun gnus-group-insert-group-line-info (group)
914 "Insert GROUP on the current line."
915 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
916 (gnus-group-indentation (gnus-group-group-indentation))
920 ;; (Un)subscribed group.
921 (setq info (nth 2 entry))
922 (gnus-group-insert-group-line
923 group (gnus-info-level info) (gnus-info-marks info)
924 (or (car entry) t) (gnus-info-method info)))
925 ;; This group is dead.
926 (gnus-group-insert-group-line
928 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
930 (if (setq active (gnus-active group))
931 (- (1+ (cdr active)) (car active)) 0)
934 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
935 gnus-tmp-marked number
937 "Insert a group line in the group buffer."
938 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
939 (gnus-tmp-number-total
941 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
943 (gnus-tmp-number-of-unread
944 (if (numberp number) (int-to-string (max 0 number))
946 (gnus-tmp-number-of-read
948 (int-to-string (max 0 (- gnus-tmp-number-total number)))
951 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
952 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
953 ((= gnus-tmp-level gnus-level-zombie) ?Z)
955 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
956 (gnus-tmp-newsgroup-description
957 (if gnus-description-hashtb
958 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
961 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
962 (gnus-tmp-moderated-string
963 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
965 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
966 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
967 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
968 (gnus-tmp-news-method-string
970 (format "(%s:%s)" (car gnus-tmp-method)
971 (cadr gnus-tmp-method)) ""))
972 (gnus-tmp-marked-mark
973 (if (and (numberp number)
975 (cdr (assq 'tick gnus-tmp-marked)))
977 (gnus-tmp-process-marked
978 (if (member gnus-tmp-group gnus-group-marked)
979 gnus-process-mark ? ))
981 (or (and gnus-use-grouplens
982 (bbb-grouplens-group-p gnus-tmp-group))
984 (buffer-read-only nil)
985 header gnus-tmp-header) ; passed as parameter to user-funcs.
987 (gnus-add-text-properties
991 (eval gnus-group-line-format-spec))
992 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
993 gnus-unread ,(if (numberp number)
994 (string-to-int gnus-tmp-number-of-unread)
996 gnus-marked ,gnus-tmp-marked-mark
997 gnus-indentation ,gnus-group-indentation
998 gnus-level ,gnus-tmp-level))
999 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1001 (run-hooks 'gnus-group-update-hook)
1003 ;; Allow XEmacs to remove front-sticky text properties.
1004 (gnus-group-remove-excess-properties)))
1006 (defun gnus-group-highlight-line ()
1007 "Highlight the current line according to `gnus-group-highlight'."
1008 (let* ((list gnus-group-highlight)
1010 (end (progn (end-of-line) (point)))
1011 ;; now find out where the line starts and leave point there.
1012 (beg (progn (beginning-of-line) (point)))
1013 (group (gnus-group-group-name))
1014 (entry (gnus-group-entry group))
1015 (unread (if (numberp (car entry)) (car entry) 0))
1016 (active (gnus-active group))
1017 (total (if active (1+ (- (cdr active) (car active))) 0))
1018 (info (nth 2 entry))
1019 (method (gnus-server-get-method group (gnus-info-method info)))
1020 (marked (gnus-info-marks info))
1021 (mailp (memq 'mail (assoc (symbol-name
1022 (car (or method gnus-select-method)))
1023 gnus-valid-select-methods)))
1024 (level (or (gnus-info-level info) 9))
1025 (score (or (gnus-info-score info) 0))
1026 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1027 (inhibit-read-only t))
1028 ;; Eval the cars of the lists until we find a match.
1030 (not (eval (caar list))))
1031 (setq list (cdr list)))
1032 (let ((face (cdar list)))
1033 (unless (eq face (get-text-property beg 'face))
1034 (gnus-put-text-property
1036 (setq face (if (boundp face) (symbol-value face) face)))
1037 (gnus-extent-start-open beg)))
1040 (defun gnus-group-update-group (group &optional visible-only)
1041 "Update all lines where GROUP appear.
1042 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1045 (set-buffer gnus-group-buffer)
1046 ;; The buffer may be narrowed.
1049 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1051 found buffer-read-only)
1052 ;; Enter the current status into the dribble buffer.
1053 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1054 (if (and entry (not (gnus-ephemeral-group-p group)))
1056 (concat "(gnus-group-set-info '"
1057 (gnus-prin1-to-string (nth 2 entry))
1059 ;; Find all group instances. If topics are in use, each group
1060 ;; may be listed in more than once.
1061 (while (setq loc (text-property-any
1062 loc (point-max) 'gnus-group ident))
1065 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1067 (gnus-group-insert-group-line-info group)
1070 (run-hooks 'gnus-group-update-group-hook)))
1071 (setq loc (1+ loc)))
1072 (unless (or found visible-only)
1073 ;; No such line in the buffer, find out where it's supposed to
1074 ;; go, and insert it there (or at the end of the buffer).
1075 (if gnus-goto-missing-group-function
1076 (funcall gnus-goto-missing-group-function group)
1077 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1078 (while (and entry (car entry)
1082 (point-min) (point-max)
1083 'gnus-group (gnus-intern-safe
1084 (caar entry) gnus-active-hashtb)))))
1085 (setq entry (cdr entry)))
1086 (or entry (goto-char (point-max)))))
1087 ;; Finally insert the line.
1088 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1089 (gnus-group-insert-group-line-info group)
1092 (run-hooks 'gnus-group-update-group-hook))))
1093 (when gnus-group-update-group-function
1094 (funcall gnus-group-update-group-function group))
1095 (gnus-group-set-mode-line)))))
1097 (defun gnus-group-set-mode-line ()
1098 "Update the mode line in the group buffer."
1099 (when (memq 'group gnus-updated-mode-lines)
1100 ;; Yes, we want to keep this mode line updated.
1102 (set-buffer gnus-group-buffer)
1103 (let* ((gformat (or gnus-group-mode-line-format-spec
1104 (setq gnus-group-mode-line-format-spec
1106 gnus-group-mode-line-format
1107 gnus-group-mode-line-format-alist))))
1108 (gnus-tmp-news-server (cadr gnus-select-method))
1109 (gnus-tmp-news-method (car gnus-select-method))
1110 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1112 gnus-tmp-header ;Dummy binding for user-defined formats
1113 ;; Get the resulting string.
1115 (and gnus-dribble-buffer
1116 (buffer-name gnus-dribble-buffer)
1117 (buffer-modified-p gnus-dribble-buffer)
1119 (set-buffer gnus-dribble-buffer)
1120 (not (zerop (buffer-size))))))
1121 (mode-string (eval gformat)))
1122 ;; Say whether the dribble buffer has been modified.
1123 (setq mode-line-modified
1124 (if modified "---*- " "----- "))
1125 ;; If the line is too long, we chop it off.
1126 (when (> (length mode-string) max-len)
1127 (setq mode-string (substring mode-string 0 (- max-len 4))))
1129 (setq mode-line-buffer-identification
1130 (gnus-mode-line-buffer-identification
1131 (list mode-string)))
1132 (set-buffer-modified-p modified))))))
1134 (defun gnus-group-group-name ()
1135 "Get the name of the newsgroup on the current line."
1136 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1137 (and group (symbol-name group))))
1139 (defun gnus-group-group-level ()
1140 "Get the level of the newsgroup on the current line."
1141 (get-text-property (gnus-point-at-bol) 'gnus-level))
1143 (defun gnus-group-group-indentation ()
1144 "Get the indentation of the newsgroup on the current line."
1145 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1146 (and gnus-group-indentation-function
1147 (funcall gnus-group-indentation-function))
1150 (defun gnus-group-group-unread ()
1151 "Get the number of unread articles of the newsgroup on the current line."
1152 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1154 (defun gnus-group-search-forward (&optional backward all level first-too)
1155 "Find the next newsgroup with unread articles.
1156 If BACKWARD is non-nil, find the previous newsgroup instead.
1157 If ALL is non-nil, just find any newsgroup.
1158 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1160 If FIRST-TOO, the current line is also eligible as a target."
1161 (let ((way (if backward -1 1))
1162 (low gnus-level-killed)
1165 (if (and backward (progn (beginning-of-line)) (bobp))
1167 (or first-too (forward-line way))
1175 (get-text-property (point) 'gnus-unread)))
1176 (and (numberp unread) (> unread 0)))
1177 (setq lev (get-text-property (point)
1179 (<= lev gnus-level-subscribed)))
1181 (and (setq lev (get-text-property (point)
1190 (zerop (forward-line way)))))
1192 (progn (gnus-group-position-point) t)
1193 (goto-char (or pos beg))
1196 ;;; Gnus group mode commands
1200 (defun gnus-group-mark-group (n &optional unmark no-advance)
1201 "Mark the current group."
1203 (let ((buffer-read-only nil)
1207 (when (setq group (gnus-group-group-name))
1208 ;; Go to the mark position.
1210 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1211 (subst-char-in-region
1212 (point) (1+ (point)) (following-char)
1215 (setq gnus-group-marked (delete group gnus-group-marked))
1217 (setq gnus-group-marked
1218 (cons group (delete group gnus-group-marked)))
1219 gnus-process-mark)))
1221 (gnus-group-next-group 1))
1223 (gnus-summary-position-point)
1226 (defun gnus-group-unmark-group (n)
1227 "Remove the mark from the current group."
1229 (gnus-group-mark-group n 'unmark)
1230 (gnus-group-position-point))
1232 (defun gnus-group-unmark-all-groups ()
1233 "Unmark all groups."
1235 (let ((groups gnus-group-marked))
1238 (gnus-group-remove-mark (pop groups)))))
1239 (gnus-group-position-point))
1241 (defun gnus-group-mark-region (unmark beg end)
1242 "Mark all groups between point and mark.
1243 If UNMARK, remove the mark instead."
1244 (interactive "P\nr")
1245 (let ((num (count-lines beg end)))
1248 (- num (gnus-group-mark-group num unmark)))))
1250 (defun gnus-group-mark-buffer (&optional unmark)
1251 "Mark all groups in the buffer.
1252 If UNMARK, remove the mark instead."
1254 (gnus-group-mark-region unmark (point-min) (point-max)))
1256 (defun gnus-group-mark-regexp (regexp)
1257 "Mark all groups that match some regexp."
1258 (interactive "sMark (regexp): ")
1259 (let ((alist (cdr gnus-newsrc-alist))
1262 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1263 (gnus-group-set-mark group))))
1264 (gnus-group-position-point))
1266 (defun gnus-group-remove-mark (group)
1267 "Remove the process mark from GROUP and move point there.
1268 Return nil if the group isn't displayed."
1269 (if (gnus-group-goto-group group)
1271 (gnus-group-mark-group 1 'unmark t)
1273 (setq gnus-group-marked
1274 (delete group gnus-group-marked))
1277 (defun gnus-group-set-mark (group)
1278 "Set the process mark on GROUP."
1279 (if (gnus-group-goto-group group)
1281 (gnus-group-mark-group 1 nil t))
1282 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1284 (defun gnus-group-universal-argument (arg &optional groups func)
1285 "Perform any command on all groups according to the process/prefix convention."
1287 (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
1393 gnus-score-find-score-files-function
1394 gnus-apply-kill-hook
1395 gnus-summary-expunge-below)
1396 (gnus-group-read-group all t)))
1398 (defun gnus-group-visible-select-group (&optional all)
1399 "Select the current group without hiding any articles."
1401 (let ((gnus-inhibit-limiting t))
1402 (gnus-group-read-group all t)))
1405 (defun gnus-fetch-group (group)
1406 "Start Gnus if necessary and enter GROUP.
1407 Returns whether the fetching was successful or not."
1408 (interactive "sGroup name: ")
1409 (or (get-buffer gnus-group-buffer)
1411 (gnus-group-read-group nil nil group))
1413 ;; Enter a group that is not in the group buffer. Non-nil is returned
1414 ;; if selection was successful.
1415 (defun gnus-group-read-ephemeral-group (group method &optional activate
1416 quit-config request-only)
1417 "Read GROUP from METHOD as an ephemeral group.
1418 If ACTIVATE, request the group first.
1419 If QUIT-CONFIG, use that window configuration when exiting from the
1421 If REQUEST-ONLY, don't actually read the group; just request it.
1423 Return the name of the group is selection was successful."
1424 (let ((group (if (gnus-group-foreign-p group) group
1425 (gnus-group-prefixed-name group method))))
1429 ,gnus-level-default-subscribed nil nil ,method
1431 ,(if quit-config quit-config
1432 (cons gnus-summary-buffer
1433 gnus-current-window-configuration))))))
1435 (set-buffer gnus-group-buffer)
1436 (unless (gnus-check-server method)
1437 (error "Unable to contact server: %s" (gnus-status-message method)))
1439 (gnus-activate-group group 'scan t)
1440 (unless (gnus-request-group group)
1441 (error "Couldn't request group: %s"
1442 (nnheader-get-report (car method)))))
1446 (when (gnus-group-read-group t t group)
1451 (defun gnus-group-jump-to-group (group)
1452 "Jump to newsgroup GROUP."
1454 (list (completing-read
1455 "Group: " gnus-active-hashtb nil
1456 (gnus-read-active-file-p)
1458 'gnus-group-history)))
1460 (when (equal group "")
1461 (error "Empty group name"))
1463 (unless (gnus-ephemeral-group-p group)
1464 ;; Either go to the line in the group buffer...
1465 (unless (gnus-group-goto-group group)
1466 ;; ... or insert the line.
1467 (gnus-group-update-group group)
1468 (gnus-group-goto-group group)))
1469 ;; Adjust cursor point.
1470 (gnus-group-position-point))
1472 (defun gnus-group-goto-group (group &optional far)
1473 "Goto to newsgroup GROUP.
1474 If FAR, it is likely that the group is not on the current line."
1479 (point-min) (point-max)
1480 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
1483 ;; It's quite likely that we are on the right line, so
1484 ;; we check the current line first.
1485 ((eq (get-text-property (point) 'gnus-group)
1486 (gnus-intern-safe group gnus-active-hashtb))
1488 ;; Previous and next line are also likely, so we check them as well.
1491 (eq (get-text-property (point) 'gnus-group)
1492 (gnus-intern-safe group gnus-active-hashtb)))
1497 (eq (get-text-property (point) 'gnus-group)
1498 (gnus-intern-safe group gnus-active-hashtb)))
1502 ;; Search through the entire buffer.
1505 (point-min) (point-max)
1506 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
1508 (defun gnus-group-next-group (n &optional silent)
1509 "Go to next N'th newsgroup.
1510 If N is negative, search backward instead.
1511 Returns the difference between N and the number of skips actually
1514 (gnus-group-next-unread-group n t nil silent))
1516 (defun gnus-group-next-unread-group (n &optional all level silent)
1517 "Go to next N'th unread newsgroup.
1518 If N is negative, search backward instead.
1519 If ALL is non-nil, choose any newsgroup, unread or not.
1520 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1521 such group can be found, the next group with a level higher than
1523 Returns the difference between N and the number of skips actually
1526 (let ((backward (< n 0))
1529 (gnus-group-search-forward
1530 backward (or (not gnus-group-goto-unread) all) level))
1534 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1535 (if level " on this level or higher" "")))
1538 (defun gnus-group-prev-group (n)
1539 "Go to previous N'th newsgroup.
1540 Returns the difference between N and the number of skips actually
1543 (gnus-group-next-unread-group (- n) t))
1545 (defun gnus-group-prev-unread-group (n)
1546 "Go to previous N'th unread newsgroup.
1547 Returns the difference between N and the number of skips actually
1550 (gnus-group-next-unread-group (- n)))
1552 (defun gnus-group-next-unread-group-same-level (n)
1553 "Go to next N'th unread newsgroup on the same level.
1554 If N is negative, search backward instead.
1555 Returns the difference between N and the number of skips actually
1558 (gnus-group-next-unread-group n t (gnus-group-group-level))
1559 (gnus-group-position-point))
1561 (defun gnus-group-prev-unread-group-same-level (n)
1562 "Go to next N'th unread newsgroup on the same level.
1563 Returns the difference between N and the number of skips actually
1566 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1567 (gnus-group-position-point))
1569 (defun gnus-group-best-unread-group (&optional exclude-group)
1570 "Go to the group with the highest level.
1571 If EXCLUDE-GROUP, do not go to that group."
1573 (goto-char (point-min))
1577 (setq unread (get-text-property (point) 'gnus-unread))
1578 (if (and (numberp unread) (> unread 0))
1580 (if (and (get-text-property (point) 'gnus-level)
1581 (< (get-text-property (point) 'gnus-level) best)
1582 (or (not exclude-group)
1583 (not (equal exclude-group (gnus-group-group-name)))))
1585 (setq best (get-text-property (point) 'gnus-level))
1586 (setq best-point (point))))))
1588 (if best-point (goto-char best-point))
1589 (gnus-summary-position-point)
1590 (and best-point (gnus-group-group-name))))
1592 (defun gnus-group-first-unread-group ()
1593 "Go to the first group with unread articles."
1596 (let ((opoint (point))
1598 (goto-char (point-min))
1599 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1600 (and (numberp unread) ; Not a topic.
1601 (not (zerop unread))) ; Has unread articles.
1602 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1605 nil)) ; Not success.
1606 (gnus-group-position-point)))
1608 (defun gnus-group-enter-server-mode ()
1609 "Jump to the server buffer."
1611 (gnus-enter-server-buffer))
1613 (defun gnus-group-make-group (name &optional method address args)
1614 "Add a new newsgroup.
1615 The user will be prompted for a NAME, for a select METHOD, and an
1619 (read-string "Group name: ")
1620 (gnus-read-method "From method: ")))
1622 (let* ((meth (when (and method
1623 (not (gnus-server-equal method gnus-select-method)))
1624 (if address (list (intern method) address)
1626 (nname (if method (gnus-group-prefixed-name name meth) name))
1628 (when (gnus-gethash nname gnus-newsrc-hashtb)
1629 (error "Group %s already exists" nname))
1630 ;; Subscribe to the new group.
1631 (gnus-group-change-level
1632 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1633 gnus-level-default-subscribed gnus-level-killed
1634 (and (gnus-group-group-name)
1635 (gnus-gethash (gnus-group-group-name)
1636 gnus-newsrc-hashtb))
1639 (gnus-set-active nname (cons 1 0))
1640 (or (gnus-ephemeral-group-p name)
1642 (concat "(gnus-group-set-info '"
1643 (gnus-prin1-to-string (cdr info)) ")")))
1645 (gnus-group-insert-group-line-info nname)
1647 (gnus-group-position-point)
1649 ;; Load the backend and try to make the backend create
1650 ;; the group as well.
1651 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1653 gnus-valid-select-methods)
1655 (gnus-check-server meth)
1656 (and (gnus-check-backend-function 'request-create-group nname)
1657 (gnus-request-create-group nname nil args))
1660 (defun gnus-group-delete-group (group &optional force)
1661 "Delete the current group. Only meaningful with mail groups.
1662 If FORCE (the prefix) is non-nil, all the articles in the group will
1663 be deleted. This is \"deleted\" as in \"removed forever from the face
1664 of the Earth\". There is no undo. The user will be prompted before
1665 doing the deletion."
1667 (list (gnus-group-group-name)
1668 current-prefix-arg))
1669 (or group (error "No group to rename"))
1670 (or (gnus-check-backend-function 'request-delete-group group)
1671 (error "This backend does not support group deletion"))
1673 (if (not (gnus-yes-or-no-p
1675 "Do you really want to delete %s%s? "
1676 group (if force " and all its contents" ""))))
1678 (gnus-message 6 "Deleting group %s..." group)
1679 (if (not (gnus-request-delete-group group force))
1680 (gnus-error 3 "Couldn't delete group %s" group)
1681 (gnus-message 6 "Deleting group %s...done" group)
1682 (gnus-group-goto-group group)
1683 (gnus-group-kill-group 1 t)
1684 (gnus-sethash group nil gnus-active-hashtb)
1686 (gnus-group-position-point)))
1688 (defun gnus-group-rename-group (group new-name)
1689 "Rename group from GROUP to NEW-NAME.
1690 When used interactively, GROUP is the group under point
1691 and NEW-NAME will be prompted for."
1694 (gnus-group-group-name)
1696 (unless (gnus-check-backend-function
1697 'request-rename-group (gnus-group-group-name))
1698 (error "This backend does not support renaming groups"))
1699 (read-string "New group name: " (gnus-group-group-name)))))
1701 (unless (gnus-check-backend-function 'request-rename-group group)
1702 (error "This backend does not support renaming groups"))
1704 (error "No group to rename"))
1705 (when (string-match "^[ \t]*$" new-name)
1706 (error "Not a valid group name"))
1707 (when (equal group new-name)
1708 (error "Can't rename to the same name"))
1710 ;; We find the proper prefixed name.
1712 (if (equal (gnus-group-real-name new-name) new-name)
1716 (gnus-group-prefixed-name
1717 (gnus-group-real-name new-name)
1718 (gnus-info-method (gnus-get-info group)))))
1720 (gnus-message 6 "Renaming group %s to %s..." group new-name)
1722 (if (not (gnus-request-rename-group group new-name))
1723 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
1724 ;; We rename the group internally by killing it...
1725 (gnus-group-goto-group group)
1726 (gnus-group-kill-group)
1727 ;; ... changing its name ...
1728 (setcar (cdar gnus-list-of-killed-groups) new-name)
1729 ;; ... and then yanking it. Magic!
1730 (gnus-group-yank-group)
1731 (gnus-set-active new-name (gnus-active group))
1732 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
1734 (gnus-group-position-point)))
1736 (defun gnus-group-edit-group (group &optional part)
1737 "Edit the group on the current line."
1738 (interactive (list (gnus-group-group-name)))
1739 (let ((part (or part 'info))
1742 (error "No group on current line"))
1743 (unless (setq info (gnus-get-info group))
1744 (error "Killed group; can't be edited"))
1746 ;; Find the proper form to edit.
1747 (cond ((eq part 'method)
1748 (or (gnus-info-method info) "native"))
1750 (gnus-info-params info))
1752 ;; The proper documentation.
1756 ((eq part 'method) "select method")
1757 ((eq part 'params) "group parameters")
1760 (gnus-group-edit-group-done ',part ,group form)))))
1762 (defun gnus-group-edit-group-method (group)
1763 "Edit the select method of GROUP."
1764 (interactive (list (gnus-group-group-name)))
1765 (gnus-group-edit-group group 'method))
1767 (defun gnus-group-edit-group-parameters (group)
1768 "Edit the group parameters of GROUP."
1769 (interactive (list (gnus-group-group-name)))
1770 (gnus-group-edit-group group 'params))
1772 (defun gnus-group-edit-group-done (part group form)
1774 (let* ((method (cond ((eq part 'info) (nth 4 form))
1775 ((eq part 'method) form)
1777 (info (cond ((eq part 'info) form)
1778 ((eq part 'method) (gnus-get-info group))
1781 (if (or (not method)
1783 gnus-select-method method))
1784 (gnus-group-real-name (car info))
1785 (gnus-group-prefixed-name
1786 (gnus-group-real-name (car info)) method))
1788 (when (and new-group
1789 (not (equal new-group group)))
1790 (when (gnus-group-goto-group group)
1791 (gnus-group-kill-group 1))
1792 (gnus-activate-group new-group))
1794 (if (not (and info new-group))
1795 (gnus-group-set-info form (or new-group group) part)
1796 (setq info (gnus-copy-sequence info))
1797 (setcar info new-group)
1798 (unless (gnus-server-equal method "native")
1799 (unless (nthcdr 3 info)
1800 (nconc info (list nil nil)))
1801 (unless (nthcdr 4 info)
1802 (nconc info (list nil)))
1803 (gnus-info-set-method info method))
1804 (gnus-group-set-info info))
1805 (gnus-group-update-group (or new-group group))
1806 (gnus-group-position-point)))
1808 (defun gnus-group-make-useful-group (group method)
1810 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
1812 gnus-useful-groups)))
1813 (list (cadr entry) (caddr entry))))
1814 (setq method (gnus-copy-sequence method))
1816 (while (setq entry (memq (assq 'eval method) method))
1817 (setcar entry (eval (cadar entry)))))
1818 (gnus-group-make-group group method))
1820 (defun gnus-group-make-help-group ()
1821 "Create the Gnus documentation group."
1823 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
1824 (file (nnheader-find-etc-directory "gnus-tut.txt" t))
1826 (when (gnus-gethash name gnus-newsrc-hashtb)
1827 (error "Documentation group already exists"))
1829 (gnus-message 1 "Couldn't find doc group")
1830 (gnus-group-make-group
1831 (gnus-group-real-name name)
1832 (list 'nndoc "gnus-help"
1833 (list 'nndoc-address file)
1834 (list 'nndoc-article-type 'mbox)))))
1835 (gnus-group-position-point))
1837 (defun gnus-group-make-doc-group (file type)
1838 "Create a group that uses a single file as the source."
1840 (list (read-file-name "File name: ")
1841 (and current-prefix-arg 'ask)))
1842 (when (eq type 'ask)
1847 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
1849 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
1850 ((= char ?b) 'babyl)
1851 ((= char ?d) 'digest)
1852 ((= char ?f) 'forward)
1854 (t (setq err (format "%c unknown. " char))
1857 (let* ((file (expand-file-name file))
1858 (name (gnus-generate-new-group-name
1859 (gnus-group-prefixed-name
1860 (file-name-nondirectory file) '(nndoc "")))))
1861 (gnus-group-make-group
1862 (gnus-group-real-name name)
1864 (list 'nndoc-address file)
1865 (list 'nndoc-article-type (or type 'guess))))))
1867 (defvar nnweb-type-definition)
1868 (defvar gnus-group-web-type-history nil)
1869 (defvar gnus-group-web-search-history nil)
1870 (defun gnus-group-make-web-group (&optional solid)
1871 "Create an ephemeral nnweb group.
1872 If SOLID (the prefix), create a solid group."
1876 (if solid (read-string "Group name: ") (message-unique-id)))
1879 "Search engine type: "
1880 (mapcar (lambda (elem) (list (symbol-name (car elem))))
1881 nnweb-type-definition)
1882 nil t (cons (or (car gnus-group-web-type-history)
1883 (symbol-name (caar nnweb-type-definition)))
1885 'gnus-group-web-type-history))
1889 (cons (or (car gnus-group-web-search-history) "") 0)
1890 'gnus-group-web-search-history))
1892 `(nnweb ,group (nnweb-search ,search)
1893 (nnweb-type ,(intern type))
1894 (nnweb-ephemeral-p t))))
1896 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
1897 (gnus-group-read-ephemeral-group
1899 (cons (current-buffer)
1900 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
1902 (defun gnus-group-make-archive-group (&optional all)
1903 "Create the (ding) Gnus archive group of the most recent articles.
1904 Given a prefix, create a full group."
1906 (let ((group (gnus-group-prefixed-name
1907 (if all "ding.archives" "ding.recent") '(nndir ""))))
1908 (when (gnus-gethash group gnus-newsrc-hashtb)
1909 (error "Archive group already exists"))
1910 (gnus-group-make-group
1911 (gnus-group-real-name group)
1912 (list 'nndir (if all "hpc" "edu")
1913 (list 'nndir-directory
1914 (if all gnus-group-archive-directory
1915 gnus-group-recent-archive-directory))))
1916 (gnus-group-add-parameter group (cons 'to-address "ding@ifi.uio.no"))))
1918 (defun gnus-group-make-directory-group (dir)
1919 "Create an nndir group.
1920 The user will be prompted for a directory. The contents of this
1921 directory will be used as a newsgroup. The directory should contain
1922 mail messages or news articles in files that have numeric names."
1924 (list (read-file-name "Create group from directory: ")))
1925 (or (file-exists-p dir) (error "No such directory"))
1926 (or (file-directory-p dir) (error "Not a directory"))
1930 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
1932 (gnus-group-prefixed-name
1933 (concat (file-name-as-directory (directory-file-name dir))
1936 (setq ext (format "<%d>" (setq i (1+ i)))))
1937 (gnus-group-make-group
1938 (gnus-group-real-name group)
1939 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
1941 (defun gnus-group-make-kiboze-group (group address scores)
1942 "Create an nnkiboze group.
1943 The user will be prompted for a name, a regexp to match groups, and
1944 score file entries for articles to include in the group."
1947 (read-string "nnkiboze group name: ")
1948 (read-string "Source groups (regexp): ")
1949 (let ((headers (mapcar (lambda (group) (list group))
1950 '("subject" "from" "number" "date" "message-id"
1951 "references" "chars" "lines" "xref"
1952 "followup" "all" "body" "head")))
1953 scores header regexp regexps)
1954 (while (not (equal "" (setq header (completing-read
1955 "Match on header: " headers nil t))))
1957 (while (not (equal "" (setq regexp (read-string
1958 (format "Match on %s (string): "
1960 (setq regexps (cons (list regexp nil nil 'r) regexps)))
1961 (setq scores (cons (cons header regexps) scores)))
1963 (gnus-group-make-group group "nnkiboze" address)
1964 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
1965 (let (emacs-lisp-mode-hook)
1966 (pp scores (current-buffer)))))
1968 (defun gnus-group-add-to-virtual (n vgroup)
1969 "Add the current group to a virtual group."
1971 (list current-prefix-arg
1972 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
1974 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
1975 (error "%s is not an nnvirtual group" vgroup))
1976 (let* ((groups (gnus-group-process-prefix n))
1977 (method (gnus-info-method (gnus-get-info vgroup))))
1978 (setcar (cdr method)
1980 (nth 1 method) "\\|"
1983 (gnus-group-remove-mark s)
1984 (concat "\\(^" (regexp-quote s) "$\\)"))
1986 (gnus-group-position-point))
1988 (defun gnus-group-make-empty-virtual (group)
1989 "Create a new, fresh, empty virtual group."
1990 (interactive "sCreate new, empty virtual group: ")
1991 (let* ((method (list 'nnvirtual "^$"))
1992 (pgroup (gnus-group-prefixed-name group method)))
1993 ;; Check whether it exists already.
1994 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
1995 (error "Group %s already exists." pgroup))
1996 ;; Subscribe the new group after the group on the current line.
1997 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
1998 (gnus-group-update-group pgroup)
2000 (gnus-group-position-point)))
2002 (defun gnus-group-enter-directory (dir)
2003 "Enter an ephemeral nneething group."
2004 (interactive "DDirectory to read: ")
2005 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2006 (leaf (gnus-group-prefixed-name
2007 (file-name-nondirectory (directory-file-name dir))
2009 (name (gnus-generate-new-group-name leaf)))
2010 (unless (gnus-group-read-ephemeral-group
2012 (cons (current-buffer)
2013 (if (eq major-mode 'gnus-summary-mode)
2015 (error "Couldn't enter %s" dir))))
2017 ;; Group sorting commands
2018 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2020 (defun gnus-group-sort-groups (func &optional reverse)
2021 "Sort the group buffer according to FUNC.
2022 If REVERSE, reverse the sorting order."
2023 (interactive (list gnus-group-sort-function current-prefix-arg))
2024 (funcall gnus-group-sort-alist-function
2025 (gnus-make-sort-function func) reverse)
2026 (gnus-group-list-groups))
2028 (defun gnus-group-sort-flat (func reverse)
2029 ;; We peel off the dummy group from the alist.
2031 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
2032 (pop gnus-newsrc-alist))
2034 (setq gnus-newsrc-alist
2035 (sort gnus-newsrc-alist func))
2037 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2038 ;; Regenerate the hash table.
2039 (gnus-make-hashtable-from-newsrc-alist)))
2041 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2042 "Sort the group buffer alphabetically by group name.
2043 If REVERSE, sort in reverse order."
2045 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2047 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2048 "Sort the group buffer by number of unread articles.
2049 If REVERSE, sort in reverse order."
2051 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2053 (defun gnus-group-sort-groups-by-level (&optional reverse)
2054 "Sort the group buffer by group level.
2055 If REVERSE, sort in reverse order."
2057 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2059 (defun gnus-group-sort-groups-by-score (&optional reverse)
2060 "Sort the group buffer by group score.
2061 If REVERSE, sort in reverse order."
2063 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2065 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2066 "Sort the group buffer by group rank.
2067 If REVERSE, sort in reverse order."
2069 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2071 (defun gnus-group-sort-groups-by-method (&optional reverse)
2072 "Sort the group buffer alphabetically by backend name.
2073 If REVERSE, sort in reverse order."
2075 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2077 ;;; Selected group sorting.
2079 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2080 "Sort the process/prefixed groups."
2081 (interactive (list current-prefix-arg gnus-group-sort-function))
2082 (let ((groups (gnus-group-process-prefix n)))
2083 (funcall gnus-group-sort-selected-function
2084 groups (gnus-make-sort-function func) reverse)
2085 (gnus-group-list-groups)))
2087 (defun gnus-group-sort-selected-flat (groups func reverse)
2088 (let (entries infos)
2089 ;; First find all the group entries for these groups.
2091 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2093 ;; Then sort the infos.
2097 (lambda (entry) (car entry))
2098 (setq entries (nreverse entries)))
2101 (setq infos (nreverse infos)))
2102 ;; Go through all the infos and replace the old entries
2103 ;; with the new infos.
2105 (setcar entries (pop infos))
2107 ;; Update the hashtable.
2108 (gnus-make-hashtable-from-newsrc-alist)))
2110 (defun gnus-group-sort-selected-groups-by-alphabet (&optional reverse)
2111 "Sort the group buffer alphabetically by group name.
2112 If REVERSE, sort in reverse order."
2114 (gnus-group-sort-selected-groups 'gnus-group-sort-by-alphabet reverse))
2116 (defun gnus-group-sort-selected-groups-by-unread (&optional reverse)
2117 "Sort the group buffer by number of unread articles.
2118 If REVERSE, sort in reverse order."
2120 (gnus-group-sort-selected-groups 'gnus-group-sort-by-unread reverse))
2122 (defun gnus-group-sort-selected-groups-by-level (&optional reverse)
2123 "Sort the group buffer by group level.
2124 If REVERSE, sort in reverse order."
2126 (gnus-group-sort-selected-groups 'gnus-group-sort-by-level reverse))
2128 (defun gnus-group-sort-selected-groups-by-score (&optional reverse)
2129 "Sort the group buffer by group score.
2130 If REVERSE, sort in reverse order."
2132 (gnus-group-sort-selected-groups 'gnus-group-sort-by-score reverse))
2134 (defun gnus-group-sort-selected-groups-by-rank (&optional reverse)
2135 "Sort the group buffer by group rank.
2136 If REVERSE, sort in reverse order."
2138 (gnus-group-sort-selected-groups 'gnus-group-sort-by-rank reverse))
2140 (defun gnus-group-sort-selected-groups-by-method (&optional reverse)
2141 "Sort the group buffer alphabetically by backend name.
2142 If REVERSE, sort in reverse order."
2144 (gnus-group-sort-selected-groups 'gnus-group-sort-by-method reverse))
2146 ;;; Sorting predicates.
2148 (defun gnus-group-sort-by-alphabet (info1 info2)
2149 "Sort alphabetically."
2150 (string< (gnus-info-group info1) (gnus-info-group info2)))
2152 (defun gnus-group-sort-by-real-name (info1 info2)
2153 "Sort alphabetically on real (unprefixed) names."
2154 (string< (gnus-group-real-name (gnus-info-group info1))
2155 (gnus-group-real-name (gnus-info-group info2))))
2157 (defun gnus-group-sort-by-unread (info1 info2)
2158 "Sort by number of unread articles."
2159 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2160 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2161 (< (or (and (numberp n1) n1) 0)
2162 (or (and (numberp n2) n2) 0))))
2164 (defun gnus-group-sort-by-level (info1 info2)
2166 (< (gnus-info-level info1) (gnus-info-level info2)))
2168 (defun gnus-group-sort-by-method (info1 info2)
2169 "Sort alphabetically by backend name."
2170 (string< (symbol-name (car (gnus-find-method-for-group
2171 (gnus-info-group info1) info1)))
2172 (symbol-name (car (gnus-find-method-for-group
2173 (gnus-info-group info2) info2)))))
2175 (defun gnus-group-sort-by-score (info1 info2)
2176 "Sort by group score."
2177 (< (gnus-info-score info1) (gnus-info-score info2)))
2179 (defun gnus-group-sort-by-rank (info1 info2)
2180 "Sort by level and score."
2181 (let ((level1 (gnus-info-level info1))
2182 (level2 (gnus-info-level info2)))
2183 (or (< level1 level2)
2184 (and (= level1 level2)
2185 (> (gnus-info-score info1) (gnus-info-score info2))))))
2189 (defun gnus-group-clear-data (n)
2190 "Clear all marks and read ranges from the current group."
2192 (let ((groups (gnus-group-process-prefix n))
2194 (while (setq group (pop groups))
2195 (gnus-info-clear-data (setq info (gnus-get-info group)))
2196 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2197 (when (gnus-group-goto-group group)
2198 (gnus-group-remove-mark group)
2199 (gnus-group-update-group-line)))))
2201 (defun gnus-group-clear-data-on-native-groups ()
2202 "Clear all marks and read ranges from all native groups."
2204 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2205 (let ((alist (cdr gnus-newsrc-alist))
2207 (while (setq info (pop alist))
2208 (gnus-info-clear-data info))
2209 (gnus-get-unread-articles))))
2211 (defun gnus-info-clear-data (info)
2212 "Clear all marks and read ranges from INFO."
2213 (let ((group (gnus-info-group info)))
2216 (gnus-info-set-marks ,info ,(gnus-info-marks info))
2217 (gnus-info-set-read ,info ,(gnus-info-read info))
2218 (when (gnus-group-goto-group ,group)
2219 (gnus-group-update-group-line))))
2220 (gnus-info-set-read info nil)
2221 (when (gnus-info-marks info)
2222 (gnus-info-set-marks info nil))))
2224 ;; Group catching up.
2226 (defun gnus-group-catchup-current (&optional n all)
2227 "Mark all articles not marked as unread in current newsgroup as read.
2228 If prefix argument N is numeric, the ARG next newsgroups will be
2229 caught up. If ALL is non-nil, marked articles will also be marked as
2230 read. Cross references (Xref: header) of articles are ignored.
2231 The difference between N and actual number of newsgroups that were
2232 caught up is returned."
2234 (unless (gnus-group-group-name)
2235 (error "No group on the current line"))
2236 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
2240 "Do you really want to mark all articles as read? "
2241 "Mark all unread articles as read? "))))
2243 (let ((groups (gnus-group-process-prefix n))
2246 ;; Virtual groups have to be given special treatment.
2247 (let ((method (gnus-find-method-for-group (car groups))))
2248 (if (eq 'nnvirtual (car method))
2249 (nnvirtual-catchup-group
2250 (gnus-group-real-name (car groups)) (nth 1 method) all)))
2251 (gnus-group-remove-mark (car groups))
2252 (if (>= (gnus-group-group-level) gnus-level-zombie)
2253 (gnus-message 2 "Dead groups can't be caught up")
2255 (gnus-group-goto-group (car groups))
2256 (gnus-group-catchup (car groups) all))
2257 (gnus-group-update-group-line)
2258 (setq ret (1+ ret))))
2259 (setq groups (cdr groups)))
2260 (gnus-group-next-unread-group 1)
2263 (defun gnus-group-catchup-current-all (&optional n)
2264 "Mark all articles in current newsgroup as read.
2265 Cross references (Xref: header) of articles are ignored."
2267 (gnus-group-catchup-current n 'all))
2269 (defun gnus-group-catchup (group &optional all)
2270 "Mark all articles in GROUP as read.
2271 If ALL is non-nil, all articles are marked as read.
2272 The return value is the number of articles that were marked as read,
2273 or nil if no action could be taken."
2274 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2276 ;; Do the updating only if the newsgroup isn't killed.
2277 (if (not (numberp (car entry)))
2278 (gnus-message 1 "Can't catch up; non-active group")
2279 ;; Do auto-expirable marks if that's required.
2280 (when (gnus-group-auto-expirable-p group)
2281 (gnus-add-marked-articles
2282 group 'expire (gnus-list-of-unread-articles group))
2284 (let ((marks (nth 3 (nth 2 entry))))
2285 (gnus-add-marked-articles
2286 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2287 (gnus-add-marked-articles
2288 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2290 (gnus-update-read-articles group nil)
2291 ;; Also nix out the lists of marks and dormants.
2293 (gnus-add-marked-articles group 'tick nil nil 'force)
2294 (gnus-add-marked-articles group 'dormant nil nil 'force))
2295 (run-hooks 'gnus-group-catchup-group-hook)
2298 (defun gnus-group-expire-articles (&optional n)
2299 "Expire all expirable articles in the current newsgroup."
2301 (let ((groups (gnus-group-process-prefix n))
2304 (error "No groups to expire"))
2305 (while (setq group (pop groups))
2306 (gnus-group-remove-mark group)
2307 (when (gnus-check-backend-function 'request-expire-articles group)
2308 (gnus-message 6 "Expiring articles in %s..." group)
2309 (let* ((info (gnus-get-info group))
2310 (expirable (if (gnus-group-total-expirable-p group)
2311 (cons nil (gnus-list-of-read-articles group))
2312 (assq 'expire (gnus-info-marks info))))
2313 (expiry-wait (gnus-group-find-parameter group 'expiry-wait)))
2317 (gnus-compress-sequence
2319 ;; We set the expiry variables to the group
2321 (let ((nnmail-expiry-wait-function nil)
2322 (nnmail-expiry-wait expiry-wait))
2323 (gnus-request-expire-articles
2324 (gnus-uncompress-sequence (cdr expirable)) group))
2325 ;; Just expire using the normal expiry values.
2326 (gnus-request-expire-articles
2327 (gnus-uncompress-sequence (cdr expirable)) group))))
2328 (gnus-close-group group))
2329 (gnus-message 6 "Expiring articles in %s...done" group)))
2330 (gnus-group-position-point))))
2332 (defun gnus-group-expire-all-groups ()
2333 "Expire all expirable articles in all newsgroups."
2336 (gnus-message 5 "Expiring...")
2337 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2338 (cdr gnus-newsrc-alist))))
2339 (gnus-group-expire-articles nil)))
2340 (gnus-group-position-point)
2341 (gnus-message 5 "Expiring...done"))
2343 (defun gnus-group-set-current-level (n level)
2344 "Set the level of the next N groups to LEVEL."
2349 (let ((s (read-string
2350 (format "Level (default %s): "
2351 (or (gnus-group-group-level)
2352 gnus-level-default-subscribed)))))
2353 (if (string-match "^\\s-*$" s)
2354 (int-to-string (or (gnus-group-group-level)
2355 gnus-level-default-subscribed))
2357 (or (and (>= level 1) (<= level gnus-level-killed))
2358 (error "Illegal level: %d" level))
2359 (let ((groups (gnus-group-process-prefix n))
2361 (while (setq group (pop groups))
2362 (gnus-group-remove-mark group)
2363 (gnus-message 6 "Changed level of %s from %d to %d"
2364 group (or (gnus-group-group-level) gnus-level-killed)
2366 (gnus-group-change-level
2367 group level (or (gnus-group-group-level) gnus-level-killed))
2368 (gnus-group-update-group-line)))
2369 (gnus-group-position-point))
2371 (defun gnus-group-unsubscribe-current-group (&optional n)
2372 "Toggle subscription of the current group.
2373 If given numerical prefix, toggle the N next groups."
2375 (let ((groups (gnus-group-process-prefix n))
2378 (setq group (car groups)
2379 groups (cdr groups))
2380 (gnus-group-remove-mark group)
2381 (gnus-group-unsubscribe-group
2382 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
2383 gnus-level-default-unsubscribed
2384 gnus-level-default-subscribed) t)
2385 (gnus-group-update-group-line))
2386 (gnus-group-next-group 1)))
2388 (defun gnus-group-unsubscribe-group (group &optional level silent)
2389 "Toggle subscription to GROUP.
2390 Killed newsgroups are subscribed. If SILENT, don't try to update the
2393 (list (completing-read
2394 "Group: " gnus-active-hashtb nil
2395 (gnus-read-active-file-p)
2397 'gnus-group-history)))
2398 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2400 ((string-match "^[ \t]$" group)
2401 (error "Empty group name"))
2403 ;; Toggle subscription flag.
2404 (gnus-group-change-level
2405 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
2406 gnus-level-subscribed)
2407 (1+ gnus-level-subscribed)
2408 gnus-level-default-subscribed)))
2410 (gnus-group-update-group group)))
2411 ((and (stringp group)
2412 (or (not (gnus-read-active-file-p))
2413 (gnus-active group)))
2414 ;; Add new newsgroup.
2415 (gnus-group-change-level
2417 (if level level gnus-level-default-subscribed)
2418 (or (and (member group gnus-zombie-list)
2421 (and (gnus-group-group-name)
2422 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2424 (gnus-group-update-group group)))
2425 (t (error "No such newsgroup: %s" group)))
2426 (gnus-group-position-point)))
2428 (defun gnus-group-transpose-groups (n)
2429 "Move the current newsgroup up N places.
2430 If given a negative prefix, move down instead. The difference between
2431 N and the number of steps taken is returned."
2433 (or (gnus-group-group-name)
2434 (error "No group on current line"))
2435 (gnus-group-kill-group 1)
2437 (forward-line (- n))
2438 (gnus-group-yank-group)
2439 (gnus-group-position-point)))
2441 (defun gnus-group-kill-all-zombies ()
2442 "Kill all zombie newsgroups."
2444 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2445 (setq gnus-zombie-list nil)
2446 (gnus-group-list-groups))
2448 (defun gnus-group-kill-region (begin end)
2449 "Kill newsgroups in current region (excluding current point).
2450 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2465 (beginning-of-line) ;Important when LINES < 1
2466 (gnus-group-kill-group lines)))
2468 (defun gnus-group-kill-group (&optional n discard)
2469 "Kill the next N groups.
2470 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2471 However, only groups that were alive can be yanked; already killed
2472 groups or zombie groups can't be yanked.
2473 The return value is the name of the group that was killed, or a list
2476 (let ((buffer-read-only nil)
2477 (groups (gnus-group-process-prefix n))
2478 group entry level out)
2479 (if (< (length groups) 10)
2480 ;; This is faster when there are few groups.
2482 (push (setq group (pop groups)) out)
2483 (gnus-group-remove-mark group)
2484 (setq level (gnus-group-group-level))
2486 (when (and (not discard)
2487 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2490 (gnus-group-goto-group ,(gnus-group-group-name))
2491 (gnus-group-yank-group)))
2492 (push (cons (car entry) (nth 2 entry))
2493 gnus-list-of-killed-groups))
2494 (gnus-group-change-level
2495 (if entry entry group) gnus-level-killed (if entry nil level)))
2496 ;; If there are lots and lots of groups to be killed, we use
2497 ;; this thing instead.
2499 (setq groups (nreverse groups))
2501 (gnus-group-remove-mark (setq group (pop groups)))
2503 (push group gnus-killed-list)
2504 (setq gnus-newsrc-alist
2505 (delq (assoc group gnus-newsrc-alist)
2507 (when gnus-group-change-level-function
2508 (funcall gnus-group-change-level-function group 9 3))
2510 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2511 (push (cons (car entry) (nth 2 entry))
2512 gnus-list-of-killed-groups)
2513 (setcdr (cdr entry) (cdddr entry)))
2514 ((member group gnus-zombie-list)
2515 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
2516 (gnus-make-hashtable-from-newsrc-alist)))
2518 (gnus-group-position-point)
2519 (if (< (length out) 2) (car out) (nreverse out))))
2521 (defun gnus-group-yank-group (&optional arg)
2522 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
2523 inserting it before the current newsgroup. The numeric ARG specifies
2524 how many newsgroups are to be yanked. The name of the newsgroup yanked
2525 is returned, or (if several groups are yanked) a list of yanked groups
2528 (setq arg (or arg 1))
2529 (let (info group prev out)
2530 (while (>= (decf arg) 0)
2531 (if (not (setq info (pop gnus-list-of-killed-groups)))
2532 (error "No more newsgroups to yank"))
2533 (push (setq group (nth 1 info)) out)
2534 ;; Find which newsgroup to insert this one before - search
2535 ;; backward until something suitable is found. If there are no
2536 ;; other newsgroups in this buffer, just make this newsgroup the
2538 (setq prev (gnus-group-group-name))
2539 (gnus-group-change-level
2540 info (gnus-info-level (cdr info)) gnus-level-killed
2541 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
2543 (gnus-group-insert-group-line-info group)
2545 `(when (gnus-group-goto-group ,group)
2546 (gnus-group-kill-group 1))))
2548 (gnus-group-position-point)
2549 (if (< (length out) 2) (car out) (nreverse out))))
2551 (defun gnus-group-kill-level (level)
2552 "Kill all groups that is on a certain LEVEL."
2553 (interactive "nKill all groups on level: ")
2555 ((= level gnus-level-zombie)
2556 (setq gnus-killed-list
2557 (nconc gnus-zombie-list gnus-killed-list))
2558 (setq gnus-zombie-list nil))
2559 ((and (< level gnus-level-zombie)
2561 (or gnus-expert-user
2564 "Do you really want to kill all groups on level %d? "
2566 (let* ((prev gnus-newsrc-alist)
2569 (if (= (gnus-info-level (car alist)) level)
2571 (push (gnus-info-group (car alist)) gnus-killed-list)
2572 (setcdr prev (cdr alist)))
2574 (setq alist (cdr alist)))
2575 (gnus-make-hashtable-from-newsrc-alist)
2576 (gnus-group-list-groups)))
2578 (error "Can't kill; illegal level: %d" level))))
2580 (defun gnus-group-list-all-groups (&optional arg)
2581 "List all newsgroups with level ARG or lower.
2582 Default is gnus-level-unsubscribed, which lists all subscribed and most
2583 unsubscribed groups."
2585 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
2587 ;; Redefine this to list ALL killed groups if prefix arg used.
2588 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
2589 (defun gnus-group-list-killed (&optional arg)
2590 "List all killed newsgroups in the group buffer.
2591 If ARG is non-nil, list ALL killed groups known to Gnus. This may
2592 entail asking the server for the groups."
2594 ;; Find all possible killed newsgroups if arg.
2596 (gnus-get-killed-groups))
2597 (if (not gnus-killed-list)
2598 (gnus-message 6 "No killed groups")
2599 (let (gnus-group-list-mode)
2600 (funcall gnus-group-prepare-function
2601 gnus-level-killed t gnus-level-killed))
2602 (goto-char (point-min)))
2603 (gnus-group-position-point))
2605 (defun gnus-group-list-zombies ()
2606 "List all zombie newsgroups in the group buffer."
2608 (if (not gnus-zombie-list)
2609 (gnus-message 6 "No zombie groups")
2610 (let (gnus-group-list-mode)
2611 (funcall gnus-group-prepare-function
2612 gnus-level-zombie t gnus-level-zombie))
2613 (goto-char (point-min)))
2614 (gnus-group-position-point))
2616 (defun gnus-group-list-active ()
2617 "List all groups that are available from the server(s)."
2619 ;; First we make sure that we have really read the active file.
2620 (unless (gnus-read-active-file-p)
2621 (let ((gnus-read-active-file t))
2622 (gnus-read-active-file)))
2623 ;; Find all groups and sort them.
2631 (setq list (cons (symbol-name sym) list))))
2635 (buffer-read-only nil))
2638 (gnus-group-insert-group-line-info (pop groups)))
2639 (goto-char (point-min))))
2641 (defun gnus-activate-all-groups (level)
2642 "Activate absolutely all groups."
2643 (interactive (list 7))
2644 (let ((gnus-activate-level level)
2645 (gnus-activate-foreign-newsgroups level))
2646 (gnus-group-get-new-news)))
2648 (defun gnus-group-get-new-news (&optional arg)
2649 "Get newly arrived articles.
2650 If ARG is a number, it specifies which levels you are interested in
2651 re-scanning. If ARG is non-nil and not a number, this will force
2652 \"hard\" re-reading of the active files from all servers."
2654 (run-hooks 'gnus-get-new-news-hook)
2656 ;; Read any slave files.
2658 (gnus-master-read-slave-newsrc))
2660 ;; We might read in new NoCeM messages here.
2661 (when (and gnus-use-nocem
2663 (gnus-nocem-scan-groups))
2664 ;; If ARG is not a number, then we read the active file.
2665 (when (and arg (not (numberp arg)))
2666 (let ((gnus-read-active-file t))
2667 (gnus-read-active-file))
2670 (setq arg (gnus-group-default-level arg t))
2671 (if (and gnus-read-active-file (not arg))
2673 (gnus-read-active-file)
2674 (gnus-get-unread-articles arg))
2675 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
2676 (gnus-get-unread-articles arg)))
2677 (run-hooks 'gnus-after-getting-new-news-hook)
2678 (gnus-group-list-groups))
2680 (defun gnus-group-get-new-news-this-group (&optional n)
2681 "Check for newly arrived news in the current group (and the N-1 next groups).
2682 The difference between N and the number of newsgroup checked is returned.
2683 If N is negative, this group and the N-1 previous groups will be checked."
2685 (let* ((groups (gnus-group-process-prefix n))
2686 (ret (if (numberp n) (- n (length groups)) 0))
2687 (beg (unless n (point)))
2689 (while (setq group (pop groups))
2690 (gnus-group-remove-mark group)
2691 ;; Bypass any previous denials from the server.
2692 (gnus-remove-denial (gnus-find-method-for-group group))
2693 (if (gnus-activate-group group 'scan)
2695 (gnus-get-unread-articles-in-group
2696 (gnus-get-info group) (gnus-active group) t)
2697 (unless (gnus-virtual-group-p group)
2698 (gnus-close-group group))
2699 (gnus-group-update-group group))
2700 (if (eq (gnus-server-status (gnus-find-method-for-group group))
2702 (gnus-error 3 "Server denied access")
2703 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
2704 (when beg (goto-char beg))
2705 (when gnus-goto-next-group-when-activating
2706 (gnus-group-next-unread-group 1 t))
2707 (gnus-summary-position-point)
2710 (defun gnus-group-fetch-faq (group &optional faq-dir)
2711 "Fetch the FAQ for the current group.
2712 If given a prefix argument, prompt for the FAQ dir
2716 (gnus-group-group-name)
2717 (cond (current-prefix-arg
2719 "Faq dir: " (and (listp gnus-group-faq-directory)
2720 (mapcar (lambda (file) (list file))
2721 gnus-group-faq-directory)))))))
2723 (error "No group name given"))
2724 (let ((dirs (or faq-dir gnus-group-faq-directory))
2726 (unless (listp dirs)
2727 (setq dirs (list dirs)))
2728 (while (and (not found)
2729 (setq dir (pop dirs)))
2730 (setq file (concat (file-name-as-directory dir)
2731 (gnus-group-real-name group)))
2732 (if (not (file-exists-p file))
2733 (gnus-message 1 "No such file: %s" file)
2737 (defun gnus-group-describe-group (force &optional group)
2738 "Display a description of the current newsgroup."
2739 (interactive (list current-prefix-arg (gnus-group-group-name)))
2740 (let* ((method (gnus-find-method-for-group group))
2741 (mname (gnus-group-prefixed-name "" method))
2744 gnus-description-hashtb)
2745 (gnus-sethash mname nil gnus-description-hashtb))
2746 (or group (error "No group name given"))
2747 (and (or (and gnus-description-hashtb
2748 ;; We check whether this group's method has been
2749 ;; queried for a description file.
2750 (gnus-gethash mname gnus-description-hashtb))
2751 (setq desc (gnus-group-get-description group))
2752 (gnus-read-descriptions-file method))
2754 (or desc (gnus-gethash group gnus-description-hashtb)
2755 "No description available")))))
2757 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
2758 (defun gnus-group-describe-all-groups (&optional force)
2759 "Pop up a buffer with descriptions of all newsgroups."
2761 (and force (setq gnus-description-hashtb nil))
2762 (if (not (or gnus-description-hashtb
2763 (gnus-read-all-descriptions-files)))
2764 (error "Couldn't request descriptions file"))
2765 (let ((buffer-read-only nil)
2771 (insert (format " *: %-20s %s\n" (symbol-name group)
2772 (symbol-value group)))
2773 (gnus-add-text-properties
2774 b (1+ b) (list 'gnus-group group
2775 'gnus-unread t 'gnus-marked nil
2776 'gnus-level (1+ gnus-level-subscribed))))
2777 gnus-description-hashtb)
2778 (goto-char (point-min))
2779 (gnus-group-position-point)))
2781 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
2782 (defun gnus-group-apropos (regexp &optional search-description)
2783 "List all newsgroups that have names that match a regexp."
2784 (interactive "sGnus apropos (regexp): ")
2786 (obuf (current-buffer))
2788 ;; Go through all newsgroups that are known to Gnus.
2791 (and (symbol-name group)
2792 (string-match regexp (symbol-name group))
2793 (setq groups (cons (symbol-name group) groups))))
2795 ;; Also go through all descriptions that are known to Gnus.
2796 (when search-description
2799 (and (string-match regexp (symbol-value group))
2800 (gnus-active (symbol-name group))
2801 (setq groups (cons (symbol-name group) groups))))
2802 gnus-description-hashtb))
2804 (gnus-message 3 "No groups matched \"%s\"." regexp)
2805 ;; Print out all the groups.
2807 (pop-to-buffer "*Gnus Help*")
2808 (buffer-disable-undo (current-buffer))
2810 (setq groups (sort groups 'string<))
2812 ;; Groups may be entered twice into the list of groups.
2813 (if (not (string= (car groups) prev))
2815 (insert (setq prev (car groups)) "\n")
2816 (if (and gnus-description-hashtb
2817 (setq des (gnus-gethash (car groups)
2818 gnus-description-hashtb)))
2819 (insert " " des "\n"))))
2820 (setq groups (cdr groups)))
2821 (goto-char (point-min))))
2822 (pop-to-buffer obuf)))
2824 (defun gnus-group-description-apropos (regexp)
2825 "List all newsgroups that have names or descriptions that match a regexp."
2826 (interactive "sGnus description apropos (regexp): ")
2827 (if (not (or gnus-description-hashtb
2828 (gnus-read-all-descriptions-files)))
2829 (error "Couldn't request descriptions file"))
2830 (gnus-group-apropos regexp t))
2832 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
2833 (defun gnus-group-list-matching (level regexp &optional all lowest)
2834 "List all groups with unread articles that match REGEXP.
2835 If the prefix LEVEL is non-nil, it should be a number that says which
2836 level to cut off listing groups.
2837 If ALL, also list groups with no unread articles.
2838 If LOWEST, don't list groups with level lower than LOWEST.
2840 This command may read the active file."
2841 (interactive "P\nsList newsgroups matching: ")
2842 ;; First make sure active file has been read.
2844 (> (prefix-numeric-value level) gnus-level-killed))
2845 (gnus-get-killed-groups))
2846 (gnus-group-prepare-flat (or level gnus-level-subscribed)
2847 all (or lowest 1) regexp)
2848 (goto-char (point-min))
2849 (gnus-group-position-point))
2851 (defun gnus-group-list-all-matching (level regexp &optional lowest)
2852 "List all groups that match REGEXP.
2853 If the prefix LEVEL is non-nil, it should be a number that says which
2854 level to cut off listing groups.
2855 If LOWEST, don't list groups with level lower than LOWEST."
2856 (interactive "P\nsList newsgroups matching: ")
2857 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
2859 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
2860 (defun gnus-group-save-newsrc (&optional force)
2861 "Save the Gnus startup files.
2862 If FORCE, force saving whether it is necessary or not."
2864 (gnus-save-newsrc-file force))
2866 (defun gnus-group-restart (&optional arg)
2867 "Force Gnus to read the .newsrc file."
2869 (when (gnus-yes-or-no-p
2870 (format "Are you sure you want to restart Gnus? "))
2871 (gnus-save-newsrc-file)
2872 (gnus-setup-news 'force)
2873 (gnus-group-list-groups arg)))
2875 (defun gnus-group-read-init-file ()
2876 "Read the Gnus elisp init file."
2878 (gnus-read-init-file))
2880 (defun gnus-group-check-bogus-groups (&optional silent)
2881 "Check bogus newsgroups.
2882 If given a prefix, don't ask for confirmation before removing a bogus
2885 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
2886 (gnus-group-list-groups))
2888 (defun gnus-group-edit-global-kill (&optional article group)
2889 "Edit the global kill file.
2890 If GROUP, edit that local kill file instead."
2892 (setq gnus-current-kill-article article)
2893 (gnus-kill-file-edit-file group)
2896 (substitute-command-keys
2897 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
2898 (if group "local" "global")))))
2900 (defun gnus-group-edit-local-kill (article group)
2901 "Edit a local kill file."
2902 (interactive (list nil (gnus-group-group-name)))
2903 (gnus-group-edit-global-kill article group))
2905 (defun gnus-group-force-update ()
2906 "Update `.newsrc' file."
2908 (gnus-save-newsrc-file))
2910 (defun gnus-group-suspend ()
2911 "Suspend the current Gnus session.
2912 In fact, cleanup buffers except for group mode buffer.
2913 The hook gnus-suspend-gnus-hook is called before actually suspending."
2915 (run-hooks 'gnus-suspend-gnus-hook)
2916 ;; Kill Gnus buffers except for group mode buffer.
2917 (let* ((group-buf (get-buffer gnus-group-buffer))
2918 ;; Do this on a separate list in case the user does a ^G before we finish
2920 (delete group-buf (delete gnus-dribble-buffer
2921 (append gnus-buffer-list nil)))))
2922 (while gnus-buffer-list
2923 (gnus-kill-buffer (pop gnus-buffer-list)))
2924 (gnus-kill-gnus-frames)
2926 (setq gnus-buffer-list (list group-buf))
2927 (bury-buffer group-buf)
2928 (delete-windows-on group-buf t))))
2930 (defun gnus-group-clear-dribble ()
2931 "Clear all information from the dribble buffer."
2933 (gnus-dribble-clear)
2934 (gnus-message 7 "Cleared dribble buffer"))
2936 (defun gnus-group-exit ()
2937 "Quit reading news after updating .newsrc.eld and .newsrc.
2938 The hook `gnus-exit-gnus-hook' is called before actually exiting."
2941 (or noninteractive ;For gnus-batch-kill
2942 (not gnus-interactive-exit) ;Without confirmation
2944 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
2945 (run-hooks 'gnus-exit-gnus-hook)
2946 ;; Offer to save data from non-quitted summary buffers.
2947 (gnus-offer-save-summaries)
2948 ;; Save the newsrc file(s).
2949 (gnus-save-newsrc-file)
2951 (gnus-close-backends)
2952 ;; Reset everything.
2954 ;; Allow the user to do things after cleaning up.
2955 (run-hooks 'gnus-after-exiting-gnus-hook)))
2957 (defun gnus-group-quit ()
2958 "Quit reading news without updating .newsrc.eld or .newsrc.
2959 The hook `gnus-exit-gnus-hook' is called before actually exiting."
2961 (when (or noninteractive ;For gnus-batch-kill
2962 (zerop (buffer-size))
2963 (not (gnus-server-opened gnus-select-method))
2965 (not gnus-current-startup-file)
2967 (format "Quit reading news without saving %s? "
2968 (file-name-nondirectory gnus-current-startup-file))))
2969 (run-hooks 'gnus-exit-gnus-hook)
2970 (gnus-configure-windows 'group t)
2972 (gnus-close-backends)
2974 (gnus-kill-buffer gnus-group-buffer)
2975 ;; Allow the user to do things after cleaning up.
2976 (run-hooks 'gnus-after-exiting-gnus-hook)))
2978 (defun gnus-group-describe-briefly ()
2979 "Give a one line description of the group mode commands."
2981 (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")))
2983 (defun gnus-group-browse-foreign-server (method)
2984 "Browse a foreign news server.
2985 If called interactively, this function will ask for a select method
2986 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
2987 If not, METHOD should be a list where the first element is the method
2988 and the second element is the address."
2990 (list (let ((how (completing-read
2992 (append gnus-valid-select-methods gnus-server-alist)
2993 nil t (cons "nntp" 0) 'gnus-method-history)))
2994 ;; We either got a backend name or a virtual server name.
2995 ;; If the first, we also need an address.
2996 (if (assoc how gnus-valid-select-methods)
2998 ;; Suggested by mapjph@bath.ac.uk.
3001 (mapcar (lambda (server) (list server))
3002 gnus-secondary-servers)))
3003 ;; We got a server name, so we find the method.
3004 (gnus-server-to-method how)))))
3005 (gnus-browse-foreign-server method))
3007 (defun gnus-group-set-info (info &optional method-only-group part)
3008 (let* ((entry (gnus-gethash
3009 (or method-only-group (gnus-info-group info))
3010 gnus-newsrc-hashtb))
3012 (info (if method-only-group (nth 2 entry) info))
3014 (when method-only-group
3016 (error "Trying to change non-existent group %s" method-only-group))
3017 ;; We have received parts of the actual group info - either the
3018 ;; select method or the group parameters. We first check
3019 ;; whether we have to extend the info, and if so, do that.
3020 (let ((len (length info))
3021 (total (if (eq part 'method) 5 6)))
3023 (setcdr (nthcdr (1- len) info)
3024 (make-list (- total len) nil)))
3025 ;; Then we enter the new info.
3026 (setcar (nthcdr (1- total) info) part-info)))
3028 ;; This is a new group, so we just create it.
3030 (set-buffer gnus-group-buffer)
3031 (setq method (gnus-info-method info))
3032 (when (gnus-server-equal method "native")
3035 (set-buffer gnus-group-buffer)
3037 ;; It's a foreign group...
3038 (gnus-group-make-group
3039 (gnus-group-real-name (gnus-info-group info))
3040 (if (stringp method) method
3041 (prin1-to-string (car method)))
3043 (nth 1 (gnus-info-method info))))
3044 ;; It's a native group.
3045 (gnus-group-make-group (gnus-info-group info))))
3046 (gnus-message 6 "Note: New group created")
3048 (gnus-gethash (gnus-group-prefixed-name
3049 (gnus-group-real-name (gnus-info-group info))
3050 (or (gnus-info-method info) gnus-select-method))
3051 gnus-newsrc-hashtb))))
3052 ;; Whether it was a new group or not, we now have the entry, so we
3053 ;; can do the update.
3056 (setcar (nthcdr 2 entry) info)
3057 (when (and (not (eq (car entry) t))
3058 (gnus-active (gnus-info-group info)))
3059 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3060 (error "No such group: %s" (gnus-info-group info)))))
3062 (defun gnus-group-set-method-info (group select-method)
3063 (gnus-group-set-info select-method group 'method))
3065 (defun gnus-group-set-params-info (group params)
3066 (gnus-group-set-info params group 'params))
3068 (defun gnus-add-marked-articles (group type articles &optional info force)
3069 ;; Add ARTICLES of TYPE to the info of GROUP.
3070 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3071 ;; add, but replace marked articles of TYPE with ARTICLES.
3072 (let ((info (or info (gnus-get-info group)))
3073 (uncompressed '(score bookmark killed))
3076 (and (not (setq marked (nthcdr 3 info)))
3078 (setcdr (nthcdr 2 info)
3079 (list (list (cons type (gnus-compress-sequence
3081 (and (not (setq m (assq type (car marked))))
3084 (cons (cons type (gnus-compress-sequence articles t) )
3088 (setcar (nthcdr 3 info)
3089 (delq (assq type (car marked)) (car marked)))
3090 (setcdr m (gnus-compress-sequence articles t)))
3091 (setcdr m (gnus-compress-sequence
3092 (sort (nconc (gnus-uncompress-range (cdr m))
3093 (copy-sequence articles)) '<) t))))))
3095 (provide 'gnus-group)
3097 ;;; gnus-group.el ends here