gnus-group.el 168 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-2012  Free Software Foundation, Inc.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
4

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

;; This file is part of GNU Emacs.

10
;; GNU Emacs is free software: you can redistribute it and/or modify
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
11
;; it under the terms of the GNU General Public License as published by
12 13
;; 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
14 15 16

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

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

;;; Commentary:

;;; Code:

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

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

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

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

57 58
(autoload 'gnus-group-make-nnir-group "nnir")

59
(defcustom gnus-no-groups-message "No news is good news"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
60 61 62 63 64 65 66 67 68 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
  "*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.
95 96 97 98
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
99
  :group 'gnus-group-listing
100
  :type '(choice regexp (const nil)))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
101

Miles Bader's avatar
Miles Bader committed
102 103 104 105 106 107 108 109 110 111 112 113
(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
114 115 116 117 118 119 120
(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
121
  "Default listing level.
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
122 123
Ignored if `gnus-group-use-permanent-levels' is non-nil."
  :group 'gnus-group-listing
124 125
  :type '(choice (integer :tag "Level")
                 (function :tag "Function returning level")))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
126 127 128 129 130 131 132 133 134 135 136 137 138

(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',
139 140
`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
141

142
This variable can also be a list of sorting functions.  In that case,
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
143 144 145 146
the most significant sort function should be the last function in the
list."
  :group 'gnus-group-listing
  :link '(custom-manual "(gnus)Sorting Groups")
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
  :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))))

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

Note that this format specification is not always respected.  For
reasons of efficiency, when listing killed groups, this specification
204
is ignored altogether.  If the spec is changed considerably, your
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
205 206 207 208
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
209 210 211 212
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.
213 214 215 216

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
217 218 219 220 221 222 223 224 225 226 227 228 229 230
  :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)

231 232 233 234
;; 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
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

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

285 286
(defcustom gnus-group-update-hook nil
  "Hook called when a group line is changed."
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
287
  :group 'gnus-group-visual
288
  :version "24.1"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
289 290 291
  :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

Juanma Barranquero's avatar
Juanma Barranquero committed
365
Below is a list of `Form'/`Face' pairs.  When deciding how a
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
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
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.
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
422
(put 'gnus-group-icon-list 'risky-local-variable t)
423 424

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

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

433 434 435 436 437 438
(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.
439 440

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

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

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'."
455
  :version "22.1"
456 457
  :group 'gnus-group-various
  :type '(choice (string :tag "Prompt string")
458 459 460
		 (const :tag "Empty" nil)
		 (repeat (cons (integer :tag "Argument")
			       (string :tag "Prompt string")))))
461 462 463 464 465 466

