gnus-group.el 163 KB
Newer Older
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1
;;; gnus-group.el --- group mode commands for Gnus
2 3

;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
Glenn Morris's avatar
Glenn Morris committed
4
;;   2005, 2006, 2007 Free Software Foundation, Inc.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
5

6
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
7 8 9 10 11 12
;; Keywords: news

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
13
;; the Free Software Foundation; either version 3, or (at your option)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
14 15 16 17 18 19 20 21 22
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
Lute Kamstra's avatar
Lute Kamstra committed
23 24
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
25 26 27 28 29

;;; Commentary:

;;; Code:

30 31
(eval-when-compile
  (require 'cl)
32
  (defvar tool-bar-mode))
33

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
34 35 36 37 38 39 40 41
(require 'gnus)
(require 'gnus-start)
(require 'nnmail)
(require 'gnus-spec)
(require 'gnus-int)
(require 'gnus-range)
(require 'gnus-win)
(require 'gnus-undo)
42
(require 'gmm-utils)
43
(require 'time-date)
44 45
(require 'gnus-ems)

46 47 48 49
(eval-when-compile
  (require 'mm-url)
  (let ((features (cons 'gnus-group features)))
    (require 'gnus-sum))
50 51 52 53 54
  (unless (boundp 'gnus-cache-active-hashtb)
    (defvar gnus-cache-active-hashtb nil)))

(autoload 'gnus-agent-total-fetched-for "gnus-agent")
(autoload 'gnus-cache-total-fetched-for "gnus-cache")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
55 56

(defcustom gnus-group-archive-directory
57
  "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
58 59 60 61 62
  "*The address of the (ding) archives."
  :group 'gnus-group-foreign
  :type 'directory)

(defcustom gnus-group-recent-archive-directory
63
  "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
64 65 66 67
  "*The address of the most recent (ding) articles."
  :group 'gnus-group-foreign
  :type 'directory)

68
(defcustom gnus-no-groups-message "No Gnus is good news"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
  "*Message displayed by Gnus when no groups are available."
  :group 'gnus-start
  :type 'string)

(defcustom gnus-keep-same-level nil
  "*Non-nil means that the next newsgroup after the current will be on the same level.
When you type, for instance, `n' after reading the last article in the
current newsgroup, you will go to the next newsgroup.  If this variable
is nil, the next newsgroup will be the next from the group
buffer.
If this variable is non-nil, Gnus will either put you in the
next newsgroup with the same level, or, if no such newsgroup is
available, the next newsgroup with the lowest possible level higher
than the current level.
If this variable is `best', Gnus will make the next newsgroup the one
with the best level."
  :group 'gnus-group-levels
  :type '(choice (const nil)
		 (const best)
		 (sexp :tag "other" t)))

(defcustom gnus-group-goto-unread t
  "*If non-nil, movement commands will go to the next unread and subscribed group."
  :link '(custom-manual "(gnus)Group Maneuvering")
  :group 'gnus-group-various
  :type 'boolean)

(defcustom gnus-goto-next-group-when-activating t
  "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
  :link '(custom-manual "(gnus)Scanning New Messages")
  :group 'gnus-group-various
  :type 'boolean)

(defcustom gnus-permanently-visible-groups nil
  "*Regexp to match groups that should always be listed in the group buffer.
104 105 106 107
This means that they will still be listed even when there are no
unread articles in the groups.

If nil, no groups are permanently visible."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
108
  :group 'gnus-group-listing
109
  :type '(choice regexp (const nil)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134

(defcustom gnus-list-groups-with-ticked-articles t
  "*If non-nil, list groups that have only ticked articles.
If nil, only list groups that have unread articles."
  :group 'gnus-group-listing
  :type 'boolean)

(defcustom gnus-group-default-list-level gnus-level-subscribed
  "*Default listing level.
Ignored if `gnus-group-use-permanent-levels' is non-nil."
  :group 'gnus-group-listing
  :type 'integer)

(defcustom gnus-group-list-inactive-groups t
  "*If non-nil, inactive groups will be listed."
  :group 'gnus-group-listing
  :group 'gnus-group-levels
  :type 'boolean)

(defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
  "*Function used for sorting the group buffer.
This function will be called with group info entries as the arguments
for the groups to be sorted.  Pre-made functions include
`gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
`gnus-group-sort-by-unread', `gnus-group-sort-by-level',
135 136
`gnus-group-sort-by-score', `gnus-group-sort-by-method',
`gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
137

138
This variable can also be a list of sorting functions.  In that case,
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
139 140 141 142
the most significant sort function should be the last function in the
list."
  :group 'gnus-group-listing
  :link '(custom-manual "(gnus)Sorting Groups")
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
  :type '(repeat :value-to-internal (lambda (widget value)
				      (if (listp value) value (list value)))
		 :match (lambda (widget value)
			  (or (symbolp value)
			      (widget-editable-list-match widget value)))
		 (choice (function-item gnus-group-sort-by-alphabet)
			 (function-item gnus-group-sort-by-real-name)
			 (function-item gnus-group-sort-by-unread)
			 (function-item gnus-group-sort-by-level)
			 (function-item gnus-group-sort-by-score)
			 (function-item gnus-group-sort-by-method)
			 (function-item gnus-group-sort-by-server)
			 (function-item gnus-group-sort-by-rank)
			 (function :tag "other" nil))))

158
(defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
159 160 161 162 163 164 165 166 167 168 169 170
  "*Format of group lines.
It works along the same lines as a normal formatting string,
with some simple extensions.

%M    Only marked articles (character, \"*\" or \" \")
%S    Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
%L    Level of subscribedness (integer)
%N    Number of unread articles (integer)
%I    Number of dormant articles (integer)
%i    Number of ticked and dormant (integer)
%T    Number of ticked articles (integer)
%R    Number of read articles (integer)
171
%U    Number of unseen articles (integer)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
172 173 174 175
%t    Estimated total number of articles (integer)
%y    Number of unread, unticked articles (integer)
%G    Group name (string)
%g    Qualified group name (string)
176 177
%c    Short (collapsed) group name.  See `gnus-group-uncollapsed-levels'.
%C    Group comment (string)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
178 179 180 181
%D    Group description (string)
%s    Select method (string)
%o    Moderated group (char, \"m\")
%p    Process mark (char)
182
%B    Whether a summary buffer for the group is open (char, \"*\")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
183 184 185 186 187 188
%O    Moderated group (string, \"(m)\" or \"\")
%P    Topic indentation (string)
%m    Whether there is new(ish) mail in the group (char, \"%\")
%n    Select from where (string)
%z    A string that look like `<%s:%n>' if a foreign select method is used
%d    The date the group was last entered.
189
%E    Icon as defined by `gnus-group-icon-list'.
190
%F    The disk space used by the articles fetched by both the cache and agent.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
191 192
%u    User defined specifier.  The next character in the format string should
      be a letter.  Gnus will call the function gnus-user-format-function-X,
193 194 195 196
      where X is the letter following %u.  The function will be passed a
      single dummy parameter as argument.  The function should return a
      string, which will be inserted into the buffer just like information
      from any other group specifier.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
197 198 199

Note that this format specification is not always respected.  For
reasons of efficiency, when listing killed groups, this specification
200
is ignored altogether.  If the spec is changed considerably, your
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
201 202 203 204
output may end up looking strange when listing both alive and killed
groups.

If you use %o or %O, reading the active file will be slower and quite
205 206 207 208
a bit of extra memory will be used.  %D and %F will also worsen
performance.  Also note that if you change the format specification to
include any of these specs, you must probably re-start Gnus to see
them go into effect.
209 210 211 212

General format specifiers can also be used.
See Info node `(gnus)Formatting Variables'."
  :link '(custom-manual "(gnus)Formatting Variables")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
213 214 215 216 217 218 219 220 221 222 223 224 225 226
  :group 'gnus-group-visual
  :type 'string)

(defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
  "*The format specification for the group mode line.
It works along the same lines as a normal formatting string,
with some simple extensions:

%S   The native news server.
%M   The native select method.
%:   \":\" if %S isn't \"\"."
  :group 'gnus-group-visual
  :type 'string)

227 228 229 230
;; Extracted from gnus-xmas-redefine in order to preserve user settings
(when (featurep 'xemacs)
  (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
  (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291

(defcustom gnus-group-menu-hook nil
  "Hook run after the creation of the group mode menu."
  :group 'gnus-group-various
  :type 'hook)

(defcustom gnus-group-catchup-group-hook nil
  "Hook run when catching up a group from the group buffer."
  :group 'gnus-group-various
  :link '(custom-manual "(gnus)Group Data")
  :type 'hook)

(defcustom gnus-group-update-group-hook nil
  "Hook called when updating group lines."
  :group 'gnus-group-visual
  :type 'hook)

(defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
  "*A function that is called to generate the group buffer.
The function is called with three arguments: The first is a number;
all group with a level less or equal to that number should be listed,
if the second is non-nil, empty groups should also be displayed.  If
the third is non-nil, it is a number.  No groups with a level lower
than this number should be displayed.

The only current function implemented is `gnus-group-prepare-flat'."
  :group 'gnus-group-listing
  :type 'function)

(defcustom gnus-group-prepare-hook nil
  "Hook called after the group buffer has been generated.
If you want to modify the group buffer, you can use this hook."
  :group 'gnus-group-listing
  :type 'hook)

(defcustom gnus-suspend-gnus-hook nil
  "Hook called when suspending (not exiting) Gnus."
  :group 'gnus-exit
  :type 'hook)

(defcustom gnus-exit-gnus-hook nil
  "Hook called when exiting Gnus."
  :group 'gnus-exit
  :type 'hook)

(defcustom gnus-after-exiting-gnus-hook nil
  "Hook called after exiting Gnus."
  :group 'gnus-exit
  :type 'hook)

(defcustom gnus-group-update-hook '(gnus-group-highlight-line)
  "Hook called when a group line is changed.
The hook will not be called if `gnus-visual' is nil.

The default function `gnus-group-highlight-line' will
highlight the line according to the `gnus-group-highlight'
variable."
  :group 'gnus-group-visual
  :type 'hook)

(defcustom gnus-useful-groups
292 293 294 295 296 297 298 299 300
  '(("(ding) mailing list mirrored at gmane.org"
     "gmane.emacs.gnus.general"
     (nntp "Gmane"
	   (nntp-address "news.gmane.org")))
    ("Gnus bug archive"
     "gnus.gnus-bug"
     (nntp "news.gnus.org"
	   (nntp-address "news.gnus.org")))
    ("Local Gnus help group"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
301 302 303 304 305 306 307 308 309
     "gnus-help"
     (nndoc "gnus-help"
	    (nndoc-article-type mbox)
	    (eval `(nndoc-address
		    ,(let ((file (nnheader-find-etc-directory
				  "gnus-tut.txt" t)))
		       (unless file
			 (error "Couldn't find doc group"))
		       file))))))
310
  "*Alist of useful group-server pairs."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
311 312 313 314 315 316
  :group 'gnus-group-listing
  :type '(repeat (list (string :tag "Description")
		       (string :tag "Name")
		       (sexp :tag "Method"))))

(defcustom gnus-group-highlight
317 318
  '(;; Mail.
    ((and mailp (= unread 0) (eq level 1)) .
319
     gnus-group-mail-1-empty)
320
    ((and mailp (eq level 1)) .
321
     gnus-group-mail-1)
322
    ((and mailp (= unread 0) (eq level 2)) .
323
     gnus-group-mail-2-empty)
324
    ((and mailp (eq level 2)) .
325
     gnus-group-mail-2)
326
    ((and mailp (= unread 0) (eq level 3)) .
327
     gnus-group-mail-3-empty)
328
    ((and mailp (eq level 3)) .
329
     gnus-group-mail-3)
330
    ((and mailp (= unread 0)) .
331
     gnus-group-mail-low-empty)
332
    ((and mailp) .
333
     gnus-group-mail-low)
334 335
    ;; News.
    ((and (= unread 0) (eq level 1)) .
336
     gnus-group-news-1-empty)
337
    ((and (eq level 1)) .
338
     gnus-group-news-1)
339
    ((and (= unread 0) (eq level 2)) .
340
     gnus-group-news-2-empty)
341
    ((and (eq level 2)) .
342
     gnus-group-news-2)
343
    ((and (= unread 0) (eq level 3)) .
344
     gnus-group-news-3-empty)
345
    ((and (eq level 3)) .
346
     gnus-group-news-3)
347
    ((and (= unread 0) (eq level 4)) .
348
     gnus-group-news-4-empty)
349
    ((and (eq level 4)) .
350
     gnus-group-news-4)
351
    ((and (= unread 0) (eq level 5)) .
352
     gnus-group-news-5-empty)
353
    ((and (eq level 5)) .
354
     gnus-group-news-5)
355
    ((and (= unread 0) (eq level 6)) .
356
     gnus-group-news-6-empty)
357
    ((and (eq level 6)) .
358
     gnus-group-news-6)
359
    ((and (= unread 0)) .
360
     gnus-group-news-low-empty)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
361
    (t .
362
     gnus-group-news-low))
363
  "*Controls the highlighting of group buffer lines.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384

Below is a list of `Form'/`Face' pairs.  When deciding how a a
particular group line should be displayed, each form is
evaluated.  The content of the face field after the first true form is
used.  You can change how those group lines are displayed by
editing the face field.

It is also possible to change and add form fields, but currently that
requires an understanding of Lisp expressions.  Hopefully this will
change in a future release.  For now, you can use the following
variables in the Lisp expression:

group: The name of the group.
unread: The number of unread articles in the group.
method: The select method used.
mailp: Whether it's a mail group or not.
level: The level of the group.
score: The score of the group.
ticked: The number of ticked articles."
  :group 'gnus-group-visual
  :type '(repeat (cons (sexp :tag "Form") face)))
385
(put 'gnus-group-highlight 'risky-local-variable t)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
386 387 388 389 390 391

(defcustom gnus-new-mail-mark ?%
  "Mark used for groups with new mail."
  :group 'gnus-group-visual
  :type 'character)

392
(defgroup gnus-group-icons nil
393
  "Add Icons to your group buffer."
394 395 396 397 398 399 400 401 402 403 404
  :group 'gnus-group-visual)

(defcustom gnus-group-icon-list
  nil
  "*Controls the insertion of icons into group buffer lines.

Below is a list of `Form'/`File' pairs.  When deciding how a
particular group line should be displayed, each form is evaluated.
The icon from the file field after the first true form is used.  You
can change how those group lines are displayed by editing the file
field.  The File will either be found in the
405
`gnus-group-glyph-directory' or by designating absolute name of the
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
file.

It is also possible to change and add form fields, but currently that
requires an understanding of Lisp expressions.  Hopefully this will
change in a future release.  For now, you can use the following
variables in the Lisp expression:

group: The name of the group.
unread: The number of unread articles in the group.
method: The select method used.
mailp: Whether it's a mail group or not.
newsp: Whether it's a news group or not
level: The level of the group.
score: The score of the group.
ticked: The number of ticked articles."
  :group 'gnus-group-icons
  :type '(repeat (cons (sexp :tag "Form") file)))
Miles Bader's avatar
Miles Bader committed
423
(put 'gnus-group-icon-list 'risky-local-variable t)
424 425

(defcustom gnus-group-name-charset-method-alist nil
426
  "Alist of method and the charset for group names.
427 428

For example:
429
    (((nntp \"news.com.cn\") . cn-gb-2312))"
430
  :version "21.1"
431 432 433
  :group 'gnus-charset
  :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))

434 435 436 437 438 439
(defcustom gnus-group-name-charset-group-alist
  (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
	  (mm-coding-system-p 'utf-8))
      '((".*" . utf-8))
    nil)
  "Alist of group regexp and the charset for group names.
440 441

For example:
442
    ((\"\\.com\\.cn:\" . cn-gb-2312))"
443 444 445
  :group 'gnus-charset
  :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))

446 447
(defcustom gnus-group-jump-to-group-prompt nil
  "Default prompt for `gnus-group-jump-to-group'.
448 449 450 451 452 453 454 455

If non-nil, the value should be a string or an alist.  If it is a string,
e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
nnml:\" in the minibuffer prompt.

If it is an alist, it must consist of \(NUMBER .  PROMPT\) pairs, for example:
\((1 .  \"\") (2 .  \"nnfolder+archive:\")).  The element with number 0 is
used when no prefix argument is given to `gnus-group-jump-to-group'."
456
  :version "22.1"
457 458
  :group 'gnus-group-various
  :type '(choice (string :tag "Prompt string")
459 460 461
		 (const :tag "Empty" nil)
		 (repeat (cons (integer :tag "Argument")
			       (string :tag "Prompt string")))))
462 463 464 465 466 467

(defvar gnus-group-listing-limit 1000
  "*A limit of the number of groups when listing.
If the number of groups is larger than the limit, list them in a
simple manner.")

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
468 469
;;; Internal variables

470 471
(defvar gnus-group-is-exiting-p nil)
(defvar gnus-group-is-exiting-without-update-p nil)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
(defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
  "Function for sorting the group buffer.")

(defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
  "Function for sorting the selected groups in the group buffer.")

(defvar gnus-group-indentation-function nil)
(defvar gnus-goto-missing-group-function nil)
(defvar gnus-group-update-group-function nil)
(defvar gnus-group-goto-next-group-function nil
  "Function to override finding the next group after listing groups.")

(defvar gnus-group-edit-buffer nil)

(defvar gnus-group-line-format-alist
  `((?M gnus-tmp-marked-mark ?c)
    (?S gnus-tmp-subscribed ?c)
    (?L gnus-tmp-level ?d)
    (?N (cond ((eq number t) "*" )
	      ((numberp number)
	       (int-to-string
		(+ number
		   (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
		   (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
	      (t number)) ?s)
    (?R gnus-tmp-number-of-read ?s)
498
    (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
499 500 501 502 503 504
    (?t gnus-tmp-number-total ?d)
    (?y gnus-tmp-number-of-unread ?s)
    (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
    (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
    (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
	   (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
505 506 507 508
    (?g (if (boundp 'gnus-tmp-decoded-group)
	    gnus-tmp-decoded-group
	  gnus-tmp-group)
	?s)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
509
    (?G gnus-tmp-qualified-group ?s)
510 511 512 513
    (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
				   gnus-tmp-decoded-group
				 gnus-tmp-group))
	?s)
514
    (?C gnus-tmp-comment ?s)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
515 516 517 518 519
    (?D gnus-tmp-newsgroup-description ?s)
    (?o gnus-tmp-moderated ?c)
    (?O gnus-tmp-moderated-string ?s)
    (?p gnus-tmp-process-marked ?c)
    (?s gnus-tmp-news-server ?s)
520 521 522 523
    (?n ,(if (featurep 'xemacs)
	     '(symbol-name gnus-tmp-news-method)
	   'gnus-tmp-news-method)
	?s)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
524
    (?P gnus-group-indentation ?s)
525
    (?E gnus-tmp-group-icon ?s)
526
    (?B gnus-tmp-summary-live ?c)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
527 528 529
    (?z gnus-tmp-news-method-string ?s)
    (?m (gnus-group-new-mail gnus-tmp-group) ?c)
    (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
530 531 532
    (?u gnus-tmp-user-defined ?s)
    (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
    ))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549

(defvar gnus-group-mode-line-format-alist
  `((?S gnus-tmp-news-server ?s)
    (?M gnus-tmp-news-method ?s)
    (?u gnus-tmp-user-defined ?s)
    (?: gnus-tmp-colon ?s)))

(defvar gnus-topic-topology nil
  "The complete topic hierarchy.")

(defvar gnus-topic-alist nil
  "The complete topic-group alist.")

(defvar gnus-group-marked nil)

(defvar gnus-group-list-mode nil)

550 551 552

(defvar gnus-group-icon-cache nil)

553 554 555
(defvar gnus-group-listed-groups nil)
(defvar gnus-group-list-option nil)

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
556 557 558 559 560 561
;;;
;;; Gnus group mode
;;;

(put 'gnus-group-mode 'mode-class 'special)

562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620
(gnus-define-keys gnus-group-mode-map
  " " gnus-group-read-group
  "=" gnus-group-select-group
  "\r" gnus-group-select-group
  "\M-\r" gnus-group-quick-select-group
  "\M- " gnus-group-visible-select-group
  [(meta control return)] gnus-group-select-group-ephemerally
  "j" gnus-group-jump-to-group
  "n" gnus-group-next-unread-group
  "p" gnus-group-prev-unread-group
  "\177" gnus-group-prev-unread-group
  [delete] gnus-group-prev-unread-group
  [backspace] gnus-group-prev-unread-group
  "N" gnus-group-next-group
  "P" gnus-group-prev-group
  "\M-n" gnus-group-next-unread-group-same-level
  "\M-p" gnus-group-prev-unread-group-same-level
  "," gnus-group-best-unread-group
  "." gnus-group-first-unread-group
  "u" gnus-group-unsubscribe-current-group
  "U" gnus-group-unsubscribe-group
  "c" gnus-group-catchup-current
  "C" gnus-group-catchup-current-all
  "\M-c" gnus-group-clear-data
  "l" gnus-group-list-groups
  "L" gnus-group-list-all-groups
  "m" gnus-group-mail
  "i" gnus-group-news
  "g" gnus-group-get-new-news
  "\M-g" gnus-group-get-new-news-this-group
  "R" gnus-group-restart
  "r" gnus-group-read-init-file
  "B" gnus-group-browse-foreign-server
  "b" gnus-group-check-bogus-groups
  "F" gnus-group-find-new-groups
  "\C-c\C-d" gnus-group-describe-group
  "\M-d" gnus-group-describe-all-groups
  "\C-c\C-a" gnus-group-apropos
  "\C-c\M-\C-a" gnus-group-description-apropos
  "a" gnus-group-post-news
  "\ek" gnus-group-edit-local-kill
  "\eK" gnus-group-edit-global-kill
  "\C-k" gnus-group-kill-group
  "\C-y" gnus-group-yank-group
  "\C-w" gnus-group-kill-region
  "\C-x\C-t" gnus-group-transpose-groups
  "\C-c\C-l" gnus-group-list-killed
  "\C-c\C-x" gnus-group-expire-articles
  "\C-c\M-\C-x" gnus-group-expire-all-groups
  "V" gnus-version
  "s" gnus-group-save-newsrc
  "z" gnus-group-suspend
  "q" gnus-group-exit
  "Q" gnus-group-quit
  "?" gnus-group-describe-briefly
  "\C-c\C-i" gnus-info-find-node
  "\M-e" gnus-group-edit-group-method
  "^" gnus-group-enter-server-mode
  gnus-mouse-2 gnus-mouse-pick-group
621
  [follow-link] mouse-face
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663
  "<" beginning-of-buffer
  ">" end-of-buffer
  "\C-c\C-b" gnus-bug
  "\C-c\C-s" gnus-group-sort-groups
  "t" gnus-topic-mode
  "\C-c\M-g" gnus-activate-all-groups
  "\M-&" gnus-group-universal-argument
  "#" gnus-group-mark-group
  "\M-#" gnus-group-unmark-group)

(gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
  "m" gnus-group-mark-group
  "u" gnus-group-unmark-group
  "w" gnus-group-mark-region
  "b" gnus-group-mark-buffer
  "r" gnus-group-mark-regexp
  "U" gnus-group-unmark-all-groups)

(gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
  "u" gnus-sieve-update
  "g" gnus-sieve-generate)

(gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
  "d" gnus-group-make-directory-group
  "h" gnus-group-make-help-group
  "u" gnus-group-make-useful-group
  "a" gnus-group-make-archive-group
  "k" gnus-group-make-kiboze-group
  "l" gnus-group-nnimap-edit-acl
  "m" gnus-group-make-group
  "E" gnus-group-edit-group
  "e" gnus-group-edit-group-method
  "p" gnus-group-edit-group-parameters
  "v" gnus-group-add-to-virtual
  "V" gnus-group-make-empty-virtual
  "D" gnus-group-enter-directory
  "f" gnus-group-make-doc-group
  "w" gnus-group-make-web-group
  "M" gnus-group-read-ephemeral-group
  "r" gnus-group-rename-group
  "R" gnus-group-make-rss-group
  "c" gnus-group-customize
664
  "z" gnus-group-compact-group
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746
  "x" gnus-group-nnimap-expunge
  "\177" gnus-group-delete-group
  [delete] gnus-group-delete-group)

(gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
  "b" gnus-group-brew-soup
  "w" gnus-soup-save-areas
  "s" gnus-soup-send-replies
  "p" gnus-soup-pack-packet
  "r" nnsoup-pack-replies)

(gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
  "s" gnus-group-sort-groups
  "a" gnus-group-sort-groups-by-alphabet
  "u" gnus-group-sort-groups-by-unread
  "l" gnus-group-sort-groups-by-level
  "v" gnus-group-sort-groups-by-score
  "r" gnus-group-sort-groups-by-rank
  "m" gnus-group-sort-groups-by-method
  "n" gnus-group-sort-groups-by-real-name)

(gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
  "s" gnus-group-sort-selected-groups
  "a" gnus-group-sort-selected-groups-by-alphabet
  "u" gnus-group-sort-selected-groups-by-unread
  "l" gnus-group-sort-selected-groups-by-level
  "v" gnus-group-sort-selected-groups-by-score
  "r" gnus-group-sort-selected-groups-by-rank
  "m" gnus-group-sort-selected-groups-by-method
  "n" gnus-group-sort-selected-groups-by-real-name)

(gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
  "k" gnus-group-list-killed
  "z" gnus-group-list-zombies
  "s" gnus-group-list-groups
  "u" gnus-group-list-all-groups
  "A" gnus-group-list-active
  "a" gnus-group-apropos
  "d" gnus-group-description-apropos
  "m" gnus-group-list-matching
  "M" gnus-group-list-all-matching
  "l" gnus-group-list-level
  "c" gnus-group-list-cached
  "?" gnus-group-list-dormant)

(gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
  "k"  gnus-group-list-limit
  "z"  gnus-group-list-limit
  "s"  gnus-group-list-limit
  "u"  gnus-group-list-limit
  "A"  gnus-group-list-limit
  "m"  gnus-group-list-limit
  "M"  gnus-group-list-limit
  "l"  gnus-group-list-limit
  "c"  gnus-group-list-limit
  "?"  gnus-group-list-limit)

(gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
  "k"  gnus-group-list-flush
  "z"  gnus-group-list-flush
  "s"  gnus-group-list-flush
  "u"  gnus-group-list-flush
  "A"  gnus-group-list-flush
  "m"  gnus-group-list-flush
  "M"  gnus-group-list-flush
  "l"  gnus-group-list-flush
  "c"  gnus-group-list-flush
  "?"  gnus-group-list-flush)

(gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
  "k"  gnus-group-list-plus
  "z"  gnus-group-list-plus
  "s"  gnus-group-list-plus
  "u"  gnus-group-list-plus
  "A"  gnus-group-list-plus
  "m"  gnus-group-list-plus
  "M"  gnus-group-list-plus
  "l"  gnus-group-list-plus
  "c"  gnus-group-list-plus
  "?"  gnus-group-list-plus)

(gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
747 748
  "f" gnus-score-flush-cache
  "e" gnus-score-edit-all-score)
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770

(gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
  "c" gnus-group-fetch-charter
  "C" gnus-group-fetch-control
  "d" gnus-group-describe-group
  "f" gnus-group-fetch-faq
  "v" gnus-version)

(gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
  "l" gnus-group-set-current-level
  "t" gnus-group-unsubscribe-current-group
  "s" gnus-group-unsubscribe-group
  "k" gnus-group-kill-group
  "y" gnus-group-yank-group
  "w" gnus-group-kill-region
  "\C-k" gnus-group-kill-level
  "z" gnus-group-kill-all-zombies)

(defun gnus-topic-mode-p ()
  "Return non-nil in `gnus-topic-mode'."
  (and (boundp 'gnus-topic-mode)
       (symbol-value 'gnus-topic-mode)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
771 772 773 774 775 776 777

(defun gnus-group-make-menu-bar ()
  (gnus-turn-off-edit-menu 'group)
  (unless (boundp 'gnus-group-reading-menu)

    (easy-menu-define
     gnus-group-reading-menu gnus-group-mode-map ""
778 779 780 781 782 783 784 785 786 787 788
     `("Group"
       ["Read" gnus-group-read-group
	:included (not (gnus-topic-mode-p))
	:active (gnus-group-group-name)]
       ["Read " gnus-topic-read-group
	:included (gnus-topic-mode-p)]
       ["Select" gnus-group-select-group
	:included (not (gnus-topic-mode-p))
	:active (gnus-group-group-name)]
       ["Select " gnus-topic-select-group
	:included (gnus-topic-mode-p)]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
789 790
       ["See old articles" (gnus-group-select-group 'all)
	:keys "C-u SPC" :active (gnus-group-group-name)]
791 792 793 794 795 796 797 798 799
       ["Catch up" gnus-group-catchup-current
	:included (not (gnus-topic-mode-p))
	:active (gnus-group-group-name)
	,@(if (featurep 'xemacs) nil
	    '(:help "Mark unread articles in the current group as read"))]
       ["Catch up " gnus-topic-catchup-articles
	:included (gnus-topic-mode-p)
	,@(if (featurep 'xemacs) nil
	    '(:help "Mark unread articles in the current group or topic as read"))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
800 801 802
       ["Catch up all articles" gnus-group-catchup-current-all
	(gnus-group-group-name)]
       ["Check for new articles" gnus-group-get-new-news-this-group
803
	:included (not (gnus-topic-mode-p))
804
	:active (gnus-group-group-name)
805 806 807 808 809 810
	,@(if (featurep 'xemacs) nil
	    '(:help "Check for new messages in current group"))]
       ["Check for new articles " gnus-topic-get-new-news-this-topic
	:included (gnus-topic-mode-p)
	,@(if (featurep 'xemacs) nil
	    '(:help "Check for new messages in current group or topic"))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
811 812
       ["Toggle subscription" gnus-group-unsubscribe-current-group
	(gnus-group-group-name)]
813
       ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
814 815
	,@(if (featurep 'xemacs) nil
	      '(:help "Kill (remove) current group"))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
816
       ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
817
       ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
818 819
	,@(if (featurep 'xemacs) nil
	    '(:help "Display description of the current group"))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
820
       ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
821 822 823 824 825 826 827 828
       ["Fetch charter" gnus-group-fetch-charter
	:active (gnus-group-group-name)
	,@(if (featurep 'xemacs) nil
	    '(:help "Display the charter of the current group"))]
       ["Fetch control message" gnus-group-fetch-control
	:active (gnus-group-group-name)
	,@(if (featurep 'xemacs) nil
	    '(:help "Display the archived control message for the current group"))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
829 830 831
       ;; Actually one should check, if any of the marked groups gives t for
       ;; (gnus-check-backend-function 'request-expire-articles ...)
       ["Expire articles" gnus-group-expire-articles
832 833 834 835 836 837 838 839
	:included (not (gnus-topic-mode-p))
	:active (or (and (gnus-group-group-name)
			 (gnus-check-backend-function
			  'request-expire-articles
			  (gnus-group-group-name))) gnus-group-marked)]
       ["Expire articles " gnus-topic-expire-articles
	:included (gnus-topic-mode-p)]
       ["Set group level..." gnus-group-set-current-level
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
840 841 842
	(gnus-group-group-name)]
       ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
       ["Customize" gnus-group-customize (gnus-group-group-name)]
843 844
       ["Compact" gnus-group-compact-group
	:active (gnus-group-group-name)]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
845 846
       ("Edit"
	["Parameters" gnus-group-edit-group-parameters
847 848 849 850
	 :included (not (gnus-topic-mode-p))
	 :active (gnus-group-group-name)]
	["Parameters " gnus-topic-edit-parameters
	 :included (gnus-topic-mode-p)]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
851 852 853 854
	["Select method" gnus-group-edit-group-method
	 (gnus-group-group-name)]
	["Info" gnus-group-edit-group (gnus-group-group-name)]
	["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
855
	["Global kill file" gnus-group-edit-global-kill t])))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
856 857 858 859 860 861 862 863 864 865 866 867 868 869 870

    (easy-menu-define
     gnus-group-group-menu gnus-group-mode-map ""
     '("Groups"
       ("Listing"
	["List unread subscribed groups" gnus-group-list-groups t]
	["List (un)subscribed groups" gnus-group-list-all-groups t]
	["List killed groups" gnus-group-list-killed gnus-killed-list]
	["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
	["List level..." gnus-group-list-level t]
	["Describe all groups" gnus-group-describe-all-groups t]
	["Group apropos..." gnus-group-apropos t]
	["Group and description apropos..." gnus-group-description-apropos t]
	["List groups matching..." gnus-group-list-matching t]
	["List all groups matching..." gnus-group-list-all-matching t]
871 872 873
	["List active file" gnus-group-list-active t]
	["List groups with cached" gnus-group-list-cached t]
	["List groups with dormant" gnus-group-list-dormant t])
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
874 875 876 877 878 879 880
       ("Sort"
	["Default sort" gnus-group-sort-groups t]
	["Sort by method" gnus-group-sort-groups-by-method t]
	["Sort by rank" gnus-group-sort-groups-by-rank t]
	["Sort by score" gnus-group-sort-groups-by-score t]
	["Sort by level" gnus-group-sort-groups-by-level t]
	["Sort by unread" gnus-group-sort-groups-by-unread t]
881 882
	["Sort by name" gnus-group-sort-groups-by-alphabet t]
	["Sort by real name" gnus-group-sort-groups-by-real-name t])
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
883 884
       ("Sort process/prefixed"
	["Default sort" gnus-group-sort-selected-groups
885
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
886
	["Sort by method" gnus-group-sort-selected-groups-by-method
887
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
888
	["Sort by rank" gnus-group-sort-selected-groups-by-rank
889
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
890
	["Sort by score" gnus-group-sort-selected-groups-by-score
891
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
892
	["Sort by level" gnus-group-sort-selected-groups-by-level
893
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
894
	["Sort by unread" gnus-group-sort-selected-groups-by-unread
895
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
896
	["Sort by name" gnus-group-sort-selected-groups-by-alphabet
897 898 899
	 (not (gnus-topic-mode-p))]
	["Sort by real name" gnus-group-sort-selected-groups-by-real-name
	 (not (gnus-topic-mode-p))])
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
900 901 902 903 904 905 906 907 908
       ("Mark"
	["Mark group" gnus-group-mark-group
	 (and (gnus-group-group-name)
	      (not (memq (gnus-group-group-name) gnus-group-marked)))]
	["Unmark group" gnus-group-unmark-group
	 (and (gnus-group-group-name)
	      (memq (gnus-group-group-name) gnus-group-marked))]
	["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
	["Mark regexp..." gnus-group-mark-regexp t]
909
	["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
910 911 912 913
	["Mark buffer" gnus-group-mark-buffer t]
	["Execute command" gnus-group-universal-argument
	 (or gnus-group-marked (gnus-group-group-name))])
       ("Subscribe"
914 915 916
	["Subscribe to a group..." gnus-group-unsubscribe-group t]
	["Kill all newsgroups in region" gnus-group-kill-region
	 :active (gnus-mark-active-p)]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
917 918 919 920
	["Kill all zombie groups" gnus-group-kill-all-zombies
	 gnus-zombie-list]
	["Kill all groups on level..." gnus-group-kill-level t])
       ("Foreign groups"
921 922
	["Make a foreign group..." gnus-group-make-group t]
	["Add a directory group..." gnus-group-make-directory-group t]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
923 924
	["Add the help group" gnus-group-make-help-group t]
	["Add the archive group" gnus-group-make-archive-group t]
925 926 927 928 929 930 931 932
	["Make a doc group..." gnus-group-make-doc-group t]
	["Make a web group..." gnus-group-make-web-group t]
	["Make a kiboze group..." gnus-group-make-kiboze-group t]
	["Make a virtual group..." gnus-group-make-empty-virtual t]
	["Add a group to a virtual..." gnus-group-add-to-virtual t]
	["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
	["Make an RSS group..." gnus-group-make-rss-group t]
	["Rename group..." gnus-group-rename-group
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
933 934 935 936 937 938 939 940 941 942 943 944 945
	 (gnus-check-backend-function
	  'request-rename-group (gnus-group-group-name))]
	["Delete group" gnus-group-delete-group
	 (gnus-check-backend-function
	  'request-delete-group (gnus-group-group-name))])
       ("Move"
	["Next" gnus-group-next-group t]
	["Previous" gnus-group-prev-group t]
	["Next unread" gnus-group-next-unread-group t]
	["Previous unread" gnus-group-prev-unread-group t]
	["Next unread same level" gnus-group-next-unread-group-same-level t]
	["Previous unread same level"
	 gnus-group-prev-unread-group-same-level t]
946
	["Jump to group..." gnus-group-jump-to-group t]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
947 948
	["First unread group" gnus-group-first-unread-group t]
	["Best unread group" gnus-group-best-unread-group t])
949 950 951
       ("Sieve"
	["Generate" gnus-sieve-generate t]
	["Generate and update" gnus-sieve-update t])
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
952
       ["Delete bogus groups" gnus-group-check-bogus-groups t]
953
       ["Find new newsgroups" gnus-group-find-new-groups t]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
954 955
       ["Transpose" gnus-group-transpose-groups
	(gnus-group-group-name)]
956
       ["Read a directory as a group..." gnus-group-enter-directory t]))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
957 958 959

    (easy-menu-define
     gnus-group-misc-menu gnus-group-mode-map ""
960
     `("Gnus"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
961 962 963 964 965 966
       ("SOUP"
	["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
	["Send replies" gnus-soup-send-replies
	 (fboundp 'gnus-soup-pack-packet)]
	["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
	["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
967
	["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
968
       ["Send a mail" gnus-group-mail t]
969 970
       ["Send a message (mail or news)" gnus-group-post-news t]
       ["Create a local message" gnus-group-news t]
971
       ["Check for new news" gnus-group-get-new-news
972 973 974 975 976 977 978
	,@(if (featurep 'xemacs) '(t)
	    '(:help "Get newly arrived articles"))
	]
       ["Send queued messages" gnus-delay-send-queue
	,@(if (featurep 'xemacs) '(t)
	    '(:help "Send all messages that are scheduled to be sent now"))
	]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
979 980 981
       ["Activate all groups" gnus-activate-all-groups t]
       ["Restart Gnus" gnus-group-restart t]
       ["Read init file" gnus-group-read-init-file t]
982
       ["Browse foreign server..." gnus-group-browse-foreign-server t]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
983 984 985 986 987 988 989 990 991 992
       ["Enter server buffer" gnus-group-enter-server-mode t]
       ["Expire all expirable articles" gnus-group-expire-all-groups t]
       ["Generate any kiboze groups" nnkiboze-generate-groups t]
       ["Gnus version" gnus-version t]
       ["Save .newsrc files" gnus-group-save-newsrc t]
       ["Suspend Gnus" gnus-group-suspend t]
       ["Clear dribble buffer" gnus-group-clear-dribble t]
       ["Read manual" gnus-info-find-node t]
       ["Flush score cache" gnus-score-flush-cache t]
       ["Toggle topics" gnus-topic-mode t]
993
       ["Send a bug report" gnus-bug t]
994
       ["Exit from Gnus" gnus-group-exit
995 996
	,@(if (featurep 'xemacs) '(t)
	    '(:help "Quit reading news"))]
997
       ["Exit without saving" gnus-group-quit t]))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
998

999
    (gnus-run-hooks 'gnus-group-menu-hook)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1000

1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029

(defvar gnus-group-tool-bar-map nil)

(defun gnus-group-tool-bar-update (&optional symbol value)
  "Update group buffer toolbar.
Setter function for custom variables."
  (when symbol
    (set-default symbol value))
  ;; (setq-default gnus-group-tool-bar-map nil)
  ;; (use-local-map gnus-group-mode-map)
  (when (gnus-alive-p)
    (with-current-buffer gnus-group-buffer
      (gnus-group-make-tool-bar t))))

(defcustom gnus-group-tool-bar (if (eq gmm-tool-bar-style 'gnome)
				   'gnus-group-tool-bar-gnome
				 'gnus-group-tool-bar-retro)
  "Specifies the Gnus group tool bar.

It can be either a list or a symbol refering to a list.  See
`gmm-tool-bar-from-list' for the format of the list.  The
default key map is `gnus-group-mode-map'.

Pre-defined symbols include `gnus-group-tool-bar-gnome' and
`gnus-group-tool-bar-retro'."
  :type '(choice (const :tag "GNOME style" gnus-group-tool-bar-gnome)
		 (const :tag "Retro look" gnus-group-tool-bar-retro)
		 (repeat :tag "User defined list" gmm-tool-bar-item)
		 (symbol))
1030
  :version "23.0" ;; No Gnus
1031 1032 1033 1034 1035 1036 1037 1038 1039
  :initialize 'custom-initialize-default
  :set 'gnus-group-tool-bar-update
  :group 'gnus-group)

(defcustom gnus-group-tool-bar-gnome
  '((gnus-group-post-news "mail/compose")
    ;; Some useful agent icons?  I don't use the agent so agent users should
    ;; suggest useful commands:
    (gnus-agent-toggle-plugged "disconnect" t
Miles Bader's avatar
Miles Bader committed
1040 1041 1042 1043
			       :help "Gnus is currently unplugged.  Click to work online."
     			       :visible (and gnus-agent (not gnus-plugged)))
    (gnus-agent-toggle-plugged "connect" t
			       :help "Gnus is currently plugged.  Click to work offline."
1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
     			       :visible (and gnus-agent gnus-plugged))
    ;; FIXME: gnus-agent-toggle-plugged (in gnus-agent-group-make-menu-bar)
    ;; should have a better help text.
    (gnus-group-send-queue "mail/outbox" t
			   :visible (and gnus-agent gnus-plugged)
			   :help "Send articles from the queue group")
    (gnus-group-get-new-news "mail/inbox" nil
			     :visible (or (not gnus-agent)
					  gnus-plugged))
    ;; FIXME: gnus-*-read-group should have a better help text.
    (gnus-topic-read-group "open" nil
			   :visible (and (boundp 'gnus-topic-mode)
					 gnus-topic-mode))
    (gnus-group-read-group "open" nil
			   :visible (not (and (boundp 'gnus-topic-mode)
					      gnus-topic-mode)))
    ;; (gnus-group-find-new-groups "???" nil)
    (gnus-group-save-newsrc "save")
    (gnus-group-describe-group "describe")
    (gnus-group-unsubscribe-current-group "gnus/toggle-subscription")
    (gnus-group-prev-unread-group "left-arrow")
    (gnus-group-next-unread-group "right-arrow")
    (gnus-group-exit "exit")
    (gmm-customize-mode "preferences" t :help "Edit mode preferences")
    (gnus-info-find-node "help"))
  "List of functions for the group tool bar (GNOME style).

See `gmm-tool-bar-from-list' for the format of the list."
  :type '(repeat gmm-tool-bar-item)
1073
  :version "23.0" ;; No Gnus
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091
  :initialize 'custom-initialize-default
  :set 'gnus-group-tool-bar-update
  :group 'gnus-group)

(defcustom gnus-group-tool-bar-retro
  '((gnus-group-get-new-news "gnus/get-news")
    (gnus-group-get-new-news-this-group "gnus/gnntg")
    (gnus-group-catchup-current "gnus/catchup")
    (gnus-group-describe-group "gnus/describe-group")
    (gnus-group-subscribe "gnus/subscribe" t
			  :help "Subscribe to the current group")
    (gnus-group-unsubscribe "gnus/unsubscribe" t
			    :help "Unsubscribe from the current group")
    (gnus-group-exit "gnus/exit-gnus" gnus-group-mode-map))
  "List of functions for the group tool bar (retro look).

See `gmm-tool-bar-from-list' for the format of the list."
  :type '(repeat gmm-tool-bar-item)
1092
  :version "23.0" ;; No Gnus
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102
  :initialize 'custom-initialize-default
  :set 'gnus-group-tool-bar-update
  :group 'gnus-group)

(defcustom gnus-group-tool-bar-zap-list t
  "List of icon items from the global tool bar.
These items are not displayed in the Gnus group mode tool bar.

See `gmm-tool-bar-from-list' for the format of the list."
  :type 'gmm-tool-bar-zap-list
1103
  :version "23.0" ;; No Gnus
1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131
  :initialize 'custom-initialize-default
  :set 'gnus-group-tool-bar-update
  :group 'gnus-group)

(defvar image-load-path)

(defun gnus-group-make-tool-bar (&optional force)
  "Make a group mode tool bar from `gnus-group-tool-bar'.
When FORCE, rebuild the tool bar."
  (when (and (not (featurep 'xemacs))
	     (boundp 'tool-bar-mode)
	     tool-bar-mode
	     ;; The Gnus 5.10.6 code checked (default-value 'tool-bar-mode).
	     ;; Why?  --rsteib
	     (or (not gnus-group-tool-bar-map) force))
    (let* ((load-path
	    (gmm-image-load-path-for-library "gnus"
					     "gnus/toggle-subscription.xpm"
					     nil t))
           (image-load-path (cons (car load-path)
                                  (when (boundp 'image-load-path)
                                    image-load-path)))
	   (map (gmm-tool-bar-from-list gnus-group-tool-bar
					gnus-group-tool-bar-zap-list
					'gnus-group-mode-map)))
      (if map
	  (set (make-local-variable 'tool-bar-map) map))))
  gnus-group-tool-bar-map)
1132

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1133 1134 1135 1136 1137
(defun gnus-group-mode ()
  "Major mode for reading news.

All normal editing commands are switched off.
\\<gnus-group-mode-map>
1138
The group buffer lists (some of) the groups available.  For instance,
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150
`\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
lists all zombie groups.

Groups that are displayed can be entered with `\\[gnus-group-read-group]'.  To subscribe
to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.

For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').

The following commands are available:

\\{gnus-group-mode-map}"
  (interactive)
1151
  (kill-all-local-variables)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1152
  (when (gnus-visual-p 'group-menu 'menu)
1153 1154
    (gnus-group-make-menu-bar)
    (gnus-group-make-tool-bar))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1155 1156 1157 1158 1159 1160
  (gnus-simplify-mode-line)
  (setq major-mode 'gnus-group-mode)
  (setq mode-name "Group")
  (gnus-group-set-mode-line)
  (setq mode-line-process nil)
  (use-local-map gnus-group-mode-map)
1161
  (buffer-disable-undo)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1162
  (setq truncate-lines t)
1163 1164
  (setq buffer-read-only t
	show-trailing-whitespace nil)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1165 1166 1167 1168 1169
  (gnus-set-default-directory)
  (gnus-update-format-specifications nil 'group 'group-mode)
  (gnus-update-group-mark-positions)
  (when gnus-use-undo
    (gnus-undo-mode 1))
1170 1171
  (when gnus-slave
    (gnus-slave-mode))
1172
  (gnus-run-mode-hooks 'gnus-group-mode-hook))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1173 1174 1175

(defun gnus-update-group-mark-positions ()
  (save-excursion
1176
    (let ((gnus-process-mark ?\200)
1177
	  (gnus-group-update-hook nil)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1178
	  (gnus-group-marked '("dummy.group"))
1179 1180
	  (gnus-active-hashtb (make-vector 10 0))
	  (topic ""))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1181 1182 1183 1184 1185
      (gnus-set-active "dummy.group" '(0 . 0))
      (gnus-set-work-buffer)
      (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
      (goto-char (point-min))
      (setq gnus-group-mark-positions
1186
	    (list (cons 'process (and (search-forward
1187
				       (mm-string-as-multibyte "\200") nil t)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213
				      (- (point) 2))))))))

(defun gnus-mouse-pick-group (e)
  "Enter the group under the mouse pointer."
  (interactive "e")
  (mouse-set-point e)
  (gnus-group-read-group nil))

;; Look at LEVEL and find out what the level is really supposed to be.
;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
;; will depend on whether `gnus-group-use-permanent-levels' is used.
(defun gnus-group-default-level (&optional level number-or-nil)
  (cond
   (gnus-group-use-permanent-levels
    (or (setq gnus-group-use-permanent-levels
	      (or level (if (numberp gnus-group-use-permanent-levels)
			    gnus-group-use-permanent-levels
			  (or gnus-group-default-list-level
			      gnus-level-subscribed))))
	gnus-group-default-list-level gnus-level-subscribed))
   (number-or-nil
    level)
   (t
    (or level gnus-group-default-list-level gnus-level-subscribed))))

(defun gnus-group-setup-buffer ()
1214
  (set-buffer (gnus-get-buffer-create gnus-group-buffer))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1215 1216 1217 1218 1219
  (unless (eq major-mode 'gnus-group-mode)
    (gnus-group-mode)
    (when gnus-carpal
      (gnus-carpal-setup-buffer 'group))))

1220
(defun gnus-group-name-charset (method group)
1221 1222
  (if (null method)
      (setq method (gnus-find-method-for-group group)))
1223 1224 1225 1226
  (let ((item (or (assoc method gnus-group-name-charset-method-alist)
		  (and (consp method)
		       (assoc (list (car method) (cadr method))
			      gnus-group-name-charset-method-alist))))
1227 1228
	(alist gnus-group-name-charset-group-alist)
	result)
1229
    (if item
1230 1231 1232 1233 1234 1235 1236
	(cdr item)
      (while (setq item (pop alist))
	(if (string-match (car item) group)
	    (setq alist nil
		  result (cdr item))))
      result)))

1237 1238
(defun gnus-group-name-decode (string charset)
  ;; Fixme: Don't decode in unibyte mode.
1239 1240 1241 1242 1243 1244 1245 1246
  (if (and string charset (featurep 'mule))
      (mm-decode-coding-string string charset)
    string))

(defun gnus-group-decoded-name (string)
  (let ((charset (gnus-group-name-charset nil string)))
    (gnus-group-name-decode string charset)))

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267
(defun gnus-group-list-groups (&optional level unread lowest)
  "List newsgroups with level LEVEL or lower that have unread articles.
Default is all subscribed groups.
If argument UNREAD is non-nil, groups with no unread articles are also
listed.

Also see the `gnus-group-use-permanent-levels' variable."
  (interactive
   (list (if current-prefix-arg
	     (prefix-numeric-value current-prefix-arg)
	   (or
	    (gnus-group-default-level nil t)
	    gnus-group-default-list-level
	    gnus-level-subscribed))))
  (unless level
    (setq level (car gnus-group-list-mode)
	  unread (cdr gnus-group-list-mode)))
  (setq level (