(gmm-tool-bar-from-list): Fix typos in doc string. Remove debug
[gnus] / lisp / gnus-group.el
1 ;;; gnus-group.el --- group mode commands for Gnus
2
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;;   2005 Free Software Foundation, Inc.
5
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile
31   (require 'cl)
32   (defvar tool-bar-map))
33
34 (require 'gnus)
35 (require 'gnus-start)
36 (require 'nnmail)
37 (require 'gnus-spec)
38 (require 'gnus-int)
39 (require 'gnus-range)
40 (require 'gnus-win)
41 (require 'gnus-undo)
42 (require 'time-date)
43 (require 'gnus-ems)
44
45 (eval-when-compile
46   (require 'mm-url)
47   (let ((features (cons 'gnus-group features)))
48     (require 'gnus-sum))
49   (unless (boundp 'gnus-cache-active-hashtb)
50     (defvar gnus-cache-active-hashtb nil)))
51
52 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
53 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
54
55 (defcustom gnus-group-archive-directory
56   "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
57   "*The address of the (ding) archives."
58   :group 'gnus-group-foreign
59   :type 'directory)
60
61 (defcustom gnus-group-recent-archive-directory
62   "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
63   "*The address of the most recent (ding) articles."
64   :group 'gnus-group-foreign
65   :type 'directory)
66
67 (defcustom gnus-no-groups-message "No Gnus is good news"
68   "*Message displayed by Gnus when no groups are available."
69   :group 'gnus-start
70   :type 'string)
71
72 (defcustom gnus-keep-same-level nil
73   "*Non-nil means that the next newsgroup after the current will be on the same level.
74 When you type, for instance, `n' after reading the last article in the
75 current newsgroup, you will go to the next newsgroup.  If this variable
76 is nil, the next newsgroup will be the next from the group
77 buffer.
78 If this variable is non-nil, Gnus will either put you in the
79 next newsgroup with the same level, or, if no such newsgroup is
80 available, the next newsgroup with the lowest possible level higher
81 than the current level.
82 If this variable is `best', Gnus will make the next newsgroup the one
83 with the best level."
84   :group 'gnus-group-levels
85   :type '(choice (const nil)
86                  (const best)
87                  (sexp :tag "other" t)))
88
89 (defcustom gnus-group-goto-unread t
90   "*If non-nil, movement commands will go to the next unread and subscribed group."
91   :link '(custom-manual "(gnus)Group Maneuvering")
92   :group 'gnus-group-various
93   :type 'boolean)
94
95 (defcustom gnus-goto-next-group-when-activating t
96   "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
97   :link '(custom-manual "(gnus)Scanning New Messages")
98   :group 'gnus-group-various
99   :type 'boolean)
100
101 (defcustom gnus-permanently-visible-groups nil
102   "*Regexp to match groups that should always be listed in the group buffer.
103 This means that they will still be listed even when there are no
104 unread articles in the groups.
105
106 If nil, no groups are permanently visible."
107   :group 'gnus-group-listing
108   :type '(choice regexp (const nil)))
109
110 (defcustom gnus-list-groups-with-ticked-articles t
111   "*If non-nil, list groups that have only ticked articles.
112 If nil, only list groups that have unread articles."
113   :group 'gnus-group-listing
114   :type 'boolean)
115
116 (defcustom gnus-group-default-list-level gnus-level-subscribed
117   "*Default listing level.
118 Ignored if `gnus-group-use-permanent-levels' is non-nil."
119   :group 'gnus-group-listing
120   :type 'integer)
121
122 (defcustom gnus-group-list-inactive-groups t
123   "*If non-nil, inactive groups will be listed."
124   :group 'gnus-group-listing
125   :group 'gnus-group-levels
126   :type 'boolean)
127
128 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
129   "*Function used for sorting the group buffer.
130 This function will be called with group info entries as the arguments
131 for the groups to be sorted.  Pre-made functions include
132 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
133 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
134 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
135 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
136
137 This variable can also be a list of sorting functions.  In that case,
138 the most significant sort function should be the last function in the
139 list."
140   :group 'gnus-group-listing
141   :link '(custom-manual "(gnus)Sorting Groups")
142   :type '(repeat :value-to-internal (lambda (widget value)
143                                       (if (listp value) value (list value)))
144                  :match (lambda (widget value)
145                           (or (symbolp value)
146                               (widget-editable-list-match widget value)))
147                  (choice (function-item gnus-group-sort-by-alphabet)
148                          (function-item gnus-group-sort-by-real-name)
149                          (function-item gnus-group-sort-by-unread)
150                          (function-item gnus-group-sort-by-level)
151                          (function-item gnus-group-sort-by-score)
152                          (function-item gnus-group-sort-by-method)
153                          (function-item gnus-group-sort-by-server)
154                          (function-item gnus-group-sort-by-rank)
155                          (function :tag "other" nil))))
156
157 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
158   "*Format of group lines.
159 It works along the same lines as a normal formatting string,
160 with some simple extensions.
161
162 %M    Only marked articles (character, \"*\" or \" \")
163 %S    Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
164 %L    Level of subscribedness (integer)
165 %N    Number of unread articles (integer)
166 %I    Number of dormant articles (integer)
167 %i    Number of ticked and dormant (integer)
168 %T    Number of ticked articles (integer)
169 %R    Number of read articles (integer)
170 %U    Number of unseen articles (integer)
171 %t    Estimated total number of articles (integer)
172 %y    Number of unread, unticked articles (integer)
173 %G    Group name (string)
174 %g    Qualified group name (string)
175 %c    Short (collapsed) group name.  See `gnus-group-uncollapsed-levels'.
176 %C    Group comment (string)
177 %D    Group description (string)
178 %s    Select method (string)
179 %o    Moderated group (char, \"m\")
180 %p    Process mark (char)
181 %B    Whether a summary buffer for the group is open (char, \"*\")
182 %O    Moderated group (string, \"(m)\" or \"\")
183 %P    Topic indentation (string)
184 %m    Whether there is new(ish) mail in the group (char, \"%\")
185 %n    Select from where (string)
186 %z    A string that look like `<%s:%n>' if a foreign select method is used
187 %d    The date the group was last entered.
188 %E    Icon as defined by `gnus-group-icon-list'.
189 %F    The disk space used by the articles fetched by both the cache and agent.
190 %u    User defined specifier.  The next character in the format string should
191       be a letter.  Gnus will call the function gnus-user-format-function-X,
192       where X is the letter following %u.  The function will be passed a
193       single dummy parameter as argument.  The function should return a
194       string, which will be inserted into the buffer just like information
195       from any other group specifier.
196
197 Note that this format specification is not always respected.  For
198 reasons of efficiency, when listing killed groups, this specification
199 is ignored altogether.  If the spec is changed considerably, your
200 output may end up looking strange when listing both alive and killed
201 groups.
202
203 If you use %o or %O, reading the active file will be slower and quite
204 a bit of extra memory will be used.  %D and %F will also worsen
205 performance.  Also note that if you change the format specification to
206 include any of these specs, you must probably re-start Gnus to see
207 them go into effect.
208
209 General format specifiers can also be used.
210 See Info node `(gnus)Formatting Variables'."
211   :link '(custom-manual "(gnus)Formatting Variables")
212   :group 'gnus-group-visual
213   :type 'string)
214
215 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
216   "*The format specification for the group mode line.
217 It works along the same lines as a normal formatting string,
218 with some simple extensions:
219
220 %S   The native news server.
221 %M   The native select method.
222 %:   \":\" if %S isn't \"\"."
223   :group 'gnus-group-visual
224   :type 'string)
225
226 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
227 (when (featurep 'xemacs)
228   (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
229   (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
230
231 (defcustom gnus-group-menu-hook nil
232   "Hook run after the creation of the group mode menu."
233   :group 'gnus-group-various
234   :type 'hook)
235
236 (defcustom gnus-group-catchup-group-hook nil
237   "Hook run when catching up a group from the group buffer."
238   :group 'gnus-group-various
239   :link '(custom-manual "(gnus)Group Data")
240   :type 'hook)
241
242 (defcustom gnus-group-update-group-hook nil
243   "Hook called when updating group lines."
244   :group 'gnus-group-visual
245   :type 'hook)
246
247 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
248   "*A function that is called to generate the group buffer.
249 The function is called with three arguments: The first is a number;
250 all group with a level less or equal to that number should be listed,
251 if the second is non-nil, empty groups should also be displayed.  If
252 the third is non-nil, it is a number.  No groups with a level lower
253 than this number should be displayed.
254
255 The only current function implemented is `gnus-group-prepare-flat'."
256   :group 'gnus-group-listing
257   :type 'function)
258
259 (defcustom gnus-group-prepare-hook nil
260   "Hook called after the group buffer has been generated.
261 If you want to modify the group buffer, you can use this hook."
262   :group 'gnus-group-listing
263   :type 'hook)
264
265 (defcustom gnus-suspend-gnus-hook nil
266   "Hook called when suspending (not exiting) Gnus."
267   :group 'gnus-exit
268   :type 'hook)
269
270 (defcustom gnus-exit-gnus-hook nil
271   "Hook called when exiting Gnus."
272   :group 'gnus-exit
273   :type 'hook)
274
275 (defcustom gnus-after-exiting-gnus-hook nil
276   "Hook called after exiting Gnus."
277   :group 'gnus-exit
278   :type 'hook)
279
280 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
281   "Hook called when a group line is changed.
282 The hook will not be called if `gnus-visual' is nil.
283
284 The default function `gnus-group-highlight-line' will
285 highlight the line according to the `gnus-group-highlight'
286 variable."
287   :group 'gnus-group-visual
288   :type 'hook)
289
290 (defcustom gnus-useful-groups
291   '(("(ding) mailing list mirrored at sunsite.auc.dk"
292      "emacs.ding"
293      (nntp "sunsite.auc.dk"
294            (nntp-address "sunsite.auc.dk")))
295     ("gnus-bug archive"
296      "gnus-bug"
297      (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
298     ("Gnus help group"
299      "gnus-help"
300      (nndoc "gnus-help"
301             (nndoc-article-type mbox)
302             (eval `(nndoc-address
303                     ,(let ((file (nnheader-find-etc-directory
304                                   "gnus-tut.txt" t)))
305                        (unless file
306                          (error "Couldn't find doc group"))
307                        file))))))
308   "*Alist of useful group-server pairs."
309   :group 'gnus-group-listing
310   :type '(repeat (list (string :tag "Description")
311                        (string :tag "Name")
312                        (sexp :tag "Method"))))
313
314 (defcustom gnus-group-highlight
315   '(;; Mail.
316     ((and mailp (= unread 0) (eq level 1)) .
317      gnus-group-mail-1-empty)
318     ((and mailp (eq level 1)) .
319      gnus-group-mail-1)
320     ((and mailp (= unread 0) (eq level 2)) .
321      gnus-group-mail-2-empty)
322     ((and mailp (eq level 2)) .
323      gnus-group-mail-2)
324     ((and mailp (= unread 0) (eq level 3)) .
325      gnus-group-mail-3-empty)
326     ((and mailp (eq level 3)) .
327      gnus-group-mail-3)
328     ((and mailp (= unread 0)) .
329      gnus-group-mail-low-empty)
330     ((and mailp) .
331      gnus-group-mail-low)
332     ;; News.
333     ((and (= unread 0) (eq level 1)) .
334      gnus-group-news-1-empty)
335     ((and (eq level 1)) .
336      gnus-group-news-1)
337     ((and (= unread 0) (eq level 2)) .
338      gnus-group-news-2-empty)
339     ((and (eq level 2)) .
340      gnus-group-news-2)
341     ((and (= unread 0) (eq level 3)) .
342      gnus-group-news-3-empty)
343     ((and (eq level 3)) .
344      gnus-group-news-3)
345     ((and (= unread 0) (eq level 4)) .
346      gnus-group-news-4-empty)
347     ((and (eq level 4)) .
348      gnus-group-news-4)
349     ((and (= unread 0) (eq level 5)) .
350      gnus-group-news-5-empty)
351     ((and (eq level 5)) .
352      gnus-group-news-5)
353     ((and (= unread 0) (eq level 6)) .
354      gnus-group-news-6-empty)
355     ((and (eq level 6)) .
356      gnus-group-news-6)
357     ((and (= unread 0)) .
358      gnus-group-news-low-empty)
359     (t .
360      gnus-group-news-low))
361   "*Controls the highlighting of group buffer lines.
362
363 Below is a list of `Form'/`Face' pairs.  When deciding how a a
364 particular group line should be displayed, each form is
365 evaluated.  The content of the face field after the first true form is
366 used.  You can change how those group lines are displayed by
367 editing the face field.
368
369 It is also possible to change and add form fields, but currently that
370 requires an understanding of Lisp expressions.  Hopefully this will
371 change in a future release.  For now, you can use the following
372 variables in the Lisp expression:
373
374 group: The name of the group.
375 unread: The number of unread articles in the group.
376 method: The select method used.
377 mailp: Whether it's a mail group or not.
378 level: The level of the group.
379 score: The score of the group.
380 ticked: The number of ticked articles."
381   :group 'gnus-group-visual
382   :type '(repeat (cons (sexp :tag "Form") face)))
383
384 (defcustom gnus-new-mail-mark ?%
385   "Mark used for groups with new mail."
386   :group 'gnus-group-visual
387   :type 'character)
388
389 (defgroup gnus-group-icons nil
390   "Add Icons to your group buffer."
391   :group 'gnus-group-visual)
392