1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (let ((features (cons 'gnus-group features)))
48 (unless (boundp 'gnus-cache-active-hashtb)
49 (defvar gnus-cache-active-hashtb nil)))
51 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
52 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
54 (defcustom gnus-group-archive-directory
55 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
56 "*The address of the (ding) archives."
57 :group 'gnus-group-foreign
60 (defcustom gnus-group-recent-archive-directory
61 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
62 "*The address of the most recent (ding) articles."
63 :group 'gnus-group-foreign
66 (defcustom gnus-no-groups-message "No Gnus is good news"
67 "*Message displayed by Gnus when no groups are available."
71 (defcustom gnus-keep-same-level nil
72 "*Non-nil means that the next newsgroup after the current will be on the same level.
73 When you type, for instance, `n' after reading the last article in the
74 current newsgroup, you will go to the next newsgroup. If this variable
75 is nil, the next newsgroup will be the next from the group
77 If this variable is non-nil, Gnus will either put you in the
78 next newsgroup with the same level, or, if no such newsgroup is
79 available, the next newsgroup with the lowest possible level higher
80 than the current level.
81 If this variable is `best', Gnus will make the next newsgroup the one
83 :group 'gnus-group-levels
84 :type '(choice (const nil)
86 (sexp :tag "other" t)))
88 (defcustom gnus-group-goto-unread t
89 "*If non-nil, movement commands will go to the next unread and subscribed group."
90 :link '(custom-manual "(gnus)Group Maneuvering")
91 :group 'gnus-group-various
94 (defcustom gnus-goto-next-group-when-activating t
95 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
96 :link '(custom-manual "(gnus)Scanning New Messages")
97 :group 'gnus-group-various
100 (defcustom gnus-permanently-visible-groups nil
101 "*Regexp to match groups that should always be listed in the group buffer.
102 This means that they will still be listed even when there are no
103 unread articles in the groups.
105 If nil, no groups are permanently visible."
106 :group 'gnus-group-listing
107 :type '(choice regexp (const nil)))
109 (defcustom gnus-list-groups-with-ticked-articles t
110 "*If non-nil, list groups that have only ticked articles.
111 If nil, only list groups that have unread articles."
112 :group 'gnus-group-listing
115 (defcustom gnus-group-default-list-level gnus-level-subscribed
116 "*Default listing level.
117 Ignored if `gnus-group-use-permanent-levels' is non-nil."
118 :group 'gnus-group-listing
121 (defcustom gnus-group-list-inactive-groups t
122 "*If non-nil, inactive groups will be listed."
123 :group 'gnus-group-listing
124 :group 'gnus-group-levels
127 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
128 "*Function used for sorting the group buffer.
129 This function will be called with group info entries as the arguments
130 for the groups to be sorted. Pre-made functions include
131 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
132 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
133 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
134 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
136 This variable can also be a list of sorting functions. In that case,
137 the most significant sort function should be the last function in the
139 :group 'gnus-group-listing
140 :link '(custom-manual "(gnus)Sorting Groups")
141 :type '(repeat :value-to-internal (lambda (widget value)
142 (if (listp value) value (list value)))
143 :match (lambda (widget value)
145 (widget-editable-list-match widget value)))
146 (choice (function-item gnus-group-sort-by-alphabet)
147 (function-item gnus-group-sort-by-real-name)
148 (function-item gnus-group-sort-by-unread)
149 (function-item gnus-group-sort-by-level)
150 (function-item gnus-group-sort-by-score)
151 (function-item gnus-group-sort-by-method)
152 (function-item gnus-group-sort-by-server)
153 (function-item gnus-group-sort-by-rank)
154 (function :tag "other" nil))))
156 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
157 "*Format of group lines.
158 It works along the same lines as a normal formatting string,
159 with some simple extensions.
161 %M Only marked articles (character, \"*\" or \" \")
162 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
163 %L Level of subscribedness (integer)
164 %N Number of unread articles (integer)
165 %I Number of dormant articles (integer)
166 %i Number of ticked and dormant (integer)
167 %T Number of ticked articles (integer)
168 %R Number of read articles (integer)
169 %U Number of unseen articles (integer)
170 %t Estimated total number of articles (integer)
171 %y Number of unread, unticked articles (integer)
172 %G Group name (string)
173 %g Qualified group name (string)
174 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
175 %C Group comment (string)
176 %D Group description (string)
177 %s Select method (string)
178 %o Moderated group (char, \"m\")
179 %p Process mark (char)
180 %B Whether a summary buffer for the group is open (char, \"*\")
181 %O Moderated group (string, \"(m)\" or \"\")
182 %P Topic indentation (string)
183 %m Whether there is new(ish) mail in the group (char, \"%\")
184 %n Select from where (string)
185 %z A string that look like `<%s:%n>' if a foreign select method is used
186 %d The date the group was last entered.
187 %E Icon as defined by `gnus-group-icon-list'.
188 %F The disk space used by the articles fetched by both the cache and agent.
189 %u User defined specifier. The next character in the format string should
190 be a letter. Gnus will call the function gnus-user-format-function-X,
191 where X is the letter following %u. The function will be passed a
192 single dummy parameter as argument. The function should return a
193 string, which will be inserted into the buffer just like information
194 from any other group specifier.
196 Note that this format specification is not always respected. For
197 reasons of efficiency, when listing killed groups, this specification
198 is ignored altogether. If the spec is changed considerably, your
199 output may end up looking strange when listing both alive and killed
202 If you use %o or %O, reading the active file will be slower and quite
203 a bit of extra memory will be used. %D and %F will also worsen
204 performance. Also note that if you change the format specification to
205 include any of these specs, you must probably re-start Gnus to see
208 General format specifiers can also be used.
209 See Info node `(gnus)Formatting Variables'."
210 :link '(custom-manual "(gnus)Formatting Variables")
211 :group 'gnus-group-visual
214 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
215 "*The format specification for the group mode line.
216 It works along the same lines as a normal formatting string,
217 with some simple extensions:
219 %S The native news server.
220 %M The native select method.
221 %: \":\" if %S isn't \"\"."
222 :group 'gnus-group-visual
225 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
226 (when (featurep 'xemacs)
227 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
228 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
230 (defcustom gnus-group-menu-hook nil
231 "Hook run after the creation of the group mode menu."
232 :group 'gnus-group-various
235 (defcustom gnus-group-catchup-group-hook nil
236 "Hook run when catching up a group from the group buffer."
237 :group 'gnus-group-various
238 :link '(custom-manual "(gnus)Group Data")
241 (defcustom gnus-group-update-group-hook nil
242 "Hook called when updating group lines."
243 :group 'gnus-group-visual
246 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
247 "*A function that is called to generate the group buffer.
248 The function is called with three arguments: The first is a number;
249 all group with a level less or equal to that number should be listed,
250 if the second is non-nil, empty groups should also be displayed. If
251 the third is non-nil, it is a number. No groups with a level lower
252 than this number should be displayed.
254 The only current function implemented is `gnus-group-prepare-flat'."
255 :group 'gnus-group-listing
258 (defcustom gnus-group-prepare-hook nil
259 "Hook called after the group buffer has been generated.
260 If you want to modify the group buffer, you can use this hook."
261 :group 'gnus-group-listing
264 (defcustom gnus-suspend-gnus-hook nil
265 "Hook called when suspending (not exiting) Gnus."
269 (defcustom gnus-exit-gnus-hook nil
270 "Hook called when exiting Gnus."
274 (defcustom gnus-after-exiting-gnus-hook nil
275 "Hook called after exiting Gnus."
279 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
280 "Hook called when a group line is changed.
281 The hook will not be called if `gnus-visual' is nil.
283 The default function `gnus-group-highlight-line' will
284 highlight the line according to the `gnus-group-highlight'
286 :group 'gnus-group-visual
289 (defcustom gnus-useful-groups
290 '(("(ding) mailing list mirrored at sunsite.auc.dk"
292 (nntp "sunsite.auc.dk"
293 (nntp-address "sunsite.auc.dk")))
296 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
300 (nndoc-article-type mbox)
301 (eval `(nndoc-address
302 ,(let ((file (nnheader-find-etc-directory
305 (error "Couldn't find doc group"))
307 "*Alist of useful group-server pairs."
308 :group 'gnus-group-listing
309 :type '(repeat (list (string :tag "Description")
311 (sexp :tag "Method"))))
313 (defcustom gnus-group-highlight
315 ((and mailp (= unread 0) (eq level 1)) .
316 gnus-group-mail-1-empty-face)
317 ((and mailp (eq level 1)) .
318 gnus-group-mail-1-face)
319 ((and mailp (= unread 0) (eq level 2)) .
320 gnus-group-mail-2-empty-face)
321 ((and mailp (eq level 2)) .
322 gnus-group-mail-2-face)
323 ((and mailp (= unread 0) (eq level 3)) .
324 gnus-group-mail-3-empty-face)
325 ((and mailp (eq level 3)) .
326 gnus-group-mail-3-face)
327 ((and mailp (= unread 0)) .
328 gnus-group-mail-low-empty-face)
330 gnus-group-mail-low-face)
332 ((and (= unread 0) (eq level 1)) .
333 gnus-group-news-1-empty-face)
334 ((and (eq level 1)) .
335 gnus-group-news-1-face)
336 ((and (= unread 0) (eq level 2)) .
337 gnus-group-news-2-empty-face)
338 ((and (eq level 2)) .
339 gnus-group-news-2-face)
340 ((and (= unread 0) (eq level 3)) .
341 gnus-group-news-3-empty-face)
342 ((and (eq level 3)) .
343 gnus-group-news-3-face)
344 ((and (= unread 0) (eq level 4)) .
345 gnus-group-news-4-empty-face)
346 ((and (eq level 4)) .
347 gnus-group-news-4-face)
348 ((and (= unread 0) (eq level 5)) .
349 gnus-group-news-5-empty-face)
350 ((and (eq level 5)) .
351 gnus-group-news-5-face)
352 ((and (= unread 0) (eq level 6)) .
353 gnus-group-news-6-empty-face)
354 ((and (eq level 6)) .
355 gnus-group-news-6-face)
356 ((and (= unread 0)) .
357 gnus-group-news-low-empty-face)
359 gnus-group-news-low-face))
360 "*Controls the highlighting of group buffer lines.
362 Below is a list of `Form'/`Face' pairs. When deciding how a a
363 particular group line should be displayed, each form is
364 evaluated. The content of the face field after the first true form is
365 used. You can change how those group lines are displayed by
366 editing the face field.
368 It is also possible to change and add form fields, but currently that
369 requires an understanding of Lisp expressions. Hopefully this will
370 change in a future release. For now, you can use the following
371 variables in the Lisp expression:
373 group: The name of the group.
374 unread: The number of unread articles in the group.
375 method: The select method used.
376 mailp: Whether it's a mail group or not.
377 level: The level of the group.
378 score: The score of the group.
379 ticked: The number of ticked articles."
380 :group 'gnus-group-visual
381 :type '(repeat (cons (sexp :tag "Form") face)))
383 (defcustom gnus-new-mail-mark ?%
384 "Mark used for groups with new mail."
385 :group 'gnus-group-visual
388 (defgroup gnus-group-icons nil
389 "Add Icons to your group buffer. "
390 :group 'gnus-group-visual)
392 (defcustom gnus-group-icon-list
394 "*Controls the insertion of icons into group buffer lines.
396 Below is a list of `Form'/`File' pairs. When deciding how a
397 particular group line should be displayed, each form is evaluated.
398 The icon from the file field after the first true form is used. You
399 can change how those group lines are displayed by editing the file
400 field. The File will either be found in the
401 `gnus-group-glyph-directory' or by designating absolute name of the
404 It is also possible to change and add form fields, but currently that
405 requires an understanding of Lisp expressions. Hopefully this will
406 change in a future release. For now, you can use the following
407 variables in the Lisp expression:
409 group: The name of the group.
410 unread: The number of unread articles in the group.
411 method: The select method used.
412 mailp: Whether it's a mail group or not.
413 newsp: Whether it's a news group or not
414 level: The level of the group.
415 score: The score of the group.
416 ticked: The number of ticked articles."
417 :group 'gnus-group-icons
418 :type '(repeat (cons (sexp :tag "Form") file)))
420 (defcustom gnus-group-name-charset-method-alist nil
421 "Alist of method and the charset for group names.
424 (((nntp \"news.com.cn\") . cn-gb-2312))"
427 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
429 (defcustom gnus-group-name-charset-group-alist
430 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
431 (mm-coding-system-p 'utf-8))
434 "Alist of group regexp and the charset for group names.
437 ((\"\\.com\\.cn:\" . cn-gb-2312))"
439 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
441 (defcustom gnus-group-jump-to-group-prompt nil
442 "Default prompt for `gnus-group-jump-to-group'.
444 If non-nil, the value should be a string or an alist. If it is a string,
445 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
446 nnml:\" in the minibuffer prompt.
448 If it is an alist, it must consist of \(NUMBER . PROMPT\) pairs, for example:
449 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
450 used when no prefix argument is given to `gnus-group-jump-to-group'."
452 :group 'gnus-group-various
453 :type '(choice (string :tag "Prompt string")
454 (const :tag "Empty" nil)
455 (repeat (cons (integer :tag "Argument")
456 (string :tag "Prompt string")))))
458 (defvar gnus-group-listing-limit 1000
459 "*A limit of the number of groups when listing.
460 If the number of groups is larger than the limit, list them in a
463 ;;; Internal variables
465 (defvar gnus-group-is-exiting-p nil)
466 (defvar gnus-group-is-exiting-without-update-p nil)
467 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
468 "Function for sorting the group buffer.")
470 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
471 "Function for sorting the selected groups in the group buffer.")
473 (defvar gnus-group-indentation-function nil)
474 (defvar gnus-goto-missing-group-function nil)
475 (defvar gnus-group-update-group-function nil)
476 (defvar gnus-group-goto-next-group-function nil
477 "Function to override finding the next group after listing groups.")
479 (defvar gnus-group-edit-buffer nil)
481 (defvar gnus-group-line-format-alist
482 `((?M gnus-tmp-marked-mark ?c)
483 (?S gnus-tmp-subscribed ?c)
484 (?L gnus-tmp-level ?d)
485 (?N (cond ((eq number t) "*" )
489 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
490 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
492 (?R gnus-tmp-number-of-read ?s)
493 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
494 (?t gnus-tmp-number-total ?d)
495 (?y gnus-tmp-number-of-unread ?s)
496 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
497 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
498 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
499 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
500 (?g (if (boundp 'gnus-tmp-decoded-group)
501 gnus-tmp-decoded-group
504 (?G gnus-tmp-qualified-group ?s)
505 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
506 gnus-tmp-decoded-group
509 (?C gnus-tmp-comment ?s)
510 (?D gnus-tmp-newsgroup-description ?s)
511 (?o gnus-tmp-moderated ?c)
512 (?O gnus-tmp-moderated-string ?s)
513 (?p gnus-tmp-process-marked ?c)
514 (?s gnus-tmp-news-server ?s)
515 (?n ,(if (featurep 'xemacs)
516 '(symbol-name gnus-tmp-news-method)
517 'gnus-tmp-news-method)
519 (?P gnus-group-indentation ?s)
520 (?E gnus-tmp-group-icon ?s)
521 (?B gnus-tmp-summary-live ?c)
522 (?z gnus-tmp-news-method-string ?s)
523 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
524 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
525 (?u gnus-tmp-user-defined ?s)
526 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
529 (defvar gnus-group-mode-line-format-alist
530 `((?S gnus-tmp-news-server ?s)
531 (?M gnus-tmp-news-method ?s)
532 (?u gnus-tmp-user-defined ?s)
533 (?: gnus-tmp-colon ?s)))
535 (defvar gnus-topic-topology nil
536 "The complete topic hierarchy.")
538 (defvar gnus-topic-alist nil
539 "The complete topic-group alist.")
541 (defvar gnus-group-marked nil)
543 (defvar gnus-group-list-mode nil)
546 (defvar gnus-group-icon-cache nil)
548 (defvar gnus-group-listed-groups nil)
549 (defvar gnus-group-list-option nil)
555 (put 'gnus-group-mode 'mode-class 'special)
557 (gnus-define-keys gnus-group-mode-map
558 " " gnus-group-read-group
559 "=" gnus-group-select-group
560 "\r" gnus-group-select-group
561 "\M-\r" gnus-group-quick-select-group
562 "\M- " gnus-group-visible-select-group
563 [(meta control return)] gnus-group-select-group-ephemerally
564 "j" gnus-group-jump-to-group
565 "n" gnus-group-next-unread-group
566 "p" gnus-group-prev-unread-group
567 "\177" gnus-group-prev-unread-group
568 [delete] gnus-group-prev-unread-group
569 [backspace] gnus-group-prev-unread-group
570 "N" gnus-group-next-group
571 "P" gnus-group-prev-group
572 "\M-n" gnus-group-next-unread-group-same-level
573 "\M-p" gnus-group-prev-unread-group-same-level
574 "," gnus-group-best-unread-group
575 "." gnus-group-first-unread-group
576 "u" gnus-group-unsubscribe-current-group
577 "U" gnus-group-unsubscribe-group
578 "c" gnus-group-catchup-current
579 "C" gnus-group-catchup-current-all
580 "\M-c" gnus-group-clear-data
581 "l" gnus-group-list-groups
582 "L" gnus-group-list-all-groups
585 "g" gnus-group-get-new-news
586 "\M-g" gnus-group-get-new-news-this-group
587 "R" gnus-group-restart
588 "r" gnus-group-read-init-file
589 "B" gnus-group-browse-foreign-server
590 "b" gnus-group-check-bogus-groups
591 "F" gnus-group-find-new-groups
592 "\C-c\C-d" gnus-group-describe-group
593 "\M-d" gnus-group-describe-all-groups
594 "\C-c\C-a" gnus-group-apropos
595 "\C-c\M-\C-a" gnus-group-description-apropos
596 "a" gnus-group-post-news
597 "\ek" gnus-group-edit-local-kill
598 "\eK" gnus-group-edit-global-kill
599 "\C-k" gnus-group-kill-group
600 "\C-y" gnus-group-yank-group
601 "\C-w" gnus-group-kill-region
602 "\C-x\C-t" gnus-group-transpose-groups
603 "\C-c\C-l" gnus-group-list-killed
604 "\C-c\C-x" gnus-group-expire-articles
605 "\C-c\M-\C-x" gnus-group-expire-all-groups
607 "s" gnus-group-save-newsrc
608 "z" gnus-group-suspend
611 "?" gnus-group-describe-briefly
612 "\C-c\C-i" gnus-info-find-node
613 "\M-e" gnus-group-edit-group-method
614 "^" gnus-group-enter-server-mode
615 gnus-mouse-2 gnus-mouse-pick-group
616 [follow-link] mouse-face
617 "<" beginning-of-buffer
620 "\C-c\C-s" gnus-group-sort-groups
622 "\C-c\M-g" gnus-activate-all-groups
623 "\M-&" gnus-group-universal-argument
624 "#" gnus-group-mark-group
625 "\M-#" gnus-group-unmark-group)
627 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
628 "m" gnus-group-mark-group
629 "u" gnus-group-unmark-group
630 "w" gnus-group-mark-region
631 "b" gnus-group-mark-buffer
632 "r" gnus-group-mark-regexp
633 "U" gnus-group-unmark-all-groups)
635 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
636 "u" gnus-sieve-update
637 "g" gnus-sieve-generate)
639 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
640 "d" gnus-group-make-directory-group
641 "h" gnus-group-make-help-group
642 "u" gnus-group-make-useful-group
643 "a" gnus-group-make-archive-group
644 "k" gnus-group-make-kiboze-group
645 "l" gnus-group-nnimap-edit-acl
646 "m" gnus-group-make-group
647 "E" gnus-group-edit-group
648 "e" gnus-group-edit-group-method
649 "p" gnus-group-edit-group-parameters
650 "v" gnus-group-add-to-virtual
651 "V" gnus-group-make-empty-virtual
652 "D" gnus-group-enter-directory
653 "f" gnus-group-make-doc-group
654 "w" gnus-group-make-web-group
655 "M" gnus-group-read-ephemeral-group
656 "r" gnus-group-rename-group
657 "R" gnus-group-make-rss-group
658 "c" gnus-group-customize
659 "x" gnus-group-nnimap-expunge
660 "\177" gnus-group-delete-group
661 [delete] gnus-group-delete-group)
663 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
664 "b" gnus-group-brew-soup
665 "w" gnus-soup-save-areas
666 "s" gnus-soup-send-replies
667 "p" gnus-soup-pack-packet
668 "r" nnsoup-pack-replies)
670 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
671 "s" gnus-group-sort-groups
672 "a" gnus-group-sort-groups-by-alphabet
673 "u" gnus-group-sort-groups-by-unread
674 "l" gnus-group-sort-groups-by-level
675 "v" gnus-group-sort-groups-by-score
676 "r" gnus-group-sort-groups-by-rank
677 "m" gnus-group-sort-groups-by-method
678 "n" gnus-group-sort-groups-by-real-name)
680 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
681 "s" gnus-group-sort-selected-groups
682 "a" gnus-group-sort-selected-groups-by-alphabet
683 "u" gnus-group-sort-selected-groups-by-unread
684 "l" gnus-group-sort-selected-groups-by-level
685 "v" gnus-group-sort-selected-groups-by-score
686 "r" gnus-group-sort-selected-groups-by-rank
687 "m" gnus-group-sort-selected-groups-by-method
688 "n" gnus-group-sort-selected-groups-by-real-name)
690 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
691 "k" gnus-group-list-killed
692 "z" gnus-group-list-zombies
693 "s" gnus-group-list-groups
694 "u" gnus-group-list-all-groups
695 "A" gnus-group-list-active
696 "a" gnus-group-apropos
697 "d" gnus-group-description-apropos
698 "m" gnus-group-list-matching
699 "M" gnus-group-list-all-matching
700 "l" gnus-group-list-level
701 "c" gnus-group-list-cached
702 "?" gnus-group-list-dormant)
704 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
705 "k" gnus-group-list-limit
706 "z" gnus-group-list-limit
707 "s" gnus-group-list-limit
708 "u" gnus-group-list-limit
709 "A" gnus-group-list-limit
710 "m" gnus-group-list-limit
711 "M" gnus-group-list-limit
712 "l" gnus-group-list-limit
713 "c" gnus-group-list-limit
714 "?" gnus-group-list-limit)
716 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
717 "k" gnus-group-list-flush
718 "z" gnus-group-list-flush
719 "s" gnus-group-list-flush
720 "u" gnus-group-list-flush
721 "A" gnus-group-list-flush
722 "m" gnus-group-list-flush
723 "M" gnus-group-list-flush
724 "l" gnus-group-list-flush
725 "c" gnus-group-list-flush
726 "?" gnus-group-list-flush)
728 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
729 "k" gnus-group-list-plus
730 "z" gnus-group-list-plus
731 "s" gnus-group-list-plus
732 "u" gnus-group-list-plus
733 "A" gnus-group-list-plus
734 "m" gnus-group-list-plus
735 "M" gnus-group-list-plus
736 "l" gnus-group-list-plus
737 "c" gnus-group-list-plus
738 "?" gnus-group-list-plus)
740 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
741 "f" gnus-score-flush-cache
742 "e" gnus-score-edit-all-score)
744 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
745 "c" gnus-group-fetch-charter
746 "C" gnus-group-fetch-control
747 "d" gnus-group-describe-group
748 "f" gnus-group-fetch-faq
751 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
752 "l" gnus-group-set-current-level
753 "t" gnus-group-unsubscribe-current-group
754 "s" gnus-group-unsubscribe-group
755 "k" gnus-group-kill-group
756 "y" gnus-group-yank-group
757 "w" gnus-group-kill-region
758 "\C-k" gnus-group-kill-level
759 "z" gnus-group-kill-all-zombies)
761 (defun gnus-topic-mode-p ()
762 "Return non-nil in `gnus-topic-mode'."
763 (and (boundp 'gnus-topic-mode)
764 (symbol-value 'gnus-topic-mode)))
766 (defun gnus-group-make-menu-bar ()
767 (gnus-turn-off-edit-menu 'group)
768 (unless (boundp 'gnus-group-reading-menu)
771 gnus-group-reading-menu gnus-group-mode-map ""
773 ["Read" gnus-group-read-group
774 :included (not (gnus-topic-mode-p))
775 :active (gnus-group-group-name)]
776 ["Read " gnus-topic-read-group
777 :included (gnus-topic-mode-p)]
778 ["Select" gnus-group-select-group
779 :included (not (gnus-topic-mode-p))
780 :active (gnus-group-group-name)]
781 ["Select " gnus-topic-select-group
782 :included (gnus-topic-mode-p)]
783 ["See old articles" (gnus-group-select-group 'all)
784 :keys "C-u SPC" :active (gnus-group-group-name)]
785 ["Catch up" gnus-group-catchup-current
786 :included (not (gnus-topic-mode-p))
787 :active (gnus-group-group-name)
788 ,@(if (featurep 'xemacs) nil
789 '(:help "Mark unread articles in the current group as read"))]
790 ["Catch up " gnus-topic-catchup-articles
791 :included (gnus-topic-mode-p)
792 ,@(if (featurep 'xemacs) nil
793 '(:help "Mark unread articles in the current group or topic as read"))]
794 ["Catch up all articles" gnus-group-catchup-current-all
795 (gnus-group-group-name)]
796 ["Check for new articles" gnus-group-get-new-news-this-group
797 :included (not (gnus-topic-mode-p))
798 :active (gnus-group-group-name)
799 ,@(if (featurep 'xemacs) nil
800 '(:help "Check for new messages in current group"))]
801 ["Check for new articles " gnus-topic-get-new-news-this-topic
802 :included (gnus-topic-mode-p)
803 ,@(if (featurep 'xemacs) nil
804 '(:help "Check for new messages in current group or topic"))]
805 ["Toggle subscription" gnus-group-unsubscribe-current-group
806 (gnus-group-group-name)]
807 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
808 ,@(if (featurep 'xemacs) nil
809 '(:help "Kill (remove) current group"))]
810 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
811 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
812 ,@(if (featurep 'xemacs) nil
813 '(:help "Display description of the current group"))]
814 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
815 ["Fetch charter" gnus-group-fetch-charter
816 :active (gnus-group-group-name)
817 ,@(if (featurep 'xemacs) nil
818 '(:help "Display the charter of the current group"))]
819 ["Fetch control message" gnus-group-fetch-control
820 :active (gnus-group-group-name)
821 ,@(if (featurep 'xemacs) nil
822 '(:help "Display the archived control message for the current group"))]
823 ;; Actually one should check, if any of the marked groups gives t for
824 ;; (gnus-check-backend-function 'request-expire-articles ...)
825 ["Expire articles" gnus-group-expire-articles
826 :included (not (gnus-topic-mode-p))
827 :active (or (and (gnus-group-group-name)
828 (gnus-check-backend-function
829 'request-expire-articles
830 (gnus-group-group-name))) gnus-group-marked)]
831 ["Expire articles " gnus-topic-expire-articles
832 :included (gnus-topic-mode-p)]
833 ["Set group level..." gnus-group-set-current-level
834 (gnus-group-group-name)]
835 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
836 ["Customize" gnus-group-customize (gnus-group-group-name)]
838 ["Parameters" gnus-group-edit-group-parameters
839 :included (not (gnus-topic-mode-p))
840 :active (gnus-group-group-name)]
841 ["Parameters " gnus-topic-edit-parameters
842 :included (gnus-topic-mode-p)]
843 ["Select method" gnus-group-edit-group-method
844 (gnus-group-group-name)]
845 ["Info" gnus-group-edit-group (gnus-group-group-name)]
846 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
847 ["Global kill file" gnus-group-edit-global-kill t])))
850 gnus-group-group-menu gnus-group-mode-map ""
853 ["List unread subscribed groups" gnus-group-list-groups t]
854 ["List (un)subscribed groups" gnus-group-list-all-groups t]
855 ["List killed groups" gnus-group-list-killed gnus-killed-list]
856 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
857 ["List level..." gnus-group-list-level t]
858 ["Describe all groups" gnus-group-describe-all-groups t]
859 ["Group apropos..." gnus-group-apropos t]
860 ["Group and description apropos..." gnus-group-description-apropos t]
861 ["List groups matching..." gnus-group-list-matching t]
862 ["List all groups matching..." gnus-group-list-all-matching t]
863 ["List active file" gnus-group-list-active t]
864 ["List groups with cached" gnus-group-list-cached t]
865 ["List groups with dormant" gnus-group-list-dormant t])
867 ["Default sort" gnus-group-sort-groups t]
868 ["Sort by method" gnus-group-sort-groups-by-method t]
869 ["Sort by rank" gnus-group-sort-groups-by-rank t]
870 ["Sort by score" gnus-group-sort-groups-by-score t]
871 ["Sort by level" gnus-group-sort-groups-by-level t]
872 ["Sort by unread" gnus-group-sort-groups-by-unread t]
873 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
874 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
875 ("Sort process/prefixed"
876 ["Default sort" gnus-group-sort-selected-groups
877 (not (gnus-topic-mode-p))]
878 ["Sort by method" gnus-group-sort-selected-groups-by-method
879 (not (gnus-topic-mode-p))]
880 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
881 (not (gnus-topic-mode-p))]
882 ["Sort by score" gnus-group-sort-selected-groups-by-score
883 (not (gnus-topic-mode-p))]
884 ["Sort by level" gnus-group-sort-selected-groups-by-level
885 (not (gnus-topic-mode-p))]
886 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
887 (not (gnus-topic-mode-p))]
888 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
889 (not (gnus-topic-mode-p))]
890 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
891 (not (gnus-topic-mode-p))])
893 ["Mark group" gnus-group-mark-group
894 (and (gnus-group-group-name)
895 (not (memq (gnus-group-group-name) gnus-group-marked)))]
896 ["Unmark group" gnus-group-unmark-group
897 (and (gnus-group-group-name)
898 (memq (gnus-group-group-name) gnus-group-marked))]
899 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
900 ["Mark regexp..." gnus-group-mark-regexp t]
901 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
902 ["Mark buffer" gnus-group-mark-buffer t]
903 ["Execute command" gnus-group-universal-argument
904 (or gnus-group-marked (gnus-group-group-name))])
906 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
907 ["Kill all newsgroups in region" gnus-group-kill-region
908 :active (gnus-mark-active-p)]
909 ["Kill all zombie groups" gnus-group-kill-all-zombies
911 ["Kill all groups on level..." gnus-group-kill-level t])
913 ["Make a foreign group..." gnus-group-make-group t]
914 ["Add a directory group..." gnus-group-make-directory-group t]
915 ["Add the help group" gnus-group-make-help-group t]
916 ["Add the archive group" gnus-group-make-archive-group t]
917 ["Make a doc group..." gnus-group-make-doc-group t]
918 ["Make a web group..." gnus-group-make-web-group t]
919 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
920 ["Make a virtual group..." gnus-group-make-empty-virtual t]
921 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
922 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
923 ["Make an RSS group..." gnus-group-make-rss-group t]
924 ["Rename group..." gnus-group-rename-group
925 (gnus-check-backend-function
926 'request-rename-group (gnus-group-group-name))]
927 ["Delete group" gnus-group-delete-group
928 (gnus-check-backend-function
929 'request-delete-group (gnus-group-group-name))])
931 ["Next" gnus-group-next-group t]
932 ["Previous" gnus-group-prev-group t]
933 ["Next unread" gnus-group-next-unread-group t]
934 ["Previous unread" gnus-group-prev-unread-group t]
935 ["Next unread same level" gnus-group-next-unread-group-same-level t]
936 ["Previous unread same level"
937 gnus-group-prev-unread-group-same-level t]
938 ["Jump to group..." gnus-group-jump-to-group t]
939 ["First unread group" gnus-group-first-unread-group t]
940 ["Best unread group" gnus-group-best-unread-group t])
942 ["Generate" gnus-sieve-generate t]
943 ["Generate and update" gnus-sieve-update t])
944 ["Delete bogus groups" gnus-group-check-bogus-groups t]
945 ["Find new newsgroups" gnus-group-find-new-groups t]
946 ["Transpose" gnus-group-transpose-groups
947 (gnus-group-group-name)]
948 ["Read a directory as a group..." gnus-group-enter-directory t]))
951 gnus-group-misc-menu gnus-group-mode-map ""
954 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
955 ["Send replies" gnus-soup-send-replies
956 (fboundp 'gnus-soup-pack-packet)]
957 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
958 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
959 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
960 ["Send a mail" gnus-group-mail t]
961 ["Send a message (mail or news)" gnus-group-post-news t]
962 ["Create a local message" gnus-group-news t]
963 ["Check for new news" gnus-group-get-new-news
964 ,@(if (featurep 'xemacs) '(t)
965 '(:help "Get newly arrived articles"))
967 ["Send queued messages" gnus-delay-send-queue
968 ,@(if (featurep 'xemacs) '(t)
969 '(:help "Send all messages that are scheduled to be sent now"))
971 ["Activate all groups" gnus-activate-all-groups t]
972 ["Restart Gnus" gnus-group-restart t]
973 ["Read init file" gnus-group-read-init-file t]
974 ["Browse foreign server..." gnus-group-browse-foreign-server t]
975 ["Enter server buffer" gnus-group-enter-server-mode t]
976 ["Expire all expirable articles" gnus-group-expire-all-groups t]
977 ["Generate any kiboze groups" nnkiboze-generate-groups t]
978 ["Gnus version" gnus-version t]
979 ["Save .newsrc files" gnus-group-save-newsrc t]
980 ["Suspend Gnus" gnus-group-suspend t]
981 ["Clear dribble buffer" gnus-group-clear-dribble t]
982 ["Read manual" gnus-info-find-node t]
983 ["Flush score cache" gnus-score-flush-cache t]
984 ["Toggle topics" gnus-topic-mode t]
985 ["Send a bug report" gnus-bug t]
986 ["Exit from Gnus" gnus-group-exit
987 ,@(if (featurep 'xemacs) '(t)
988 '(:help "Quit reading news"))]
989 ["Exit without saving" gnus-group-quit t]))
991 (gnus-run-hooks 'gnus-group-menu-hook)))
993 (defvar gnus-group-toolbar-map nil)
995 ;; Emacs 21 tool bar. Should be no-op otherwise.
996 (defun gnus-group-make-tool-bar ()
998 (condition-case nil (require 'tool-bar) (error nil))
999 (fboundp 'tool-bar-add-item-from-menu)
1000 (default-value 'tool-bar-mode)
1001 (not gnus-group-toolbar-map))
1002 (setq gnus-group-toolbar-map
1003 (let ((tool-bar-map (make-sparse-keymap))
1004 (load-path (mm-image-load-path)))
1005 (tool-bar-add-item-from-menu
1006 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
1007 (tool-bar-add-item-from-menu
1008 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
1009 (tool-bar-add-item-from-menu
1010 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
1011 (tool-bar-add-item-from-menu
1012 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
1013 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
1014 :help "Subscribe to the current group")
1015 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
1017 :help "Unsubscribe from the current group")
1018 (tool-bar-add-item-from-menu
1019 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
1021 (if gnus-group-toolbar-map
1022 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
1024 (defun gnus-group-mode ()
1025 "Major mode for reading news.
1027 All normal editing commands are switched off.
1028 \\<gnus-group-mode-map>
1029 The group buffer lists (some of) the groups available. For instance,
1030 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1031 lists all zombie groups.
1033 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1034 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1036 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1038 The following commands are available:
1040 \\{gnus-group-mode-map}"
1042 (kill-all-local-variables)
1043 (when (gnus-visual-p 'group-menu 'menu)
1044 (gnus-group-make-menu-bar)
1045 (gnus-group-make-tool-bar))
1046 (gnus-simplify-mode-line)
1047 (setq major-mode 'gnus-group-mode)
1048 (setq mode-name "Group")
1049 (gnus-group-set-mode-line)
1050 (setq mode-line-process nil)
1051 (use-local-map gnus-group-mode-map)
1052 (buffer-disable-undo)
1053 (setq truncate-lines t)
1054 (setq buffer-read-only t
1055 show-trailing-whitespace nil)
1056 (gnus-set-default-directory)
1057 (gnus-update-format-specifications nil 'group 'group-mode)
1058 (gnus-update-group-mark-positions)
1063 (gnus-run-hooks 'gnus-group-mode-hook))
1065 (defun gnus-update-group-mark-positions ()
1067 (let ((gnus-process-mark ?\200)
1068 (gnus-group-update-hook nil)
1069 (gnus-group-marked '("dummy.group"))
1070 (gnus-active-hashtb (make-vector 10 0))
1072 (gnus-set-active "dummy.group" '(0 . 0))
1073 (gnus-set-work-buffer)
1074 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1075 (goto-char (point-min))
1076 (setq gnus-group-mark-positions
1077 (list (cons 'process (and (search-forward
1078 (mm-string-as-multibyte "\200") nil t)
1079 (- (point) 2))))))))
1081 (defun gnus-mouse-pick-group (e)
1082 "Enter the group under the mouse pointer."
1085 (gnus-group-read-group nil))
1087 ;; Look at LEVEL and find out what the level is really supposed to be.
1088 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1089 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1090 (defun gnus-group-default-level (&optional level number-or-nil)
1092 (gnus-group-use-permanent-levels
1093 (or (setq gnus-group-use-permanent-levels
1094 (or level (if (numberp gnus-group-use-permanent-levels)
1095 gnus-group-use-permanent-levels
1096 (or gnus-group-default-list-level
1097 gnus-level-subscribed))))
1098 gnus-group-default-list-level gnus-level-subscribed))
1102 (or level gnus-group-default-list-level gnus-level-subscribed))))
1104 (defun gnus-group-setup-buffer ()
1105 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1106 (unless (eq major-mode 'gnus-group-mode)
1109 (gnus-carpal-setup-buffer 'group))))
1111 (defun gnus-group-name-charset (method group)
1113 (setq method (gnus-find-method-for-group group)))
1114 (let ((item (assoc method gnus-group-name-charset-method-alist))
1115 (alist gnus-group-name-charset-group-alist)
1119 (while (setq item (pop alist))
1120 (if (string-match (car item) group)
1122 result (cdr item))))
1125 (defun gnus-group-name-decode (string charset)
1126 ;; Fixme: Don't decode in unibyte mode.
1127 (if (and string charset (featurep 'mule))
1128 (mm-decode-coding-string string charset)
1131 (defun gnus-group-decoded-name (string)
1132 (let ((charset (gnus-group-name-charset nil string)))
1133 (gnus-group-name-decode string charset)))
1135 (defun gnus-group-list-groups (&optional level unread lowest)
1136 "List newsgroups with level LEVEL or lower that have unread articles.
1137 Default is all subscribed groups.
1138 If argument UNREAD is non-nil, groups with no unread articles are also
1141 Also see the `gnus-group-use-permanent-levels' variable."
1143 (list (if current-prefix-arg
1144 (prefix-numeric-value current-prefix-arg)
1146 (gnus-group-default-level nil t)
1147 gnus-group-default-list-level
1148 gnus-level-subscribed))))
1150 (setq level (car gnus-group-list-mode)
1151 unread (cdr gnus-group-list-mode)))
1152 (setq level (gnus-group-default-level level))
1153 (gnus-group-setup-buffer)
1154 (gnus-update-format-specifications nil 'group 'group-mode)
1155 (let ((case-fold-search nil)
1156 (props (text-properties-at (point-at-bol)))
1157 (empty (= (point-min) (point-max)))
1158 (group (gnus-group-group-name))
1160 (set-buffer gnus-group-buffer)
1161 (setq number (funcall gnus-group-prepare-function level unread lowest))
1162 (when (or (and (numberp number)
1164 (zerop (buffer-size)))
1165 ;; No groups in the buffer.
1166 (gnus-message 5 gnus-no-groups-message))
1167 ;; We have some groups displayed.
1168 (goto-char (point-max))
1169 (when (or (not gnus-group-goto-next-group-function)
1170 (not (funcall gnus-group-goto-next-group-function
1174 (goto-char (point-min)))
1176 ;; Go to the first group with unread articles.
1177 (gnus-group-search-forward t))
1179 ;; Find the right group to put point on. If the current group
1180 ;; has disappeared in the new listing, try to find the next
1181 ;; one. If no next one can be found, just leave point at the
1182 ;; first newsgroup in the buffer.
1183 (when (not (gnus-goto-char
1185 (point-min) (point-max)
1186 'gnus-group (gnus-intern-safe
1187 group gnus-active-hashtb))))
1188 (let ((newsrc (cdddr (gnus-group-entry group))))
1190 (not (gnus-goto-char
1192 (point-min) (point-max) 'gnus-group
1194 (caar newsrc) gnus-active-hashtb)))))
1195 (setq newsrc (cdr newsrc)))
1197 (goto-char (point-max))
1198 (forward-line -1)))))))
1199 ;; Adjust cursor point.
1200 (gnus-group-position-point)))
1202 (defun gnus-group-list-level (level &optional all)
1203 "List groups on LEVEL.
1204 If ALL (the prefix), also list groups that have no unread articles."
1205 (interactive "nList groups on level: \nP")
1206 (gnus-group-list-groups level all level))
1208 (defun gnus-group-prepare-logic (group test)
1209 (or (and gnus-group-listed-groups
1210 (null gnus-group-list-option)
1211 (member group gnus-group-listed-groups))
1213 ((null gnus-group-listed-groups) test)
1214 ((null gnus-group-list-option) test)
1215 (t (and (member group gnus-group-listed-groups)
1216 (if (eq gnus-group-list-option 'flush)
1220 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1221 "List all newsgroups with unread articles of level LEVEL or lower.
1222 If PREDICATE is a function, list groups that the function returns non-nil;
1223 if it is t, list groups that have no unread articles.
1224 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1225 If REGEXP is a function, list dead groups that the function returns non-nil;
1226 if it is a string, only list groups matching REGEXP."
1227 (set-buffer gnus-group-buffer)
1228 (let ((buffer-read-only nil)
1229 (newsrc (cdr gnus-newsrc-alist))
1230 (lowest (or lowest 1))
1231 (not-in-list (and gnus-group-listed-groups
1232 (copy-sequence gnus-group-listed-groups)))
1233 info clevel unread group params)
1235 (when (or (< lowest gnus-level-zombie)
1236 gnus-group-listed-groups)
1237 ;; List living groups.
1239 (setq info (car newsrc)
1240 group (gnus-info-group info)
1241 params (gnus-info-params info)
1243 unread (gnus-group-unread group))
1245 (setq not-in-list (delete group not-in-list)))
1246 (when (gnus-group-prepare-logic
1248 (and unread ; This group might be unchecked
1249 (or (not (stringp regexp))
1250 (string-match regexp group))
1251 (<= (setq clevel (gnus-info-level info)) level)
1254 ((functionp predicate)
1255 (funcall predicate info))
1256 (predicate t) ; We list all groups?
1259 (if (eq unread t) ; Unactivated?
1260 gnus-group-list-inactive-groups
1261 ; We list unactivated
1263 ; We list groups with unread articles
1264 (and gnus-list-groups-with-ticked-articles
1265 (cdr (assq 'tick (gnus-info-marks info))))
1266 ; And groups with tickeds
1267 ;; Check for permanent visibility.
1268 (and gnus-permanently-visible-groups
1269 (string-match gnus-permanently-visible-groups
1271 (memq 'visible params)
1272 (cdr (assq 'visible params)))))))
1273 (gnus-group-insert-group-line
1274 group (gnus-info-level info)
1275 (gnus-info-marks info) unread (gnus-info-method info)))))
1277 ;; List dead groups.
1278 (when (or gnus-group-listed-groups
1279 (and (>= level gnus-level-zombie)
1280 (<= lowest gnus-level-zombie)))
1281 (gnus-group-prepare-flat-list-dead
1282 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1283 gnus-level-zombie ?Z
1286 (dolist (group gnus-zombie-list)
1287 (setq not-in-list (delete group not-in-list))))
1288 (when (or gnus-group-listed-groups
1289 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1290 (gnus-group-prepare-flat-list-dead
1293 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1294 gnus-level-killed ?K regexp))
1296 (gnus-group-set-mode-line)
1297 (setq gnus-group-list-mode (cons level predicate))
1298 (gnus-run-hooks 'gnus-group-prepare-hook)
1301 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1302 ;; List zombies and killed lists somewhat faster, which was
1303 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1304 ;; this by ignoring the group format specification altogether.
1306 (if (> (length groups) gnus-group-listing-limit)
1308 (setq group (pop groups))
1309 (when (gnus-group-prepare-logic
1312 (and (stringp regexp) (string-match regexp group))
1313 (and (functionp regexp) (funcall regexp group))))
1314 (gnus-add-text-properties
1315 (point) (prog1 (1+ (point))
1316 (insert " " mark " *: "
1317 (gnus-group-decoded-name group)
1319 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1321 'gnus-level level))))
1323 (setq group (pop groups))
1324 (when (gnus-group-prepare-logic
1327 (and (stringp regexp) (string-match regexp group))
1328 (and (functionp regexp) (funcall regexp group))))
1329 (gnus-group-insert-group-line
1331 (let ((active (gnus-active group)))
1333 (if (zerop (cdr active))
1335 (- (1+ (cdr active)) (car active)))
1337 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1339 (defun gnus-group-update-group-line ()
1340 "Update the current line in the group buffer."
1341 (let* ((buffer-read-only nil)
1342 (group (gnus-group-group-name))
1343 (entry (and group (gnus-group-entry group)))
1344 gnus-group-indentation)
1347 (not (gnus-ephemeral-group-p group))
1349 (concat "(gnus-group-set-info '"
1350 (gnus-prin1-to-string (nth 2 entry))
1352 (setq gnus-group-indentation (gnus-group-group-indentation))
1354 (gnus-group-insert-group-line-info group)
1356 (gnus-group-position-point))))
1358 (defun gnus-group-insert-group-line-info (group)
1359 "Insert GROUP on the current line."
1360 (let ((entry (gnus-group-entry group))
1361 (gnus-group-indentation (gnus-group-group-indentation))
1365 ;; (Un)subscribed group.
1366 (setq info (nth 2 entry))
1367 (gnus-group-insert-group-line
1368 group (gnus-info-level info) (gnus-info-marks info)
1369 (or (car entry) t) (gnus-info-method info)))
1370 ;; This group is dead.
1371 (gnus-group-insert-group-line
1373 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1375 (if (setq active (gnus-active group))
1376 (if (zerop (cdr active))
1378 (- (1+ (cdr active)) (car active)))
1380 (gnus-method-simplify (gnus-find-method-for-group group))))))
1382 (defun gnus-number-of-unseen-articles-in-group (group)
1383 (let* ((info (nth 2 (gnus-group-entry group)))
1384 (marked (gnus-info-marks info))
1385 (seen (cdr (assq 'seen marked)))
1386 (active (gnus-active group)))
1389 (length (gnus-uncompress-range
1390 (gnus-range-difference
1391 (gnus-range-difference (list active) (gnus-info-read info))
1394 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1395 gnus-tmp-marked number
1397 "Insert a group line in the group buffer."
1398 (let* ((gnus-tmp-method
1399 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1400 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1402 (gnus-tmp-active (gnus-active gnus-tmp-group))
1403 (gnus-tmp-number-total
1405 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1407 (gnus-tmp-number-of-unread
1408 (if (numberp number) (int-to-string (max 0 number))
1410 (gnus-tmp-number-of-read
1411 (if (numberp number)
1412 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1414 (gnus-tmp-subscribed
1415 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1416 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1417 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1419 (gnus-tmp-qualified-group
1420 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1421 group-name-charset))
1423 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1425 (gnus-tmp-newsgroup-description
1426 (if gnus-description-hashtb
1427 (or (gnus-group-name-decode
1428 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1429 group-name-charset) "")
1432 (if (and gnus-moderated-hashtb
1433 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1435 (gnus-tmp-moderated-string
1436 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1437 (gnus-tmp-group-icon "==&&==")
1438 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1439 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1440 (gnus-tmp-news-method-string
1442 (format "(%s:%s)" (car gnus-tmp-method)
1443 (cadr gnus-tmp-method)) ""))
1444 (gnus-tmp-marked-mark
1445 (if (and (numberp number)
1447 (cdr (assq 'tick gnus-tmp-marked)))
1449 (gnus-tmp-summary-live
1450 (if (and (not gnus-group-is-exiting-p)
1451 (gnus-buffer-live-p (gnus-summary-buffer-name
1454 (gnus-tmp-process-marked
1455 (if (member gnus-tmp-group gnus-group-marked)
1456 gnus-process-mark ? ))
1457 (buffer-read-only nil)
1458 header gnus-tmp-header) ; passed as parameter to user-funcs.
1460 (gnus-add-text-properties
1464 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1465 gnus-tmp-group group-name-charset)))
1466 (eval gnus-group-line-format-spec)))
1467 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1468 gnus-unread ,(if (numberp number)
1469 (string-to-int gnus-tmp-number-of-unread)
1471 gnus-marked ,gnus-tmp-marked-mark
1472 gnus-indentation ,gnus-group-indentation
1473 gnus-level ,gnus-tmp-level))
1475 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1476 (gnus-run-hooks 'gnus-group-update-hook))
1478 ;; Allow XEmacs to remove front-sticky text properties.
1479 (gnus-group-remove-excess-properties)))
1481 (defun gnus-group-highlight-line ()
1482 "Highlight the current line according to `gnus-group-highlight'."
1483 (let* ((list gnus-group-highlight)
1485 (end (point-at-eol))
1486 ;; now find out where the line starts and leave point there.
1487 (beg (progn (beginning-of-line) (point)))
1488 (group (gnus-group-group-name))
1489 (entry (gnus-group-entry group))
1490 (unread (if (numberp (car entry)) (car entry) 0))
1491 (active (gnus-active group))
1492 (total (if active (1+ (- (cdr active) (car active))) 0))
1493 (info (nth 2 entry))
1494 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1495 (marked (gnus-info-marks info))
1496 (mailp (apply 'append
1499 (memq x (assoc (symbol-name
1500 (car (or method gnus-select-method)))
1501 gnus-valid-select-methods)))
1502 '(mail post-mail))))
1503 (level (or (gnus-info-level info) gnus-level-killed))
1504 (score (or (gnus-info-score info) 0))
1505 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1506 (group-age (gnus-group-timestamp-delta group))
1507 (inhibit-read-only t))
1508 ;; Eval the cars of the lists until we find a match.
1510 (not (eval (caar list))))
1511 (setq list (cdr list)))
1512 (let ((face (cdar list)))
1513 (unless (eq face (get-text-property beg 'face))
1514 (gnus-put-text-property-excluding-characters-with-faces
1516 (setq face (if (boundp face) (symbol-value face) face)))
1517 (gnus-extent-start-open beg)))
1520 (defun gnus-group-update-group (group &optional visible-only)
1521 "Update all lines where GROUP appear.
1522 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1524 ;; Can't use `save-excursion' here, so we do it manually.
1525 (let ((buf (current-buffer))
1527 (set-buffer gnus-group-buffer)
1528 (setq mark (point-marker))
1529 ;; The buffer may be narrowed.
1532 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1534 found buffer-read-only)
1535 ;; Enter the current status into the dribble buffer.
1536 (let ((entry (gnus-group-entry group)))
1538 (not (gnus-ephemeral-group-p group)))
1540 (concat "(gnus-group-set-info '"
1541 (gnus-prin1-to-string (nth 2 entry))
1543 ;; Find all group instances. If topics are in use, each group
1544 ;; may be listed in more than once.
1545 (while (setq loc (text-property-any
1546 loc (point-max) 'gnus-group ident))
1549 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1551 (gnus-group-insert-group-line-info group)
1554 (gnus-run-hooks 'gnus-group-update-group-hook)))
1555 (setq loc (1+ loc)))
1556 (unless (or found visible-only)
1557 ;; No such line in the buffer, find out where it's supposed to
1558 ;; go, and insert it there (or at the end of the buffer).
1559 (if gnus-goto-missing-group-function
1560 (funcall gnus-goto-missing-group-function group)
1561 (let ((entry (cddr (gnus-group-entry group))))
1562 (while (and entry (car entry)
1566 (point-min) (point-max)
1567 'gnus-group (gnus-intern-safe
1568 (caar entry) gnus-active-hashtb)))))
1569 (setq entry (cdr entry)))
1570 (or entry (goto-char (point-max)))))
1571 ;; Finally insert the line.
1572 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1573 (gnus-group-insert-group-line-info group)
1576 (gnus-run-hooks 'gnus-group-update-group-hook))))
1577 (when gnus-group-update-group-function
1578 (funcall gnus-group-update-group-function group))
1579 (gnus-group-set-mode-line)))
1581 (set-marker mark nil)
1584 (defun gnus-group-set-mode-line ()
1585 "Update the mode line in the group buffer."
1586 (when (memq 'group gnus-updated-mode-lines)
1587 ;; Yes, we want to keep this mode line updated.
1589 (set-buffer gnus-group-buffer)
1590 (let* ((gformat (or gnus-group-mode-line-format-spec
1591 (gnus-set-format 'group-mode)))
1592 (gnus-tmp-news-server (cadr gnus-select-method))
1593 (gnus-tmp-news-method (car gnus-select-method))
1594 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1596 gnus-tmp-header ;Dummy binding for user-defined formats
1597 ;; Get the resulting string.
1599 (and gnus-dribble-buffer
1600 (buffer-name gnus-dribble-buffer)
1601 (buffer-modified-p gnus-dribble-buffer)
1603 (set-buffer gnus-dribble-buffer)
1604 (not (zerop (buffer-size))))))
1605 (mode-string (eval gformat)))
1606 ;; Say whether the dribble buffer has been modified.
1607 (setq mode-line-modified
1608 (if modified (car gnus-mode-line-modified)
1609 (cdr gnus-mode-line-modified)))
1610 ;; If the line is too long, we chop it off.
1611 (when (> (length mode-string) max-len)
1612 (setq mode-string (substring mode-string 0 (- max-len 4))))
1614 (setq mode-line-buffer-identification
1615 (gnus-mode-line-buffer-identification
1616 (list mode-string)))
1617 (set-buffer-modified-p modified))))))
1619 (defun gnus-group-group-name ()
1620 "Get the name of the newsgroup on the current line."
1621 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1623 (symbol-name group))))
1625 (defun gnus-group-group-level ()
1626 "Get the level of the newsgroup on the current line."
1627 (get-text-property (point-at-bol) 'gnus-level))
1629 (defun gnus-group-group-indentation ()
1630 "Get the indentation of the newsgroup on the current line."
1631 (or (get-text-property (point-at-bol) 'gnus-indentation)
1632 (and gnus-group-indentation-function
1633 (funcall gnus-group-indentation-function))
1636 (defun gnus-group-group-unread ()
1637 "Get the number of unread articles of the newsgroup on the current line."
1638 (get-text-property (point-at-bol) 'gnus-unread))
1640 (defun gnus-group-new-mail (group)
1641 (if (nnmail-new-mail-p (gnus-group-real-name group))
1645 (defun gnus-group-level (group)
1646 "Return the estimated level of GROUP."
1647 (or (gnus-info-level (gnus-get-info group))
1648 (and (member group gnus-zombie-list) gnus-level-zombie)
1651 (defun gnus-group-search-forward (&optional backward all level first-too)
1652 "Find the next newsgroup with unread articles.
1653 If BACKWARD is non-nil, find the previous newsgroup instead.
1654 If ALL is non-nil, just find any newsgroup.
1655 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1657 If FIRST-TOO, the current line is also eligible as a target."
1658 (let ((way (if backward -1 1))
1659 (low gnus-level-killed)
1662 (if (and backward (progn (beginning-of-line)) (bobp))
1671 (get-text-property (point) 'gnus-group)
1675 (get-text-property (point) 'gnus-unread)))
1676 (and (numberp unread) (> unread 0)))
1677 (setq lev (get-text-property (point)
1679 (<= lev gnus-level-subscribed)))
1681 (and (setq lev (get-text-property (point)
1690 (zerop (forward-line way)))))
1692 (progn (gnus-group-position-point) t)
1693 (goto-char (or pos beg))
1696 (defun gnus-total-fetched-for (group)
1697 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1698 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1699 (size (+ size-in-cache size-in-agent))
1700 (suffix '("B" "K" "M" "G"))
1702 (cutoff (* 10 scale)))
1703 (while (> size cutoff)
1704 (setq size (/ size scale)
1705 suffix (cdr suffix)))
1706 (format "%5.1f%s" size (car suffix))))
1708 ;;; Gnus group mode commands
1712 (defun gnus-group-mark-line-p ()
1715 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1716 (eq (char-after) gnus-process-mark)))
1718 (defun gnus-group-mark-group (n &optional unmark no-advance)
1719 "Mark the current group."
1721 (let ((buffer-read-only nil)
1725 (when (setq group (gnus-group-group-name))
1726 ;; Go to the mark position.
1728 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1732 (setq gnus-group-marked (delete group gnus-group-marked))
1733 (insert-char ? 1 t))
1734 (setq gnus-group-marked
1735 (cons group (delete group gnus-group-marked)))
1736 (insert-char gnus-process-mark 1 t)))
1738 (gnus-group-next-group 1))
1740 (gnus-summary-position-point)
1743 (defun gnus-group-unmark-group (n)
1744 "Remove the mark from the current group."
1746 (gnus-group-mark-group n 'unmark)
1747 (gnus-group-position-point))
1749 (defun gnus-group-unmark-all-groups ()
1750 "Unmark all groups."
1753 (mapc 'gnus-group-remove-mark gnus-group-marked))
1754 (gnus-group-position-point))
1756 (defun gnus-group-mark-region (unmark beg end)
1757 "Mark all groups between point and mark.
1758 If UNMARK, remove the mark instead."
1759 (interactive "P\nr")
1760 (let ((num (count-lines beg end)))
1763 (- num (gnus-group-mark-group num unmark)))))
1765 (defun gnus-group-mark-buffer (&optional unmark)
1766 "Mark all groups in the buffer.
1767 If UNMARK, remove the mark instead."
1769 (gnus-group-mark-region unmark (point-min) (point-max)))
1771 (defun gnus-group-mark-regexp (regexp)
1772 "Mark all groups that match some regexp."
1773 (interactive "sMark (regexp): ")
1774 (let ((alist (cdr gnus-newsrc-alist))
1778 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1779 (gnus-group-jump-to-group group)
1780 (gnus-group-set-mark group)))))
1781 (gnus-group-position-point))
1783 (defun gnus-group-remove-mark (group &optional test-marked)
1784 "Remove the process mark from GROUP and move point there.
1785 Return nil if the group isn't displayed."
1786 (if (gnus-group-goto-group group nil test-marked)
1788 (gnus-group-mark-group 1 'unmark t)
1790 (setq gnus-group-marked
1791 (delete group gnus-group-marked))
1794 (defun gnus-group-set-mark (group)
1795 "Set the process mark on GROUP."
1796 (if (gnus-group-goto-group group)
1798 (gnus-group-mark-group 1 nil t))
1799 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1801 (defun gnus-group-universal-argument (arg &optional groups func)
1802 "Perform any command on all groups according to the process/prefix convention."
1804 (if (eq (setq func (or func
1807 (substitute-command-keys
1808 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1810 (gnus-error 1 "Undefined key")
1811 (gnus-group-iterate arg
1813 (command-execute func))))
1814 (gnus-group-position-point))
1816 (defun gnus-group-process-prefix (n)
1817 "Return a list of groups to work on.
1818 Take into consideration N (the prefix) and the list of marked groups."
1821 (setq n (prefix-numeric-value n))
1822 ;; There is a prefix, so we return a list of the N next
1824 (let ((way (if (< n 0) -1 1))
1829 (if (setq group (gnus-group-group-name))
1830 (push group groups))
1832 (gnus-group-next-group way)))
1834 ((and (gnus-region-active-p) (mark))
1835 ;; Work on the region between point and mark.
1836 (let ((max (max (point) (mark)))
1839 (goto-char (min (point) (mark)))
1842 (push (gnus-group-group-name) groups)
1843 (zerop (gnus-group-next-group 1))
1845 (nreverse groups))))
1847 ;; No prefix, but a list of marked articles.
1848 (reverse gnus-group-marked))
1850 ;; Neither marked articles or a prefix, so we return the
1852 (let ((group (gnus-group-group-name)))
1853 (and group (list group))))))
1855 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1856 ;;; imagine why I went through these contortions...
1858 (let ((function (make-symbol "gnus-group-iterate-function"))
1859 (window (make-symbol "gnus-group-iterate-window"))
1860 (groups (make-symbol "gnus-group-iterate-groups"))
1861 (group (make-symbol "gnus-group-iterate-group")))
1863 `(defun gnus-group-iterate (arg ,function)
1864 "Iterate FUNCTION over all process/prefixed groups.
1865 FUNCTION will be called with the group name as the parameter
1866 and with point over the group in question."
1867 (let ((,groups (gnus-group-process-prefix arg))
1868 (,window (selected-window))
1871 (setq ,group (car ,groups)
1872 ,groups (cdr ,groups))
1873 (select-window ,window)
1874 (gnus-group-remove-mark ,group)
1875 (save-selected-window
1877 (funcall ,function ,group)))))))))
1879 (put 'gnus-group-iterate 'lisp-indent-function 1)
1881 ;; Selecting groups.
1883 (defun gnus-group-read-group (&optional all no-article group select-articles)
1884 "Read news in this newsgroup.
1885 If the prefix argument ALL is non-nil, already read articles become
1886 readable. IF ALL is a number, fetch this number of articles. If the
1887 optional argument NO-ARTICLE is non-nil, no article will be
1888 auto-selected upon group entry. If GROUP is non-nil, fetch that
1891 (let ((no-display (eq all 0))
1892 (group (or group (gnus-group-group-name)))
1893 number active marked entry)
1897 (error "No group on current line"))
1898 (setq marked (gnus-info-marks
1899 (nth 2 (setq entry (gnus-group-entry group)))))
1900 ;; This group might be a dead group. In that case we have to get
1901 ;; the number of unread articles from `gnus-active-hashtb'.
1903 (cond ((numberp all) all)
1905 ((setq active (gnus-active group))
1906 (- (1+ (cdr active)) (car active)))))
1907 (gnus-summary-read-group
1908 group (or all (and (numberp number)
1909 (zerop (+ number (gnus-range-length
1910 (cdr (assq 'tick marked)))
1912 (cdr (assq 'dormant marked)))))))
1913 no-article nil no-display nil select-articles)))
1915 (defun gnus-group-select-group (&optional all)
1916 "Select this newsgroup.
1917 No article is selected automatically.
1918 If the group is opened, just switch the summary buffer.
1919 If ALL is non-nil, already read articles become readable.
1920 If ALL is a positive number, fetch this number of the latest