gnus-group.el 167 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, 2008, 2009, 2010 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
;; Keywords: news

;; This file is part of GNU Emacs.

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

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
19 20 21
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
22
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
23 24 25 26 27

;;; Commentary:

;;; Code:

28 29 30 31
;; For Emacs < 22.2.
(eval-and-compile
  (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))

32
(eval-when-compile
Dan Nicolaescu's avatar
Dan Nicolaescu committed
33 34
  (require 'cl))
(defvar tool-bar-mode)
35

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

48 49 50 51
(eval-when-compile
  (require 'mm-url)
  (let ((features (cons 'gnus-group features)))
    (require 'gnus-sum))
52 53 54 55 56
  (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
57 58

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

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

70
(defcustom gnus-no-groups-message "No Gnus is good news"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
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 104 105
  "*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.
106 107 108 109
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
110
  :group 'gnus-group-listing
111
  :type '(choice regexp (const nil)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
112

Miles Bader's avatar
Miles Bader committed
113 114 115 116 117 118 119 120 121 122 123 124
(defcustom gnus-safe-html-newsgroups "\\`nnrss[+:]"
  "Groups in which links in html articles are considered all safe.
The value may be a regexp matching those groups, a list of group names,
or nil.  This overrides `mm-w3m-safe-url-regexp' (which see).  This is
effective only when emacs-w3m renders html articles, i.e., in the case
`mm-text-html-renderer' is set to `w3m'."
  :version "23.2"
  :group 'gnus-group-various
  :type '(choice regexp
		 (repeat :tag "List of group names" (string :tag "Group"))
		 (const nil)))

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
(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',
149 150
`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
151

152
This variable can also be a list of sorting functions.  In that case,
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
153 154 155 156
the most significant sort function should be the last function in the
list."
  :group 'gnus-group-listing
  :link '(custom-manual "(gnus)Sorting Groups")
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
  :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))))

172
(defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)\n"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
173 174 175 176 177 178 179 180 181 182 183 184
  "*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)
185
%U    Number of unseen articles (integer)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
186 187 188 189
%t    Estimated total number of articles (integer)
%y    Number of unread, unticked articles (integer)
%G    Group name (string)
%g    Qualified group name (string)
190 191
%c    Short (collapsed) group name.  See `gnus-group-uncollapsed-levels'.
%C    Group comment (string)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
192 193 194 195
%D    Group description (string)
%s    Select method (string)
%o    Moderated group (char, \"m\")
%p    Process mark (char)
196
%B    Whether a summary buffer for the group is open (char, \"*\")
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
197 198 199 200 201 202
%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.
203
%E    Icon as defined by `gnus-group-icon-list'.
204
%F    The disk space used by the articles fetched by both the cache and agent.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
205 206
%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,
207 208 209 210
      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
211 212 213

Note that this format specification is not always respected.  For
reasons of efficiency, when listing killed groups, this specification
214
is ignored altogether.  If the spec is changed considerably, your
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
215 216 217 218
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
219 220 221 222
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.
223 224 225 226

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
227 228 229 230 231 232 233 234 235 236 237 238 239 240
  :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)

241 242 243 244
;; 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
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 292 293 294 295 296 297 298 299 300 301 302 303 304 305

(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
306 307 308 309 310 311 312 313 314
  '(("(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
315 316 317 318 319 320 321 322 323
     "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))))))
324
  "*Alist of useful group-server pairs."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
325 326 327 328 329 330
  :group 'gnus-group-listing
  :type '(repeat (list (string :tag "Description")
		       (string :tag "Name")
		       (sexp :tag "Method"))))

(defcustom gnus-group-highlight
331 332
  '(;; Mail.
    ((and mailp (= unread 0) (eq level 1)) .
333
     gnus-group-mail-1-empty)
334
    ((and mailp (eq level 1)) .
335
     gnus-group-mail-1)
336
    ((and mailp (= unread 0) (eq level 2)) .
337
     gnus-group-mail-2-empty)
338
    ((and mailp (eq level 2)) .
339
     gnus-group-mail-2)
340
    ((and mailp (= unread 0) (eq level 3)) .
341
     gnus-group-mail-3-empty)
342
    ((and mailp (eq level 3)) .
343
     gnus-group-mail-3)
344
    ((and mailp (= unread 0)) .
345
     gnus-group-mail-low-empty)
346
    ((and mailp) .
347
     gnus-group-mail-low)
348 349
    ;; News.
    ((and (= unread 0) (eq level 1)) .
350
     gnus-group-news-1-empty)
351
    ((and (eq level 1)) .
352
     gnus-group-news-1)
353
    ((and (= unread 0) (eq level 2)) .
354
     gnus-group-news-2-empty)
355
    ((and (eq level 2)) .
356
     gnus-group-news-2)
357
    ((and (= unread 0) (eq level 3)) .
358
     gnus-group-news-3-empty)
359
    ((and (eq level 3)) .
360
     gnus-group-news-3)
361
    ((and (= unread 0) (eq level 4)) .
362
     gnus-group-news-4-empty)
363
    ((and (eq level 4)) .
364
     gnus-group-news-4)
365
    ((and (= unread 0) (eq level 5)) .
366
     gnus-group-news-5-empty)
367
    ((and (eq level 5)) .
368
     gnus-group-news-5)
369
    ((and (= unread 0) (eq level 6)) .
370
     gnus-group-news-6-empty)
371
    ((and (eq level 6)) .
372
     gnus-group-news-6)
373
    ((and (= unread 0)) .
374
     gnus-group-news-low-empty)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
375
    (t .
376
     gnus-group-news-low))
377
  "*Controls the highlighting of group buffer lines.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398

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)))
399
(put 'gnus-group-highlight 'risky-local-variable t)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
400 401 402 403 404 405

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

406
(defgroup gnus-group-icons nil
407
  "Add Icons to your group buffer."
408 409 410 411 412 413 414 415 416 417 418
  :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
419
`gnus-group-glyph-directory' or by designating absolute name of the
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
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
437
(put 'gnus-group-icon-list 'risky-local-variable t)
438 439

(defcustom gnus-group-name-charset-method-alist nil
440
  "Alist of method and the charset for group names.
441 442

For example:
443
    (((nntp \"news.com.cn\") . cn-gb-2312))"
444
  :version "21.1"
445 446 447
  :group 'gnus-charset
  :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))

448 449 450 451 452 453
(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.
454 455

For example:
456
    ((\"\\.com\\.cn:\" . cn-gb-2312))"
457 458 459
  :group 'gnus-charset
  :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))

460 461
(defcustom gnus-group-jump-to-group-prompt nil
  "Default prompt for `gnus-group-jump-to-group'.
462 463 464 465 466 467 468 469

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'."
470
  :version "22.1"
471 472
  :group 'gnus-group-various
  :type '(choice (string :tag "Prompt string")
473 474 475
		 (const :tag "Empty" nil)
		 (repeat (cons (integer :tag "Argument")
			       (string :tag "Prompt string")))))
476 477 478 479 480 481

(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
482 483
;;; Internal variables

484 485
(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
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
(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)
512 513 514 515
    (?U (if (gnus-active gnus-tmp-group)
	    (gnus-number-of-unseen-articles-in-group gnus-tmp-group)
	  "*")
	?s)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
516 517 518 519 520 521
    (?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)
522 523 524 525
    (?g (if (boundp 'gnus-tmp-decoded-group)
	    gnus-tmp-decoded-group
	  gnus-tmp-group)
	?s)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
526
    (?G gnus-tmp-qualified-group ?s)
527 528 529 530
    (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
				   gnus-tmp-decoded-group
				 gnus-tmp-group))
	?s)
531
    (?C gnus-tmp-comment ?s)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
532 533 534 535 536
    (?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)
537 538 539 540
    (?n ,(if (featurep 'xemacs)
	     '(symbol-name gnus-tmp-news-method)
	   'gnus-tmp-news-method)
	?s)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
541
    (?P gnus-group-indentation ?s)
542
    (?E gnus-tmp-group-icon ?s)
543
    (?B gnus-tmp-summary-live ?c)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
544 545 546
    (?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)
547 548 549
    (?u gnus-tmp-user-defined ?s)
    (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
    ))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566

(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)

567 568 569

(defvar gnus-group-icon-cache nil)

570 571 572
(defvar gnus-group-listed-groups nil)
(defvar gnus-group-list-option nil)

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
573 574 575 576 577 578
;;;
;;; Gnus group mode
;;;

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

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 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637
(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
638
  [follow-link] mouse-face
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 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
  "<" 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
  "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
680
  "z" gnus-group-compact-group
681
  "x" gnus-group-expunge-group
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 747 748 749 750 751 752 753 754 755
  "\177" gnus-group-delete-group
  [delete] gnus-group-delete-group)

(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)
756 757
  "f" gnus-score-flush-cache
  "e" gnus-score-edit-all-score)
758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779

(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
780 781 782 783 784 785 786

(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 ""
787 788 789 790 791 792 793 794 795 796 797
     `("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
798 799
       ["See old articles" (gnus-group-select-group 'all)
	:keys "C-u SPC" :active (gnus-group-group-name)]
800 801 802 803 804 805 806 807 808
       ["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
809 810 811
       ["Catch up all articles" gnus-group-catchup-current-all
	(gnus-group-group-name)]
       ["Check for new articles" gnus-group-get-new-news-this-group
812
	:included (not (gnus-topic-mode-p))
813
	:active (gnus-group-group-name)
814 815 816 817 818 819
	,@(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
820 821
       ["Toggle subscription" gnus-group-unsubscribe-current-group
	(gnus-group-group-name)]
822
       ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
823 824
	,@(if (featurep 'xemacs) nil
	      '(:help "Kill (remove) current group"))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
825
       ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
826
       ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
827 828
	,@(if (featurep 'xemacs) nil
	    '(:help "Display description of the current group"))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
829
       ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
830 831 832 833 834 835 836 837
       ["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
838 839 840
       ;; 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
841 842 843 844 845 846 847 848
	: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
849 850 851
	(gnus-group-group-name)]
       ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
       ["Customize" gnus-group-customize (gnus-group-group-name)]
852 853
       ["Compact" gnus-group-compact-group
	:active (gnus-group-group-name)]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
854 855
       ("Edit"
	["Parameters" gnus-group-edit-group-parameters
856 857 858 859
	 :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
860 861 862 863
	["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)]
864
	["Global kill file" gnus-group-edit-global-kill t])))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879

    (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]
880 881 882
	["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
883 884 885 886 887 888 889
       ("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]
890 891
	["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
892 893
       ("Sort process/prefixed"
	["Default sort" gnus-group-sort-selected-groups
894
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
895
	["Sort by method" gnus-group-sort-selected-groups-by-method
896
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
897
	["Sort by rank" gnus-group-sort-selected-groups-by-rank
898
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
899
	["Sort by score" gnus-group-sort-selected-groups-by-score
900
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
901
	["Sort by level" gnus-group-sort-selected-groups-by-level
902
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
903
	["Sort by unread" gnus-group-sort-selected-groups-by-unread
904
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
905
	["Sort by name" gnus-group-sort-selected-groups-by-alphabet
906 907 908
	 (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
909 910 911 912 913 914 915 916 917
       ("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]
918
	["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
919 920 921 922
	["Mark buffer" gnus-group-mark-buffer t]
	["Execute command" gnus-group-universal-argument
	 (or gnus-group-marked (gnus-group-group-name))])
       ("Subscribe"
923 924 925
	["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
926 927 928 929
	["Kill all zombie groups" gnus-group-kill-all-zombies
	 gnus-zombie-list]
	["Kill all groups on level..." gnus-group-kill-level t])
       ("Foreign groups"
930 931
	["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
932 933
	["Add the help group" gnus-group-make-help-group t]
	["Add the archive group" gnus-group-make-archive-group t]
934 935 936 937 938 939 940
	["Make a doc group..." gnus-group-make-doc-group t]
	["Make a web group..." gnus-group-make-web-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
941 942 943 944 945 946 947 948 949 950 951 952 953
	 (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]
954
	["Jump to group..." gnus-group-jump-to-group t]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
955 956
	["First unread group" gnus-group-first-unread-group t]
	["Best unread group" gnus-group-best-unread-group t])
957 958 959
       ("Sieve"
	["Generate" gnus-sieve-generate t]
	["Generate and update" gnus-sieve-update t])
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
960
       ["Delete bogus groups" gnus-group-check-bogus-groups t]
961
       ["Find new newsgroups" gnus-group-find-new-groups t]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
962 963
       ["Transpose" gnus-group-transpose-groups
	(gnus-group-group-name)]
964
       ["Read a directory as a group..." gnus-group-enter-directory t]))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
965 966 967

    (easy-menu-define
     gnus-group-misc-menu gnus-group-mode-map ""
968
     `("Gnus"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
969
       ["Send a mail" gnus-group-mail t]
970 971
       ["Send a message (mail or news)" gnus-group-post-news t]
       ["Create a local message" gnus-group-news t]
972
       ["Check for new news" gnus-group-get-new-news
973 974 975 976 977 978 979
	,@(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
980 981 982
       ["Activate all groups" gnus-activate-all-groups t]
       ["Restart Gnus" gnus-group-restart t]
       ["Read init file" gnus-group-read-init-file t]
983
       ["Browse foreign server..." gnus-group-browse-foreign-server t]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
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]
       ["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.1" ;; 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.1" ;; 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.1" ;; 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.1" ;; No Gnus
1104 1105 1106 1107 1108
  :initialize 'custom-initialize-default
  :set 'gnus-group-tool-bar-update
  :group 'gnus-group)

(defvar image-load-path)
1109
(defvar tool-bar-map)
1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132

(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)
1133

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

All normal editing commands are switched off.
\\<gnus-group-mode-map>
1139
The group buffer lists (some of) the groups available.  For instance,
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151
`\\[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)
1152
  (kill-all-local-variables)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1153
  (when (gnus-visual-p 'group-menu 'menu)
1154 1155
    (gnus-group-make-menu-bar)
    (gnus-group-make-tool-bar))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1156 1157 1158 1159 1160 1161
  (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)
1162
  (buffer-disable-undo)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1163
  (setq truncate-lines t)
1164 1165
  (setq buffer-read-only t
	show-trailing-whitespace nil)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1166 1167 1168 1169 1170
  (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))
1171 1172
  (when gnus-slave
    (gnus-slave-mode))
1173
  (gnus-run-mode-hooks 'gnus-group-mode-hook))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1174 1175 1176

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

(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 ()
1215
  (set-buffer (gnus-get-buffer-create gnus-group-buffer))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1216 1217 1218 1219 1220
  (unless (eq major-mode 'gnus-group-mode)
    (gnus-group-mode)
    (when gnus-carpal
      (gnus-carpal-setup-buffer 'group))))

1221
(defun gnus-group-name-charset (method group)
1222 1223
  (if (null method)
      (setq method (gnus-find-method-for-group group)))
1224 1225 1226 1227
  (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))))
1228 1229
	(alist gnus-group-name-charset-group-alist)
	result)
1230
    (if item
1231 1232 1233 1234 1235 1236 1237
	(cdr item)
      (while (setq item (pop alist))
	(if (string-match (car item) group)
	    (setq alist nil
		  result (cdr item))))
      result)))

1238 1239
(defun gnus-group-name-decode (string charset)
  ;; Fixme: Don't decode in unibyte mode.
1240 1241 1242 1243 1244 1245 1246 1247
  (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
1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268
(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 (gnus-group-default-level level))
  (gnus-group-setup-buffer)
  (gnus-update-format-specifications nil 'group 'group-mode)
  (let ((case-fold-search nil)
1269
	(props (text-properties-at (point-at-bol)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1270 1271 1272 1273 1274 1275 1276 1277 1278
	(empty (= (point-min) (point-max)))
	(group (gnus-group-group-name))
	number)
    (set-buffer gnus-group-buffer)
    (setq number (funcall gnus-group-prepare-function level unread lowest))
    (when (or (and (numberp number)
		   (zerop number))
	      (zerop (buffer-size)))
      ;; No groups in the buffer.
1279
      (gnus-message 5 "%s" gnus-no-groups-message))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300
    ;; We have some groups displayed.
    (goto-char (point-max))
    (when (or (not gnus-group-goto-next-group-function)
	      (not (funcall gnus-group-goto-next-group-function
			    group props)))
      (cond
       (empty
	(goto-char (point-min)))
       ((not group)
	;; Go to the first group with unread articles.
	(gnus-group-search-forward t))
       (t
	;; Find the right group to put point on.  If the current group
	;; has disappeared in the new listing, try to find the next
	;; one.  If no next one can be found, just leave point at the
	;; first newsgroup in the buffer.
	(when (not (gnus-goto-char
		    (text-property-any
		     (point-min) (point-max)
		     'gnus-group (gnus-intern-safe
				  group gnus-active-hashtb))))
1301
	  (let ((newsrc (cdddr (gnus-group-entry group))))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320
	    (while (and newsrc
			(not (gnus-goto-char
			      (text-property-any
			       (point-min) (point-max) 'gnus-group
			       (gnus-intern-safe
				(caar newsrc) gnus-active-hashtb)))))
	      (setq newsrc (cdr newsrc)))
	    (unless newsrc
	      (goto-char (point-max))
	      (forward-line -1)))))))
    ;; Adjust cursor point.
    (gnus-group-position-point)))

(defun gnus-group-list-level (level &optional all)
  "List groups on LEVEL.
If ALL (the prefix), also list groups that have no unread articles."
  (interactive "nList groups on level: \nP")
  (gnus-group-list-groups level all level))

1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333
(defun gnus-group-prepare-logic (group test)
  (or (and gnus-group-listed-groups
	   (null gnus-group-list-option)
	   (member group gnus-group-listed-groups))
      (cond
       ((null gnus-group-listed-groups) test)
       ((null gnus-group-list-option) test)
       (t (and (member group gnus-group-listed-groups)
	       (if (eq gnus-group-list-option 'flush)
		   (not test)
		 test))))))

(defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1334
  "List all newsgroups with unread articles of level LEVEL or lower.
1335 1336
If PREDICATE is a function, list groups that the function returns non-nil;
if it is t, list groups that have no unread articles.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1337
If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1338 1339
If REGEXP is a function, list dead groups that the function returns non-nil;
if it is a string, only list groups matching REGEXP."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1340 1341 1342 1343
  (set-buffer gnus-group-buffer)
  (let ((buffer-read-only nil)
	(newsrc (cdr gnus-newsrc-alist))
	(lowest (or lowest 1))
1344 1345
	(not-in-list (and gnus-group-listed-groups
			  (copy-sequence gnus-group-listed-groups)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1346 1347
	info clevel unread group params)
    (erase-buffer)
1348 1349
    (when (or (< lowest gnus-level-zombie)
	      gnus-group-listed-groups)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1350 1351 1352 1353 1354 1355
      ;; List living groups.
      (while newsrc
	(setq info (car newsrc)
	      group (gnus-info-group info)
	      params (gnus-info-params info)
	      newsrc (cdr newsrc)
1356
	      unread (gnus-group-unread group))
1357 1358 1359 1360
	(when not-in-list
	  (setq not-in-list (delete group not-in-list)))
	(when (gnus-group-prepare-logic
	       group
1361 1362
	       (and (or unread		; This group might be unchecked
			predicate)	; Check if this group should be listed
1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375
		    (or (not (stringp regexp))
			(string-match regexp group))
		    (<= (setq clevel (gnus-info-level info)) level)
		    (>= clevel lowest)
		    (cond
		     ((functionp predicate)
		      (funcall predicate info))
		     (predicate t)	; We list all groups?
		     (t
		      (or
		       (if (eq unread t) ; Unactivated?
			   gnus-group-list-inactive-groups
					; We list unactivated
1376
			 (and (numberp unread) (> unread 0)))
1377 1378 1379
					; We list groups with unread articles
		       (and gnus-list-groups-with-ticked-articles
			    (cdr (assq 'tick (gnus-info-marks info))))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1380
					; And groups with tickeds
1381 1382 1383 1384 1385 1386 1387 1388 1389
		       ;; Check for permanent visibility.
		       (and gnus-permanently-visible-groups
			    (string-match gnus-permanently-visible-groups
					  group))
		       (memq 'visible params)
		       (cdr (assq 'visible params)))))))
	  (gnus-group-insert-group-line
	   group (gnus-info-level info)
	   (gnus-info-marks info) unread (gnus-info-method info)))))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1390 1391

    ;; List dead groups.
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408
    (when (or gnus-group-listed-groups
	      (and (>= level gnus-level-zombie)
		   (<= lowest gnus-level-zombie)))
      (gnus-group-prepare-flat-list-dead
       (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
       gnus-level-zombie ?Z
       regexp))
    (when not-in-list
      (dolist (group gnus-zombie-list)
	(setq not-in-list (delete group not-in-list))))
    (when (or gnus-group-listed-groups
	      (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
      (gnus-group-prepare-flat-list-dead
       (gnus-union
	not-in-list
	(setq gnus-killed-list (sort gnus-killed-list 'string<)))
       gnus-level-killed ?K regexp))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1409 1410

    (gnus-group-set-mode-line)