(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
467 468
;;; Internal variables

469 470
(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
471 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
(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)
497 498 499 500
    (?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
501 502 503 504 505 506
    (?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)
507 508 509 510
    (?g (if (boundp 'gnus-tmp-decoded-group)
	    gnus-tmp-decoded-group
	  gnus-tmp-group)
	?s)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
511
    (?G gnus-tmp-qualified-group ?s)
512 513 514 515
    (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
				   gnus-tmp-decoded-group
				 gnus-tmp-group))
	?s)
516
    (?C gnus-tmp-comment ?s)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
517 518 519 520 521
    (?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)
522 523 524 525
    (?n ,(if (featurep 'xemacs)
	     '(symbol-name gnus-tmp-news-method)
	   'gnus-tmp-news-method)
	?s)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
526
    (?P gnus-group-indentation ?s)
527
    (?E gnus-tmp-group-icon ?s)
528
    (?B gnus-tmp-summary-live ?c)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
529 530 531
    (?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)
532 533 534
    (?u gnus-tmp-user-defined ?s)
    (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
    ))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551

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

552

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
  "<" 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
  "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
658
  "G" gnus-group-make-nnir-group
659 660 661 662
  "M" gnus-group-read-ephemeral-group
  "r" gnus-group-rename-group
  "R" gnus-group-make-rss-group
  "c" gnus-group-customize
663
  "z" gnus-group-compact-group
664
  "x" gnus-group-expunge-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
  "\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
700 701
  "?" gnus-group-list-dormant
  "!" gnus-group-list-ticked)
702 703 704 705 706 707 708 709 710 711 712

(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
713 714
  "?"  gnus-group-list-limit
  "!"  gnus-group-list-limit)
715 716 717 718 719 720 721 722 723 724 725

(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
726 727
  "?"  gnus-group-list-flush
  "!"  gnus-group-list-flush)
728 729 730 731 732 733 734 735 736 737 738

(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
739 740
  "?"  gnus-group-list-plus
  "!"  gnus-group-list-plus)
741 742

(gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
743 744
  "f" gnus-score-flush-cache
  "e" gnus-score-edit-all-score)
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763

(gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
  "d" gnus-group-describe-group
  "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
764 765 766 767 768 769

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

    (easy-menu-define
     gnus-group-reading-menu gnus-group-mode-map ""
770 771 772 773 774 775 776 777 778 779 780
     `("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
781 782
       ["See old articles" (gnus-group-select-group 'all)
	:keys "C-u SPC" :active (gnus-group-group-name)]
783 784 785 786 787 788 789 790 791
       ["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
792 793 794
       ["Catch up all articles" gnus-group-catchup-current-all
	(gnus-group-group-name)]
       ["Check for new articles" gnus-group-get-new-news-this-group
795
	:included (not (gnus-topic-mode-p))
796
	:active (gnus-group-group-name)
797 798 799 800 801 802
	,@(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
803 804
       ["Toggle subscription" gnus-group-unsubscribe-current-group
	(gnus-group-group-name)]
805
       ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
806 807
	,@(if (featurep 'xemacs) nil
	      '(:help "Kill (remove) current group"))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
808
       ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
809
       ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
810 811
	,@(if (featurep 'xemacs) nil
	    '(:help "Display description of the current group"))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
812 813 814
       ;; 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
815 816 817 818 819 820 821 822
	: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
823 824 825
	(gnus-group-group-name)]
       ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
       ["Customize" gnus-group-customize (gnus-group-group-name)]
826 827
       ["Compact" gnus-group-compact-group
	:active (gnus-group-group-name)]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
828 829
       ("Edit"
	["Parameters" gnus-group-edit-group-parameters
830 831 832 833
	 :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
834 835 836 837
	["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)]
838
	["Global kill file" gnus-group-edit-global-kill t])))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
839 840 841 842 843 844 845 846 847 848 849 850 851 852 853

    (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]
854 855
	["List active file" gnus-group-list-active t]
	["List groups with cached" gnus-group-list-cached t]
856 857
	["List groups with dormant" gnus-group-list-dormant t]
	["List groups with ticked" gnus-group-list-ticked t])
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
858 859 860 861 862 863 864
       ("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]
865 866
	["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
867 868
       ("Sort process/prefixed"
	["Default sort" gnus-group-sort-selected-groups
869
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
870
	["Sort by method" gnus-group-sort-selected-groups-by-method
871
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
872
	["Sort by rank" gnus-group-sort-selected-groups-by-rank
873
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
874
	["Sort by score" gnus-group-sort-selected-groups-by-score
875
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
876
	["Sort by level" gnus-group-sort-selected-groups-by-level
877
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
878
	["Sort by unread" gnus-group-sort-selected-groups-by-unread
879
	 (not (gnus-topic-mode-p))]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
880
	["Sort by name" gnus-group-sort-selected-groups-by-alphabet
881 882 883
	 (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
884 885 886 887 888 889 890 891 892
       ("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]
893
	["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
894 895 896 897
	["Mark buffer" gnus-group-mark-buffer t]
	["Execute command" gnus-group-universal-argument
	 (or gnus-group-marked (gnus-group-group-name))])
       ("Subscribe"
898 899 900
	["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
901 902 903 904
	["Kill all zombie groups" gnus-group-kill-all-zombies
	 gnus-zombie-list]
	["Kill all groups on level..." gnus-group-kill-level t])
       ("Foreign groups"
905 906
	["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
907
	["Add the help group" gnus-group-make-help-group t]
908 909
	["Make a doc group..." gnus-group-make-doc-group t]
	["Make a web group..." gnus-group-make-web-group t]
910
	["Make a search group..." gnus-group-make-nnir-group t]
911 912 913 914 915
	["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
916 917 918 919 920 921 922 923 924 925 926 927 928
	 (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]
929
	["Jump to group..." gnus-group-jump-to-group t]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
930 931
	["First unread group" gnus-group-first-unread-group t]
	["Best unread group" gnus-group-best-unread-group t])
932 933 934
       ("Sieve"
	["Generate" gnus-sieve-generate t]
	["Generate and update" gnus-sieve-update t])
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
935
       ["Delete bogus groups" gnus-group-check-bogus-groups t]
936
       ["Find new newsgroups" gnus-group-find-new-groups t]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
937 938
       ["Transpose" gnus-group-transpose-groups
	(gnus-group-group-name)]
939
       ["Read a directory as a group..." gnus-group-enter-directory t]))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
940 941 942

    (easy-menu-define
     gnus-group-misc-menu gnus-group-mode-map ""
943
     `("Gnus"
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
944
       ["Send a mail" gnus-group-mail t]
945 946
       ["Send a message (mail or news)" gnus-group-post-news t]
       ["Create a local message" gnus-group-news t]
947
       ["Check for new news" gnus-group-get-new-news
948 949 950 951 952 953 954
	,@(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
955 956 957
       ["Activate all groups" gnus-activate-all-groups t]
       ["Restart Gnus" gnus-group-restart t]
       ["Read init file" gnus-group-read-init-file t]
958
       ["Browse foreign server..." gnus-group-browse-foreign-server t]
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
959 960 961 962 963 964 965 966 967
       ["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]
968
       ["Send a bug report" gnus-bug t]
969
       ["Exit from Gnus" gnus-group-exit
970 971
	,@(if (featurep 'xemacs) '(t)
	    '(:help "Quit reading news"))]
972
       ["Exit without saving" gnus-group-quit t]))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
973

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

976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994

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

Paul Eggert's avatar
Paul Eggert committed
995
It can be either a list or a symbol referring to a list.  See
996 997 998 999 1000 1001 1002 1003 1004
`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))
1005
  :version "23.1" ;; No Gnus
1006 1007 1008 1009 1010 1011 1012 1013
  :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:
1014
    (gnus-agent-toggle-plugged "unplugged" t
Miles Bader's avatar
Miles Bader committed
1015 1016
			       :help "Gnus is currently unplugged.  Click to work online."
     			       :visible (and gnus-agent (not gnus-plugged)))
1017
    (gnus-agent-toggle-plugged "plugged" t
Miles Bader's avatar
Miles Bader committed
1018
			       :help "Gnus is currently plugged.  Click to work offline."
1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
     			       :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)
1048
  :version "23.1" ;; No Gnus
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066
  :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)
1067
  :version "23.1" ;; No Gnus
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077
  :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
1078
  :version "23.1" ;; No Gnus
1079 1080 1081 1082 1083
  :initialize 'custom-initialize-default
  :set 'gnus-group-tool-bar-update
  :group 'gnus-group)

(defvar image-load-path)
1084
(defvar tool-bar-map)
1085 1086 1087 1088 1089 1090 1091

(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
1092
             (display-graphic-p)
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106
	     (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)
1107

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1108 1109 1110 1111 1112
(defun gnus-group-mode ()
  "Major mode for reading news.

All normal editing commands are switched off.
\\<gnus-group-mode-map>
1113
The group buffer lists (some of) the groups available.  For instance,
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125
`\\[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)
1126
  (kill-all-local-variables)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1127
  (when (gnus-visual-p 'group-menu 'menu)
1128 1129
    (gnus-group-make-menu-bar)
    (gnus-group-make-tool-bar))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1130 1131 1132 1133 1134 1135
  (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)
1136
  (buffer-disable-undo)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1137
  (setq truncate-lines t)
1138 1139
  (setq buffer-read-only t
	show-trailing-whitespace nil)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1140 1141 1142 1143 1144
  (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))
1145 1146
  (when gnus-slave
    (gnus-slave-mode))
1147
  (gnus-run-mode-hooks 'gnus-group-mode-hook))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1148 1149 1150

(defun gnus-update-group-mark-positions ()
  (save-excursion
1151
    (let ((gnus-process-mark ?\200)
1152
	  (gnus-group-update-hook nil)
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1153
	  (gnus-group-marked '("dummy.group"))
1154 1155
	  (gnus-active-hashtb (make-vector 10 0))
	  (topic ""))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1156 1157 1158 1159 1160
      (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
1161
	    (list (cons 'process (and (search-forward
1162 1163
				       (mm-string-to-multibyte "\200") nil t)
				      (- (point) (point-min) 1))))))))
Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1164 1165 1166 1167 1168 1169 1170

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

1171 1172 1173 1174 1175 1176
(defun gnus-group-default-list-level ()
  "Return the real value for `gnus-group-default-list-level'."
  (if (functionp gnus-group-default-list-level)
      (funcall gnus-group-default-list-level)
    gnus-group-default-list-level))

Lars Magne Ingebrigtsen's avatar
Lars Magne Ingebrigtsen committed
1177 1178 1179 1180 1181 1182 1183 1184 1185
;; 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