1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996,97 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 (defcustom gnus-group-archive-directory
38 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
39 "*The address of the (ding) archives."
40 :group 'gnus-group-foreign
43 (defcustom gnus-group-recent-archive-directory
44 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
45 "*The address of the most recent (ding) articles."
46 :group 'gnus-group-foreign
49 (defcustom gnus-no-groups-message "No news is no news"
50 "*Message displayed by Gnus when no groups are available."
54 (defcustom gnus-keep-same-level nil
55 "*Non-nil means that the next newsgroup after the current will be on the same level.
56 When you type, for instance, `n' after reading the last article in the
57 current newsgroup, you will go to the next newsgroup. If this variable
58 is nil, the next newsgroup will be the next from the group
60 If this variable is non-nil, Gnus will either put you in the
61 next newsgroup with the same level, or, if no such newsgroup is
62 available, the next newsgroup with the lowest possible level higher
63 than the current level.
64 If this variable is `best', Gnus will make the next newsgroup the one
66 :group 'gnus-group-levels
67 :type '(choice (const nil)
69 (sexp :tag "other" t)))
71 (defcustom gnus-group-goto-unread t
72 "*If non-nil, movement commands will go to the next unread and subscribed group."
73 :link '(custom-manual "(gnus)Group Maneuvering")
74 :group 'gnus-group-various
77 (defcustom gnus-goto-next-group-when-activating t
78 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
79 :link '(custom-manual "(gnus)Scanning New Messages")
80 :group 'gnus-group-various
83 (defcustom gnus-permanently-visible-groups nil
84 "*Regexp to match groups that should always be listed in the group buffer.
85 This means that they will still be listed when there are no unread
86 articles in the groups."
87 :group 'gnus-group-listing
90 (defcustom gnus-list-groups-with-ticked-articles t
91 "*If non-nil, list groups that have only ticked articles.
92 If nil, only list groups that have unread articles."
93 :group 'gnus-group-listing
96 (defcustom gnus-group-default-list-level gnus-level-subscribed
97 "*Default listing level.
98 Ignored if `gnus-group-use-permanent-levels' is non-nil."
99 :group 'gnus-group-listing
102 (defcustom gnus-group-list-inactive-groups t
103 "*If non-nil, inactive groups will be listed."
104 :group 'gnus-group-listing
105 :group 'gnus-group-levels
108 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
109 "*Function used for sorting the group buffer.
110 This function will be called with group info entries as the arguments
111 for the groups to be sorted. Pre-made functions include
112 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
113 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
114 `gnus-group-sort-by-score', `gnus-group-sort-by-method', and
115 `gnus-group-sort-by-rank'.
117 This variable can also be a list of sorting functions. In that case,
118 the most significant sort function should be the last function in the
120 :group 'gnus-group-listing
121 :link '(custom-manual "(gnus)Sorting Groups")
122 :type '(radio (function-item gnus-group-sort-by-alphabet)
123 (function-item gnus-group-sort-by-real-name)
124 (function-item gnus-group-sort-by-unread)
125 (function-item gnus-group-sort-by-level)
126 (function-item gnus-group-sort-by-score)
127 (function-item gnus-group-sort-by-method)
128 (function-item gnus-group-sort-by-rank)
129 (function :tag "other" nil)))
131 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n"
132 "*Format of group lines.
133 It works along the same lines as a normal formatting string,
134 with some simple extensions.
136 %M Only marked articles (character, \"*\" or \" \")
137 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
138 %L Level of subscribedness (integer)
139 %N Number of unread articles (integer)
140 %I Number of dormant articles (integer)
141 %i Number of ticked and dormant (integer)
142 %T Number of ticked articles (integer)
143 %R Number of read articles (integer)
144 %t Estimated total number of articles (integer)
145 %y Number of unread, unticked articles (integer)
146 %G Group name (string)
147 %g Qualified group name (string)
148 %D Group description (string)
149 %s Select method (string)
150 %o Moderated group (char, \"m\")
151 %p Process mark (char)
152 %O Moderated group (string, \"(m)\" or \"\")
153 %P Topic indentation (string)
154 %m Whether there is new(ish) mail in the group (char, \"%\")
155 %l Whether there are GroupLens predictions for this group (string)
156 %n Select from where (string)
157 %z A string that look like `<%s:%n>' if a foreign select method is used
158 %d The date the group was last entered.
159 %u User defined specifier. The next character in the format string should
160 be a letter. Gnus will call the function gnus-user-format-function-X,
161 where X is the letter following %u. The function will be passed the
162 current header as argument. The function should return a string, which
163 will be inserted into the buffer just like information from any other
166 Text between %( and %) will be highlighted with `gnus-mouse-face' when
167 the mouse point move inside the area. There can only be one such area.
169 Note that this format specification is not always respected. For
170 reasons of efficiency, when listing killed groups, this specification
171 is ignored altogether. If the spec is changed considerably, your
172 output may end up looking strange when listing both alive and killed
175 If you use %o or %O, reading the active file will be slower and quite
176 a bit of extra memory will be used. %D will also worsen performance.
177 Also note that if you change the format specification to include any
178 of these specs, you must probably re-start Gnus to see them go into
180 :group 'gnus-group-visual
183 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
184 "*The format specification for the group mode line.
185 It works along the same lines as a normal formatting string,
186 with some simple extensions:
188 %S The native news server.
189 %M The native select method.
190 %: \":\" if %S isn't \"\"."
191 :group 'gnus-group-visual
194 (defcustom gnus-group-mode-hook nil
195 "Hook for Gnus group mode."
196 :group 'gnus-group-various
197 :options '(gnus-topic-mode)
200 (defcustom gnus-group-menu-hook nil
201 "Hook run after the creation of the group mode menu."
202 :group 'gnus-group-various
205 (defcustom gnus-group-catchup-group-hook nil
206 "Hook run when catching up a group from the group buffer."
207 :group 'gnus-group-various
208 :link '(custom-manual "(gnus)Group Data")
211 (defcustom gnus-group-update-group-hook nil
212 "Hook called when updating group lines."
213 :group 'gnus-group-visual
216 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
217 "*A function that is called to generate the group buffer.
218 The function is called with three arguments: The first is a number;
219 all group with a level less or equal to that number should be listed,
220 if the second is non-nil, empty groups should also be displayed. If
221 the third is non-nil, it is a number. No groups with a level lower
222 than this number should be displayed.
224 The only current function implemented is `gnus-group-prepare-flat'."
225 :group 'gnus-group-listing
228 (defcustom gnus-group-prepare-hook nil
229 "Hook called after the group buffer has been generated.
230 If you want to modify the group buffer, you can use this hook."
231 :group 'gnus-group-listing
234 (defcustom gnus-suspend-gnus-hook nil
235 "Hook called when suspending (not exiting) Gnus."
239 (defcustom gnus-exit-gnus-hook nil
240 "Hook called when exiting Gnus."
244 (defcustom gnus-after-exiting-gnus-hook nil
245 "Hook called after exiting Gnus."
249 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
250 "Hook called when a group line is changed.
251 The hook will not be called if `gnus-visual' is nil.
253 The default function `gnus-group-highlight-line' will
254 highlight the line according to the `gnus-group-highlight'
256 :group 'gnus-group-visual
259 (defcustom gnus-useful-groups
260 `(("(ding) mailing list mirrored at sunsite.auc.dk"
262 (nntp "sunsite.auc.dk"
263 (nntp-address "sunsite.auc.dk")))
267 (nndoc-article-type mbox)
268 (eval `(nndoc-address
269 ,(let ((file (nnheader-find-etc-directory
272 (error "Couldn't find doc group"))
274 "Alist of useful group-server pairs."
275 :group 'gnus-group-listing
276 :type '(repeat (list (string :tag "Description")
278 (sexp :tag "Method"))))
280 (defcustom gnus-group-highlight
282 ((and (= unread 0) (not mailp) (eq level 1)) .
283 gnus-group-news-1-empty-face)
284 ((and (not mailp) (eq level 1)) .
285 gnus-group-news-1-face)
286 ((and (= unread 0) (not mailp) (eq level 2)) .
287 gnus-group-news-2-empty-face)
288 ((and (not mailp) (eq level 2)) .
289 gnus-group-news-2-face)
290 ((and (= unread 0) (not mailp) (eq level 3)) .
291 gnus-group-news-3-empty-face)
292 ((and (not mailp) (eq level 3)) .
293 gnus-group-news-3-face)
294 ((and (= unread 0) (not mailp)) .
295 gnus-group-news-low-empty-face)
297 gnus-group-news-low-face)
299 ((and (= unread 0) (eq level 1)) .
300 gnus-group-mail-1-empty-face)
302 gnus-group-mail-1-face)
303 ((and (= unread 0) (eq level 2)) .
304 gnus-group-mail-2-empty-face)
306 gnus-group-mail-2-face)
307 ((and (= unread 0) (eq level 3)) .
308 gnus-group-mail-3-empty-face)
310 gnus-group-mail-3-face)
312 gnus-group-mail-low-empty-face)
314 gnus-group-mail-low-face))
315 "Controls the highlighting of group buffer lines.
317 Below is a list of `Form'/`Face' pairs. When deciding how a a
318 particular group line should be displayed, each form is
319 evaluated. The content of the face field after the first true form is
320 used. You can change how those group lines are displayed by
321 editing the face field.
323 It is also possible to change and add form fields, but currently that
324 requires an understanding of Lisp expressions. Hopefully this will
325 change in a future release. For now, you can use the following
326 variables in the Lisp expression:
328 group: The name of the group.
329 unread: The number of unread articles in the group.
330 method: The select method used.
331 mailp: Whether it's a mail group or not.
332 level: The level of the group.
333 score: The score of the group.
334 ticked: The number of ticked articles."
335 :group 'gnus-group-visual
336 :type '(repeat (cons (sexp :tag "Form") face)))
338 (defcustom gnus-new-mail-mark ?%
339 "Mark used for groups with new mail."
340 :group 'gnus-group-visual
343 ;;; Internal variables
345 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
346 "Function for sorting the group buffer.")
348 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
349 "Function for sorting the selected groups in the group buffer.")
351 (defvar gnus-group-indentation-function nil)
352 (defvar gnus-goto-missing-group-function nil)
353 (defvar gnus-group-update-group-function nil)
354 (defvar gnus-group-goto-next-group-function nil
355 "Function to override finding the next group after listing groups.")
357 (defvar gnus-group-edit-buffer nil)
359 (defvar gnus-group-line-format-alist
360 `((?M gnus-tmp-marked-mark ?c)
361 (?S gnus-tmp-subscribed ?c)
362 (?L gnus-tmp-level ?d)
363 (?N (cond ((eq number t) "*" )
367 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
368 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
370 (?R gnus-tmp-number-of-read ?s)
371 (?t gnus-tmp-number-total ?d)
372 (?y gnus-tmp-number-of-unread ?s)
373 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
374 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
375 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
376 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
377 (?g gnus-tmp-group ?s)
378 (?G gnus-tmp-qualified-group ?s)
379 (?c (gnus-short-group-name gnus-tmp-group) ?s)
380 (?D gnus-tmp-newsgroup-description ?s)
381 (?o gnus-tmp-moderated ?c)
382 (?O gnus-tmp-moderated-string ?s)
383 (?p gnus-tmp-process-marked ?c)
384 (?s gnus-tmp-news-server ?s)
385 (?n gnus-tmp-news-method ?s)
386 (?P gnus-group-indentation ?s)
387 (?l gnus-tmp-grouplens ?s)
388 (?z gnus-tmp-news-method-string ?s)
389 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
390 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
391 (?u gnus-tmp-user-defined ?s)))
393 (defvar gnus-group-mode-line-format-alist
394 `((?S gnus-tmp-news-server ?s)
395 (?M gnus-tmp-news-method ?s)
396 (?u gnus-tmp-user-defined ?s)
397 (?: gnus-tmp-colon ?s)))
399 (defvar gnus-topic-topology nil
400 "The complete topic hierarchy.")
402 (defvar gnus-topic-alist nil
403 "The complete topic-group alist.")
405 (defvar gnus-group-marked nil)
407 (defvar gnus-group-list-mode nil)
413 (put 'gnus-group-mode 'mode-class 'special)
416 (gnus-define-keys gnus-group-mode-map
417 " " gnus-group-read-group
418 "=" gnus-group-select-group
419 "\r" gnus-group-select-group
420 "\M-\r" gnus-group-quick-select-group
421 [(meta control return)] gnus-group-select-group-ephemerally
422 "j" gnus-group-jump-to-group
423 "n" gnus-group-next-unread-group
424 "p" gnus-group-prev-unread-group
425 "\177" gnus-group-prev-unread-group
426 [delete] gnus-group-prev-unread-group
427 "N" gnus-group-next-group
428 "P" gnus-group-prev-group
429 "\M-n" gnus-group-next-unread-group-same-level
430 "\M-p" gnus-group-prev-unread-group-same-level
431 "," gnus-group-best-unread-group
432 "." gnus-group-first-unread-group
433 "u" gnus-group-unsubscribe-current-group
434 "U" gnus-group-unsubscribe-group
435 "c" gnus-group-catchup-current
436 "C" gnus-group-catchup-current-all
437 "\M-c" gnus-group-clear-data
438 "l" gnus-group-list-groups
439 "L" gnus-group-list-all-groups
441 "g" gnus-group-get-new-news
442 "\M-g" gnus-group-get-new-news-this-group
443 "R" gnus-group-restart
444 "r" gnus-group-read-init-file
445 "B" gnus-group-browse-foreign-server
446 "b" gnus-group-check-bogus-groups
447 "F" gnus-find-new-newsgroups
448 "\C-c\C-d" gnus-group-describe-group
449 "\M-d" gnus-group-describe-all-groups
450 "\C-c\C-a" gnus-group-apropos
451 "\C-c\M-\C-a" gnus-group-description-apropos
452 "a" gnus-group-post-news
453 "\ek" gnus-group-edit-local-kill
454 "\eK" gnus-group-edit-global-kill
455 "\C-k" gnus-group-kill-group
456 "\C-y" gnus-group-yank-group
457 "\C-w" gnus-group-kill-region
458 "\C-x\C-t" gnus-group-transpose-groups
459 "\C-c\C-l" gnus-group-list-killed
460 "\C-c\C-x" gnus-group-expire-articles
461 "\C-c\M-\C-x" gnus-group-expire-all-groups
463 "s" gnus-group-save-newsrc
464 "z" gnus-group-suspend
467 "?" gnus-group-describe-briefly
468 "\C-c\C-i" gnus-info-find-node
469 "\M-e" gnus-group-edit-group-method
470 "^" gnus-group-enter-server-mode
471 gnus-mouse-2 gnus-mouse-pick-group
472 "<" beginning-of-buffer
475 "\C-c\C-s" gnus-group-sort-groups
477 "\C-c\M-g" gnus-activate-all-groups
478 "\M-&" gnus-group-universal-argument
479 "#" gnus-group-mark-group
480 "\M-#" gnus-group-unmark-group)
482 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
483 "m" gnus-group-mark-group
484 "u" gnus-group-unmark-group
485 "w" gnus-group-mark-region
486 "m" gnus-group-mark-buffer
487 "r" gnus-group-mark-regexp
488 "U" gnus-group-unmark-all-groups)
490 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
491 "d" gnus-group-make-directory-group
492 "h" gnus-group-make-help-group
493 "u" gnus-group-make-useful-group
494 "a" gnus-group-make-archive-group
495 "k" gnus-group-make-kiboze-group
496 "m" gnus-group-make-group
497 "E" gnus-group-edit-group
498 "e" gnus-group-edit-group-method
499 "p" gnus-group-edit-group-parameters
500 "v" gnus-group-add-to-virtual
501 "V" gnus-group-make-empty-virtual
502 "D" gnus-group-enter-directory
503 "f" gnus-group-make-doc-group
504 "w" gnus-group-make-web-group
505 "r" gnus-group-rename-group
506 "c" gnus-group-customize
507 "\177" gnus-group-delete-group
508 [delete] gnus-group-delete-group)
510 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
511 "b" gnus-group-brew-soup
512 "w" gnus-soup-save-areas
513 "s" gnus-soup-send-replies
514 "p" gnus-soup-pack-packet
515 "r" nnsoup-pack-replies)
517 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
518 "s" gnus-group-sort-groups
519 "a" gnus-group-sort-groups-by-alphabet
520 "u" gnus-group-sort-groups-by-unread
521 "l" gnus-group-sort-groups-by-level
522 "v" gnus-group-sort-groups-by-score
523 "r" gnus-group-sort-groups-by-rank
524 "m" gnus-group-sort-groups-by-method)
526 (gnus-define-keys (gnus-group-sort-map "P" gnus-group-group-map)
527 "s" gnus-group-sort-selected-groups
528 "a" gnus-group-sort-selected-groups-by-alphabet
529 "u" gnus-group-sort-selected-groups-by-unread
530 "l" gnus-group-sort-selected-groups-by-level
531 "v" gnus-group-sort-selected-groups-by-score
532 "r" gnus-group-sort-selected-groups-by-rank
533 "m" gnus-group-sort-selected-groups-by-method)
535 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
536 "k" gnus-group-list-killed
537 "z" gnus-group-list-zombies
538 "s" gnus-group-list-groups
539 "u" gnus-group-list-all-groups
540 "A" gnus-group-list-active
541 "a" gnus-group-apropos
542 "d" gnus-group-description-apropos
543 "m" gnus-group-list-matching
544 "M" gnus-group-list-all-matching
545 "l" gnus-group-list-level)
547 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
548 "f" gnus-score-flush-cache)
550 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
551 "d" gnus-group-describe-group
552 "f" gnus-group-fetch-faq)
554 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
555 "l" gnus-group-set-current-level
556 "t" gnus-group-unsubscribe-current-group
557 "s" gnus-group-unsubscribe-group
558 "k" gnus-group-kill-group
559 "y" gnus-group-yank-group
560 "w" gnus-group-kill-region
561 "\C-k" gnus-group-kill-level
562 "z" gnus-group-kill-all-zombies))
564 (defun gnus-group-make-menu-bar ()
565 (gnus-turn-off-edit-menu 'group)
566 (unless (boundp 'gnus-group-reading-menu)
569 gnus-group-reading-menu gnus-group-mode-map ""
571 ["Read" gnus-group-read-group (gnus-group-group-name)]
572 ["Select" gnus-group-select-group (gnus-group-group-name)]
573 ["See old articles" (gnus-group-select-group 'all)
574 :keys "C-u SPC" :active (gnus-group-group-name)]
575 ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
576 ["Catch up all articles" gnus-group-catchup-current-all
577 (gnus-group-group-name)]
578 ["Check for new articles" gnus-group-get-new-news-this-group
579 (gnus-group-group-name)]
580 ["Toggle subscription" gnus-group-unsubscribe-current-group
581 (gnus-group-group-name)]
582 ["Kill" gnus-group-kill-group (gnus-group-group-name)]
583 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
584 ["Describe" gnus-group-describe-group (gnus-group-group-name)]
585 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
586 ;; Actually one should check, if any of the marked groups gives t for
587 ;; (gnus-check-backend-function 'request-expire-articles ...)
588 ["Expire articles" gnus-group-expire-articles
589 (or (and (gnus-group-group-name)
590 (gnus-check-backend-function
591 'request-expire-articles
592 (gnus-group-group-name))) gnus-group-marked)]
593 ["Set group level" gnus-group-set-current-level
594 (gnus-group-group-name)]
595 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
596 ["Customize" gnus-group-customize (gnus-group-group-name)]
598 ["Parameters" gnus-group-edit-group-parameters
599 (gnus-group-group-name)]
600 ["Select method" gnus-group-edit-group-method
601 (gnus-group-group-name)]
602 ["Info" gnus-group-edit-group (gnus-group-group-name)]
603 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
604 ["Global kill file" gnus-group-edit-global-kill t])
608 gnus-group-group-menu gnus-group-mode-map ""
611 ["List unread subscribed groups" gnus-group-list-groups t]
612 ["List (un)subscribed groups" gnus-group-list-all-groups t]
613 ["List killed groups" gnus-group-list-killed gnus-killed-list]
614 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
615 ["List level..." gnus-group-list-level t]
616 ["Describe all groups" gnus-group-describe-all-groups t]
617 ["Group apropos..." gnus-group-apropos t]
618 ["Group and description apropos..." gnus-group-description-apropos t]
619 ["List groups matching..." gnus-group-list-matching t]
620 ["List all groups matching..." gnus-group-list-all-matching t]
621 ["List active file" gnus-group-list-active t])
623 ["Default sort" gnus-group-sort-groups t]
624 ["Sort by method" gnus-group-sort-groups-by-method t]
625 ["Sort by rank" gnus-group-sort-groups-by-rank t]
626 ["Sort by score" gnus-group-sort-groups-by-score t]
627 ["Sort by level" gnus-group-sort-groups-by-level t]
628 ["Sort by unread" gnus-group-sort-groups-by-unread t]
629 ["Sort by name" gnus-group-sort-groups-by-alphabet t])
630 ("Sort process/prefixed"
631 ["Default sort" gnus-group-sort-selected-groups
632 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
633 ["Sort by method" gnus-group-sort-selected-groups-by-method
634 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
635 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
636 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
637 ["Sort by score" gnus-group-sort-selected-groups-by-score
638 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
639 ["Sort by level" gnus-group-sort-selected-groups-by-level
640 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
641 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
642 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
643 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
644 (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
646 ["Mark group" gnus-group-mark-group
647 (and (gnus-group-group-name)
648 (not (memq (gnus-group-group-name) gnus-group-marked)))]
649 ["Unmark group" gnus-group-unmark-group
650 (and (gnus-group-group-name)
651 (memq (gnus-group-group-name) gnus-group-marked))]
652 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
653 ["Mark regexp..." gnus-group-mark-regexp t]
654 ["Mark region" gnus-group-mark-region t]
655 ["Mark buffer" gnus-group-mark-buffer t]
656 ["Execute command" gnus-group-universal-argument
657 (or gnus-group-marked (gnus-group-group-name))])
659 ["Subscribe to a group" gnus-group-unsubscribe-group t]
660 ["Kill all newsgroups in region" gnus-group-kill-region t]
661 ["Kill all zombie groups" gnus-group-kill-all-zombies
663 ["Kill all groups on level..." gnus-group-kill-level t])
665 ["Make a foreign group" gnus-group-make-group t]
666 ["Add a directory group" gnus-group-make-directory-group t]
667 ["Add the help group" gnus-group-make-help-group t]
668 ["Add the archive group" gnus-group-make-archive-group t]
669 ["Make a doc group" gnus-group-make-doc-group t]
670 ["Make a web group" gnus-group-make-web-group t]
671 ["Make a kiboze group" gnus-group-make-kiboze-group t]
672 ["Make a virtual group" gnus-group-make-empty-virtual t]
673 ["Add a group to a virtual" gnus-group-add-to-virtual t]
674 ["Rename group" gnus-group-rename-group
675 (gnus-check-backend-function
676 'request-rename-group (gnus-group-group-name))]
677 ["Delete group" gnus-group-delete-group
678 (gnus-check-backend-function
679 'request-delete-group (gnus-group-group-name))])
681 ["Next" gnus-group-next-group t]
682 ["Previous" gnus-group-prev-group t]
683 ["Next unread" gnus-group-next-unread-group t]
684 ["Previous unread" gnus-group-prev-unread-group t]
685 ["Next unread same level" gnus-group-next-unread-group-same-level t]
686 ["Previous unread same level"
687 gnus-group-prev-unread-group-same-level t]
688 ["Jump to group" gnus-group-jump-to-group t]
689 ["First unread group" gnus-group-first-unread-group t]
690 ["Best unread group" gnus-group-best-unread-group t])
691 ["Delete bogus groups" gnus-group-check-bogus-groups t]
692 ["Find new newsgroups" gnus-find-new-newsgroups t]
693 ["Transpose" gnus-group-transpose-groups
694 (gnus-group-group-name)]
695 ["Read a directory as a group..." gnus-group-enter-directory t]
699 gnus-group-misc-menu gnus-group-mode-map ""
702 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
703 ["Send replies" gnus-soup-send-replies
704 (fboundp 'gnus-soup-pack-packet)]
705 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
706 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
707 ["Brew SOUP" gnus-soup-brew-soup (fboundp 'gnus-soup-pack-packet)])
708 ["Send a bug report" gnus-bug t]
709 ["Send a mail" gnus-group-mail t]
710 ["Post an article..." gnus-group-post-news t]
711 ["Check for new news" gnus-group-get-new-news t]
712 ["Activate all groups" gnus-activate-all-groups t]
713 ["Restart Gnus" gnus-group-restart t]
714 ["Read init file" gnus-group-read-init-file t]
715 ["Browse foreign server" gnus-group-browse-foreign-server t]
716 ["Enter server buffer" gnus-group-enter-server-mode t]
717 ["Expire all expirable articles" gnus-group-expire-all-groups t]
718 ["Generate any kiboze groups" nnkiboze-generate-groups t]
719 ["Gnus version" gnus-version t]
720 ["Save .newsrc files" gnus-group-save-newsrc t]
721 ["Suspend Gnus" gnus-group-suspend t]
722 ["Clear dribble buffer" gnus-group-clear-dribble t]
723 ["Read manual" gnus-info-find-node t]
724 ["Flush score cache" gnus-score-flush-cache t]
725 ["Toggle topics" gnus-topic-mode t]
726 ["Exit from Gnus" gnus-group-exit t]
727 ["Exit without saving" gnus-group-quit t]
730 (run-hooks 'gnus-group-menu-hook)))
732 (defun gnus-group-mode ()
733 "Major mode for reading news.
735 All normal editing commands are switched off.
736 \\<gnus-group-mode-map>
737 The group buffer lists (some of) the groups available. For instance,
738 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
739 lists all zombie groups.
741 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
742 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
744 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
746 The following commands are available:
748 \\{gnus-group-mode-map}"
750 (when (gnus-visual-p 'group-menu 'menu)
751 (gnus-group-make-menu-bar))
752 (kill-all-local-variables)
753 (gnus-simplify-mode-line)
754 (setq major-mode 'gnus-group-mode)
755 (setq mode-name "Group")
756 (gnus-group-set-mode-line)
757 (setq mode-line-process nil)
758 (use-local-map gnus-group-mode-map)
759 (buffer-disable-undo (current-buffer))
760 (setq truncate-lines t)
761 (setq buffer-read-only t)
762 (gnus-set-default-directory)
763 (gnus-update-format-specifications nil 'group 'group-mode)
764 (gnus-update-group-mark-positions)
765 (make-local-hook 'post-command-hook)
766 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
769 (run-hooks 'gnus-group-mode-hook))
771 (defun gnus-update-group-mark-positions ()
773 (let ((gnus-process-mark 128)
774 (gnus-group-marked '("dummy.group"))
775 (gnus-active-hashtb (make-vector 10 0)))
776 (gnus-set-active "dummy.group" '(0 . 0))
777 (gnus-set-work-buffer)
778 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
779 (goto-char (point-min))
780 (setq gnus-group-mark-positions
781 (list (cons 'process (and (search-forward "\200" nil t)
784 (defun gnus-clear-inboxes-moved ()
785 (setq nnmail-moved-inboxes nil))
787 (defun gnus-mouse-pick-group (e)
788 "Enter the group under the mouse pointer."
791 (gnus-group-read-group nil))
793 ;; Look at LEVEL and find out what the level is really supposed to be.
794 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
795 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
796 (defun gnus-group-default-level (&optional level number-or-nil)
798 (gnus-group-use-permanent-levels
799 (or (setq gnus-group-use-permanent-levels
800 (or level (if (numberp gnus-group-use-permanent-levels)
801 gnus-group-use-permanent-levels
802 (or gnus-group-default-list-level
803 gnus-level-subscribed))))
804 gnus-group-default-list-level gnus-level-subscribed))
808 (or level gnus-group-default-list-level gnus-level-subscribed))))
810 (defun gnus-group-setup-buffer ()
811 (switch-to-buffer gnus-group-buffer)
812 (unless (eq major-mode 'gnus-group-mode)
813 (gnus-add-current-to-buffer-list)
816 (gnus-carpal-setup-buffer 'group))))
818 (defun gnus-group-list-groups (&optional level unread lowest)
819 "List newsgroups with level LEVEL or lower that have unread articles.
820 Default is all subscribed groups.
821 If argument UNREAD is non-nil, groups with no unread articles are also
824 Also see the `gnus-group-use-permanent-levels' variable."
826 (list (if current-prefix-arg
827 (prefix-numeric-value current-prefix-arg)
829 (gnus-group-default-level nil t)
830 gnus-group-default-list-level
831 gnus-level-subscribed))))
832 ;; Just do this here, for no particular good reason.
833 (gnus-clear-inboxes-moved)
835 (setq level (car gnus-group-list-mode)
836 unread (cdr gnus-group-list-mode)))
837 (setq level (gnus-group-default-level level))
838 (gnus-group-setup-buffer)
839 (gnus-update-format-specifications nil 'group 'group-mode)
840 (let ((case-fold-search nil)
841 (props (text-properties-at (gnus-point-at-bol)))
842 (empty (= (point-min) (point-max)))
843 (group (gnus-group-group-name))
845 (set-buffer gnus-group-buffer)
846 (setq number (funcall gnus-group-prepare-function level unread lowest))
847 (when (or (and (numberp number)
849 (zerop (buffer-size)))
850 ;; No groups in the buffer.
851 (gnus-message 5 gnus-no-groups-message))
852 ;; We have some groups displayed.
853 (goto-char (point-max))
854 (when (or (not gnus-group-goto-next-group-function)
855 (not (funcall gnus-group-goto-next-group-function
859 (goto-char (point-min)))
861 ;; Go to the first group with unread articles.
862 (gnus-group-search-forward t))
864 ;; Find the right group to put point on. If the current group
865 ;; has disappeared in the new listing, try to find the next
866 ;; one. If no next one can be found, just leave point at the
867 ;; first newsgroup in the buffer.
868 (when (not (gnus-goto-char
870 (point-min) (point-max)
871 'gnus-group (gnus-intern-safe
872 group gnus-active-hashtb))))
873 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
877 (point-min) (point-max) 'gnus-group
879 (caar newsrc) gnus-active-hashtb)))))
880 (setq newsrc (cdr newsrc)))
882 (goto-char (point-max))
883 (forward-line -1)))))))
884 ;; Adjust cursor point.
885 (gnus-group-position-point)))
887 (defun gnus-group-list-level (level &optional all)
888 "List groups on LEVEL.
889 If ALL (the prefix), also list groups that have no unread articles."
890 (interactive "nList groups on level: \nP")
891 (gnus-group-list-groups level all level))
893 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
894 "List all newsgroups with unread articles of level LEVEL or lower.
895 If ALL is non-nil, list groups that have no unread articles.
896 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
897 If REGEXP, only list groups matching REGEXP."
898 (set-buffer gnus-group-buffer)
899 (let ((buffer-read-only nil)
900 (newsrc (cdr gnus-newsrc-alist))
901 (lowest (or lowest 1))
902 info clevel unread group params)
904 (when (< lowest gnus-level-zombie)
905 ;; List living groups.
907 (setq info (car newsrc)
908 group (gnus-info-group info)
909 params (gnus-info-params info)
911 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
912 (and unread ; This group might be bogus
914 (string-match regexp group))
915 (<= (setq clevel (gnus-info-level info)) level)
917 (or all ; We list all groups?
918 (if (eq unread t) ; Unactivated?
919 gnus-group-list-inactive-groups ; We list unactivated
920 (> unread 0)) ; We list groups with unread articles
921 (and gnus-list-groups-with-ticked-articles
922 (cdr (assq 'tick (gnus-info-marks info))))
923 ; And groups with tickeds
924 ;; Check for permanent visibility.
925 (and gnus-permanently-visible-groups
926 (string-match gnus-permanently-visible-groups
928 (memq 'visible params)
929 (cdr (assq 'visible params)))
930 (gnus-group-insert-group-line
931 group (gnus-info-level info)
932 (gnus-info-marks info) unread (gnus-info-method info)))))
935 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
936 (gnus-group-prepare-flat-list-dead
937 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
940 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
941 (gnus-group-prepare-flat-list-dead
942 (setq gnus-killed-list (sort gnus-killed-list 'string<))
943 gnus-level-killed ?K regexp))
945 (gnus-group-set-mode-line)
946 (setq gnus-group-list-mode (cons level all))
947 (run-hooks 'gnus-group-prepare-hook)
950 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
951 ;; List zombies and killed lists somewhat faster, which was
952 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
953 ;; this by ignoring the group format specification altogether.
956 ;; This loop is used when listing groups that match some
959 (setq group (pop groups))
960 (when (string-match regexp group)
961 (gnus-add-text-properties
962 (point) (prog1 (1+ (point))
963 (insert " " mark " *: " group "\n"))
964 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
966 'gnus-level level))))
967 ;; This loop is used when listing all groups.
969 (gnus-add-text-properties
970 (point) (prog1 (1+ (point))
971 (insert " " mark " *: "
972 (setq group (pop groups)) "\n"))
973 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
975 'gnus-level level))))))
977 (defun gnus-group-update-group-line ()
978 "Update the current line in the group buffer."
979 (let* ((buffer-read-only nil)
980 (group (gnus-group-group-name))
981 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
982 gnus-group-indentation)
985 (not (gnus-ephemeral-group-p group))
987 (concat "(gnus-group-set-info '"
988 (gnus-prin1-to-string (nth 2 entry))
990 (setq gnus-group-indentation (gnus-group-group-indentation))
992 (gnus-group-insert-group-line-info group)
994 (gnus-group-position-point))))
996 (defun gnus-group-insert-group-line-info (group)
997 "Insert GROUP on the current line."
998 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
999 (gnus-group-indentation (gnus-group-group-indentation))
1003 ;; (Un)subscribed group.
1004 (setq info (nth 2 entry))
1005 (gnus-group-insert-group-line
1006 group (gnus-info-level info) (gnus-info-marks info)
1007 (or (car entry) t) (gnus-info-method info)))
1008 ;; This group is dead.
1009 (gnus-group-insert-group-line
1011 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1013 (if (setq active (gnus-active group))
1014 (if (zerop (cdr active))
1016 (- (1+ (cdr active)) (car active)))
1020 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1021 gnus-tmp-marked number
1023 "Insert a group line in the group buffer."
1024 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
1025 (gnus-tmp-number-total
1027 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1029 (gnus-tmp-number-of-unread
1030 (if (numberp number) (int-to-string (max 0 number))
1032 (gnus-tmp-number-of-read
1033 (if (numberp number)
1034 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1036 (gnus-tmp-subscribed
1037 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1038 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1039 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1041 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
1042 (gnus-tmp-newsgroup-description
1043 (if gnus-description-hashtb
1044 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
1047 (if (and gnus-moderated-hashtb
1048 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1050 (gnus-tmp-moderated-string
1051 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1053 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1054 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1055 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1056 (gnus-tmp-news-method-string
1058 (format "(%s:%s)" (car gnus-tmp-method)
1059 (cadr gnus-tmp-method)) ""))
1060 (gnus-tmp-marked-mark
1061 (if (and (numberp number)
1063 (cdr (assq 'tick gnus-tmp-marked)))
1065 (gnus-tmp-process-marked
1066 (if (member gnus-tmp-group gnus-group-marked)
1067 gnus-process-mark ? ))
1069 (or (and gnus-use-grouplens
1070 (bbb-grouplens-group-p gnus-tmp-group))
1072 (buffer-read-only nil)
1073 header gnus-tmp-header) ; passed as parameter to user-funcs.
1075 (gnus-add-text-properties
1079 (eval gnus-group-line-format-spec))
1080 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1081 gnus-unread ,(if (numberp number)
1082 (string-to-int gnus-tmp-number-of-unread)
1084 gnus-marked ,gnus-tmp-marked-mark
1085 gnus-indentation ,gnus-group-indentation
1086 gnus-level ,gnus-tmp-level))
1087 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1089 (run-hooks 'gnus-group-update-hook)
1091 ;; Allow XEmacs to remove front-sticky text properties.
1092 (gnus-group-remove-excess-properties)))
1094 (defun gnus-group-highlight-line ()
1095 "Highlight the current line according to `gnus-group-highlight'."
1096 (let* ((list gnus-group-highlight)
1098 (end (progn (end-of-line) (point)))
1099 ;; now find out where the line starts and leave point there.
1100 (beg (progn (beginning-of-line) (point)))
1101 (group (gnus-group-group-name))
1102 (entry (gnus-group-entry group))
1103 (unread (if (numberp (car entry)) (car entry) 0))
1104 (active (gnus-active group))
1105 (total (if active (1+ (- (cdr active) (car active))) 0))
1106 (info (nth 2 entry))
1107 (method (gnus-server-get-method group (gnus-info-method info)))
1108 (marked (gnus-info-marks info))
1109 (mailp (memq 'mail (assoc (symbol-name
1110 (car (or method gnus-select-method)))
1111 gnus-valid-select-methods)))
1112 (level (or (gnus-info-level info) 9))
1113 (score (or (gnus-info-score info) 0))
1114 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1115 (group-age (gnus-group-timestamp-delta group))
1116 (inhibit-read-only t))
1117 ;; Eval the cars of the lists until we find a match.
1119 (not (eval (caar list))))
1120 (setq list (cdr list)))
1121 (let ((face (cdar list)))
1122 (unless (eq face (get-text-property beg 'face))
1123 (gnus-put-text-property
1125 (setq face (if (boundp face) (symbol-value face) face)))
1126 (gnus-extent-start-open beg)))
1129 (defun gnus-group-update-group (group &optional visible-only)
1130 "Update all lines where GROUP appear.
1131 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1133 ;; Can't use `save-excursion' here, so we do it manually.
1134 (let ((buf (current-buffer))
1136 (set-buffer gnus-group-buffer)
1137 (setq mark (point-marker))
1138 ;; The buffer may be narrowed.
1141 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1143 found buffer-read-only)
1144 ;; Enter the current status into the dribble buffer.
1145 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1146 (when (and entry (not (gnus-ephemeral-group-p group)))
1148 (concat "(gnus-group-set-info '"
1149 (gnus-prin1-to-string (nth 2 entry))
1151 ;; Find all group instances. If topics are in use, each group
1152 ;; may be listed in more than once.
1153 (while (setq loc (text-property-any
1154 loc (point-max) 'gnus-group ident))
1157 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1159 (gnus-group-insert-group-line-info group)
1162 (run-hooks 'gnus-group-update-group-hook)))
1163 (setq loc (1+ loc)))
1164 (unless (or found visible-only)
1165 ;; No such line in the buffer, find out where it's supposed to
1166 ;; go, and insert it there (or at the end of the buffer).
1167 (if gnus-goto-missing-group-function
1168 (funcall gnus-goto-missing-group-function group)
1169 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1170 (while (and entry (car entry)
1174 (point-min) (point-max)
1175 'gnus-group (gnus-intern-safe
1176 (caar entry) gnus-active-hashtb)))))
1177 (setq entry (cdr entry)))
1178 (or entry (goto-char (point-max)))))
1179 ;; Finally insert the line.
1180 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1181 (gnus-group-insert-group-line-info group)
1184 (run-hooks 'gnus-group-update-group-hook))))
1185 (when gnus-group-update-group-function
1186 (funcall gnus-group-update-group-function group))
1187 (gnus-group-set-mode-line)))
1189 (set-marker mark nil)
1192 (defun gnus-group-set-mode-line ()
1193 "Update the mode line in the group buffer."
1194 (when (memq 'group gnus-updated-mode-lines)
1195 ;; Yes, we want to keep this mode line updated.
1197 (set-buffer gnus-group-buffer)
1198 (let* ((gformat (or gnus-group-mode-line-format-spec
1199 (setq gnus-group-mode-line-format-spec
1201 gnus-group-mode-line-format
1202 gnus-group-mode-line-format-alist))))
1203 (gnus-tmp-news-server (cadr gnus-select-method))
1204 (gnus-tmp-news-method (car gnus-select-method))
1205 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1207 gnus-tmp-header ;Dummy binding for user-defined formats
1208 ;; Get the resulting string.
1210 (and gnus-dribble-buffer
1211 (buffer-name gnus-dribble-buffer)
1212 (buffer-modified-p gnus-dribble-buffer)
1214 (set-buffer gnus-dribble-buffer)
1215 (not (zerop (buffer-size))))))
1216 (mode-string (eval gformat)))
1217 ;; Say whether the dribble buffer has been modified.
1218 (setq mode-line-modified
1219 (if modified "--**- " "----- "))
1220 ;; If the line is too long, we chop it off.
1221 (when (> (length mode-string) max-len)
1222 (setq mode-string (substring mode-string 0 (- max-len 4))))
1224 (setq mode-line-buffer-identification
1225 (gnus-mode-line-buffer-identification
1226 (list mode-string)))
1227 (set-buffer-modified-p modified))))))
1229 (defun gnus-group-group-name ()
1230 "Get the name of the newsgroup on the current line."
1231 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1232 (and group (symbol-name group))))
1234 (defun gnus-group-group-level ()
1235 "Get the level of the newsgroup on the current line."
1236 (get-text-property (gnus-point-at-bol) 'gnus-level))
1238 (defun gnus-group-group-indentation ()
1239 "Get the indentation of the newsgroup on the current line."
1240 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1241 (and gnus-group-indentation-function
1242 (funcall gnus-group-indentation-function))
1245 (defun gnus-group-group-unread ()
1246 "Get the number of unread articles of the newsgroup on the current line."
1247 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1249 (defun gnus-group-new-mail (group)
1250 (if (nnmail-new-mail-p (gnus-group-real-name group))
1254 (defun gnus-group-level (group)
1255 "Return the estimated level of GROUP."
1256 (or (gnus-info-level (gnus-get-info group))
1257 (and (member group gnus-zombie-list) 8)
1260 (defun gnus-group-search-forward (&optional backward all level first-too)
1261 "Find the next newsgroup with unread articles.
1262 If BACKWARD is non-nil, find the previous newsgroup instead.
1263 If ALL is non-nil, just find any newsgroup.
1264 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1266 If FIRST-TOO, the current line is also eligible as a target."
1267 (let ((way (if backward -1 1))
1268 (low gnus-level-killed)
1271 (if (and backward (progn (beginning-of-line)) (bobp))
1282 (get-text-property (point) 'gnus-unread)))
1283 (and (numberp unread) (> unread 0)))
1284 (setq lev (get-text-property (point)
1286 (<= lev gnus-level-subscribed)))
1288 (and (setq lev (get-text-property (point)
1297 (zerop (forward-line way)))))
1299 (progn (gnus-group-position-point) t)
1300 (goto-char (or pos beg))
1303 ;;; Gnus group mode commands
1307 (defun gnus-group-mark-group (n &optional unmark no-advance)
1308 "Mark the current group."
1310 (let ((buffer-read-only nil)
1314 (when (setq group (gnus-group-group-name))
1315 ;; Go to the mark position.
1317 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1318 (subst-char-in-region
1319 (point) (1+ (point)) (following-char)
1322 (setq gnus-group-marked (delete group gnus-group-marked))
1324 (setq gnus-group-marked
1325 (cons group (delete group gnus-group-marked)))
1326 gnus-process-mark)))
1328 (gnus-group-next-group 1))
1330 (gnus-summary-position-point)
1333 (defun gnus-group-unmark-group (n)
1334 "Remove the mark from the current group."
1336 (gnus-group-mark-group n 'unmark)
1337 (gnus-group-position-point))
1339 (defun gnus-group-unmark-all-groups ()
1340 "Unmark all groups."
1342 (let ((groups gnus-group-marked))
1345 (gnus-group-remove-mark (pop groups)))))
1346 (gnus-group-position-point))
1348 (defun gnus-group-mark-region (unmark beg end)
1349 "Mark all groups between point and mark.
1350 If UNMARK, remove the mark instead."
1351 (interactive "P\nr")
1352 (let ((num (count-lines beg end)))
1355 (- num (gnus-group-mark-group num unmark)))))
1357 (defun gnus-group-mark-buffer (&optional unmark)
1358 "Mark all groups in the buffer.
1359 If UNMARK, remove the mark instead."
1361 (gnus-group-mark-region unmark (point-min) (point-max)))
1363 (defun gnus-group-mark-regexp (regexp)
1364 "Mark all groups that match some regexp."
1365 (interactive "sMark (regexp): ")
1366 (let ((alist (cdr gnus-newsrc-alist))
1369 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1370 (gnus-group-set-mark group))))
1371 (gnus-group-position-point))
1373 (defun gnus-group-remove-mark (group)
1374 "Remove the process mark from GROUP and move point there.
1375 Return nil if the group isn't displayed."
1376 (if (gnus-group-goto-group group)
1378 (gnus-group-mark-group 1 'unmark t)
1380 (setq gnus-group-marked
1381 (delete group gnus-group-marked))
1384 (defun gnus-group-set-mark (group)
1385 "Set the process mark on GROUP."
1386 (if (gnus-group-goto-group group)
1388 (gnus-group-mark-group 1 nil t))
1389 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1391 (defun gnus-group-universal-argument (arg &optional groups func)
1392 "Perform any command on all groups according to the process/prefix convention."
1394 (if (eq (setq func (or func
1397 (substitute-command-keys
1398 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1400 (gnus-error 1 "Undefined key")
1401 (gnus-group-iterate arg
1403 (command-execute func))))
1404 (gnus-group-position-point))
1406 (defun gnus-group-process-prefix (n)
1407 "Return a list of groups to work on.
1408 Take into consideration N (the prefix) and the list of marked groups."
1411 (setq n (prefix-numeric-value n))
1412 ;; There is a prefix, so we return a list of the N next
1414 (let ((way (if (< n 0) -1 1))
1419 (setq group (gnus-group-group-name)))
1422 (gnus-group-next-group way)))
1424 ((gnus-region-active-p)
1425 ;; Work on the region between point and mark.
1426 (let ((max (max (point) (mark)))
1429 (goto-char (min (point) (mark)))
1432 (push (gnus-group-group-name) groups)
1433 (zerop (gnus-group-next-group 1))
1435 (nreverse groups))))
1437 ;; No prefix, but a list of marked articles.
1438 (reverse gnus-group-marked))
1440 ;; Neither marked articles or a prefix, so we return the
1442 (let ((group (gnus-group-group-name)))
1443 (and group (list group))))))
1445 (defun gnus-group-iterate (arg function)
1446 "Iterate FUNCTION over all process/prefixed groups.
1447 FUNCTION will be called with the group name as the paremeter
1448 and with point over the group in question."
1449 (let ((groups (gnus-group-process-prefix arg))
1451 (while (setq group (pop groups))
1452 (gnus-group-remove-mark group)
1453 (funcall function group))))
1455 (put 'gnus-group-iterate 'lisp-indent-function 1)
1457 ;; Selecting groups.
1459 (defun gnus-group-read-group (&optional all no-article group)
1460 "Read news in this newsgroup.
1461 If the prefix argument ALL is non-nil, already read articles become
1462 readable. IF ALL is a number, fetch this number of articles. If the
1463 optional argument NO-ARTICLE is non-nil, no article will be
1464 auto-selected upon group entry. If GROUP is non-nil, fetch that
1467 (let ((no-display (eq all 0))
1468 (group (or group (gnus-group-group-name)))
1469 number active marked entry)
1473 (error "No group on current line"))
1474 (setq marked (gnus-info-marks
1475 (nth 2 (setq entry (gnus-gethash
1476 group gnus-newsrc-hashtb)))))
1477 ;; This group might be a dead group. In that case we have to get
1478 ;; the number of unread articles from `gnus-active-hashtb'.
1480 (cond ((numberp all) all)
1482 ((setq active (gnus-active group))
1483 (- (1+ (cdr active)) (car active)))))
1484 (gnus-summary-read-group
1485 group (or all (and (numberp number)
1486 (zerop (+ number (gnus-range-length
1487 (cdr (assq 'tick marked)))
1489 (cdr (assq 'dormant marked)))))))
1490 no-article nil no-display)))
1492 (defun gnus-group-select-group (&optional all)
1493 "Select this newsgroup.
1494 No article is selected automatically.
1495 If ALL is non-nil, already read articles become readable.
1496 If ALL is a number, fetch this number of articles."
1498 (gnus-group-read-group all t))
1500 (defun gnus-group-quick-select-group (&optional all)
1501 "Select the current group \"quickly\".
1502 This means that no highlighting or scoring will be performed.
1503 If ALL (the prefix argument) is 0, don't even generate the summary
1506 (require 'gnus-score)
1508 gnus-score-find-score-files-function
1509 gnus-home-score-file
1510 gnus-apply-kill-hook
1511 gnus-summary-expunge-below)
1512 (gnus-group-read-group all t)))
1514 (defun gnus-group-visible-select-group (&optional all)
1515 "Select the current group without hiding any articles."
1517 (let ((gnus-inhibit-limiting t))
1518 (gnus-group-read-group all t)))
1520 (defun gnus-group-select-group-ephemerally ()
1521 "Select the current group without doing any processing whatsoever.
1522 You will actually be entered into a group that's a copy of
1523 the current group; no changes you make while in this group will
1526 (require 'gnus-score)
1528 gnus-score-find-score-files-function gnus-apply-kill-hook
1529 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1530 gnus-summary-mode-hook gnus-select-group-hook
1531 (group (gnus-group-group-name))
1532 (method (gnus-find-method-for-group group)))
1534 `(,(car method) ,(concat (cadr method) "-ephemeral")
1535 (,(intern (format "%s-address" (car method))) ,(cadr method))
1537 (gnus-group-read-ephemeral-group
1538 (gnus-group-prefixed-name group method) method)))
1541 (defun gnus-fetch-group (group)
1542 "Start Gnus if necessary and enter GROUP.
1543 Returns whether the fetching was successful or not."
1544 (interactive "sGroup name: ")
1545 (unless (get-buffer gnus-group-buffer)
1547 (gnus-group-read-group nil nil group))
1549 (defvar gnus-ephemeral-group-server 0)
1551 ;; Enter a group that is not in the group buffer. Non-nil is returned
1552 ;; if selection was successful.
1553 (defun gnus-group-read-ephemeral-group (group method &optional activate
1554 quit-config request-only)
1555 "Read GROUP from METHOD as an ephemeral group.
1556 If ACTIVATE, request the group first.
1557 If QUIT-CONFIG, use that window configuration when exiting from the
1559 If REQUEST-ONLY, don't actually read the group; just request it.
1561 Return the name of the group is selection was successful."
1562 ;; Transform the select method into a unique server.
1563 (let ((saddr (intern (format "%s-address" (car method)))))
1564 (setq method (gnus-copy-sequence method))
1565 (require (car method))
1566 (when (boundp saddr)
1567 (unless (assq saddr method)
1568 (nconc method `((,saddr ,(cadr method))))
1569 (setf (cadr method) (format "%s-%d" (cadr method)
1570 (incf gnus-ephemeral-group-server))))))
1571 (let ((group (if (gnus-group-foreign-p group) group
1572 (gnus-group-prefixed-name group method))))
1576 ,gnus-level-default-subscribed nil nil ,method
1578 ,(if quit-config quit-config
1579 (cons gnus-summary-buffer
1580 gnus-current-window-configuration))))))
1582 (set-buffer gnus-group-buffer)
1583 (unless (gnus-check-server method)
1584 (error "Unable to contact server: %s" (gnus-status-message method)))
1586 (gnus-activate-group group 'scan)
1587 (unless (gnus-request-group group)
1588 (error "Couldn't request group: %s"
1589 (nnheader-get-report (car method)))))
1593 (when (gnus-group-read-group t t group)
1598 (defun gnus-group-jump-to-group (group)
1599 "Jump to newsgroup GROUP."
1601 (list (completing-read
1602 "Group: " gnus-active-hashtb nil
1603 (gnus-read-active-file-p)
1605 'gnus-group-history)))
1607 (when (equal group "")
1608 (error "Empty group name"))
1610 (unless (gnus-ephemeral-group-p group)
1611 ;; Either go to the line in the group buffer...
1612 (unless (gnus-group-goto-group group)
1613 ;; ... or insert the line.
1614 (gnus-group-update-group group)
1615 (gnus-group-goto-group group)))
1616 ;; Adjust cursor point.
1617 (gnus-group-position-point))
1619 (defun gnus-group-goto-group (group &optional far)
1620 "Goto to newsgroup GROUP.
1621 If FAR, it is likely that the group is not on the current line."
1626 (point-min) (point-max)
1627 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
1630 ;; It's quite likely that we are on the right line, so
1631 ;; we check the current line first.
1632 ((eq (get-text-property (point) 'gnus-group)
1633 (gnus-intern-safe group gnus-active-hashtb))
1635 ;; Previous and next line are also likely, so we check them as well.
1638 (eq (get-text-property (point) 'gnus-group)
1639 (gnus-intern-safe group gnus-active-hashtb)))
1644 (eq (get-text-property (point) 'gnus-group)
1645 (gnus-intern-safe group gnus-active-hashtb)))
1649 ;; Search through the entire buffer.
1652 (point-min) (point-max)
1653 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))))
1655 (defun gnus-group-next-group (n &optional silent)
1656 "Go to next N'th newsgroup.
1657 If N is negative, search backward instead.
1658 Returns the difference between N and the number of skips actually
1661 (gnus-group-next-unread-group n t nil silent))
1663 (defun gnus-group-next-unread-group (n &optional all level silent)
1664 "Go to next N'th unread newsgroup.
1665 If N is negative, search backward instead.
1666 If ALL is non-nil, choose any newsgroup, unread or not.
1667 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
1668 such group can be found, the next group with a level higher than
1670 Returns the difference between N and the number of skips actually
1673 (let ((backward (< n 0))
1676 (gnus-group-search-forward
1677 backward (or (not gnus-group-goto-unread) all) level))
1681 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
1682 (if level " on this level or higher" "")))
1685 (defun gnus-group-prev-group (n)
1686 "Go to previous N'th newsgroup.
1687 Returns the difference between N and the number of skips actually
1690 (gnus-group-next-unread-group (- n) t))
1692 (defun gnus-group-prev-unread-group (n)
1693 "Go to previous N'th unread newsgroup.
1694 Returns the difference between N and the number of skips actually
1697 (gnus-group-next-unread-group (- n)))
1699 (defun gnus-group-next-unread-group-same-level (n)
1700 "Go to next N'th unread newsgroup on the same level.
1701 If N is negative, search backward instead.
1702 Returns the difference between N and the number of skips actually
1705 (gnus-group-next-unread-group n t (gnus-group-group-level))
1706 (gnus-group-position-point))
1708 (defun gnus-group-prev-unread-group-same-level (n)
1709 "Go to next N'th unread newsgroup on the same level.
1710 Returns the difference between N and the number of skips actually
1713 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
1714 (gnus-group-position-point))
1716 (defun gnus-group-best-unread-group (&optional exclude-group)
1717 "Go to the group with the highest level.
1718 If EXCLUDE-GROUP, do not go to that group."
1720 (goto-char (point-min))
1724 (setq unread (get-text-property (point) 'gnus-unread))
1725 (when (and (numberp unread) (> unread 0))
1726 (when (and (get-text-property (point) 'gnus-level)
1727 (< (get-text-property (point) 'gnus-level) best)
1728 (or (not exclude-group)
1729 (not (equal exclude-group (gnus-group-group-name)))))
1730 (setq best (get-text-property (point) 'gnus-level))
1731 (setq best-point (point))))
1734 (goto-char best-point))
1735 (gnus-summary-position-point)
1736 (and best-point (gnus-group-group-name))))
1738 (defun gnus-group-first-unread-group ()
1739 "Go to the first group with unread articles."
1742 (let ((opoint (point))
1744 (goto-char (point-min))
1745 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
1746 (and (numberp unread) ; Not a topic.
1747 (not (zerop unread))) ; Has unread articles.
1748 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
1751 nil)) ; Not success.
1752 (gnus-group-position-point)))
1754 (defun gnus-group-enter-server-mode ()
1755 "Jump to the server buffer."
1757 (gnus-enter-server-buffer))
1759 (defun gnus-group-make-group (name &optional method address args)
1760 "Add a new newsgroup.
1761 The user will be prompted for a NAME, for a select METHOD, and an
1765 (gnus-read-group "Group name: ")
1766 (gnus-read-method "From method: ")))
1768 (let* ((meth (when (and method
1769 (not (gnus-server-equal method gnus-select-method)))
1770 (if address (list (intern method) address)
1772 (nname (if method (gnus-group-prefixed-name name meth) name))
1774 (when (gnus-gethash nname gnus-newsrc-hashtb)
1775 (error "Group %s already exists" nname))
1776 ;; Subscribe to the new group.
1777 (gnus-group-change-level
1778 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
1779 gnus-level-default-subscribed gnus-level-killed
1780 (and (gnus-group-group-name)
1781 (gnus-gethash (gnus-group-group-name)
1782 gnus-newsrc-hashtb))
1785 (gnus-set-active nname (cons 1 0))
1786 (unless (gnus-ephemeral-group-p name)
1788 (concat "(gnus-group-set-info '"
1789 (gnus-prin1-to-string (cdr info)) ")")))
1791 (gnus-group-insert-group-line-info nname)
1793 (gnus-group-position-point)
1795 ;; Load the backend and try to make the backend create
1796 ;; the group as well.
1797 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
1799 gnus-valid-select-methods)
1801 (gnus-check-server meth)
1802 (when (gnus-check-backend-function 'request-create-group nname)
1803 (gnus-request-create-group nname nil args))
1806 (defun gnus-group-delete-group (group &optional force)
1807 "Delete the current group. Only meaningful with mail groups.
1808 If FORCE (the prefix) is non-nil, all the articles in the group will
1809 be deleted. This is \"deleted\" as in \"removed forever from the face
1810 of the Earth\". There is no undo. The user will be prompted before
1811 doing the deletion."
1813 (list (gnus-group-group-name)
1814 current-prefix-arg))
1816 (error "No group to rename"))
1817 (unless (gnus-check-backend-function 'request-delete-group group)
1818 (error "This backend does not support group deletion"))
1820 (if (not (gnus-yes-or-no-p
1822 "Do you really want to delete %s%s? "
1823 group (if force " and all its contents" ""))))
1825 (gnus-message 6 "Deleting group %s..." group)
1826 (if (not (gnus-request-delete-group group force))
1827 (gnus-error 3 "Couldn't delete group %s" group)
1828 (gnus-message 6 "Deleting group %s...done" group)
1829 (gnus-group-goto-group group)
1830 (gnus-group-kill-group 1 t)
1831 (gnus-sethash group nil gnus-active-hashtb)
1833 (gnus-group-position-point)))
1835 (defun gnus-group-rename-group (group new-name)
1836 "Rename group from GROUP to NEW-NAME.
1837 When used interactively, GROUP is the group under point
1838 and NEW-NAME will be prompted for."
1841 (gnus-group-group-name)
1843 (unless (gnus-check-backend-function
1844 'request-rename-group (gnus-group-group-name))
1845 (error "This backend does not support renaming groups"))
1846 (gnus-read-group "Rename group to: "
1847 (gnus-group-real-name (gnus-group-group-name))))))
1849 (unless (gnus-check-backend-function 'request-rename-group group)
1850 (error "This backend does not support renaming groups"))
1852 (error "No group to rename"))
1853 (when (equal (gnus-group-real-name group) new-name)
1854 (error "Can't rename to the same name"))
1856 ;; We find the proper prefixed name.
1858 (if (gnus-group-native-p group)
1862 (gnus-group-prefixed-name
1863 (gnus-group-real-name new-name)
1864 (gnus-info-method (gnus-get-info group)))))
1866 (gnus-message 6 "Renaming group %s to %s..." group new-name)
1868 (if (not (gnus-request-rename-group group new-name))
1869 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
1870 ;; We rename the group internally by killing it...
1871 (gnus-group-goto-group group)
1872 (gnus-group-kill-group)
1873 ;; ... changing its name ...
1874 (setcar (cdar gnus-list-of-killed-groups) new-name)
1875 ;; ... and then yanking it. Magic!
1876 (gnus-group-yank-group)
1877 (gnus-set-active new-name (gnus-active group))
1878 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
1880 (gnus-group-position-point)))
1882 (defun gnus-group-edit-group (group &optional part)
1883 "Edit the group on the current line."
1884 (interactive (list (gnus-group-group-name)))
1885 (let ((part (or part 'info))
1888 (error "No group on current line"))
1889 (unless (setq info (gnus-get-info group))
1890 (error "Killed group; can't be edited"))
1892 (gnus-close-group group))
1894 ;; Find the proper form to edit.
1895 (cond ((eq part 'method)
1896 (or (gnus-info-method info) "native"))
1898 (gnus-info-params info))
1900 ;; The proper documentation.
1902 "Editing the %s for `%s'."
1904 ((eq part 'method) "select method")
1905 ((eq part 'params) "group parameters")
1909 (gnus-group-edit-group-done ',part ,group form)))))
1911 (defun gnus-group-edit-group-method (group)
1912 "Edit the select method of GROUP."
1913 (interactive (list (gnus-group-group-name)))
1914 (gnus-group-edit-group group 'method))
1916 (defun gnus-group-edit-group-parameters (group)
1917 "Edit the group parameters of GROUP."
1918 (interactive (list (gnus-group-group-name)))
1919 (gnus-group-edit-group group 'params))
1921 (defun gnus-group-edit-group-done (part group form)
1923 (let* ((method (cond ((eq part 'info) (nth 4 form))
1924 ((eq part 'method) form)
1926 (info (cond ((eq part 'info) form)
1927 ((eq part 'method) (gnus-get-info group))
1930 (if (or (not method)
1932 gnus-select-method method))
1933 (gnus-group-real-name (car info))
1934 (gnus-group-prefixed-name
1935 (gnus-group-real-name (car info)) method))
1937 (when (and new-group
1938 (not (equal new-group group)))
1939 (when (gnus-group-goto-group group)
1940 (gnus-group-kill-group 1))
1941 (gnus-activate-group new-group))
1943 (if (not (and info new-group))
1944 (gnus-group-set-info form (or new-group group) part)
1945 (setq info (gnus-copy-sequence info))
1946 (setcar info new-group)
1947 (unless (gnus-server-equal method "native")
1948 (unless (nthcdr 3 info)
1949 (nconc info (list nil nil)))
1950 (unless (nthcdr 4 info)
1951 (nconc info (list nil)))
1952 (gnus-info-set-method info method))
1953 (gnus-group-set-info info))
1954 (gnus-group-update-group (or new-group group))
1955 (gnus-group-position-point)))
1957 (defun gnus-group-make-useful-group (group method)
1959 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
1961 gnus-useful-groups)))
1962 (list (cadr entry) (caddr entry))))
1963 (setq method (gnus-copy-sequence method))
1965 (while (setq entry (memq (assq 'eval method) method))
1966 (setcar entry (eval (cadar entry)))))
1967 (gnus-group-make-group group method))
1969 (defun gnus-group-make-help-group ()
1970 "Create the Gnus documentation group."
1972 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
1973 (file (nnheader-find-etc-directory "gnus-tut.txt" t))
1975 (when (gnus-gethash name gnus-newsrc-hashtb)
1976 (error "Documentation group already exists"))
1978 (gnus-message 1 "Couldn't find doc group")
1979 (gnus-group-make-group
1980 (gnus-group-real-name name)
1981 (list 'nndoc "gnus-help"
1982 (list 'nndoc-address file)
1983 (list 'nndoc-article-type 'mbox)))))
1984 (gnus-group-position-point))
1986 (defun gnus-group-make-doc-group (file type)
1987 "Create a group that uses a single file as the source."
1989 (list (read-file-name "File name: ")
1990 (and current-prefix-arg 'ask)))
1991 (when (eq type 'ask)
1996 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: "
1998 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
1999 ((= char ?b) 'babyl)
2000 ((= char ?d) 'digest)
2001 ((= char ?f) 'forward)
2003 (t (setq err (format "%c unknown. " char))
2006 (let* ((file (expand-file-name file))
2007 (name (gnus-generate-new-group-name
2008 (gnus-group-prefixed-name
2009 (file-name-nondirectory file) '(nndoc "")))))
2010 (gnus-group-make-group
2011 (gnus-group-real-name name)
2013 (list 'nndoc-address file)
2014 (list 'nndoc-article-type (or type 'guess))))))
2016 (defvar nnweb-type-definition)
2017 (defvar gnus-group-web-type-history nil)
2018 (defvar gnus-group-web-search-history nil)
2019 (defun gnus-group-make-web-group (&optional solid)
2020 "Create an ephemeral nnweb group.
2021 If SOLID (the prefix), create a solid group."
2025 (if solid (gnus-read-group "Group name: ")
2026 (message-unique-id)))
2029 "Search engine type: "
2030 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2031 nnweb-type-definition)
2032 nil t (cons (or (car gnus-group-web-type-history)
2033 (symbol-name (caar nnweb-type-definition)))
2035 'gnus-group-web-type-history))
2039 (cons (or (car gnus-group-web-search-history) "") 0)
2040 'gnus-group-web-search-history))
2042 `(nnweb ,group (nnweb-search ,search)
2043 (nnweb-type ,(intern type))
2044 (nnweb-ephemeral-p t))))
2046 (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search))
2047 (gnus-group-read-ephemeral-group
2049 (cons (current-buffer)
2050 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2052 (defun gnus-group-make-archive-group (&optional all)
2053 "Create the (ding) Gnus archive group of the most recent articles.
2054 Given a prefix, create a full group."
2056 (let ((group (gnus-group-prefixed-name
2057 (if all "ding.archives" "ding.recent") '(nndir ""))))
2058 (when (gnus-gethash group gnus-newsrc-hashtb)
2059 (error "Archive group already exists"))
2060 (gnus-group-make-group
2061 (gnus-group-real-name group)
2062 (list 'nndir (if all "hpc" "edu")
2063 (list 'nndir-directory
2064 (if all gnus-group-archive-directory
2065 gnus-group-recent-archive-directory))))
2066 (gnus-group-add-parameter group (cons 'to-address "ding@ifi.uio.no"))))
2068 (defun gnus-group-make-directory-group (dir)
2069 "Create an nndir group.
2070 The user will be prompted for a directory. The contents of this
2071 directory will be used as a newsgroup. The directory should contain
2072 mail messages or news articles in files that have numeric names."
2074 (list (read-file-name "Create group from directory: ")))
2075 (unless (file-exists-p dir)
2076 (error "No such directory"))
2077 (unless (file-directory-p dir)
2078 (error "Not a directory"))
2082 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2084 (gnus-group-prefixed-name
2085 (concat (file-name-as-directory (directory-file-name dir))
2088 (setq ext (format "<%d>" (setq i (1+ i)))))
2089 (gnus-group-make-group
2090 (gnus-group-real-name group)
2091 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2093 (defun gnus-group-make-kiboze-group (group address scores)
2094 "Create an nnkiboze group.
2095 The user will be prompted for a name, a regexp to match groups, and
2096 score file entries for articles to include in the group."
2099 (read-string "nnkiboze group name: ")
2100 (read-string "Source groups (regexp): ")
2101 (let ((headers (mapcar (lambda (group) (list group))
2102 '("subject" "from" "number" "date" "message-id"
2103 "references" "chars" "lines" "xref"
2104 "followup" "all" "body" "head")))
2105 scores header regexp regexps)
2106 (while (not (equal "" (setq header (completing-read
2107 "Match on header: " headers nil t))))
2109 (while (not (equal "" (setq regexp (read-string
2110 (format "Match on %s (string): "
2112 (push (list regexp nil nil 'r) regexps))
2113 (push (cons header regexps) scores))
2115 (gnus-group-make-group group "nnkiboze" address)
2116 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
2117 (let (emacs-lisp-mode-hook)
2118 (pp scores (current-buffer)))))
2120 (defun gnus-group-add-to-virtual (n vgroup)
2121 "Add the current group to a virtual group."
2123 (list current-prefix-arg
2124 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2126 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2127 (error "%s is not an nnvirtual group" vgroup))
2128 (gnus-close-group vgroup)
2129 (let* ((groups (gnus-group-process-prefix n))
2130 (method (gnus-info-method (gnus-get-info vgroup))))
2131 (setcar (cdr method)
2133 (nth 1 method) "\\|"
2136 (gnus-group-remove-mark s)
2137 (concat "\\(^" (regexp-quote s) "$\\)"))
2139 (gnus-group-position-point))
2141 (defun gnus-group-make-empty-virtual (group)
2142 "Create a new, fresh, empty virtual group."
2143 (interactive "sCreate new, empty virtual group: ")
2144 (let* ((method (list 'nnvirtual "^$"))
2145 (pgroup (gnus-group-prefixed-name group method)))
2146 ;; Check whether it exists already.
2147 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2148 (error "Group %s already exists." pgroup))
2149 ;; Subscribe the new group after the group on the current line.
2150 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2151 (gnus-group-update-group pgroup)
2153 (gnus-group-position-point)))
2155 (defun gnus-group-enter-directory (dir)
2156 "Enter an ephemeral nneething group."
2157 (interactive "DDirectory to read: ")
2158 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2159 (leaf (gnus-group-prefixed-name
2160 (file-name-nondirectory (directory-file-name dir))
2162 (name (gnus-generate-new-group-name leaf)))
2163 (unless (gnus-group-read-ephemeral-group
2165 (cons (current-buffer)
2166 (if (eq major-mode 'gnus-summary-mode)
2168 (error "Couldn't enter %s" dir))))
2170 ;; Group sorting commands
2171 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2173 (defun gnus-group-sort-groups (func &optional reverse)
2174 "Sort the group buffer according to FUNC.
2175 When used interactively, the sorting function used will be
2176 determined by the `gnus-group-sort-function' variable.
2177 If REVERSE (the prefix), reverse the sorting order."
2178 (interactive (list gnus-group-sort-function current-prefix-arg))
2179 (funcall gnus-group-sort-alist-function
2180 (gnus-make-sort-function func) reverse)
2181 (gnus-group-list-groups))
2183 (defun gnus-group-sort-flat (func reverse)
2184 ;; We peel off the dummy group from the alist.
2186 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
2187 (pop gnus-newsrc-alist))
2189 (setq gnus-newsrc-alist
2190 (sort gnus-newsrc-alist func))
2192 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2193 ;; Regenerate the hash table.
2194 (gnus-make-hashtable-from-newsrc-alist)))
2196 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2197 "Sort the group buffer alphabetically by group name.
2198 If REVERSE, sort in reverse order."
2200 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2202 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2203 "Sort the group buffer by number of unread articles.
2204 If REVERSE, sort in reverse order."
2206 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2208 (defun gnus-group-sort-groups-by-level (&optional reverse)
2209 "Sort the group buffer by group level.
2210 If REVERSE, sort in reverse order."
2212 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2214 (defun gnus-group-sort-groups-by-score (&optional reverse)
2215 "Sort the group buffer by group score.
2216 If REVERSE, sort in reverse order."
2218 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2220 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2221 "Sort the group buffer by group rank.
2222 If REVERSE, sort in reverse order."
2224 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2226 (defun gnus-group-sort-groups-by-method (&optional reverse)
2227 "Sort the group buffer alphabetically by backend name.
2228 If REVERSE, sort in reverse order."
2230 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2232 ;;; Selected group sorting.
2234 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2235 "Sort the process/prefixed groups."
2236 (interactive (list current-prefix-arg gnus-group-sort-function))
2237 (let ((groups (gnus-group-process-prefix n)))
2238 (funcall gnus-group-sort-selected-function
2239 groups (gnus-make-sort-function func) reverse)
2240 (gnus-group-list-groups)))
2242 (defun gnus-group-sort-selected-flat (groups func reverse)
2243 (let (entries infos)
2244 ;; First find all the group entries for these groups.
2246 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
2248 ;; Then sort the infos.
2252 (lambda (entry) (car entry))
2253 (setq entries (nreverse entries)))
2256 (setq infos (nreverse infos)))
2257 ;; Go through all the infos and replace the old entries
2258 ;; with the new infos.
2260 (setcar entries (pop infos))
2262 ;; Update the hashtable.
2263 (gnus-make-hashtable-from-newsrc-alist)))
2265 (defun gnus-group-sort-selected-groups-by-alphabet (&optional reverse)
2266 "Sort the group buffer alphabetically by group name.
2267 If REVERSE, sort in reverse order."
2269 (gnus-group-sort-selected-groups 'gnus-group-sort-by-alphabet reverse))
2271 (defun gnus-group-sort-selected-groups-by-unread (&optional reverse)
2272 "Sort the group buffer by number of unread articles.
2273 If REVERSE, sort in reverse order."
2275 (gnus-group-sort-selected-groups 'gnus-group-sort-by-unread reverse))
2277 (defun gnus-group-sort-selected-groups-by-level (&optional reverse)
2278 "Sort the group buffer by group level.
2279 If REVERSE, sort in reverse order."
2281 (gnus-group-sort-selected-groups 'gnus-group-sort-by-level reverse))
2283 (defun gnus-group-sort-selected-groups-by-score (&optional reverse)
2284 "Sort the group buffer by group score.
2285 If REVERSE, sort in reverse order."
2287 (gnus-group-sort-selected-groups 'gnus-group-sort-by-score reverse))
2289 (defun gnus-group-sort-selected-groups-by-rank (&optional reverse)
2290 "Sort the group buffer by group rank.
2291 If REVERSE, sort in reverse order."
2293 (gnus-group-sort-selected-groups 'gnus-group-sort-by-rank reverse))
2295 (defun gnus-group-sort-selected-groups-by-method (&optional reverse)
2296 "Sort the group buffer alphabetically by backend name.
2297 If REVERSE, sort in reverse order."
2299 (gnus-group-sort-selected-groups 'gnus-group-sort-by-method reverse))
2301 ;;; Sorting predicates.
2303 (defun gnus-group-sort-by-alphabet (info1 info2)
2304 "Sort alphabetically."
2305 (string< (gnus-info-group info1) (gnus-info-group info2)))
2307 (defun gnus-group-sort-by-real-name (info1 info2)
2308 "Sort alphabetically on real (unprefixed) names."
2309 (string< (gnus-group-real-name (gnus-info-group info1))
2310 (gnus-group-real-name (gnus-info-group info2))))
2312 (defun gnus-group-sort-by-unread (info1 info2)
2313 "Sort by number of unread articles."
2314 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
2315 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
2316 (< (or (and (numberp n1) n1) 0)
2317 (or (and (numberp n2) n2) 0))))
2319 (defun gnus-group-sort-by-level (info1 info2)
2321 (< (gnus-info-level info1) (gnus-info-level info2)))
2323 (defun gnus-group-sort-by-method (info1 info2)
2324 "Sort alphabetically by backend name."
2325 (string< (symbol-name (car (gnus-find-method-for-group
2326 (gnus-info-group info1) info1)))
2327 (symbol-name (car (gnus-find-method-for-group
2328 (gnus-info-group info2) info2)))))
2330 (defun gnus-group-sort-by-score (info1 info2)
2331 "Sort by group score."
2332 (< (gnus-info-score info1) (gnus-info-score info2)))
2334 (defun gnus-group-sort-by-rank (info1 info2)
2335 "Sort by level and score."
2336 (let ((level1 (gnus-info-level info1))
2337 (level2 (gnus-info-level info2)))
2338 (or (< level1 level2)
2339 (and (= level1 level2)
2340 (> (gnus-info-score info1) (gnus-info-score info2))))))
2344 (defun gnus-group-clear-data (&optional arg)
2345 "Clear all marks and read ranges from the current group."
2347 (gnus-group-iterate arg
2350 (gnus-info-clear-data (setq info (gnus-get-info group)))
2351 (gnus-get-unread-articles-in-group info (gnus-active group) t)
2352 (when (gnus-group-goto-group group)
2353 (gnus-group-update-group-line))))))
2355 (defun gnus-group-clear-data-on-native-groups ()
2356 "Clear all marks and read ranges from all native groups."
2358 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
2359 (let ((alist (cdr gnus-newsrc-alist))
2361 (while (setq info (pop alist))
2362 (when (gnus-group-native-p (gnus-info-group info))
2363 (gnus-info-clear-data info)))
2364 (gnus-get-unread-articles)
2365 (gnus-dribble-enter "")
2366 (when (gnus-y-or-n-p
2367 "Move the cache away to avoid problems in the future? ")
2368 (call-interactively 'gnus-cache-move-cache)))))
2370 (defun gnus-info-clear-data (info)
2371 "Clear all marks and read ranges from INFO."
2372 (let ((group (gnus-info-group info)))
2375 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
2376 (gnus-info-set-read ',info ',(gnus-info-read info))
2377 (when (gnus-group-goto-group ,group)
2378 (gnus-group-update-group-line))))
2379 (gnus-info-set-read info nil)
2380 (when (gnus-info-marks info)
2381 (gnus-info-set-marks info nil))))
2383 ;; Group catching up.
2385 (defun gnus-group-catchup-current (&optional n all)
2386 "Mark all articles not marked as unread in current newsgroup as read.
2387 If prefix argument N is numeric, the ARG next newsgroups will be
2388 caught up. If ALL is non-nil, marked articles will also be marked as
2389 read. Cross references (Xref: header) of articles are ignored.
2390 The difference between N and actual number of newsgroups that were
2391 caught up is returned."
2393 (unless (gnus-group-group-name)
2394 (error "No group on the current line"))
2395 (let ((groups (gnus-group-process-prefix n))
2398 (or (not gnus-interactive-catchup) ;Without confirmation?
2403 "Do you really want to mark all articles in %s as read? "
2404 "Mark all unread articles in %s as read? ")
2405 (if (= (length groups) 1)
2407 (format "these %d groups" (length groups)))))))
2410 ;; Virtual groups have to be given special treatment.
2411 (let ((method (gnus-find-method-for-group (car groups))))
2412 (when (eq 'nnvirtual (car method))
2413 (nnvirtual-catchup-group
2414 (gnus-group-real-name (car groups)) (nth 1 method) all)))
2415 (gnus-group-remove-mark (car groups))
2416 (if (>= (gnus-group-group-level) gnus-level-zombie)
2417 (gnus-message 2 "Dead groups can't be caught up")
2419 (gnus-group-goto-group (car groups))
2420 (gnus-group-catchup (car groups) all))
2421 (gnus-group-update-group-line)
2422 (setq ret (1+ ret))))
2423 (setq groups (cdr groups)))
2424 (gnus-group-next-unread-group 1)
2427 (defun gnus-group-catchup-current-all (&optional n)
2428 "Mark all articles in current newsgroup as read.
2429 Cross references (Xref: header) of articles are ignored."
2431 (gnus-group-catchup-current n 'all))
2433 (defun gnus-group-catchup (group &optional all)
2434 "Mark all articles in GROUP as read.
2435 If ALL is non-nil, all articles are marked as read.
2436 The return value is the number of articles that were marked as read,
2437 or nil if no action could be taken."
2438 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
2440 ;; Do the updating only if the newsgroup isn't killed.
2441 (if (not (numberp (car entry)))
2442 (gnus-message 1 "Can't catch up %s; non-active group" group)
2443 ;; Do auto-expirable marks if that's required.
2444 (when (gnus-group-auto-expirable-p group)
2445 (gnus-add-marked-articles
2446 group 'expire (gnus-list-of-unread-articles group))
2448 (let ((marks (nth 3 (nth 2 entry))))
2449 (gnus-add-marked-articles
2450 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
2451 (gnus-add-marked-articles
2452 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
2454 (gnus-update-read-articles group nil)
2455 ;; Also nix out the lists of marks and dormants.
2457 (gnus-add-marked-articles group 'tick nil nil 'force)
2458 (gnus-add-marked-articles group 'dormant nil nil 'force))
2459 (let ((gnus-newsgroup-name group))
2460 (run-hooks 'gnus-group-catchup-group-hook))
2463 (defun gnus-group-expire-articles (&optional n)
2464 "Expire all expirable articles in the current newsgroup."
2466 (let ((groups (gnus-group-process-prefix n))
2469 (error "No groups to expire"))
2470 (while (setq group (pop groups))
2471 (gnus-group-remove-mark group)
2472 (when (gnus-check-backend-function 'request-expire-articles group)
2473 (gnus-message 6 "Expiring articles in %s..." group)
2474 (let* ((info (gnus-get-info group))
2475 (expirable (if (gnus-group-total-expirable-p group)
2476 (cons nil (gnus-list-of-read-articles group))
2477 (assq 'expire (gnus-info-marks info))))
2478 (expiry-wait (gnus-group-find-parameter group 'expiry-wait)))
2482 (gnus-compress-sequence
2484 ;; We set the expiry variables to the group
2486 (let ((nnmail-expiry-wait-function nil)
2487 (nnmail-expiry-wait expiry-wait))
2488 (gnus-request-expire-articles
2489 (gnus-uncompress-sequence (cdr expirable)) group))
2490 ;; Just expire using the normal expiry values.
2491 (gnus-request-expire-articles
2492 (gnus-uncompress-sequence (cdr expirable)) group))))
2493 (gnus-close-group group))
2494 (gnus-message 6 "Expiring articles in %s...done" group)))
2495 (gnus-dribble-touch)
2496 (gnus-group-position-point))))
2498 (defun gnus-group-expire-all-groups ()
2499 "Expire all expirable articles in all newsgroups."
2502 (gnus-message 5 "Expiring...")
2503 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
2504 (cdr gnus-newsrc-alist))))
2505 (gnus-group-expire-articles nil)))
2506 (gnus-group-position-point)
2507 (gnus-message 5 "Expiring...done"))
2509 (defun gnus-group-set-current-level (n level)
2510 "Set the level of the next N groups to LEVEL."
2515 (let ((s (read-string
2516 (format "Level (default %s): "
2517 (or (gnus-group-group-level)
2518 gnus-level-default-subscribed)))))
2519 (if (string-match "^\\s-*$" s)
2520 (int-to-string (or (gnus-group-group-level)
2521 gnus-level-default-subscribed))
2523 (unless (and (>= level 1) (<= level gnus-level-killed))
2524 (error "Illegal level: %d" level))
2525 (let ((groups (gnus-group-process-prefix n))
2527 (while (setq group (pop groups))
2528 (gnus-group-remove-mark group)
2529 (gnus-message 6 "Changed level of %s from %d to %d"
2530 group (or (gnus-group-group-level) gnus-level-killed)
2532 (gnus-group-change-level
2533 group level (or (gnus-group-group-level) gnus-level-killed))
2534 (gnus-group-update-group-line)))
2535 (gnus-group-position-point))
2537 (defun gnus-group-unsubscribe (&optional n)
2538 "Unsubscribe the current group."
2540 (gnus-group-unsubscribe-current-group n 'unsubscribe))
2542 (defun gnus-group-subscribe (&optional n)
2543 "Subscribe the current group."
2545 (gnus-group-unsubscribe-current-group n 'subscribe))
2547 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
2548 "Toggle subscription of the current group.
2549 If given numerical prefix, toggle the N next groups."
2551 (let ((groups (gnus-group-process-prefix n))
2554 (setq group (car groups)
2555 groups (cdr groups))
2556 (gnus-group-remove-mark group)
2557 (gnus-group-unsubscribe-group
2560 ((eq do-sub 'unsubscribe)
2561 gnus-level-default-unsubscribed)
2562 ((eq do-sub 'subscribe)
2563 gnus-level-default-subscribed)
2564 ((<= (gnus-group-group-level) gnus-level-subscribed)
2565 gnus-level-default-unsubscribed)
2567 gnus-level-default-subscribed))
2569 (gnus-group-update-group-line))
2570 (gnus-group-next-group 1)))
2572 (defun gnus-group-unsubscribe-group (group &optional level silent)
2573 "Toggle subscription to GROUP.
2574 Killed newsgroups are subscribed. If SILENT, don't try to update the
2577 (list (completing-read
2578 "Group: " gnus-active-hashtb nil
2579 (gnus-read-active-file-p)
2581 'gnus-group-history)))
2582 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
2584 ((string-match "^[ \t]$" group)
2585 (error "Empty group name"))
2587 ;; Toggle subscription flag.
2588 (gnus-group-change-level
2589 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
2590 gnus-level-subscribed)
2591 (1+ gnus-level-subscribed)
2592 gnus-level-default-subscribed)))
2594 (gnus-group-update-group group)))
2595 ((and (stringp group)
2596 (or (not (gnus-read-active-file-p))
2597 (gnus-active group)))
2598 ;; Add new newsgroup.
2599 (gnus-group-change-level
2601 (if level level gnus-level-default-subscribed)
2602 (or (and (member group gnus-zombie-list)
2605 (when (gnus-group-group-name)
2606 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
2608 (gnus-group-update-group group)))
2609 (t (error "No such newsgroup: %s" group)))
2610 (gnus-group-position-point)))
2612 (defun gnus-group-transpose-groups (n)
2613 "Move the current newsgroup up N places.
2614 If given a negative prefix, move down instead. The difference between
2615 N and the number of steps taken is returned."
2617 (unless (gnus-group-group-name)
2618 (error "No group on current line"))
2619 (gnus-group-kill-group 1)
2621 (forward-line (- n))
2622 (gnus-group-yank-group)
2623 (gnus-group-position-point)))
2625 (defun gnus-group-kill-all-zombies ()
2626 "Kill all zombie newsgroups."
2628 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
2629 (setq gnus-zombie-list nil)
2630 (gnus-dribble-touch)
2631 (gnus-group-list-groups))
2633 (defun gnus-group-kill-region (begin end)
2634 "Kill newsgroups in current region (excluding current point).
2635 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
2650 (beginning-of-line) ;Important when LINES < 1
2651 (gnus-group-kill-group lines)))
2653 (defun gnus-group-kill-group (&optional n discard)
2654 "Kill the next N groups.
2655 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
2656 However, only groups that were alive can be yanked; already killed
2657 groups or zombie groups can't be yanked.
2658 The return value is the name of the group that was killed, or a list
2661 (let ((buffer-read-only nil)
2662 (groups (gnus-group-process-prefix n))
2663 group entry level out)
2664 (if (< (length groups) 10)
2665 ;; This is faster when there are few groups.
2667 (push (setq group (pop groups)) out)
2668 (gnus-group-remove-mark group)
2669 (setq level (gnus-group-group-level))
2671 (when (and (not discard)
2672 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
2675 (gnus-group-goto-group ,(gnus-group-group-name))
2676 (gnus-group-yank-group)))
2677 (push (cons (car entry) (nth 2 entry))
2678 gnus-list-of-killed-groups))
2679 (gnus-group-change-level
2680 (if entry entry group) gnus-level-killed (if entry nil level)))
2681 ;; If there are lots and lots of groups to be killed, we use
2682 ;; this thing instead.
2684 (setq groups (nreverse groups))
2686 (gnus-group-remove-mark (setq group (pop groups)))
2688 (push group gnus-killed-list)
2689 (setq gnus-newsrc-alist
2690 (delq (assoc group gnus-newsrc-alist)
2692 (when gnus-group-change-level-function
2693 (funcall gnus-group-change-level-function group 9 3))
2695 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
2696 (push (cons (car entry) (nth 2 entry))
2697 gnus-list-of-killed-groups)
2698 (setcdr (cdr entry) (cdddr entry)))
2699 ((member group gnus-zombie-list)
2700 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
2701 (gnus-make-hashtable-from-newsrc-alist)))
2703 (gnus-group-position-point)
2704 (if (< (length out) 2) (car out) (nreverse out))))
2706 (defun gnus-group-yank-group (&optional arg)
2707 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
2708 inserting it before the current newsgroup. The numeric ARG specifies
2709 how many newsgroups are to be yanked. The name of the newsgroup yanked
2710 is returned, or (if several groups are yanked) a list of yanked groups
2713 (setq arg (or arg 1))
2714 (let (info group prev out)
2715 (while (>= (decf arg) 0)
2716 (when (not (setq info (pop gnus-list-of-killed-groups)))
2717 (error "No more newsgroups to yank"))
2718 (push (setq group (nth 1 info)) out)
2719 ;; Find which newsgroup to insert this one before - search
2720 ;; backward until something suitable is found. If there are no
2721 ;; other newsgroups in this buffer, just make this newsgroup the
2723 (setq prev (gnus-group-group-name))
2724 (gnus-group-change-level
2725 info (gnus-info-level (cdr info)) gnus-level-killed
2726 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
2728 (gnus-group-insert-group-line-info group)
2730 `(when (gnus-group-goto-group ,group)
2731 (gnus-group-kill-group 1))))
2733 (gnus-group-position-point)
2734 (if (< (length out) 2) (car out) (nreverse out))))
2736 (defun gnus-group-kill-level (level)
2737 "Kill all groups that is on a certain LEVEL."
2738 (interactive "nKill all groups on level: ")
2740 ((= level gnus-level-zombie)
2741 (setq gnus-killed-list
2742 (nconc gnus-zombie-list gnus-killed-list))
2743 (setq gnus-zombie-list nil))
2744 ((and (< level gnus-level-zombie)
2746 (or gnus-expert-user
2749 "Do you really want to kill all groups on level %d? "
2751 (let* ((prev gnus-newsrc-alist)
2754 (if (= (gnus-info-level (car alist)) level)
2756 (push (gnus-info-group (car alist)) gnus-killed-list)
2757 (setcdr prev (cdr alist)))
2759 (setq alist (cdr alist)))
2760 (gnus-make-hashtable-from-newsrc-alist)
2761 (gnus-group-list-groups)))
2763 (error "Can't kill; illegal level: %d" level))))
2765 (defun gnus-group-list-all-groups (&optional arg)
2766 "List all newsgroups with level ARG or lower.
2767 Default is gnus-level-unsubscribed, which lists all subscribed and most
2768 unsubscribed groups."
2770 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
2772 ;; Redefine this to list ALL killed groups if prefix arg used.
2773 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
2774 (defun gnus-group-list-killed (&optional arg)
2775 "List all killed newsgroups in the group buffer.
2776 If ARG is non-nil, list ALL killed groups known to Gnus. This may
2777 entail asking the server for the groups."
2779 ;; Find all possible killed newsgroups if arg.
2781 (gnus-get-killed-groups))
2782 (if (not gnus-killed-list)
2783 (gnus-message 6 "No killed groups")
2784 (let (gnus-group-list-mode)
2785 (funcall gnus-group-prepare-function
2786 gnus-level-killed t gnus-level-killed))
2787 (goto-char (point-min)))
2788 (gnus-group-position-point))
2790 (defun gnus-group-list-zombies ()
2791 "List all zombie newsgroups in the group buffer."
2793 (if (not gnus-zombie-list)
2794 (gnus-message 6 "No zombie groups")
2795 (let (gnus-group-list-mode)
2796 (funcall gnus-group-prepare-function
2797 gnus-level-zombie t gnus-level-zombie))
2798 (goto-char (point-min)))
2799 (gnus-group-position-point))
2801 (defun gnus-group-list-active ()
2802 "List all groups that are available from the server(s)."
2804 ;; First we make sure that we have really read the active file.
2805 (unless (gnus-read-active-file-p)
2806 (let ((gnus-read-active-file t))
2807 (gnus-read-active-file)))
2808 ;; Find all groups and sort them.
2816 (push (symbol-name sym) list)))
2820 (buffer-read-only nil)
2824 (gnus-add-text-properties
2825 (point) (prog1 (1+ (point))
2827 (setq group (pop groups)) "\n"))
2828 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
2830 'gnus-level (inline (gnus-group-level group)))))
2831 (goto-char (point-min))))
2833 (defun gnus-activate-all-groups (level)
2834 "Activate absolutely all groups."
2835 (interactive (list 7))
2836 (let ((gnus-activate-level level)
2837 (gnus-activate-foreign-newsgroups level))
2838 (gnus-group-get-new-news)))
2840 (defun gnus-group-get-new-news (&optional arg)
2841 "Get newly arrived articles.
2842 If ARG is a number, it specifies which levels you are interested in
2843 re-scanning. If ARG is non-nil and not a number, this will force
2844 \"hard\" re-reading of the active files from all servers."
2846 (let ((gnus-inhibit-demon t))
2847 (run-hooks 'gnus-get-new-news-hook)
2849 ;; Read any slave files.
2851 (gnus-master-read-slave-newsrc))
2853 ;; We might read in new NoCeM messages here.
2854 (when (and gnus-use-nocem
2856 (gnus-nocem-scan-groups))
2857 ;; If ARG is not a number, then we read the active file.
2858 (when (and arg (not (numberp arg)))
2859 (let ((gnus-read-active-file t))
2860 (gnus-read-active-file))
2863 ;; If the user wants it, we scan for new groups.
2864 (when (eq gnus-check-new-newsgroups 'always)
2865 (gnus-find-new-newsgroups)))
2867 (setq arg (gnus-group-default-level arg t))
2868 (if (and gnus-read-active-file (not arg))
2870 (gnus-read-active-file)
2871 (gnus-get-unread-articles arg))
2872 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
2873 (gnus-get-unread-articles arg)))
2874 (run-hooks 'gnus-after-getting-new-news-hook)
2875 (gnus-group-list-groups (and (numberp arg)
2876 (max (car gnus-group-list-mode) arg)))))
2878 (defun gnus-group-get-new-news-this-group (&optional n)
2879 "Check for newly arrived news in the current group (and the N-1 next groups).
2880 The difference between N and the number of newsgroup checked is returned.
2881 If N is negative, this group and the N-1 previous groups will be checked."
2883 (let* ((groups (gnus-group-process-prefix n))
2884 (ret (if (numberp n) (- n (length groups)) 0))
2888 (while (setq group (pop groups))
2889 (gnus-group-remove-mark group)
2890 ;; Bypass any previous denials from the server.
2891 (gnus-remove-denial (gnus-find-method-for-group group))
2892 (if (gnus-activate-group group 'scan)
2894 (gnus-get-unread-articles-in-group
2895 (gnus-get-info group) (gnus-active group) t)
2896 (unless (gnus-virtual-group-p group)
2897 (gnus-close-group group))
2898 (gnus-group-update-group group))
2899 (if (eq (gnus-server-status (gnus-find-method-for-group group))
2901 (gnus-error 3 "Server denied access")
2902 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
2905 (when gnus-goto-next-group-when-activating
2906 (gnus-group-next-unread-group 1 t))
2907 (gnus-summary-position-point)
2910 (defun gnus-group-fetch-faq (group &optional faq-dir)
2911 "Fetch the FAQ for the current group.
2912 If given a prefix argument, prompt for the FAQ dir
2916 (gnus-group-group-name)
2917 (cond (current-prefix-arg
2919 "Faq dir: " (and (listp gnus-group-faq-directory)
2920 (mapcar (lambda (file) (list file))
2921 gnus-group-faq-directory)))))))
2923 (error "No group name given"))
2924 (let ((dirs (or faq-dir gnus-group-faq-directory))
2926 (unless (listp dirs)
2927 (setq dirs (list dirs)))
2928 (while (and (not found)
2929 (setq dir (pop dirs)))
2930 (setq file (concat (file-name-as-directory dir)
2931 (gnus-group-real-name group)))
2932 (if (not (file-exists-p file))
2933 (gnus-message 1 "No such file: %s" file)
2934 (let ((enable-local-variables nil))
2938 (defun gnus-group-describe-group (force &optional group)
2939 "Display a description of the current newsgroup."
2940 (interactive (list current-prefix-arg (gnus-group-group-name)))
2941 (let* ((method (gnus-find-method-for-group group))
2942 (mname (gnus-group-prefixed-name "" method))
2945 gnus-description-hashtb)
2946 (gnus-sethash mname nil gnus-description-hashtb))
2948 (error "No group name given"))
2949 (when (or (and gnus-description-hashtb
2950 ;; We check whether this group's method has been
2951 ;; queried for a description file.
2952 (gnus-gethash mname gnus-description-hashtb))
2953 (setq desc (gnus-group-get-description group))
2954 (gnus-read-descriptions-file method))
2956 (or desc (gnus-gethash group gnus-description-hashtb)
2957 "No description available")))))
2959 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
2960 (defun gnus-group-describe-all-groups (&optional force)
2961 "Pop up a buffer with descriptions of all newsgroups."
2964 (setq gnus-description-hashtb nil))
2965 (when (not (or gnus-description-hashtb
2966 (gnus-read-all-descriptions-files)))
2967 (error "Couldn't request descriptions file"))
2968 (let ((buffer-read-only nil)
2974 (insert (format " *: %-20s %s\n" (symbol-name group)
2975 (symbol-value group)))
2976 (gnus-add-text-properties
2977 b (1+ b) (list 'gnus-group group
2978 'gnus-unread t 'gnus-marked nil
2979 'gnus-level (1+ gnus-level-subscribed))))
2980 gnus-description-hashtb)
2981 (goto-char (point-min))
2982 (gnus-group-position-point)))
2984 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
2985 (defun gnus-group-apropos (regexp &optional search-description)
2986 "List all newsgroups that have names that match a regexp."
2987 (interactive "sGnus apropos (regexp): ")
2989 (obuf (current-buffer))
2991 ;; Go through all newsgroups that are known to Gnus.
2994 (and (symbol-name group)
2995 (string-match regexp (symbol-name group))
2996 (push (symbol-name group) groups)))
2998 ;; Also go through all descriptions that are known to Gnus.
2999 (when search-description
3002 (and (string-match regexp (symbol-value group))
3003 (gnus-active (symbol-name group))
3004 (push (symbol-name group) groups)))
3005 gnus-description-hashtb))
3007 (gnus-message 3 "No groups matched \"%s\"." regexp)
3008 ;; Print out all the groups.
3010 (pop-to-buffer "*Gnus Help*")
3011 (buffer-disable-undo (current-buffer))
3013 (setq groups (sort groups 'string<))
3015 ;; Groups may be entered twice into the list of groups.
3016 (when (not (string= (car groups) prev))
3017 (insert (setq prev (car groups)) "\n")
3018 (when (and gnus-description-hashtb
3019 (setq des (gnus-gethash (car groups)
3020 gnus-description-hashtb)))
3021 (insert " " des "\n")))
3022 (setq groups (cdr groups)))
3023 (goto-char (point-min))))
3024 (pop-to-buffer obuf)))
3026 (defun gnus-group-description-apropos (regexp)
3027 "List all newsgroups that have names or descriptions that match a regexp."
3028 (interactive "sGnus description apropos (regexp): ")
3029 (when (not (or gnus-description-hashtb
3030 (gnus-read-all-descriptions-files)))
3031 (error "Couldn't request descriptions file"))
3032 (gnus-group-apropos regexp t))
3034 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3035 (defun gnus-group-list-matching (level regexp &optional all lowest)
3036 "List all groups with unread articles that match REGEXP.
3037 If the prefix LEVEL is non-nil, it should be a number that says which
3038 level to cut off listing groups.
3039 If ALL, also list groups with no unread articles.
3040 If LOWEST, don't list groups with level lower than LOWEST.
3042 This command may read the active file."
3043 (interactive "P\nsList newsgroups matching: ")
3044 ;; First make sure active file has been read.
3046 (> (prefix-numeric-value level) gnus-level-killed))
3047 (gnus-get-killed-groups))
3048 (gnus-group-prepare-flat
3049 (or level gnus-level-subscribed) all (or lowest 1) regexp)
3050 (goto-char (point-min))
3051 (gnus-group-position-point))
3053 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3054 "List all groups that match REGEXP.
3055 If the prefix LEVEL is non-nil, it should be a number that says which
3056 level to cut off listing groups.
3057 If LOWEST, don't list groups with level lower than LOWEST."
3058 (interactive "P\nsList newsgroups matching: ")
3060 (setq level (prefix-numeric-value level)))
3061 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3063 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3064 (defun gnus-group-save-newsrc (&optional force)
3065 "Save the Gnus startup files.
3066 If FORCE, force saving whether it is necessary or not."
3068 (gnus-save-newsrc-file force))
3070 (defun gnus-group-restart (&optional arg)
3071 "Force Gnus to read the .newsrc file."
3073 (when (gnus-yes-or-no-p
3074 (format "Are you sure you want to restart Gnus? "))
3075 (gnus-save-newsrc-file)
3079 (defun gnus-group-read-init-file ()
3080 "Read the Gnus elisp init file."
3082 (gnus-read-init-file))
3084 (defun gnus-group-check-bogus-groups (&optional silent)
3085 "Check bogus newsgroups.
3086 If given a prefix, don't ask for confirmation before removing a bogus
3089 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3090 (gnus-group-list-groups))
3092 (defun gnus-group-edit-global-kill (&optional article group)
3093 "Edit the global kill file.
3094 If GROUP, edit that local kill file instead."
3096 (setq gnus-current-kill-article article)
3097 (gnus-kill-file-edit-file group)
3100 (substitute-command-keys
3101 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3102 (if group "local" "global")))))
3104 (defun gnus-group-edit-local-kill (article group)
3105 "Edit a local kill file."
3106 (interactive (list nil (gnus-group-group-name)))
3107 (gnus-group-edit-global-kill article group))
3109 (defun gnus-group-force-update ()
3110 "Update `.newsrc' file."
3112 (gnus-save-newsrc-file))
3114 (defun gnus-group-suspend ()
3115 "Suspend the current Gnus session.
3116 In fact, cleanup buffers except for group mode buffer.
3117 The hook gnus-suspend-gnus-hook is called before actually suspending."
3119 (run-hooks 'gnus-suspend-gnus-hook)
3120 ;; Kill Gnus buffers except for group mode buffer.
3121 (let* ((group-buf (get-buffer gnus-group-buffer))
3122 ;; Do this on a separate list in case the user does a ^G before we finish
3124 (delete group-buf (delete gnus-dribble-buffer
3125 (append gnus-buffer-list nil)))))
3126 (while gnus-buffer-list
3127 (gnus-kill-buffer (pop gnus-buffer-list)))
3128 (gnus-kill-gnus-frames)
3130 (setq gnus-buffer-list (list group-buf))
3131 (bury-buffer group-buf)
3132 (delete-windows-on group-buf t))))
3134 (defun gnus-group-clear-dribble ()
3135 "Clear all information from the dribble buffer."
3137 (gnus-dribble-clear)
3138 (gnus-message 7 "Cleared dribble buffer"))
3140 (defun gnus-group-exit ()
3141 "Quit reading news after updating .newsrc.eld and .newsrc.
3142 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3145 (or noninteractive ;For gnus-batch-kill
3146 (not gnus-interactive-exit) ;Without confirmation
3148 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3149 (run-hooks 'gnus-exit-gnus-hook)
3150 ;; Offer to save data from non-quitted summary buffers.
3151 (gnus-offer-save-summaries)
3152 ;; Save the newsrc file(s).
3153 (gnus-save-newsrc-file)
3155 (gnus-close-backends)
3156 ;; Reset everything.
3158 ;; Allow the user to do things after cleaning up.
3159 (run-hooks 'gnus-after-exiting-gnus-hook)))
3161 (defun gnus-group-quit ()
3162 "Quit reading news without updating .newsrc.eld or .newsrc.
3163 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3165 (when (or noninteractive ;For gnus-batch-kill
3166 (zerop (buffer-size))
3167 (not (gnus-server-opened gnus-select-method))
3169 (not gnus-current-startup-file)
3171 (format "Quit reading news without saving %s? "
3172 (file-name-nondirectory gnus-current-startup-file))))
3173 (run-hooks 'gnus-exit-gnus-hook)
3174 (gnus-configure-windows 'group t)
3176 (gnus-close-backends)
3178 (gnus-kill-buffer gnus-group-buffer)
3179 ;; Allow the user to do things after cleaning up.
3180 (run-hooks 'gnus-after-exiting-gnus-hook)))
3182 (defun gnus-group-describe-briefly ()
3183 "Give a one line description of the group mode commands."
3185 (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")))
3187 (defun gnus-group-browse-foreign-server (method)
3188 "Browse a foreign news server.
3189 If called interactively, this function will ask for a select method
3190 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3191 If not, METHOD should be a list where the first element is the method
3192 and the second element is the address."
3194 (list (let ((how (completing-read
3196 (append gnus-valid-select-methods gnus-server-alist)
3197 nil t (cons "nntp" 0) 'gnus-method-history)))
3198 ;; We either got a backend name or a virtual server name.
3199 ;; If the first, we also need an address.
3200 (if (assoc how gnus-valid-select-methods)
3202 ;; Suggested by mapjph@bath.ac.uk.
3205 (mapcar (lambda (server) (list server))
3206 gnus-secondary-servers)))
3207 ;; We got a server name.
3209 (gnus-browse-foreign-server method))
3211 (defun gnus-group-set-info (info &optional method-only-group part)
3212 (let* ((entry (gnus-gethash
3213 (or method-only-group (gnus-info-group info))
3214 gnus-newsrc-hashtb))
3216 (info (if method-only-group (nth 2 entry) info))
3218 (when method-only-group
3220 (error "Trying to change non-existent group %s" method-only-group))
3221 ;; We have received parts of the actual group info - either the
3222 ;; select method or the group parameters. We first check
3223 ;; whether we have to extend the info, and if so, do that.
3224 (let ((len (length info))
3225 (total (if (eq part 'method) 5 6)))
3227 (setcdr (nthcdr (1- len) info)
3228 (make-list (- total len) nil)))
3229 ;; Then we enter the new info.
3230 (setcar (nthcdr (1- total) info) part-info)))
3232 ;; This is a new group, so we just create it.
3234 (set-buffer gnus-group-buffer)
3235 (setq method (gnus-info-method info))
3236 (when (gnus-server-equal method "native")
3239 (set-buffer gnus-group-buffer)
3241 ;; It's a foreign group...
3242 (gnus-group-make-group
3243 (gnus-group-real-name (gnus-info-group info))
3244 (if (stringp method) method
3245 (prin1-to-string (car method)))
3247 (nth 1 (gnus-info-method info))))
3248 ;; It's a native group.
3249 (gnus-group-make-group (gnus-info-group info))))
3250 (gnus-message 6 "Note: New group created")
3252 (gnus-gethash (gnus-group-prefixed-name
3253 (gnus-group-real-name (gnus-info-group info))
3254 (or (gnus-info-method info) gnus-select-method))
3255 gnus-newsrc-hashtb))))
3256 ;; Whether it was a new group or not, we now have the entry, so we
3257 ;; can do the update.
3260 (setcar (nthcdr 2 entry) info)
3261 (when (and (not (eq (car entry) t))
3262 (gnus-active (gnus-info-group info)))
3263 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
3264 (error "No such group: %s" (gnus-info-group info)))))
3266 (defun gnus-group-set-method-info (group select-method)
3267 (gnus-group-set-info select-method group 'method))
3269 (defun gnus-group-set-params-info (group params)
3270 (gnus-group-set-info params group 'params))
3272 (defun gnus-add-marked-articles (group type articles &optional info force)
3273 ;; Add ARTICLES of TYPE to the info of GROUP.
3274 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
3275 ;; add, but replace marked articles of TYPE with ARTICLES.
3276 (let ((info (or info (gnus-get-info group)))
3277 (uncompressed '(score bookmark killed))
3280 (and (not (setq marked (nthcdr 3 info)))
3282 (setcdr (nthcdr 2 info)
3283 (list (list (cons type (gnus-compress-sequence
3285 (and (not (setq m (assq type (car marked))))
3288 (cons (cons type (gnus-compress-sequence articles t) )
3292 (setcar (nthcdr 3 info)
3293 (delq (assq type (car marked)) (car marked)))
3294 (setcdr m (gnus-compress-sequence articles t)))
3295 (setcdr m (gnus-compress-sequence
3296 (sort (nconc (gnus-uncompress-range (cdr m))
3297 (copy-sequence articles)) '<) t))))))
3300 ;;; Group timestamps
3303 (defun gnus-group-set-timestamp ()
3304 "Change the timestamp of the current group to the current time.
3305 This function can be used in hooks like `gnus-select-group-hook'
3306 or `gnus-group-catchup-group-hook'."
3307 (when gnus-newsgroup-name
3308 (let ((time (current-time)))
3309 (setcdr (cdr time) nil)
3310 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
3312 (defsubst gnus-group-timestamp (group)
3313 "Return the timestamp for GROUP."
3314 (gnus-group-get-parameter group 'timestamp))
3316 (defun gnus-group-timestamp-delta (group)
3317 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
3318 (let* ((time (or (gnus-group-timestamp group)
3320 (delta (gnus-time-minus (current-time) time)))
3321 (+ (* (nth 0 delta) 65536.0)
3324 (defun gnus-group-timestamp-string (group)
3325 "Return a string of the timestamp for GROUP."
3326 (let ((time (gnus-group-timestamp group)))
3329 (gnus-time-iso8601 time))))
3331 (provide 'gnus-group)
3333 ;;; gnus-group.el ends here