* smime.el (from):
[emacs.git] / lisp / gnus / gnus-group.el
blobd043a515f492edcab22917a3803695f00ec76cdb
1 ;;; gnus-group.el --- group mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news
9 ;; This file is part of GNU Emacs.
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 3, or (at your option)
14 ;; any later version.
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.
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.
26 ;;; Commentary:
28 ;;; Code:
30 (eval-when-compile
31 (require 'cl))
32 (defvar tool-bar-mode)
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 'gmm-utils)
43 (require 'time-date)
44 (require 'gnus-ems)
46 (eval-when-compile
47 (require 'mm-url)
48 (let ((features (cons 'gnus-group features)))
49 (require 'gnus-sum))
50 (unless (boundp 'gnus-cache-active-hashtb)
51 (defvar gnus-cache-active-hashtb nil)))
53 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
54 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
56 (defcustom gnus-group-archive-directory
57 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
58 "*The address of the (ding) archives."
59 :group 'gnus-group-foreign
60 :type 'directory)
62 (defcustom gnus-group-recent-archive-directory
63 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
64 "*The address of the most recent (ding) articles."
65 :group 'gnus-group-foreign
66 :type 'directory)
68 (defcustom gnus-no-groups-message "No Gnus is good news"
69 "*Message displayed by Gnus when no groups are available."
70 :group 'gnus-start
71 :type 'string)
73 (defcustom gnus-keep-same-level nil
74 "*Non-nil means that the next newsgroup after the current will be on the same level.
75 When you type, for instance, `n' after reading the last article in the
76 current newsgroup, you will go to the next newsgroup. If this variable
77 is nil, the next newsgroup will be the next from the group
78 buffer.
79 If this variable is non-nil, Gnus will either put you in the
80 next newsgroup with the same level, or, if no such newsgroup is
81 available, the next newsgroup with the lowest possible level higher
82 than the current level.
83 If this variable is `best', Gnus will make the next newsgroup the one
84 with the best level."
85 :group 'gnus-group-levels
86 :type '(choice (const nil)
87 (const best)
88 (sexp :tag "other" t)))
90 (defcustom gnus-group-goto-unread t
91 "*If non-nil, movement commands will go to the next unread and subscribed group."
92 :link '(custom-manual "(gnus)Group Maneuvering")
93 :group 'gnus-group-various
94 :type 'boolean)
96 (defcustom gnus-goto-next-group-when-activating t
97 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
98 :link '(custom-manual "(gnus)Scanning New Messages")
99 :group 'gnus-group-various
100 :type 'boolean)
102 (defcustom gnus-permanently-visible-groups nil
103 "*Regexp to match groups that should always be listed in the group buffer.
104 This means that they will still be listed even when there are no
105 unread articles in the groups.
107 If nil, no groups are permanently visible."
108 :group 'gnus-group-listing
109 :type '(choice regexp (const nil)))
111 (defcustom gnus-list-groups-with-ticked-articles t
112 "*If non-nil, list groups that have only ticked articles.
113 If nil, only list groups that have unread articles."
114 :group 'gnus-group-listing
115 :type 'boolean)
117 (defcustom gnus-group-default-list-level gnus-level-subscribed
118 "*Default listing level.
119 Ignored if `gnus-group-use-permanent-levels' is non-nil."
120 :group 'gnus-group-listing
121 :type 'integer)
123 (defcustom gnus-group-list-inactive-groups t
124 "*If non-nil, inactive groups will be listed."
125 :group 'gnus-group-listing
126 :group 'gnus-group-levels
127 :type 'boolean)
129 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
130 "*Function used for sorting the group buffer.
131 This function will be called with group info entries as the arguments
132 for the groups to be sorted. Pre-made functions include
133 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
134 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
135 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
136 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
138 This variable can also be a list of sorting functions. In that case,
139 the most significant sort function should be the last function in the
140 list."
141 :group 'gnus-group-listing
142 :link '(custom-manual "(gnus)Sorting Groups")
143 :type '(repeat :value-to-internal (lambda (widget value)
144 (if (listp value) value (list value)))
145 :match (lambda (widget value)
146 (or (symbolp value)
147 (widget-editable-list-match widget value)))
148 (choice (function-item gnus-group-sort-by-alphabet)
149 (function-item gnus-group-sort-by-real-name)
150 (function-item gnus-group-sort-by-unread)
151 (function-item gnus-group-sort-by-level)
152 (function-item gnus-group-sort-by-score)
153 (function-item gnus-group-sort-by-method)
154 (function-item gnus-group-sort-by-server)
155 (function-item gnus-group-sort-by-rank)
156 (function :tag "other" nil))))
158 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
159 "*Format of group lines.
160 It works along the same lines as a normal formatting string,
161 with some simple extensions.
163 %M Only marked articles (character, \"*\" or \" \")
164 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
165 %L Level of subscribedness (integer)
166 %N Number of unread articles (integer)
167 %I Number of dormant articles (integer)
168 %i Number of ticked and dormant (integer)
169 %T Number of ticked articles (integer)
170 %R Number of read articles (integer)
171 %U Number of unseen articles (integer)
172 %t Estimated total number of articles (integer)
173 %y Number of unread, unticked articles (integer)
174 %G Group name (string)
175 %g Qualified group name (string)
176 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
177 %C Group comment (string)
178 %D Group description (string)
179 %s Select method (string)
180 %o Moderated group (char, \"m\")
181 %p Process mark (char)
182 %B Whether a summary buffer for the group is open (char, \"*\")
183 %O Moderated group (string, \"(m)\" or \"\")
184 %P Topic indentation (string)
185 %m Whether there is new(ish) mail in the group (char, \"%\")
186 %n Select from where (string)
187 %z A string that look like `<%s:%n>' if a foreign select method is used
188 %d The date the group was last entered.
189 %E Icon as defined by `gnus-group-icon-list'.
190 %F The disk space used by the articles fetched by both the cache and agent.
191 %u User defined specifier. The next character in the format string should
192 be a letter. Gnus will call the function gnus-user-format-function-X,
193 where X is the letter following %u. The function will be passed a
194 single dummy parameter as argument. The function should return a
195 string, which will be inserted into the buffer just like information
196 from any other group specifier.
198 Note that this format specification is not always respected. For
199 reasons of efficiency, when listing killed groups, this specification
200 is ignored altogether. If the spec is changed considerably, your
201 output may end up looking strange when listing both alive and killed
202 groups.
204 If you use %o or %O, reading the active file will be slower and quite
205 a bit of extra memory will be used. %D and %F will also worsen
206 performance. Also note that if you change the format specification to
207 include any of these specs, you must probably re-start Gnus to see
208 them go into effect.
210 General format specifiers can also be used.
211 See Info node `(gnus)Formatting Variables'."
212 :link '(custom-manual "(gnus)Formatting Variables")
213 :group 'gnus-group-visual
214 :type 'string)
216 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
217 "*The format specification for the group mode line.
218 It works along the same lines as a normal formatting string,
219 with some simple extensions:
221 %S The native news server.
222 %M The native select method.
223 %: \":\" if %S isn't \"\"."
224 :group 'gnus-group-visual
225 :type 'string)
227 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
228 (when (featurep 'xemacs)
229 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
230 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
232 (defcustom gnus-group-menu-hook nil
233 "Hook run after the creation of the group mode menu."
234 :group 'gnus-group-various
235 :type 'hook)
237 (defcustom gnus-group-catchup-group-hook nil
238 "Hook run when catching up a group from the group buffer."
239 :group 'gnus-group-various
240 :link '(custom-manual "(gnus)Group Data")
241 :type 'hook)
243 (defcustom gnus-group-update-group-hook nil
244 "Hook called when updating group lines."
245 :group 'gnus-group-visual
246 :type 'hook)
248 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
249 "*A function that is called to generate the group buffer.
250 The function is called with three arguments: The first is a number;
251 all group with a level less or equal to that number should be listed,
252 if the second is non-nil, empty groups should also be displayed. If
253 the third is non-nil, it is a number. No groups with a level lower
254 than this number should be displayed.
256 The only current function implemented is `gnus-group-prepare-flat'."
257 :group 'gnus-group-listing
258 :type 'function)
260 (defcustom gnus-group-prepare-hook nil
261 "Hook called after the group buffer has been generated.
262 If you want to modify the group buffer, you can use this hook."
263 :group 'gnus-group-listing
264 :type 'hook)
266 (defcustom gnus-suspend-gnus-hook nil
267 "Hook called when suspending (not exiting) Gnus."
268 :group 'gnus-exit
269 :type 'hook)
271 (defcustom gnus-exit-gnus-hook nil
272 "Hook called when exiting Gnus."
273 :group 'gnus-exit
274 :type 'hook)
276 (defcustom gnus-after-exiting-gnus-hook nil
277 "Hook called after exiting Gnus."
278 :group 'gnus-exit
279 :type 'hook)
281 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
282 "Hook called when a group line is changed.
283 The hook will not be called if `gnus-visual' is nil.
285 The default function `gnus-group-highlight-line' will
286 highlight the line according to the `gnus-group-highlight'
287 variable."
288 :group 'gnus-group-visual
289 :type 'hook)
291 (defcustom gnus-useful-groups
292 '(("(ding) mailing list mirrored at gmane.org"
293 "gmane.emacs.gnus.general"
294 (nntp "Gmane"
295 (nntp-address "news.gmane.org")))
296 ("Gnus bug archive"
297 "gnus.gnus-bug"
298 (nntp "news.gnus.org"
299 (nntp-address "news.gnus.org")))
300 ("Local Gnus help group"
301 "gnus-help"
302 (nndoc "gnus-help"
303 (nndoc-article-type mbox)
304 (eval `(nndoc-address
305 ,(let ((file (nnheader-find-etc-directory
306 "gnus-tut.txt" t)))
307 (unless file
308 (error "Couldn't find doc group"))
309 file))))))
310 "*Alist of useful group-server pairs."
311 :group 'gnus-group-listing
312 :type '(repeat (list (string :tag "Description")
313 (string :tag "Name")
314 (sexp :tag "Method"))))
316 (defcustom gnus-group-highlight
317 '(;; Mail.
318 ((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 ;; News.
335 ((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)
361 (t .
362 gnus-group-news-low))
363 "*Controls the highlighting of group buffer lines.
365 Below is a list of `Form'/`Face' pairs. When deciding how a a
366 particular group line should be displayed, each form is
367 evaluated. The content of the face field after the first true form is
368 used. You can change how those group lines are displayed by
369 editing the face field.
371 It is also possible to change and add form fields, but currently that
372 requires an understanding of Lisp expressions. Hopefully this will
373 change in a future release. For now, you can use the following
374 variables in the Lisp expression:
376 group: The name of the group.
377 unread: The number of unread articles in the group.
378 method: The select method used.
379 mailp: Whether it's a mail group or not.
380 level: The level of the group.
381 score: The score of the group.
382 ticked: The number of ticked articles."
383 :group 'gnus-group-visual
384 :type '(repeat (cons (sexp :tag "Form") face)))
385 (put 'gnus-group-highlight 'risky-local-variable t)
387 (defcustom gnus-new-mail-mark ?%
388 "Mark used for groups with new mail."
389 :group 'gnus-group-visual
390 :type 'character)
392 (defgroup gnus-group-icons nil
393 "Add Icons to your group buffer."
394 :group 'gnus-group-visual)
396 (defcustom gnus-group-icon-list
398 "*Controls the insertion of icons into group buffer lines.
400 Below is a list of `Form'/`File' pairs. When deciding how a
401 particular group line should be displayed, each form is evaluated.
402 The icon from the file field after the first true form is used. You
403 can change how those group lines are displayed by editing the file
404 field. The File will either be found in the
405 `gnus-group-glyph-directory' or by designating absolute name of the
406 file.
408 It is also possible to change and add form fields, but currently that
409 requires an understanding of Lisp expressions. Hopefully this will
410 change in a future release. For now, you can use the following
411 variables in the Lisp expression:
413 group: The name of the group.
414 unread: The number of unread articles in the group.
415 method: The select method used.
416 mailp: Whether it's a mail group or not.
417 newsp: Whether it's a news group or not
418 level: The level of the group.
419 score: The score of the group.
420 ticked: The number of ticked articles."
421 :group 'gnus-group-icons
422 :type '(repeat (cons (sexp :tag "Form") file)))
423 (put 'gnus-group-icon-list 'risky-local-variable t)
425 (defcustom gnus-group-name-charset-method-alist nil
426 "Alist of method and the charset for group names.
428 For example:
429 (((nntp \"news.com.cn\") . cn-gb-2312))"
430 :version "21.1"
431 :group 'gnus-charset
432 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
434 (defcustom gnus-group-name-charset-group-alist
435 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
436 (mm-coding-system-p 'utf-8))
437 '((".*" . utf-8))
438 nil)
439 "Alist of group regexp and the charset for group names.
441 For example:
442 ((\"\\.com\\.cn:\" . cn-gb-2312))"
443 :group 'gnus-charset
444 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
446 (defcustom gnus-group-jump-to-group-prompt nil
447 "Default prompt for `gnus-group-jump-to-group'.
449 If non-nil, the value should be a string or an alist. If it is a string,
450 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
451 nnml:\" in the minibuffer prompt.
453 If it is an alist, it must consist of \(NUMBER . PROMPT\) pairs, for example:
454 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
455 used when no prefix argument is given to `gnus-group-jump-to-group'."
456 :version "22.1"
457 :group 'gnus-group-various
458 :type '(choice (string :tag "Prompt string")
459 (const :tag "Empty" nil)
460 (repeat (cons (integer :tag "Argument")
461 (string :tag "Prompt string")))))
463 (defvar gnus-group-listing-limit 1000
464 "*A limit of the number of groups when listing.
465 If the number of groups is larger than the limit, list them in a
466 simple manner.")
468 ;;; Internal variables
470 (defvar gnus-group-is-exiting-p nil)
471 (defvar gnus-group-is-exiting-without-update-p nil)
472 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
473 "Function for sorting the group buffer.")
475 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
476 "Function for sorting the selected groups in the group buffer.")
478 (defvar gnus-group-indentation-function nil)
479 (defvar gnus-goto-missing-group-function nil)
480 (defvar gnus-group-update-group-function nil)
481 (defvar gnus-group-goto-next-group-function nil
482 "Function to override finding the next group after listing groups.")
484 (defvar gnus-group-edit-buffer nil)
486 (defvar gnus-group-line-format-alist
487 `((?M gnus-tmp-marked-mark ?c)
488 (?S gnus-tmp-subscribed ?c)
489 (?L gnus-tmp-level ?d)
490 (?N (cond ((eq number t) "*" )
491 ((numberp number)
492 (int-to-string
493 (+ number
494 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
495 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
496 (t number)) ?s)
497 (?R gnus-tmp-number-of-read ?s)
498 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
499 (?t gnus-tmp-number-total ?d)
500 (?y gnus-tmp-number-of-unread ?s)
501 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
502 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
503 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
504 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
505 (?g (if (boundp 'gnus-tmp-decoded-group)
506 gnus-tmp-decoded-group
507 gnus-tmp-group)
509 (?G gnus-tmp-qualified-group ?s)
510 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
511 gnus-tmp-decoded-group
512 gnus-tmp-group))
514 (?C gnus-tmp-comment ?s)
515 (?D gnus-tmp-newsgroup-description ?s)
516 (?o gnus-tmp-moderated ?c)
517 (?O gnus-tmp-moderated-string ?s)
518 (?p gnus-tmp-process-marked ?c)
519 (?s gnus-tmp-news-server ?s)
520 (?n ,(if (featurep 'xemacs)
521 '(symbol-name gnus-tmp-news-method)
522 'gnus-tmp-news-method)
524 (?P gnus-group-indentation ?s)
525 (?E gnus-tmp-group-icon ?s)
526 (?B gnus-tmp-summary-live ?c)
527 (?z gnus-tmp-news-method-string ?s)
528 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
529 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
530 (?u gnus-tmp-user-defined ?s)
531 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
534 (defvar gnus-group-mode-line-format-alist
535 `((?S gnus-tmp-news-server ?s)
536 (?M gnus-tmp-news-method ?s)
537 (?u gnus-tmp-user-defined ?s)
538 (?: gnus-tmp-colon ?s)))
540 (defvar gnus-topic-topology nil
541 "The complete topic hierarchy.")
543 (defvar gnus-topic-alist nil
544 "The complete topic-group alist.")
546 (defvar gnus-group-marked nil)
548 (defvar gnus-group-list-mode nil)
551 (defvar gnus-group-icon-cache nil)
553 (defvar gnus-group-listed-groups nil)
554 (defvar gnus-group-list-option nil)
557 ;;; Gnus group mode
560 (put 'gnus-group-mode 'mode-class 'special)
562 (gnus-define-keys gnus-group-mode-map
563 " " gnus-group-read-group
564 "=" gnus-group-select-group
565 "\r" gnus-group-select-group
566 "\M-\r" gnus-group-quick-select-group
567 "\M- " gnus-group-visible-select-group
568 [(meta control return)] gnus-group-select-group-ephemerally
569 "j" gnus-group-jump-to-group
570 "n" gnus-group-next-unread-group
571 "p" gnus-group-prev-unread-group
572 "\177" gnus-group-prev-unread-group
573 [delete] gnus-group-prev-unread-group
574 [backspace] gnus-group-prev-unread-group
575 "N" gnus-group-next-group
576 "P" gnus-group-prev-group
577 "\M-n" gnus-group-next-unread-group-same-level
578 "\M-p" gnus-group-prev-unread-group-same-level
579 "," gnus-group-best-unread-group
580 "." gnus-group-first-unread-group
581 "u" gnus-group-unsubscribe-current-group
582 "U" gnus-group-unsubscribe-group
583 "c" gnus-group-catchup-current
584 "C" gnus-group-catchup-current-all
585 "\M-c" gnus-group-clear-data
586 "l" gnus-group-list-groups
587 "L" gnus-group-list-all-groups
588 "m" gnus-group-mail
589 "i" gnus-group-news
590 "g" gnus-group-get-new-news
591 "\M-g" gnus-group-get-new-news-this-group
592 "R" gnus-group-restart
593 "r" gnus-group-read-init-file
594 "B" gnus-group-browse-foreign-server
595 "b" gnus-group-check-bogus-groups
596 "F" gnus-group-find-new-groups
597 "\C-c\C-d" gnus-group-describe-group
598 "\M-d" gnus-group-describe-all-groups
599 "\C-c\C-a" gnus-group-apropos
600 "\C-c\M-\C-a" gnus-group-description-apropos
601 "a" gnus-group-post-news
602 "\ek" gnus-group-edit-local-kill
603 "\eK" gnus-group-edit-global-kill
604 "\C-k" gnus-group-kill-group
605 "\C-y" gnus-group-yank-group
606 "\C-w" gnus-group-kill-region
607 "\C-x\C-t" gnus-group-transpose-groups
608 "\C-c\C-l" gnus-group-list-killed
609 "\C-c\C-x" gnus-group-expire-articles
610 "\C-c\M-\C-x" gnus-group-expire-all-groups
611 "V" gnus-version
612 "s" gnus-group-save-newsrc
613 "z" gnus-group-suspend
614 "q" gnus-group-exit
615 "Q" gnus-group-quit
616 "?" gnus-group-describe-briefly
617 "\C-c\C-i" gnus-info-find-node
618 "\M-e" gnus-group-edit-group-method
619 "^" gnus-group-enter-server-mode
620 gnus-mouse-2 gnus-mouse-pick-group
621 [follow-link] mouse-face
622 "<" beginning-of-buffer
623 ">" end-of-buffer
624 "\C-c\C-b" gnus-bug
625 "\C-c\C-s" gnus-group-sort-groups
626 "t" gnus-topic-mode
627 "\C-c\M-g" gnus-activate-all-groups
628 "\M-&" gnus-group-universal-argument
629 "#" gnus-group-mark-group
630 "\M-#" gnus-group-unmark-group)
632 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
633 "m" gnus-group-mark-group
634 "u" gnus-group-unmark-group
635 "w" gnus-group-mark-region
636 "b" gnus-group-mark-buffer
637 "r" gnus-group-mark-regexp
638 "U" gnus-group-unmark-all-groups)
640 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
641 "u" gnus-sieve-update
642 "g" gnus-sieve-generate)
644 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
645 "d" gnus-group-make-directory-group
646 "h" gnus-group-make-help-group
647 "u" gnus-group-make-useful-group
648 "a" gnus-group-make-archive-group
649 "k" gnus-group-make-kiboze-group
650 "l" gnus-group-nnimap-edit-acl
651 "m" gnus-group-make-group
652 "E" gnus-group-edit-group
653 "e" gnus-group-edit-group-method
654 "p" gnus-group-edit-group-parameters
655 "v" gnus-group-add-to-virtual
656 "V" gnus-group-make-empty-virtual
657 "D" gnus-group-enter-directory
658 "f" gnus-group-make-doc-group
659 "w" gnus-group-make-web-group
660 "M" gnus-group-read-ephemeral-group
661 "r" gnus-group-rename-group
662 "R" gnus-group-make-rss-group
663 "c" gnus-group-customize
664 "z" gnus-group-compact-group
665 "x" gnus-group-nnimap-expunge
666 "\177" gnus-group-delete-group
667 [delete] gnus-group-delete-group)
669 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
670 "b" gnus-group-brew-soup
671 "w" gnus-soup-save-areas
672 "s" gnus-soup-send-replies
673 "p" gnus-soup-pack-packet
674 "r" nnsoup-pack-replies)
676 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
677 "s" gnus-group-sort-groups
678 "a" gnus-group-sort-groups-by-alphabet
679 "u" gnus-group-sort-groups-by-unread
680 "l" gnus-group-sort-groups-by-level
681 "v" gnus-group-sort-groups-by-score
682 "r" gnus-group-sort-groups-by-rank
683 "m" gnus-group-sort-groups-by-method
684 "n" gnus-group-sort-groups-by-real-name)
686 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
687 "s" gnus-group-sort-selected-groups
688 "a" gnus-group-sort-selected-groups-by-alphabet
689 "u" gnus-group-sort-selected-groups-by-unread
690 "l" gnus-group-sort-selected-groups-by-level
691 "v" gnus-group-sort-selected-groups-by-score
692 "r" gnus-group-sort-selected-groups-by-rank
693 "m" gnus-group-sort-selected-groups-by-method
694 "n" gnus-group-sort-selected-groups-by-real-name)
696 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
697 "k" gnus-group-list-killed
698 "z" gnus-group-list-zombies
699 "s" gnus-group-list-groups
700 "u" gnus-group-list-all-groups
701 "A" gnus-group-list-active
702 "a" gnus-group-apropos
703 "d" gnus-group-description-apropos
704 "m" gnus-group-list-matching
705 "M" gnus-group-list-all-matching
706 "l" gnus-group-list-level
707 "c" gnus-group-list-cached
708 "?" gnus-group-list-dormant)
710 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
711 "k" gnus-group-list-limit
712 "z" gnus-group-list-limit
713 "s" gnus-group-list-limit
714 "u" gnus-group-list-limit
715 "A" gnus-group-list-limit
716 "m" gnus-group-list-limit
717 "M" gnus-group-list-limit
718 "l" gnus-group-list-limit
719 "c" gnus-group-list-limit
720 "?" gnus-group-list-limit)
722 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
723 "k" gnus-group-list-flush
724 "z" gnus-group-list-flush
725 "s" gnus-group-list-flush
726 "u" gnus-group-list-flush
727 "A" gnus-group-list-flush
728 "m" gnus-group-list-flush
729 "M" gnus-group-list-flush
730 "l" gnus-group-list-flush
731 "c" gnus-group-list-flush
732 "?" gnus-group-list-flush)
734 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
735 "k" gnus-group-list-plus
736 "z" gnus-group-list-plus
737 "s" gnus-group-list-plus
738 "u" gnus-group-list-plus
739 "A" gnus-group-list-plus
740 "m" gnus-group-list-plus
741 "M" gnus-group-list-plus
742 "l" gnus-group-list-plus
743 "c" gnus-group-list-plus
744 "?" gnus-group-list-plus)
746 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
747 "f" gnus-score-flush-cache
748 "e" gnus-score-edit-all-score)
750 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
751 "c" gnus-group-fetch-charter
752 "C" gnus-group-fetch-control
753 "d" gnus-group-describe-group
754 "f" gnus-group-fetch-faq
755 "v" gnus-version)
757 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
758 "l" gnus-group-set-current-level
759 "t" gnus-group-unsubscribe-current-group
760 "s" gnus-group-unsubscribe-group
761 "k" gnus-group-kill-group
762 "y" gnus-group-yank-group
763 "w" gnus-group-kill-region
764 "\C-k" gnus-group-kill-level
765 "z" gnus-group-kill-all-zombies)
767 (defun gnus-topic-mode-p ()
768 "Return non-nil in `gnus-topic-mode'."
769 (and (boundp 'gnus-topic-mode)
770 (symbol-value 'gnus-topic-mode)))
772 (defun gnus-group-make-menu-bar ()
773 (gnus-turn-off-edit-menu 'group)
774 (unless (boundp 'gnus-group-reading-menu)
776 (easy-menu-define
777 gnus-group-reading-menu gnus-group-mode-map ""
778 `("Group"
779 ["Read" gnus-group-read-group
780 :included (not (gnus-topic-mode-p))
781 :active (gnus-group-group-name)]
782 ["Read " gnus-topic-read-group
783 :included (gnus-topic-mode-p)]
784 ["Select" gnus-group-select-group
785 :included (not (gnus-topic-mode-p))
786 :active (gnus-group-group-name)]
787 ["Select " gnus-topic-select-group
788 :included (gnus-topic-mode-p)]
789 ["See old articles" (gnus-group-select-group 'all)
790 :keys "C-u SPC" :active (gnus-group-group-name)]
791 ["Catch up" gnus-group-catchup-current
792 :included (not (gnus-topic-mode-p))
793 :active (gnus-group-group-name)
794 ,@(if (featurep 'xemacs) nil
795 '(:help "Mark unread articles in the current group as read"))]
796 ["Catch up " gnus-topic-catchup-articles
797 :included (gnus-topic-mode-p)
798 ,@(if (featurep 'xemacs) nil
799 '(:help "Mark unread articles in the current group or topic as read"))]
800 ["Catch up all articles" gnus-group-catchup-current-all
801 (gnus-group-group-name)]
802 ["Check for new articles" gnus-group-get-new-news-this-group
803 :included (not (gnus-topic-mode-p))
804 :active (gnus-group-group-name)
805 ,@(if (featurep 'xemacs) nil
806 '(:help "Check for new messages in current group"))]
807 ["Check for new articles " gnus-topic-get-new-news-this-topic
808 :included (gnus-topic-mode-p)
809 ,@(if (featurep 'xemacs) nil
810 '(:help "Check for new messages in current group or topic"))]
811 ["Toggle subscription" gnus-group-unsubscribe-current-group
812 (gnus-group-group-name)]
813 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
814 ,@(if (featurep 'xemacs) nil
815 '(:help "Kill (remove) current group"))]
816 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
817 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
818 ,@(if (featurep 'xemacs) nil
819 '(:help "Display description of the current group"))]
820 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
821 ["Fetch charter" gnus-group-fetch-charter
822 :active (gnus-group-group-name)
823 ,@(if (featurep 'xemacs) nil
824 '(:help "Display the charter of the current group"))]
825 ["Fetch control message" gnus-group-fetch-control
826 :active (gnus-group-group-name)
827 ,@(if (featurep 'xemacs) nil
828 '(:help "Display the archived control message for the current group"))]
829 ;; Actually one should check, if any of the marked groups gives t for
830 ;; (gnus-check-backend-function 'request-expire-articles ...)
831 ["Expire articles" gnus-group-expire-articles
832 :included (not (gnus-topic-mode-p))
833 :active (or (and (gnus-group-group-name)
834 (gnus-check-backend-function
835 'request-expire-articles
836 (gnus-group-group-name))) gnus-group-marked)]
837 ["Expire articles " gnus-topic-expire-articles
838 :included (gnus-topic-mode-p)]
839 ["Set group level..." gnus-group-set-current-level
840 (gnus-group-group-name)]
841 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
842 ["Customize" gnus-group-customize (gnus-group-group-name)]
843 ["Compact" gnus-group-compact-group
844 :active (gnus-group-group-name)]
845 ("Edit"
846 ["Parameters" gnus-group-edit-group-parameters
847 :included (not (gnus-topic-mode-p))
848 :active (gnus-group-group-name)]
849 ["Parameters " gnus-topic-edit-parameters
850 :included (gnus-topic-mode-p)]
851 ["Select method" gnus-group-edit-group-method
852 (gnus-group-group-name)]
853 ["Info" gnus-group-edit-group (gnus-group-group-name)]
854 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
855 ["Global kill file" gnus-group-edit-global-kill t])))
857 (easy-menu-define
858 gnus-group-group-menu gnus-group-mode-map ""
859 '("Groups"
860 ("Listing"
861 ["List unread subscribed groups" gnus-group-list-groups t]
862 ["List (un)subscribed groups" gnus-group-list-all-groups t]
863 ["List killed groups" gnus-group-list-killed gnus-killed-list]
864 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
865 ["List level..." gnus-group-list-level t]
866 ["Describe all groups" gnus-group-describe-all-groups t]
867 ["Group apropos..." gnus-group-apropos t]
868 ["Group and description apropos..." gnus-group-description-apropos t]
869 ["List groups matching..." gnus-group-list-matching t]
870 ["List all groups matching..." gnus-group-list-all-matching t]
871 ["List active file" gnus-group-list-active t]
872 ["List groups with cached" gnus-group-list-cached t]
873 ["List groups with dormant" gnus-group-list-dormant t])
874 ("Sort"
875 ["Default sort" gnus-group-sort-groups t]
876 ["Sort by method" gnus-group-sort-groups-by-method t]
877 ["Sort by rank" gnus-group-sort-groups-by-rank t]
878 ["Sort by score" gnus-group-sort-groups-by-score t]
879 ["Sort by level" gnus-group-sort-groups-by-level t]
880 ["Sort by unread" gnus-group-sort-groups-by-unread t]
881 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
882 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
883 ("Sort process/prefixed"
884 ["Default sort" gnus-group-sort-selected-groups
885 (not (gnus-topic-mode-p))]
886 ["Sort by method" gnus-group-sort-selected-groups-by-method
887 (not (gnus-topic-mode-p))]
888 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
889 (not (gnus-topic-mode-p))]
890 ["Sort by score" gnus-group-sort-selected-groups-by-score
891 (not (gnus-topic-mode-p))]
892 ["Sort by level" gnus-group-sort-selected-groups-by-level
893 (not (gnus-topic-mode-p))]
894 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
895 (not (gnus-topic-mode-p))]
896 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
897 (not (gnus-topic-mode-p))]
898 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
899 (not (gnus-topic-mode-p))])
900 ("Mark"
901 ["Mark group" gnus-group-mark-group
902 (and (gnus-group-group-name)
903 (not (memq (gnus-group-group-name) gnus-group-marked)))]
904 ["Unmark group" gnus-group-unmark-group
905 (and (gnus-group-group-name)
906 (memq (gnus-group-group-name) gnus-group-marked))]
907 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
908 ["Mark regexp..." gnus-group-mark-regexp t]
909 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
910 ["Mark buffer" gnus-group-mark-buffer t]
911 ["Execute command" gnus-group-universal-argument
912 (or gnus-group-marked (gnus-group-group-name))])
913 ("Subscribe"
914 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
915 ["Kill all newsgroups in region" gnus-group-kill-region
916 :active (gnus-mark-active-p)]
917 ["Kill all zombie groups" gnus-group-kill-all-zombies
918 gnus-zombie-list]
919 ["Kill all groups on level..." gnus-group-kill-level t])
920 ("Foreign groups"
921 ["Make a foreign group..." gnus-group-make-group t]
922 ["Add a directory group..." gnus-group-make-directory-group t]
923 ["Add the help group" gnus-group-make-help-group t]
924 ["Add the archive group" gnus-group-make-archive-group t]
925 ["Make a doc group..." gnus-group-make-doc-group t]
926 ["Make a web group..." gnus-group-make-web-group t]
927 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
928 ["Make a virtual group..." gnus-group-make-empty-virtual t]
929 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
930 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
931 ["Make an RSS group..." gnus-group-make-rss-group t]
932 ["Rename group..." gnus-group-rename-group
933 (gnus-check-backend-function
934 'request-rename-group (gnus-group-group-name))]
935 ["Delete group" gnus-group-delete-group
936 (gnus-check-backend-function
937 'request-delete-group (gnus-group-group-name))])
938 ("Move"
939 ["Next" gnus-group-next-group t]
940 ["Previous" gnus-group-prev-group t]
941 ["Next unread" gnus-group-next-unread-group t]
942 ["Previous unread" gnus-group-prev-unread-group t]
943 ["Next unread same level" gnus-group-next-unread-group-same-level t]
944 ["Previous unread same level"
945 gnus-group-prev-unread-group-same-level t]
946 ["Jump to group..." gnus-group-jump-to-group t]
947 ["First unread group" gnus-group-first-unread-group t]
948 ["Best unread group" gnus-group-best-unread-group t])
949 ("Sieve"
950 ["Generate" gnus-sieve-generate t]
951 ["Generate and update" gnus-sieve-update t])
952 ["Delete bogus groups" gnus-group-check-bogus-groups t]
953 ["Find new newsgroups" gnus-group-find-new-groups t]
954 ["Transpose" gnus-group-transpose-groups
955 (gnus-group-group-name)]
956 ["Read a directory as a group..." gnus-group-enter-directory t]))
958 (easy-menu-define
959 gnus-group-misc-menu gnus-group-mode-map ""
960 `("Gnus"
961 ("SOUP"
962 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
963 ["Send replies" gnus-soup-send-replies
964 (fboundp 'gnus-soup-pack-packet)]
965 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
966 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
967 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
968 ["Send a mail" gnus-group-mail t]
969 ["Send a message (mail or news)" gnus-group-post-news t]
970 ["Create a local message" gnus-group-news t]
971 ["Check for new news" gnus-group-get-new-news
972 ,@(if (featurep 'xemacs) '(t)
973 '(:help "Get newly arrived articles"))
975 ["Send queued messages" gnus-delay-send-queue
976 ,@(if (featurep 'xemacs) '(t)
977 '(:help "Send all messages that are scheduled to be sent now"))
979 ["Activate all groups" gnus-activate-all-groups t]
980 ["Restart Gnus" gnus-group-restart t]
981 ["Read init file" gnus-group-read-init-file t]
982 ["Browse foreign server..." gnus-group-browse-foreign-server t]
983 ["Enter server buffer" gnus-group-enter-server-mode t]
984 ["Expire all expirable articles" gnus-group-expire-all-groups t]
985 ["Generate any kiboze groups" nnkiboze-generate-groups t]
986 ["Gnus version" gnus-version t]
987 ["Save .newsrc files" gnus-group-save-newsrc t]
988 ["Suspend Gnus" gnus-group-suspend t]
989 ["Clear dribble buffer" gnus-group-clear-dribble t]
990 ["Read manual" gnus-info-find-node t]
991 ["Flush score cache" gnus-score-flush-cache t]
992 ["Toggle topics" gnus-topic-mode t]
993 ["Send a bug report" gnus-bug t]
994 ["Exit from Gnus" gnus-group-exit
995 ,@(if (featurep 'xemacs) '(t)
996 '(:help "Quit reading news"))]
997 ["Exit without saving" gnus-group-quit t]))
999 (gnus-run-hooks 'gnus-group-menu-hook)))
1002 (defvar gnus-group-tool-bar-map nil)
1004 (defun gnus-group-tool-bar-update (&optional symbol value)
1005 "Update group buffer toolbar.
1006 Setter function for custom variables."
1007 (when symbol
1008 (set-default symbol value))
1009 ;; (setq-default gnus-group-tool-bar-map nil)
1010 ;; (use-local-map gnus-group-mode-map)
1011 (when (gnus-alive-p)
1012 (with-current-buffer gnus-group-buffer
1013 (gnus-group-make-tool-bar t))))
1015 (defcustom gnus-group-tool-bar (if (eq gmm-tool-bar-style 'gnome)
1016 'gnus-group-tool-bar-gnome
1017 'gnus-group-tool-bar-retro)
1018 "Specifies the Gnus group tool bar.
1020 It can be either a list or a symbol refering to a list. See
1021 `gmm-tool-bar-from-list' for the format of the list. The
1022 default key map is `gnus-group-mode-map'.
1024 Pre-defined symbols include `gnus-group-tool-bar-gnome' and
1025 `gnus-group-tool-bar-retro'."
1026 :type '(choice (const :tag "GNOME style" gnus-group-tool-bar-gnome)
1027 (const :tag "Retro look" gnus-group-tool-bar-retro)
1028 (repeat :tag "User defined list" gmm-tool-bar-item)
1029 (symbol))
1030 :version "23.0" ;; No Gnus
1031 :initialize 'custom-initialize-default
1032 :set 'gnus-group-tool-bar-update
1033 :group 'gnus-group)
1035 (defcustom gnus-group-tool-bar-gnome
1036 '((gnus-group-post-news "mail/compose")
1037 ;; Some useful agent icons? I don't use the agent so agent users should
1038 ;; suggest useful commands:
1039 (gnus-agent-toggle-plugged "disconnect" t
1040 :help "Gnus is currently unplugged. Click to work online."
1041 :visible (and gnus-agent (not gnus-plugged)))
1042 (gnus-agent-toggle-plugged "connect" t
1043 :help "Gnus is currently plugged. Click to work offline."
1044 :visible (and gnus-agent gnus-plugged))
1045 ;; FIXME: gnus-agent-toggle-plugged (in gnus-agent-group-make-menu-bar)
1046 ;; should have a better help text.
1047 (gnus-group-send-queue "mail/outbox" t
1048 :visible (and gnus-agent gnus-plugged)
1049 :help "Send articles from the queue group")
1050 (gnus-group-get-new-news "mail/inbox" nil
1051 :visible (or (not gnus-agent)
1052 gnus-plugged))
1053 ;; FIXME: gnus-*-read-group should have a better help text.
1054 (gnus-topic-read-group "open" nil
1055 :visible (and (boundp 'gnus-topic-mode)
1056 gnus-topic-mode))
1057 (gnus-group-read-group "open" nil
1058 :visible (not (and (boundp 'gnus-topic-mode)
1059 gnus-topic-mode)))
1060 ;; (gnus-group-find-new-groups "???" nil)
1061 (gnus-group-save-newsrc "save")
1062 (gnus-group-describe-group "describe")
1063 (gnus-group-unsubscribe-current-group "gnus/toggle-subscription")
1064 (gnus-group-prev-unread-group "left-arrow")
1065 (gnus-group-next-unread-group "right-arrow")
1066 (gnus-group-exit "exit")
1067 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
1068 (gnus-info-find-node "help"))
1069 "List of functions for the group tool bar (GNOME style).
1071 See `gmm-tool-bar-from-list' for the format of the list."
1072 :type '(repeat gmm-tool-bar-item)
1073 :version "23.0" ;; No Gnus
1074 :initialize 'custom-initialize-default
1075 :set 'gnus-group-tool-bar-update
1076 :group 'gnus-group)
1078 (defcustom gnus-group-tool-bar-retro
1079 '((gnus-group-get-new-news "gnus/get-news")
1080 (gnus-group-get-new-news-this-group "gnus/gnntg")
1081 (gnus-group-catchup-current "gnus/catchup")
1082 (gnus-group-describe-group "gnus/describe-group")
1083 (gnus-group-subscribe "gnus/subscribe" t
1084 :help "Subscribe to the current group")
1085 (gnus-group-unsubscribe "gnus/unsubscribe" t
1086 :help "Unsubscribe from the current group")
1087 (gnus-group-exit "gnus/exit-gnus" gnus-group-mode-map))
1088 "List of functions for the group tool bar (retro look).
1090 See `gmm-tool-bar-from-list' for the format of the list."
1091 :type '(repeat gmm-tool-bar-item)
1092 :version "23.0" ;; No Gnus
1093 :initialize 'custom-initialize-default
1094 :set 'gnus-group-tool-bar-update
1095 :group 'gnus-group)
1097 (defcustom gnus-group-tool-bar-zap-list t
1098 "List of icon items from the global tool bar.
1099 These items are not displayed in the Gnus group mode tool bar.
1101 See `gmm-tool-bar-from-list' for the format of the list."
1102 :type 'gmm-tool-bar-zap-list
1103 :version "23.0" ;; No Gnus
1104 :initialize 'custom-initialize-default
1105 :set 'gnus-group-tool-bar-update
1106 :group 'gnus-group)
1108 (defvar image-load-path)
1110 (defun gnus-group-make-tool-bar (&optional force)
1111 "Make a group mode tool bar from `gnus-group-tool-bar'.
1112 When FORCE, rebuild the tool bar."
1113 (when (and (not (featurep 'xemacs))
1114 (boundp 'tool-bar-mode)
1115 tool-bar-mode
1116 ;; The Gnus 5.10.6 code checked (default-value 'tool-bar-mode).
1117 ;; Why? --rsteib
1118 (or (not gnus-group-tool-bar-map) force))
1119 (let* ((load-path
1120 (gmm-image-load-path-for-library "gnus"
1121 "gnus/toggle-subscription.xpm"
1122 nil t))
1123 (image-load-path (cons (car load-path)
1124 (when (boundp 'image-load-path)
1125 image-load-path)))
1126 (map (gmm-tool-bar-from-list gnus-group-tool-bar
1127 gnus-group-tool-bar-zap-list
1128 'gnus-group-mode-map)))
1129 (if map
1130 (set (make-local-variable 'tool-bar-map) map))))
1131 gnus-group-tool-bar-map)
1133 (defun gnus-group-mode ()
1134 "Major mode for reading news.
1136 All normal editing commands are switched off.
1137 \\<gnus-group-mode-map>
1138 The group buffer lists (some of) the groups available. For instance,
1139 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1140 lists all zombie groups.
1142 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1143 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1145 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1147 The following commands are available:
1149 \\{gnus-group-mode-map}"
1150 (interactive)
1151 (kill-all-local-variables)
1152 (when (gnus-visual-p 'group-menu 'menu)
1153 (gnus-group-make-menu-bar)
1154 (gnus-group-make-tool-bar))
1155 (gnus-simplify-mode-line)
1156 (setq major-mode 'gnus-group-mode)
1157 (setq mode-name "Group")
1158 (gnus-group-set-mode-line)
1159 (setq mode-line-process nil)
1160 (use-local-map gnus-group-mode-map)
1161 (buffer-disable-undo)
1162 (setq truncate-lines t)
1163 (setq buffer-read-only t
1164 show-trailing-whitespace nil)
1165 (gnus-set-default-directory)
1166 (gnus-update-format-specifications nil 'group 'group-mode)
1167 (gnus-update-group-mark-positions)
1168 (when gnus-use-undo
1169 (gnus-undo-mode 1))
1170 (when gnus-slave
1171 (gnus-slave-mode))
1172 (gnus-run-mode-hooks 'gnus-group-mode-hook))
1174 (defun gnus-update-group-mark-positions ()
1175 (save-excursion
1176 (let ((gnus-process-mark ?\200)
1177 (gnus-group-update-hook nil)
1178 (gnus-group-marked '("dummy.group"))
1179 (gnus-active-hashtb (make-vector 10 0))
1180 (topic ""))
1181 (gnus-set-active "dummy.group" '(0 . 0))
1182 (gnus-set-work-buffer)
1183 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1184 (goto-char (point-min))
1185 (setq gnus-group-mark-positions
1186 (list (cons 'process (and (search-forward
1187 (mm-string-as-multibyte "\200") nil t)
1188 (- (point) 2))))))))
1190 (defun gnus-mouse-pick-group (e)
1191 "Enter the group under the mouse pointer."
1192 (interactive "e")
1193 (mouse-set-point e)
1194 (gnus-group-read-group nil))
1196 ;; Look at LEVEL and find out what the level is really supposed to be.
1197 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1198 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1199 (defun gnus-group-default-level (&optional level number-or-nil)
1200 (cond
1201 (gnus-group-use-permanent-levels
1202 (or (setq gnus-group-use-permanent-levels
1203 (or level (if (numberp gnus-group-use-permanent-levels)
1204 gnus-group-use-permanent-levels
1205 (or gnus-group-default-list-level
1206 gnus-level-subscribed))))
1207 gnus-group-default-list-level gnus-level-subscribed))
1208 (number-or-nil
1209 level)
1211 (or level gnus-group-default-list-level gnus-level-subscribed))))
1213 (defun gnus-group-setup-buffer ()
1214 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1215 (unless (eq major-mode 'gnus-group-mode)
1216 (gnus-group-mode)
1217 (when gnus-carpal
1218 (gnus-carpal-setup-buffer 'group))))
1220 (defun gnus-group-name-charset (method group)
1221 (if (null method)
1222 (setq method (gnus-find-method-for-group group)))
1223 (let ((item (or (assoc method gnus-group-name-charset-method-alist)
1224 (and (consp method)
1225 (assoc (list (car method) (cadr method))
1226 gnus-group-name-charset-method-alist))))
1227 (alist gnus-group-name-charset-group-alist)
1228 result)
1229 (if item
1230 (cdr item)
1231 (while (setq item (pop alist))
1232 (if (string-match (car item) group)
1233 (setq alist nil
1234 result (cdr item))))
1235 result)))
1237 (defun gnus-group-name-decode (string charset)
1238 ;; Fixme: Don't decode in unibyte mode.
1239 (if (and string charset (featurep 'mule))
1240 (mm-decode-coding-string string charset)
1241 string))
1243 (defun gnus-group-decoded-name (string)
1244 (let ((charset (gnus-group-name-charset nil string)))
1245 (gnus-group-name-decode string charset)))
1247 (defun gnus-group-list-groups (&optional level unread lowest)
1248 "List newsgroups with level LEVEL or lower that have unread articles.
1249 Default is all subscribed groups.
1250 If argument UNREAD is non-nil, groups with no unread articles are also
1251 listed.
1253 Also see the `gnus-group-use-permanent-levels' variable."
1254 (interactive
1255 (list (if current-prefix-arg
1256 (prefix-numeric-value current-prefix-arg)
1258 (gnus-group-default-level nil t)
1259 gnus-group-default-list-level
1260 gnus-level-subscribed))))
1261 (unless level
1262 (setq level (car gnus-group-list-mode)
1263 unread (cdr gnus-group-list-mode)))
1264 (setq level (gnus-group-default-level level))
1265 (gnus-group-setup-buffer)
1266 (gnus-update-format-specifications nil 'group 'group-mode)
1267 (let ((case-fold-search nil)
1268 (props (text-properties-at (point-at-bol)))
1269 (empty (= (point-min) (point-max)))
1270 (group (gnus-group-group-name))
1271 number)
1272 (set-buffer gnus-group-buffer)
1273 (setq number (funcall gnus-group-prepare-function level unread lowest))
1274 (when (or (and (numberp number)
1275 (zerop number))
1276 (zerop (buffer-size)))
1277 ;; No groups in the buffer.
1278 (gnus-message 5 gnus-no-groups-message))
1279 ;; We have some groups displayed.
1280 (goto-char (point-max))
1281 (when (or (not gnus-group-goto-next-group-function)
1282 (not (funcall gnus-group-goto-next-group-function
1283 group props)))
1284 (cond
1285 (empty
1286 (goto-char (point-min)))
1287 ((not group)
1288 ;; Go to the first group with unread articles.
1289 (gnus-group-search-forward t))
1291 ;; Find the right group to put point on. If the current group
1292 ;; has disappeared in the new listing, try to find the next
1293 ;; one. If no next one can be found, just leave point at the
1294 ;; first newsgroup in the buffer.
1295 (when (not (gnus-goto-char
1296 (text-property-any
1297 (point-min) (point-max)
1298 'gnus-group (gnus-intern-safe
1299 group gnus-active-hashtb))))
1300 (let ((newsrc (cdddr (gnus-group-entry group))))
1301 (while (and newsrc
1302 (not (gnus-goto-char
1303 (text-property-any
1304 (point-min) (point-max) 'gnus-group
1305 (gnus-intern-safe
1306 (caar newsrc) gnus-active-hashtb)))))
1307 (setq newsrc (cdr newsrc)))
1308 (unless newsrc
1309 (goto-char (point-max))
1310 (forward-line -1)))))))
1311 ;; Adjust cursor point.
1312 (gnus-group-position-point)))
1314 (defun gnus-group-list-level (level &optional all)
1315 "List groups on LEVEL.
1316 If ALL (the prefix), also list groups that have no unread articles."
1317 (interactive "nList groups on level: \nP")
1318 (gnus-group-list-groups level all level))
1320 (defun gnus-group-prepare-logic (group test)
1321 (or (and gnus-group-listed-groups
1322 (null gnus-group-list-option)
1323 (member group gnus-group-listed-groups))
1324 (cond
1325 ((null gnus-group-listed-groups) test)
1326 ((null gnus-group-list-option) test)
1327 (t (and (member group gnus-group-listed-groups)
1328 (if (eq gnus-group-list-option 'flush)
1329 (not test)
1330 test))))))
1332 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1333 "List all newsgroups with unread articles of level LEVEL or lower.
1334 If PREDICATE is a function, list groups that the function returns non-nil;
1335 if it is t, list groups that have no unread articles.
1336 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1337 If REGEXP is a function, list dead groups that the function returns non-nil;
1338 if it is a string, only list groups matching REGEXP."
1339 (set-buffer gnus-group-buffer)
1340 (let ((buffer-read-only nil)
1341 (newsrc (cdr gnus-newsrc-alist))
1342 (lowest (or lowest 1))
1343 (not-in-list (and gnus-group-listed-groups
1344 (copy-sequence gnus-group-listed-groups)))
1345 info clevel unread group params)
1346 (erase-buffer)
1347 (when (or (< lowest gnus-level-zombie)
1348 gnus-group-listed-groups)
1349 ;; List living groups.
1350 (while newsrc
1351 (setq info (car newsrc)
1352 group (gnus-info-group info)
1353 params (gnus-info-params info)
1354 newsrc (cdr newsrc)
1355 unread (gnus-group-unread group))
1356 (when not-in-list
1357 (setq not-in-list (delete group not-in-list)))
1358 (when (gnus-group-prepare-logic
1359 group
1360 (and unread ; This group might be unchecked
1361 (or (not (stringp regexp))
1362 (string-match regexp group))
1363 (<= (setq clevel (gnus-info-level info)) level)
1364 (>= clevel lowest)
1365 (cond
1366 ((functionp predicate)
1367 (funcall predicate info))
1368 (predicate t) ; We list all groups?
1371 (if (eq unread t) ; Unactivated?
1372 gnus-group-list-inactive-groups
1373 ; We list unactivated
1374 (> unread 0))
1375 ; We list groups with unread articles
1376 (and gnus-list-groups-with-ticked-articles
1377 (cdr (assq 'tick (gnus-info-marks info))))
1378 ; And groups with tickeds
1379 ;; Check for permanent visibility.
1380 (and gnus-permanently-visible-groups
1381 (string-match gnus-permanently-visible-groups
1382 group))
1383 (memq 'visible params)
1384 (cdr (assq 'visible params)))))))
1385 (gnus-group-insert-group-line
1386 group (gnus-info-level info)
1387 (gnus-info-marks info) unread (gnus-info-method info)))))
1389 ;; List dead groups.
1390 (when (or gnus-group-listed-groups
1391 (and (>= level gnus-level-zombie)
1392 (<= lowest gnus-level-zombie)))
1393 (gnus-group-prepare-flat-list-dead
1394 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1395 gnus-level-zombie ?Z
1396 regexp))
1397 (when not-in-list
1398 (dolist (group gnus-zombie-list)
1399 (setq not-in-list (delete group not-in-list))))
1400 (when (or gnus-group-listed-groups
1401 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1402 (gnus-group-prepare-flat-list-dead
1403 (gnus-union
1404 not-in-list
1405 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1406 gnus-level-killed ?K regexp))
1408 (gnus-group-set-mode-line)
1409 (setq gnus-group-list-mode (cons level predicate))
1410 (gnus-run-hooks 'gnus-group-prepare-hook)
1413 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1414 ;; List zombies and killed lists somewhat faster, which was
1415 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1416 ;; this by ignoring the group format specification altogether.
1417 (let (group)
1418 (if (> (length groups) gnus-group-listing-limit)
1419 (while groups
1420 (setq group (pop groups))
1421 (when (gnus-group-prepare-logic
1422 group
1423 (or (not regexp)
1424 (and (stringp regexp) (string-match regexp group))
1425 (and (functionp regexp) (funcall regexp group))))
1426 (gnus-add-text-properties
1427 (point) (prog1 (1+ (point))
1428 (insert " " mark " *: "
1429 (gnus-group-decoded-name group)
1430 "\n"))
1431 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1432 'gnus-unread t
1433 'gnus-level level))))
1434 (while groups
1435 (setq group (pop groups))
1436 (when (gnus-group-prepare-logic
1437 group
1438 (or (not regexp)
1439 (and (stringp regexp) (string-match regexp group))
1440 (and (functionp regexp) (funcall regexp group))))
1441 (gnus-group-insert-group-line
1442 group level nil
1443 (let ((active (gnus-active group)))
1444 (if active
1445 (if (zerop (cdr active))
1447 (- (1+ (cdr active)) (car active)))
1448 nil))
1449 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1451 (defun gnus-group-update-group-line ()
1452 "Update the current line in the group buffer."
1453 (let* ((buffer-read-only nil)
1454 (group (gnus-group-group-name))
1455 (entry (and group (gnus-group-entry group)))
1456 gnus-group-indentation)
1457 (when group
1458 (and entry
1459 (not (gnus-ephemeral-group-p group))
1460 (gnus-dribble-enter
1461 (concat "(gnus-group-set-info '"
1462 (gnus-prin1-to-string (nth 2 entry))
1463 ")")))
1464 (setq gnus-group-indentation (gnus-group-group-indentation))
1465 (gnus-delete-line)
1466 (gnus-group-insert-group-line-info group)
1467 (forward-line -1)
1468 (gnus-group-position-point))))
1470 (defun gnus-group-insert-group-line-info (group)
1471 "Insert GROUP on the current line."
1472 (let ((entry (gnus-group-entry group))
1473 (gnus-group-indentation (gnus-group-group-indentation))
1474 active info)
1475 (if entry
1476 (progn
1477 ;; (Un)subscribed group.
1478 (setq info (nth 2 entry))
1479 (gnus-group-insert-group-line
1480 group (gnus-info-level info) (gnus-info-marks info)
1481 (or (car entry) t) (gnus-info-method info)))
1482 ;; This group is dead.
1483 (gnus-group-insert-group-line
1484 group
1485 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1487 (if (setq active (gnus-active group))
1488 (if (zerop (cdr active))
1490 (- (1+ (cdr active)) (car active)))
1491 nil)
1492 (gnus-method-simplify (gnus-find-method-for-group group))))))
1494 (defun gnus-number-of-unseen-articles-in-group (group)
1495 (let* ((info (nth 2 (gnus-group-entry group)))
1496 (marked (gnus-info-marks info))
1497 (seen (cdr (assq 'seen marked)))
1498 (active (gnus-active group)))
1499 (if (not active)
1501 (length (gnus-uncompress-range
1502 (gnus-range-difference
1503 (gnus-range-difference (list active) (gnus-info-read info))
1504 seen))))))
1506 ;; Moving through the Group buffer (in topic mode) e.g. with C-n doesn't
1507 ;; update the state (enabled/disabled) of the icon `gnus-group-describe-group'
1508 ;; automatically. After `C-l' the state is correct. See the following report
1509 ;; on emacs-devel
1510 ;; <http://thread.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de>:
1511 ;; From: Reiner Steib
1512 ;; Subject: tool bar icons not updated according to :active condition
1513 ;; Newsgroups: gmane.emacs.devel
1514 ;; Date: Mon, 23 Jan 2006 19:59:13 +0100
1515 ;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
1517 (defcustom gnus-group-update-tool-bar
1518 (and (not (featurep 'xemacs))
1519 (boundp 'tool-bar-mode)
1520 tool-bar-mode
1521 ;; Using `redraw-frame' (see `gnus-tool-bar-update') in Emacs 21 might
1522 ;; be confusing, so maybe we shouldn't call it by default.
1523 (fboundp 'force-window-update))
1524 "Force updating the group buffer tool bar."
1525 :group 'gnus-group
1526 :version "22.1"
1527 :initialize 'custom-initialize-default
1528 :set (lambda (symbol value)
1529 (set-default symbol value)
1530 (when (gnus-alive-p)
1531 (with-current-buffer gnus-group-buffer
1532 ;; FIXME: Is there a better way to redraw the group buffer?
1533 (gnus-group-get-new-news 0))))
1534 :type 'boolean)
1536 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1537 gnus-tmp-marked number
1538 gnus-tmp-method)
1539 "Insert a group line in the group buffer."
1540 (let* ((gnus-tmp-method
1541 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1542 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1543 gnus-tmp-group))
1544 (gnus-tmp-active (gnus-active gnus-tmp-group))
1545 (gnus-tmp-number-total
1546 (if gnus-tmp-active
1547 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1549 (gnus-tmp-number-of-unread
1550 (if (numberp number) (int-to-string (max 0 number))
1551 "*"))
1552 (gnus-tmp-number-of-read
1553 (if (numberp number)
1554 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1555 "*"))
1556 (gnus-tmp-subscribed
1557 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1558 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1559 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1560 (t ?K)))
1561 (gnus-tmp-qualified-group
1562 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1563 group-name-charset))
1564 (gnus-tmp-comment
1565 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1566 gnus-tmp-group))
1567 (gnus-tmp-newsgroup-description
1568 (if gnus-description-hashtb
1569 (or (gnus-group-name-decode
1570 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1571 group-name-charset) "")
1572 ""))
1573 (gnus-tmp-moderated
1574 (if (and gnus-moderated-hashtb
1575 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1576 ?m ? ))
1577 (gnus-tmp-moderated-string
1578 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1579 (gnus-tmp-group-icon "==&&==")
1580 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1581 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1582 (gnus-tmp-news-method-string
1583 (if gnus-tmp-method
1584 (format "(%s:%s)" (car gnus-tmp-method)
1585 (cadr gnus-tmp-method)) ""))
1586 (gnus-tmp-marked-mark
1587 (if (and (numberp number)
1588 (zerop number)
1589 (cdr (assq 'tick gnus-tmp-marked)))
1590 ?* ? ))
1591 (gnus-tmp-summary-live
1592 (if (and (not gnus-group-is-exiting-p)
1593 (gnus-buffer-live-p (gnus-summary-buffer-name
1594 gnus-tmp-group)))
1595 ?* ? ))
1596 (gnus-tmp-process-marked
1597 (if (member gnus-tmp-group gnus-group-marked)
1598 gnus-process-mark ? ))
1599 (buffer-read-only nil)
1600 beg end
1601 header gnus-tmp-header) ; passed as parameter to user-funcs.
1602 (beginning-of-line)
1603 (setq beg (point))
1604 (gnus-add-text-properties
1605 (point)
1606 (prog1 (1+ (point))
1607 ;; Insert the text.
1608 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1609 gnus-tmp-group group-name-charset)))
1610 (eval gnus-group-line-format-spec)))
1611 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1612 gnus-unread ,(if (numberp number)
1613 (string-to-number gnus-tmp-number-of-unread)
1615 gnus-marked ,gnus-tmp-marked-mark
1616 gnus-indentation ,gnus-group-indentation
1617 gnus-level ,gnus-tmp-level))
1618 (setq end (point))
1619 (when gnus-group-update-tool-bar
1620 (gnus-put-text-property beg end 'point-entered
1621 'gnus-tool-bar-update)
1622 (gnus-put-text-property beg end 'point-left
1623 'gnus-tool-bar-update))
1624 (forward-line -1)
1625 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1626 (gnus-run-hooks 'gnus-group-update-hook))
1627 (forward-line)
1628 ;; Allow XEmacs to remove front-sticky text properties.
1629 (gnus-group-remove-excess-properties)))
1631 (defun gnus-group-highlight-line ()
1632 "Highlight the current line according to `gnus-group-highlight'."
1633 (let* ((list gnus-group-highlight)
1634 (p (point))
1635 (end (point-at-eol))
1636 ;; now find out where the line starts and leave point there.
1637 (beg (progn (beginning-of-line) (point)))
1638 (group (gnus-group-group-name))
1639 (entry (gnus-group-entry group))
1640 (unread (if (numberp (car entry)) (car entry) 0))
1641 (active (gnus-active group))
1642 (total (if active (1+ (- (cdr active) (car active))) 0))
1643 (info (nth 2 entry))
1644 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1645 (marked (gnus-info-marks info))
1646 (mailp (apply 'append
1647 (mapcar
1648 (lambda (x)
1649 (memq x (assoc (symbol-name
1650 (car (or method gnus-select-method)))
1651 gnus-valid-select-methods)))
1652 '(mail post-mail))))
1653 (level (or (gnus-info-level info) gnus-level-killed))
1654 (score (or (gnus-info-score info) 0))
1655 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1656 (group-age (gnus-group-timestamp-delta group))
1657 (inhibit-read-only t))
1658 ;; Eval the cars of the lists until we find a match.
1659 (while (and list
1660 (not (eval (caar list))))
1661 (setq list (cdr list)))
1662 (let ((face (cdar list)))
1663 (unless (eq face (get-text-property beg 'face))
1664 (gnus-put-text-property-excluding-characters-with-faces
1665 beg end 'face
1666 (setq face (if (boundp face) (symbol-value face) face)))
1667 (gnus-extent-start-open beg)))
1668 (goto-char p)))
1670 (defun gnus-group-update-group (group &optional visible-only)
1671 "Update all lines where GROUP appear.
1672 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1673 already."
1674 ;; Can't use `save-excursion' here, so we do it manually.
1675 (let ((buf (current-buffer))
1676 mark)
1677 (set-buffer gnus-group-buffer)
1678 (setq mark (point-marker))
1679 ;; The buffer may be narrowed.
1680 (save-restriction
1681 (widen)
1682 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1683 (loc (point-min))
1684 found buffer-read-only)
1685 ;; Enter the current status into the dribble buffer.
1686 (let ((entry (gnus-group-entry group)))
1687 (when (and entry
1688 (not (gnus-ephemeral-group-p group)))
1689 (gnus-dribble-enter
1690 (concat "(gnus-group-set-info '"
1691 (gnus-prin1-to-string (nth 2 entry))
1692 ")"))))
1693 ;; Find all group instances. If topics are in use, each group
1694 ;; may be listed in more than once.
1695 (while (setq loc (text-property-any
1696 loc (point-max) 'gnus-group ident))
1697 (setq found t)
1698 (goto-char loc)
1699 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1700 (gnus-delete-line)
1701 (gnus-group-insert-group-line-info group)
1702 (save-excursion
1703 (forward-line -1)
1704 (gnus-run-hooks 'gnus-group-update-group-hook)))
1705 (setq loc (1+ loc)))
1706 (unless (or found visible-only)
1707 ;; No such line in the buffer, find out where it's supposed to
1708 ;; go, and insert it there (or at the end of the buffer).
1709 (if gnus-goto-missing-group-function
1710 (funcall gnus-goto-missing-group-function group)
1711 (let ((entry (cddr (gnus-group-entry group))))
1712 (while (and entry (car entry)
1713 (not
1714 (gnus-goto-char
1715 (text-property-any
1716 (point-min) (point-max)
1717 'gnus-group (gnus-intern-safe
1718 (caar entry) gnus-active-hashtb)))))
1719 (setq entry (cdr entry)))
1720 (or entry (goto-char (point-max)))))
1721 ;; Finally insert the line.
1722 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1723 (gnus-group-insert-group-line-info group)
1724 (save-excursion
1725 (forward-line -1)
1726 (gnus-run-hooks 'gnus-group-update-group-hook))))
1727 (when gnus-group-update-group-function
1728 (funcall gnus-group-update-group-function group))
1729 (gnus-group-set-mode-line)))
1730 (goto-char mark)
1731 (set-marker mark nil)
1732 (set-buffer buf)))
1734 (defun gnus-group-set-mode-line ()
1735 "Update the mode line in the group buffer."
1736 (when (memq 'group gnus-updated-mode-lines)
1737 ;; Yes, we want to keep this mode line updated.
1738 (save-excursion
1739 (set-buffer gnus-group-buffer)
1740 (let* ((gformat (or gnus-group-mode-line-format-spec
1741 (gnus-set-format 'group-mode)))
1742 (gnus-tmp-news-server (cadr gnus-select-method))
1743 (gnus-tmp-news-method (car gnus-select-method))
1744 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1745 (max-len 60)
1746 gnus-tmp-header ;Dummy binding for user-defined formats
1747 ;; Get the resulting string.
1748 (modified
1749 (and gnus-dribble-buffer
1750 (buffer-name gnus-dribble-buffer)
1751 (buffer-modified-p gnus-dribble-buffer)
1752 (save-excursion
1753 (set-buffer gnus-dribble-buffer)
1754 (not (zerop (buffer-size))))))
1755 (mode-string (eval gformat)))
1756 ;; Say whether the dribble buffer has been modified.
1757 (setq mode-line-modified
1758 (if modified (car gnus-mode-line-modified)
1759 (cdr gnus-mode-line-modified)))
1760 ;; If the line is too long, we chop it off.
1761 (when (> (length mode-string) max-len)
1762 (setq mode-string (substring mode-string 0 (- max-len 4))))
1763 (prog1
1764 (setq mode-line-buffer-identification
1765 (gnus-mode-line-buffer-identification
1766 (list mode-string)))
1767 (set-buffer-modified-p modified))))))
1769 (defun gnus-group-group-name ()
1770 "Get the name of the newsgroup on the current line."
1771 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1772 (when group
1773 (symbol-name group))))
1775 (defun gnus-group-group-level ()
1776 "Get the level of the newsgroup on the current line."
1777 (get-text-property (point-at-bol) 'gnus-level))
1779 (defun gnus-group-group-indentation ()
1780 "Get the indentation of the newsgroup on the current line."
1781 (or (get-text-property (point-at-bol) 'gnus-indentation)
1782 (and gnus-group-indentation-function
1783 (funcall gnus-group-indentation-function))
1784 ""))
1786 (defun gnus-group-group-unread ()
1787 "Get the number of unread articles of the newsgroup on the current line."
1788 (get-text-property (point-at-bol) 'gnus-unread))
1790 (defun gnus-group-new-mail (group)
1791 (if (nnmail-new-mail-p (gnus-group-real-name group))
1792 gnus-new-mail-mark
1793 ? ))
1795 (defun gnus-group-level (group)
1796 "Return the estimated level of GROUP."
1797 (or (gnus-info-level (gnus-get-info group))
1798 (and (member group gnus-zombie-list) gnus-level-zombie)
1799 gnus-level-killed))
1801 (defun gnus-group-search-forward (&optional backward all level first-too)
1802 "Find the next newsgroup with unread articles.
1803 If BACKWARD is non-nil, find the previous newsgroup instead.
1804 If ALL is non-nil, just find any newsgroup.
1805 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1806 group exists.
1807 If FIRST-TOO, the current line is also eligible as a target."
1808 (let ((way (if backward -1 1))
1809 (low gnus-level-killed)
1810 (beg (point))
1811 pos found lev)
1812 (if (and backward (progn (beginning-of-line)) (bobp))
1814 (unless first-too
1815 (forward-line way))
1816 (while (and
1817 (not (eobp))
1818 (not (setq
1819 found
1820 (and
1821 (get-text-property (point) 'gnus-group)
1822 (or all
1823 (and
1824 (let ((unread
1825 (get-text-property (point) 'gnus-unread)))
1826 (and (numberp unread) (> unread 0)))
1827 (setq lev (get-text-property (point)
1828 'gnus-level))
1829 (<= lev gnus-level-subscribed)))
1830 (or (not level)
1831 (and (setq lev (get-text-property (point)
1832 'gnus-level))
1833 (or (= lev level)
1834 (and (< lev low)
1835 (< level lev)
1836 (progn
1837 (setq low lev)
1838 (setq pos (point))
1839 nil))))))))
1840 (zerop (forward-line way)))))
1841 (if found
1842 (progn (gnus-group-position-point) t)
1843 (goto-char (or pos beg))
1844 (and pos t))))
1846 (defun gnus-total-fetched-for (group)
1847 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1848 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1849 (size (+ size-in-cache size-in-agent))
1850 (suffix '("B" "K" "M" "G"))
1851 (scale 1024.0)
1852 (cutoff scale))
1853 (while (> size cutoff)
1854 (setq size (/ size scale)
1855 suffix (cdr suffix)))
1856 (format "%5.1f%s" size (car suffix))))
1858 ;;; Gnus group mode commands
1860 ;; Group marking.
1862 (defun gnus-group-mark-line-p ()
1863 (save-excursion
1864 (beginning-of-line)
1865 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1866 (eq (char-after) gnus-process-mark)))
1868 (defun gnus-group-mark-group (n &optional unmark no-advance)
1869 "Mark the current group."
1870 (interactive "p")
1871 (let ((buffer-read-only nil)
1872 group)
1873 (while (and (> n 0)
1874 (not (eobp)))
1875 (when (setq group (gnus-group-group-name))
1876 ;; Go to the mark position.
1877 (beginning-of-line)
1878 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1879 (delete-char 1)
1880 (if unmark
1881 (progn
1882 (setq gnus-group-marked (delete group gnus-group-marked))
1883 (insert-char ? 1 t))
1884 (setq gnus-group-marked
1885 (cons group (delete group gnus-group-marked)))
1886 (insert-char gnus-process-mark 1 t)))
1887 (unless no-advance
1888 (gnus-group-next-group 1))
1889 (decf n))
1890 (gnus-summary-position-point)
1893 (defun gnus-group-unmark-group (n)
1894 "Remove the mark from the current group."
1895 (interactive "p")
1896 (gnus-group-mark-group n 'unmark)
1897 (gnus-group-position-point))
1899 (defun gnus-group-unmark-all-groups ()
1900 "Unmark all groups."
1901 (interactive)
1902 (save-excursion
1903 (mapc 'gnus-group-remove-mark gnus-group-marked))
1904 (gnus-group-position-point))
1906 (defun gnus-group-mark-region (unmark beg end)
1907 "Mark all groups between point and mark.
1908 If UNMARK, remove the mark instead."
1909 (interactive "P\nr")
1910 (let ((num (count-lines beg end)))
1911 (save-excursion
1912 (goto-char beg)
1913 (- num (gnus-group-mark-group num unmark)))))
1915 (defun gnus-group-mark-buffer (&optional unmark)
1916 "Mark all groups in the buffer.
1917 If UNMARK, remove the mark instead."
1918 (interactive "P")
1919 (gnus-group-mark-region unmark (point-min) (point-max)))
1921 (defun gnus-group-mark-regexp (regexp)
1922 "Mark all groups that match some regexp."
1923 (interactive "sMark (regexp): ")
1924 (let ((alist (cdr gnus-newsrc-alist))
1925 group)
1926 (save-excursion
1927 (while alist
1928 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1929 (gnus-group-jump-to-group group)
1930 (gnus-group-set-mark group)))))
1931 (gnus-group-position-point))
1933 (defun gnus-group-remove-mark (group &optional test-marked)
1934 "Remove the process mark from GROUP and move point there.
1935 Return nil if the group isn't displayed."
1936 (if (gnus-group-goto-group group nil test-marked)
1937 (save-excursion
1938 (gnus-group-mark-group 1 'unmark t)
1940 (setq gnus-group-marked
1941 (delete group gnus-group-marked))
1942 nil))
1944 (defun gnus-group-set-mark (group)
1945 "Set the process mark on GROUP."
1946 (if (gnus-group-goto-group group)
1947 (save-excursion
1948 (gnus-group-mark-group 1 nil t))
1949 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1951 (defun gnus-group-universal-argument (arg &optional groups func)
1952 "Perform any command on all groups according to the process/prefix convention."
1953 (interactive "P")
1954 (if (eq (setq func (or func
1955 (key-binding
1956 (read-key-sequence
1957 (substitute-command-keys
1958 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1959 'undefined)
1960 (gnus-error 1 "Undefined key")
1961 (gnus-group-iterate arg
1962 (lambda (group)
1963 (command-execute func))))
1964 (gnus-group-position-point))
1966 (defun gnus-group-process-prefix (n)
1967 "Return a list of groups to work on.
1968 Take into consideration N (the prefix) and the list of marked groups."
1969 (cond
1971 (setq n (prefix-numeric-value n))
1972 ;; There is a prefix, so we return a list of the N next
1973 ;; groups.
1974 (let ((way (if (< n 0) -1 1))
1975 (n (abs n))
1976 group groups)
1977 (save-excursion
1978 (while (> n 0)
1979 (if (setq group (gnus-group-group-name))
1980 (push group groups))
1981 (setq n (1- n))
1982 (gnus-group-next-group way)))
1983 (nreverse groups)))
1984 ((and (gnus-region-active-p) (mark))
1985 ;; Work on the region between point and mark.
1986 (let ((max (max (point) (mark)))
1987 groups)
1988 (save-excursion
1989 (goto-char (min (point) (mark)))
1990 (while
1991 (and
1992 (push (gnus-group-group-name) groups)
1993 (zerop (gnus-group-next-group 1))
1994 (< (point) max)))
1995 (nreverse groups))))
1996 (gnus-group-marked
1997 ;; No prefix, but a list of marked articles.
1998 (reverse gnus-group-marked))
2000 ;; Neither marked articles or a prefix, so we return the
2001 ;; current group.
2002 (let ((group (gnus-group-group-name)))
2003 (and group (list group))))))
2005 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
2006 ;;; imagine why I went through these contortions...
2007 (eval-and-compile
2008 (let ((function (make-symbol "gnus-group-iterate-function"))
2009 (window (make-symbol "gnus-group-iterate-window"))
2010 (groups (make-symbol "gnus-group-iterate-groups"))
2011 (group (make-symbol "gnus-group-iterate-group")))
2012 (eval
2013 `(defun gnus-group-iterate (arg ,function)
2014 "Iterate FUNCTION over all process/prefixed groups.
2015 FUNCTION will be called with the group name as the parameter
2016 and with point over the group in question."
2017 (let ((,groups (gnus-group-process-prefix arg))
2018 (,window (selected-window))
2019 ,group)
2020 (while ,groups
2021 (setq ,group (car ,groups)
2022 ,groups (cdr ,groups))
2023 (select-window ,window)
2024 (gnus-group-remove-mark ,group)
2025 (save-selected-window
2026 (save-excursion
2027 (funcall ,function ,group)))))))))
2029 (put 'gnus-group-iterate 'lisp-indent-function 1)
2031 ;; Selecting groups.
2033 (defun gnus-group-read-group (&optional all no-article group select-articles)
2034 "Read news in this newsgroup.
2035 If the prefix argument ALL is non-nil, already read articles become
2036 readable. IF ALL is a number, fetch this number of articles. If the
2037 optional argument NO-ARTICLE is non-nil, no article will be
2038 auto-selected upon group entry. If GROUP is non-nil, fetch that
2039 group."
2040 (interactive "P")
2041 (let ((no-display (eq all 0))
2042 (group (or group (gnus-group-group-name)))
2043 number active marked entry)
2044 (when (eq all 0)
2045 (setq all nil))
2046 (unless group
2047 (error "No group on current line"))
2048 (setq marked (gnus-info-marks
2049 (nth 2 (setq entry (gnus-group-entry group)))))
2050 ;; This group might be a dead group. In that case we have to get
2051 ;; the number of unread articles from `gnus-active-hashtb'.
2052 (setq number
2053 (cond ((numberp all) all)
2054 (entry (car entry))
2055 ((setq active (gnus-active group))
2056 (- (1+ (cdr active)) (car active)))))
2057 (gnus-summary-read-group
2058 group (or all (and (numberp number)
2059 (zerop (+ number (gnus-range-length
2060 (cdr (assq 'tick marked)))
2061 (gnus-range-length
2062 (cdr (assq 'dormant marked)))))))
2063 no-article nil no-display nil select-articles)))
2065 (defun gnus-group-select-group (&optional all)
2066 "Select this newsgroup.
2067 No article is selected automatically.
2068 If the group is opened, just switch the summary buffer.
2069 If ALL is non-nil, already read articles become readable.
2070 If ALL is a positive number, fetch this number of the latest
2071 articles in the group.
2072 If ALL is a negative number, fetch this number of the earliest
2073 articles in the group."
2074 (interactive "P")
2075 (when (and (eobp) (not (gnus-group-group-name)))
2076 (forward-line -1))
2077 (gnus-group-read-group all t))
2079 (defun gnus-group-quick-select-group (&optional all group)
2080 "Select the GROUP \"quickly\".
2081 This means that no highlighting or scoring will be performed. If
2082 ALL (the prefix argument) is 0, don't even generate the summary
2083 buffer. If GROUP is nil, use current group.
2085 This might be useful if you want to toggle threading
2086 before entering the group."
2087 (interactive "P")
2088 (require 'gnus-score)
2089 (let (gnus-visual
2090 gnus-score-find-score-files-function
2091 gnus-home-score-file
2092 gnus-apply-kill-hook
2093 gnus-summary-expunge-below)
2094 (gnus-group-read-group all t group)))
2096 (defun gnus-group-visible-select-group (&optional all)
2097 "Select the current group without hiding any articles."
2098 (interactive "P")
2099 (let ((gnus-inhibit-limiting t))
2100 (gnus-group-read-group all t)))
2102 (defun gnus-group-select-group-ephemerally ()
2103 "Select the current group without doing any processing whatsoever.
2104 You will actually be entered into a group that's a copy of
2105 the current group; no changes you make while in this group will
2106 be permanent."
2107 (interactive)
2108 (require 'gnus-score)
2109 (let* (gnus-visual
2110 gnus-score-find-score-files-function gnus-apply-kill-hook
2111 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2112 gnus-summary-mode-hook gnus-select-group-hook
2113 (group (gnus-group-group-name))
2114 (method (gnus-find-method-for-group group)))
2115 (gnus-group-read-ephemeral-group
2116 (gnus-group-prefixed-name group method) method)))
2118 (defun gnus-group-name-at-point ()
2119 "Return a group name from around point if it exists, or nil."
2120 (if (eq major-mode 'gnus-group-mode)
2121 (let ((group (gnus-group-group-name)))
2122 (when group
2123 (gnus-group-decoded-name group)))
2124 (let ((regexp "[][\C-@-\t\v-*,/:-@\\^`{-\C-?]*\
2125 \\(nn[a-z]+\\(?:\\+[^][\C-@-*,/:-@\\^`{-\C-?]+\\)?:\
2126 \[^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)*\
2127 \\|[^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)+\\)")
2128 (start (point))
2129 (case-fold-search nil))
2130 (prog1
2131 (if (or (and (not (or (eobp)
2132 (looking-at "[][\C-@-*,/;-@\\^`{-\C-?]")))
2133 (prog1 t
2134 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2135 (point-at-bol))))
2136 (and (looking-at "[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*$")
2137 (prog1 t
2138 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2139 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2140 (point-at-bol))))
2141 (string-match "\\`[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*\\'"
2142 (buffer-substring (point-at-bol) (point))))
2143 (when (looking-at regexp)
2144 (match-string 1))
2145 (let (group distance)
2146 (when (looking-at regexp)
2147 (setq group (match-string 1)
2148 distance (- (match-beginning 1) (match-beginning 0))))
2149 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2150 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2151 (point-at-bol))
2152 (if (looking-at regexp)
2153 (if (and group (<= distance (- start (match-end 0))))
2154 group
2155 (match-string 1))
2156 group)))
2157 (goto-char start)))))
2159 (defun gnus-group-completing-read (prompt &optional collection predicate
2160 require-match initial-input hist def
2161 &rest args)
2162 "Read a group name with completion. Non-ASCII group names are allowed.
2163 The arguments are the same as `completing-read' except that COLLECTION
2164 and HIST default to `gnus-active-hashtb' and `gnus-group-history'
2165 respectively if they are omitted."
2166 (let (group)
2167 (mapatoms (lambda (symbol)
2168 (setq group (symbol-name symbol))
2169 (set (intern (if (string-match "[^\000-\177]" group)
2170 (gnus-group-decoded-name group)
2171 group)
2172 collection)
2173 group))
2174 (prog1
2175 (or collection
2176 (setq collection (or gnus-active-hashtb [0])))
2177 (setq collection (gnus-make-hashtable (length collection)))))
2178 (setq group (apply 'completing-read prompt collection predicate
2179 require-match initial-input
2180 (or hist 'gnus-group-history)
2181 def args))
2182 (or (prog1
2183 (symbol-value (intern-soft group collection))
2184 (setq collection nil))
2185 (mm-encode-coding-string group (gnus-group-name-charset nil group)))))
2187 ;;;###autoload
2188 (defun gnus-fetch-group (group &optional articles)
2189 "Start Gnus if necessary and enter GROUP.
2190 If ARTICLES, display those articles.
2191 Returns whether the fetching was successful or not."
2192 (interactive (list (gnus-group-completing-read "Group name: "
2193 nil nil nil
2194 (gnus-group-name-at-point))))
2195 (unless (gnus-alive-p)
2196 (gnus-no-server))
2197 (gnus-group-read-group (if articles nil t) nil group articles))
2199 ;;;###autoload
2200 (defun gnus-fetch-group-other-frame (group)
2201 "Pop up a frame and enter GROUP."
2202 (interactive "P")
2203 (let ((window (get-buffer-window gnus-group-buffer)))
2204 (cond (window
2205 (select-frame (window-frame window)))
2206 ((= (length (frame-list)) 1)
2207 (select-frame (make-frame)))
2209 (other-frame 1))))
2210 (gnus-fetch-group group))
2212 (defvar gnus-ephemeral-group-server 0)
2214 (defcustom gnus-large-ephemeral-newsgroup 200
2215 "The number of articles which indicates a large ephemeral newsgroup.
2216 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2218 If the number of articles in a newsgroup is greater than this value,
2219 confirmation is required for selecting the newsgroup. If it is nil, no
2220 confirmation is required."
2221 :version "22.1"
2222 :group 'gnus-group-select
2223 :type '(choice (const :tag "No limit" nil)
2224 integer))
2226 (defcustom gnus-fetch-old-ephemeral-headers nil
2227 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2228 :version "22.1"
2229 :group 'gnus-thread
2230 :type '(choice (const :tag "off" nil)
2231 (const some)
2232 number
2233 (sexp :menu-tag "other" t)))
2235 ;; Enter a group that is not in the group buffer. Non-nil is returned
2236 ;; if selection was successful.
2237 (defun gnus-group-read-ephemeral-group (group method &optional activate
2238 quit-config request-only
2239 select-articles
2240 parameters
2241 number)
2242 "Read GROUP from METHOD as an ephemeral group.
2243 If ACTIVATE, request the group first.
2244 If QUIT-CONFIG, use that window configuration when exiting from the
2245 ephemeral group.
2246 If REQUEST-ONLY, don't actually read the group; just request it.
2247 If SELECT-ARTICLES, only select those articles.
2248 If PARAMETERS, use those as the group parameters.
2249 If NUMBER, fetch this number of articles.
2251 Return the name of the group if selection was successful."
2252 (interactive
2253 (list
2254 ;; (gnus-read-group "Group name: ")
2255 (gnus-group-completing-read "Group: ")
2256 (gnus-read-method "From method: ")))
2257 ;; Transform the select method into a unique server.
2258 (when (stringp method)
2259 (setq method (gnus-server-to-method method)))
2260 (setq method
2261 `(,(car method) ,(concat (cadr method) "-ephemeral")
2262 (,(intern (format "%s-address" (car method))) ,(cadr method))
2263 ,@(cddr method)))
2264 (let ((group (if (gnus-group-foreign-p group) group
2265 (gnus-group-prefixed-name (gnus-group-real-name group)
2266 method))))
2267 (gnus-sethash
2268 group
2269 `(-1 nil (,group
2270 ,gnus-level-default-subscribed nil nil ,method
2271 ,(cons
2272 (if quit-config
2273 (cons 'quit-config quit-config)
2274 (cons 'quit-config
2275 (cons gnus-summary-buffer
2276 gnus-current-window-configuration)))
2277 parameters)))
2278 gnus-newsrc-hashtb)
2279 (push method gnus-ephemeral-servers)
2280 (set-buffer gnus-group-buffer)
2281 (unless (gnus-check-server method)
2282 (error "Unable to contact server: %s" (gnus-status-message method)))
2283 (when activate
2284 (gnus-activate-group group 'scan)
2285 (unless (gnus-request-group group)
2286 (error "Couldn't request group: %s"
2287 (nnheader-get-report (car method)))))
2288 (if request-only
2289 group
2290 (condition-case ()
2291 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2292 (gnus-fetch-old-headers
2293 gnus-fetch-old-ephemeral-headers))
2294 (gnus-group-read-group (or number t) t group select-articles))
2295 group)
2296 ;;(error nil)
2297 (quit
2298 (message "Quit reading the ephemeral group")
2299 nil)))))
2301 (defun gnus-group-jump-to-group (group &optional prompt)
2302 "Jump to newsgroup GROUP.
2304 If PROMPT (the prefix) is a number, use the prompt specified in
2305 `gnus-group-jump-to-group-prompt'."
2306 (interactive
2307 (list (gnus-group-completing-read
2308 "Group: " nil nil (gnus-read-active-file-p)
2309 (if current-prefix-arg
2310 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2311 (or (and (stringp gnus-group-jump-to-group-prompt)
2312 gnus-group-jump-to-group-prompt)
2313 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2314 (and (stringp p) p)))))))
2316 (when (equal group "")
2317 (error "Empty group name"))
2319 (unless (gnus-ephemeral-group-p group)
2320 ;; Either go to the line in the group buffer...
2321 (unless (gnus-group-goto-group group)
2322 ;; ... or insert the line.
2323 (gnus-group-update-group group)
2324 (gnus-group-goto-group group)))
2325 ;; Adjust cursor point.
2326 (gnus-group-position-point))
2328 (defun gnus-group-goto-group (group &optional far test-marked)
2329 "Goto to newsgroup GROUP.
2330 If FAR, it is likely that the group is not on the current line.
2331 If TEST-MARKED, the line must be marked."
2332 (when group
2333 (beginning-of-line)
2334 (cond
2335 ;; It's quite likely that we are on the right line, so
2336 ;; we check the current line first.
2337 ((and (not far)
2338 (eq (get-text-property (point) 'gnus-group)
2339 (gnus-intern-safe group gnus-active-hashtb))
2340 (or (not test-marked) (gnus-group-mark-line-p)))
2341 (point))
2342 ;; Previous and next line are also likely, so we check them as well.
2343 ((and (not far)
2344 (save-excursion
2345 (forward-line -1)
2346 (and (eq (get-text-property (point) 'gnus-group)
2347 (gnus-intern-safe group gnus-active-hashtb))
2348 (or (not test-marked) (gnus-group-mark-line-p)))))
2349 (forward-line -1)
2350 (point))
2351 ((and (not far)
2352 (save-excursion
2353 (forward-line 1)
2354 (and (eq (get-text-property (point) 'gnus-group)
2355 (gnus-intern-safe group gnus-active-hashtb))
2356 (or (not test-marked) (gnus-group-mark-line-p)))))
2357 (forward-line 1)
2358 (point))
2359 (test-marked
2360 (goto-char (point-min))
2361 (let (found)
2362 (while (and (not found)
2363 (gnus-goto-char
2364 (text-property-any
2365 (point) (point-max)
2366 'gnus-group
2367 (gnus-intern-safe group gnus-active-hashtb))))
2368 (if (gnus-group-mark-line-p)
2369 (setq found t)
2370 (forward-line 1)))
2371 found))
2373 ;; Search through the entire buffer.
2374 (gnus-goto-char
2375 (text-property-any
2376 (point-min) (point-max)
2377 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2379 (defun gnus-group-next-group (n &optional silent)
2380 "Go to next N'th newsgroup.
2381 If N is negative, search backward instead.
2382 Returns the difference between N and the number of skips actually
2383 done."
2384 (interactive "p")
2385 (gnus-group-next-unread-group n t nil silent))
2387 (defun gnus-group-next-unread-group (n &optional all level silent)
2388 "Go to next N'th unread newsgroup.
2389 If N is negative, search backward instead.
2390 If ALL is non-nil, choose any newsgroup, unread or not.
2391 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2392 such group can be found, the next group with a level higher than
2393 LEVEL.
2394 Returns the difference between N and the number of skips actually
2395 made."
2396 (interactive "p")
2397 (let ((backward (< n 0))
2398 (n (abs n)))
2399 (while (and (> n 0)
2400 (gnus-group-search-forward
2401 backward (or (not gnus-group-goto-unread) all) level))
2402 (setq n (1- n)))
2403 (when (and (/= 0 n)
2404 (not silent))
2405 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2406 (if level " on this level or higher" "")))
2409 (defun gnus-group-prev-group (n)
2410 "Go to previous N'th newsgroup.
2411 Returns the difference between N and the number of skips actually
2412 done."
2413 (interactive "p")
2414 (gnus-group-next-unread-group (- n) t))
2416 (defun gnus-group-prev-unread-group (n)
2417 "Go to previous N'th unread newsgroup.
2418 Returns the difference between N and the number of skips actually
2419 done."
2420 (interactive "p")
2421 (gnus-group-next-unread-group (- n)))
2423 (defun gnus-group-next-unread-group-same-level (n)
2424 "Go to next N'th unread newsgroup on the same level.
2425 If N is negative, search backward instead.
2426 Returns the difference between N and the number of skips actually
2427 done."
2428 (interactive "p")
2429 (gnus-group-next-unread-group n t (gnus-group-group-level))
2430 (gnus-group-position-point))
2432 (defun gnus-group-prev-unread-group-same-level (n)
2433 "Go to next N'th unread newsgroup on the same level.
2434 Returns the difference between N and the number of skips actually
2435 done."
2436 (interactive "p")
2437 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2438 (gnus-group-position-point))
2440 (defun gnus-group-best-unread-group (&optional exclude-group)
2441 "Go to the group with the highest level.
2442 If EXCLUDE-GROUP, do not go to that group."
2443 (interactive)
2444 (goto-char (point-min))
2445 (let ((best 100000)
2446 unread best-point)
2447 (while (not (eobp))
2448 (setq unread (get-text-property (point) 'gnus-unread))
2449 (when (and (numberp unread) (> unread 0))
2450 (when (and (get-text-property (point) 'gnus-level)
2451 (< (get-text-property (point) 'gnus-level) best)
2452 (or (not exclude-group)
2453 (not (equal exclude-group (gnus-group-group-name)))))
2454 (setq best (get-text-property (point) 'gnus-level))
2455 (setq best-point (point))))
2456 (forward-line 1))
2457 (when best-point
2458 (goto-char best-point))
2459 (gnus-group-position-point)
2460 (and best-point (gnus-group-group-name))))
2462 ;; Is there something like an after-point-motion-hook?
2463 ;; (inhibit-point-motion-hooks?). Is there a tool-bar-update function?
2465 ;; (defun gnus-group-menu-bar-update ()
2466 ;; (let* ((buf (list (with-current-buffer gnus-group-buffer
2467 ;; (current-buffer))))
2468 ;; (name (buffer-name (car buf))))
2469 ;; (setcdr buf
2470 ;; (if (> (length name) 27)
2471 ;; (concat (substring name 0 12)
2472 ;; "..."
2473 ;; (substring name -12))
2474 ;; name))
2475 ;; (menu-bar-update-buffers-1 buf)))
2477 ;; (defun gnus-group-position-point ()
2478 ;; (gnus-goto-colon)
2479 ;; (gnus-group-menu-bar-update))
2481 (defun gnus-group-first-unread-group ()
2482 "Go to the first group with unread articles."
2483 (interactive)
2484 (prog1
2485 (let ((opoint (point))
2486 unread)
2487 (goto-char (point-min))
2488 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2489 (and (numberp unread) ; Not a topic.
2490 (not (zerop unread))) ; Has unread articles.
2491 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2492 (point) ; Success.
2493 (goto-char opoint)
2494 nil)) ; Not success.
2495 (gnus-group-position-point)))
2497 (defun gnus-group-enter-server-mode ()
2498 "Jump to the server buffer."
2499 (interactive)
2500 (gnus-enter-server-buffer))
2502 (defun gnus-group-make-group-simple (&optional group)
2503 "Add a new newsgroup.
2504 The user will be prompted for GROUP."
2505 (interactive (list (gnus-group-completing-read "Group: ")))
2506 (gnus-group-make-group (gnus-group-real-name group)
2507 (gnus-group-server group)
2508 nil nil t))
2510 (defun gnus-group-make-group (name &optional method address args encoded)
2511 "Add a new newsgroup.
2512 The user will be prompted for a NAME, for a select METHOD, and an
2513 ADDRESS. NAME should be a human-readable string (i.e., not be encoded
2514 even if it contains non-ASCII characters) unless ENCODED is non-nil."
2515 (interactive
2516 (list
2517 (gnus-read-group "Group name: ")
2518 (gnus-read-method "From method: ")))
2520 (when (stringp method)
2521 (setq method (or (gnus-server-to-method method) method)))
2522 (unless encoded
2523 (setq name (mm-encode-coding-string
2524 name
2525 (gnus-group-name-charset method name))))
2526 (let* ((meth (gnus-method-simplify
2527 (when (and method
2528 (not (gnus-server-equal method gnus-select-method)))
2529 (if address (list (intern method) address)
2530 method))))
2531 (nname (if method (gnus-group-prefixed-name name meth) name))
2532 backend info)
2533 (when (gnus-group-entry nname)
2534 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2535 ;; Subscribe to the new group.
2536 (gnus-group-change-level
2537 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2538 gnus-level-default-subscribed gnus-level-killed
2539 (and (gnus-group-group-name)
2540 (gnus-group-entry (gnus-group-group-name)))
2542 ;; Make it active.
2543 (gnus-set-active nname (cons 1 0))
2544 (unless (gnus-ephemeral-group-p name)
2545 (gnus-dribble-enter
2546 (concat "(gnus-group-set-info '"
2547 (gnus-prin1-to-string (cdr info)) ")")))
2548 ;; Insert the line.
2549 (gnus-group-insert-group-line-info nname)
2550 (forward-line -1)
2551 (gnus-group-position-point)
2553 ;; Load the back end and try to make the back end create
2554 ;; the group as well.
2555 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2556 nil meth))))
2557 gnus-valid-select-methods)
2558 (require backend))
2559 (gnus-check-server meth)
2560 (when (gnus-check-backend-function 'request-create-group nname)
2561 (unless (gnus-request-create-group nname nil args)
2562 (error "Could not create group on server: %s"
2563 (nnheader-get-report backend))))
2566 (defun gnus-group-delete-groups (&optional arg)
2567 "Delete the current group. Only meaningful with editable groups."
2568 (interactive "P")
2569 (let ((n (length (gnus-group-process-prefix arg))))
2570 (when (gnus-yes-or-no-p
2571 (if (= n 1)
2572 "Delete this 1 group? "
2573 (format "Delete these %d groups? " n)))
2574 (gnus-group-iterate arg
2575 (lambda (group)
2576 (gnus-group-delete-group group nil t))))))
2578 (defun gnus-group-delete-group (group &optional force no-prompt)
2579 "Delete the current group. Only meaningful with editable groups.
2580 If FORCE (the prefix) is non-nil, all the articles in the group will
2581 be deleted. This is \"deleted\" as in \"removed forever from the face
2582 of the Earth\". There is no undo. The user will be prompted before
2583 doing the deletion.
2584 Note that you also have to specify FORCE if you want the group to
2585 be removed from the server, even when it's empty."
2586 (interactive
2587 (list (gnus-group-group-name)
2588 current-prefix-arg))
2589 (unless group
2590 (error "No group to delete"))
2591 (unless (gnus-check-backend-function 'request-delete-group group)
2592 (error "This back end does not support group deletion"))
2593 (prog1
2594 (let ((group-decoded (gnus-group-decoded-name group)))
2595 (if (and (not no-prompt)
2596 (not (gnus-yes-or-no-p
2597 (format
2598 "Do you really want to delete %s%s? "
2599 group-decoded (if force " and all its contents" "")))))
2600 () ; Whew!
2601 (gnus-message 6 "Deleting group %s..." group-decoded)
2602 (if (not (gnus-request-delete-group group force))
2603 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2604 (gnus-message 6 "Deleting group %s...done" group-decoded)
2605 (gnus-group-goto-group group)
2606 (gnus-group-kill-group 1 t)
2607 (gnus-set-active group nil)
2608 t)))
2609 (gnus-group-position-point)))
2611 (defun gnus-group-rename-group (group new-name)
2612 "Rename group from GROUP to NEW-NAME.
2613 When used interactively, GROUP is the group under point
2614 and NEW-NAME will be prompted for."
2615 (interactive
2616 (let ((group (gnus-group-group-name))
2617 method new-name)
2618 (unless (gnus-check-backend-function 'request-rename-group group)
2619 (error "This back end does not support renaming groups"))
2620 (setq new-name (gnus-read-group
2621 "Rename group to: "
2622 (gnus-group-real-name (gnus-group-decoded-name group)))
2623 method (gnus-info-method (gnus-get-info group)))
2624 (list group (mm-encode-coding-string
2625 new-name
2626 (gnus-group-name-charset
2627 method
2628 (gnus-group-prefixed-name new-name method))))))
2630 (unless (gnus-check-backend-function 'request-rename-group group)
2631 (error "This back end does not support renaming groups"))
2632 (unless group
2633 (error "No group to rename"))
2634 (when (equal (gnus-group-real-name group) new-name)
2635 (error "Can't rename to the same name"))
2637 ;; We find the proper prefixed name.
2638 (setq new-name
2639 (if (gnus-group-native-p group)
2640 ;; Native group.
2641 new-name
2642 ;; Foreign group.
2643 (gnus-group-prefixed-name
2644 (gnus-group-real-name new-name)
2645 (gnus-info-method (gnus-get-info group)))))
2647 (let ((decoded-group (gnus-group-decoded-name group))
2648 (decoded-new-name (gnus-group-decoded-name new-name)))
2649 (when (gnus-active new-name)
2650 (error "The group %s already exists" decoded-new-name))
2652 (gnus-message 6 "Renaming group %s to %s..."
2653 decoded-group decoded-new-name)
2654 (prog1
2655 (if (progn
2656 (gnus-group-goto-group group)
2657 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2658 (gnus-request-rename-group group new-name))))
2659 (gnus-error 3 "Couldn't rename group %s to %s"
2660 decoded-group decoded-new-name)
2661 ;; We rename the group internally by killing it...
2662 (gnus-group-kill-group)
2663 ;; ... changing its name ...
2664 (setcar (cdar gnus-list-of-killed-groups) new-name)
2665 ;; ... and then yanking it. Magic!
2666 (gnus-group-yank-group)
2667 (gnus-set-active new-name (gnus-active group))
2668 (gnus-message 6 "Renaming group %s to %s...done"
2669 decoded-group decoded-new-name)
2670 new-name)
2671 (setq gnus-killed-list (delete group gnus-killed-list))
2672 (gnus-set-active group nil)
2673 (gnus-dribble-touch)
2674 (gnus-group-position-point))))
2676 (defun gnus-group-edit-group (group &optional part)
2677 "Edit the group on the current line."
2678 (interactive (list (gnus-group-group-name)))
2679 (let ((part (or part 'info))
2680 info)
2681 (unless group
2682 (error "No group on current line"))
2683 (unless (setq info (gnus-get-info group))
2684 (error "Killed group; can't be edited"))
2685 (ignore-errors
2686 (gnus-close-group group))
2687 (gnus-edit-form
2688 ;; Find the proper form to edit.
2689 (cond ((eq part 'method)
2690 (or (gnus-info-method info) "native"))
2691 ((eq part 'params)
2692 (gnus-info-params info))
2693 (t info))
2694 ;; The proper documentation.
2695 (format
2696 "Editing the %s for `%s'."
2697 (cond
2698 ((eq part 'method) "select method")
2699 ((eq part 'params) "group parameters")
2700 (t "group info"))
2701 (gnus-group-decoded-name group))
2702 `(lambda (form)
2703 (gnus-group-edit-group-done ',part ,group form)))
2704 (local-set-key
2705 "\C-c\C-i"
2706 (gnus-create-info-command
2707 (cond
2708 ((eq part 'method)
2709 "(gnus)Select Methods")
2710 ((eq part 'params)
2711 "(gnus)Group Parameters")
2713 "(gnus)Group Info"))))))
2715 (defun gnus-group-edit-group-method (group)
2716 "Edit the select method of GROUP."
2717 (interactive (list (gnus-group-group-name)))
2718 (gnus-group-edit-group group 'method))
2720 (defun gnus-group-edit-group-parameters (group)
2721 "Edit the group parameters of GROUP."
2722 (interactive (list (gnus-group-group-name)))
2723 (gnus-group-edit-group group 'params))
2725 (defun gnus-group-edit-group-done (part group form)
2726 "Update variables."
2727 (let* ((method (cond ((eq part 'info) (nth 4 form))
2728 ((eq part 'method) form)
2729 (t nil)))
2730 (info (cond ((eq part 'info) form)
2731 ((eq part 'method) (gnus-get-info group))
2732 (t nil)))
2733 (new-group (if info
2734 (if (or (not method)
2735 (gnus-server-equal
2736 gnus-select-method method))
2737 (gnus-group-real-name (car info))
2738 (gnus-group-prefixed-name
2739 (gnus-group-real-name (car info)) method))
2740 nil)))
2741 (when (and new-group
2742 (not (equal new-group group)))
2743 (when (gnus-group-goto-group group)
2744 (gnus-group-kill-group 1))
2745 (gnus-activate-group new-group))
2746 ;; Set the info.
2747 (if (not (and info new-group))
2748 (gnus-group-set-info form (or new-group group) part)
2749 (setq info (gnus-copy-sequence info))
2750 (setcar info new-group)
2751 (unless (gnus-server-equal method "native")
2752 (unless (nthcdr 3 info)
2753 (nconc info (list nil nil)))
2754 (unless (nthcdr 4 info)
2755 (nconc info (list nil)))
2756 (gnus-info-set-method info method))
2757 (gnus-group-set-info info))
2758 (gnus-group-update-group (or new-group group))
2759 (gnus-group-position-point)))
2761 (defun gnus-group-make-useful-group (group method)
2762 "Create one of the groups described in `gnus-useful-groups'."
2763 (interactive
2764 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2765 nil t)
2766 gnus-useful-groups)))
2767 (list (cadr entry) (caddr entry))))
2768 (setq method (gnus-copy-sequence method))
2769 (let (entry)
2770 (while (setq entry (memq (assq 'eval method) method))
2771 (setcar entry (eval (cadar entry)))))
2772 (gnus-group-make-group group method))
2774 (defun gnus-group-make-help-group (&optional noerror)
2775 "Create the Gnus documentation group.
2776 Optional argument NOERROR modifies the behavior of this function when the
2777 group already exists:
2778 - if not given, and error is signaled,
2779 - if t, stay silent,
2780 - if anything else, just print a message."
2781 (interactive)
2782 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2783 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2784 (if (gnus-group-entry name)
2785 (cond ((eq noerror nil)
2786 (error "Documentation group already exists"))
2787 ((eq noerror t)
2788 ;; stay silent
2791 (gnus-message 1 "Documentation group already exists")))
2792 ;; else:
2793 (if (not file)
2794 (gnus-message 1 "Couldn't find doc group")
2795 (gnus-group-make-group
2796 (gnus-group-real-name name)
2797 (list 'nndoc "gnus-help"
2798 (list 'nndoc-address file)
2799 (list 'nndoc-article-type 'mbox))))
2801 (gnus-group-position-point))
2803 (defun gnus-group-make-doc-group (file type)
2804 "Create a group that uses a single file as the source.
2806 If called with a prefix argument, ask for the file type."
2807 (interactive
2808 (list (read-file-name "File name: ")
2809 (and current-prefix-arg 'ask)))
2810 (when (eq type 'ask)
2811 (let ((err "")
2812 char found)
2813 (while (not found)
2814 (message
2815 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
2816 err)
2817 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2818 ((= char ?b) 'babyl)
2819 ((= char ?d) 'digest)
2820 ((= char ?f) 'forward)
2821 ((= char ?a) 'mmfd)
2822 ((= char ?g) 'guess)
2823 (t (setq err (format "%c unknown. " char))
2824 nil))))
2825 (setq type found)))
2826 (setq file (expand-file-name file))
2827 (let* ((name (gnus-generate-new-group-name
2828 (gnus-group-prefixed-name
2829 (file-name-nondirectory file) '(nndoc ""))))
2830 (method (list 'nndoc file
2831 (list 'nndoc-address file)
2832 (list 'nndoc-article-type (or type 'guess))))
2833 (coding (gnus-group-name-charset method name)))
2834 (setcar (cdr method) (mm-encode-coding-string file coding))
2835 (gnus-group-make-group
2836 (mm-encode-coding-string (gnus-group-real-name name) coding)
2837 method nil nil t)))
2839 (defvar nnweb-type-definition)
2840 (defvar gnus-group-web-type-history nil)
2841 (defvar gnus-group-web-search-history nil)
2842 (defun gnus-group-make-web-group (&optional solid)
2843 "Create an ephemeral nnweb group.
2844 If SOLID (the prefix), create a solid group."
2845 (interactive "P")
2846 (require 'nnweb)
2847 (let* ((group
2848 (if solid (gnus-read-group "Group name: ")
2849 (message-unique-id)))
2850 (default-type (or (car gnus-group-web-type-history)
2851 (symbol-name (caar nnweb-type-definition))))
2852 (type
2853 (gnus-string-or
2854 (completing-read
2855 (format "Search engine type (default %s): " default-type)
2856 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2857 nnweb-type-definition)
2858 nil t nil 'gnus-group-web-type-history)
2859 default-type))
2860 (search
2861 (read-string
2862 "Search string: "
2863 (cons (or (car gnus-group-web-search-history) "") 0)
2864 'gnus-group-web-search-history))
2865 (method
2866 `(nnweb ,group (nnweb-search ,search)
2867 (nnweb-type ,(intern type))
2868 (nnweb-ephemeral-p t))))
2869 (if solid
2870 (progn
2871 (gnus-pull 'nnweb-ephemeral-p method)
2872 (gnus-group-make-group group method))
2873 (gnus-group-read-ephemeral-group
2874 group method t
2875 (cons (current-buffer)
2876 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2878 (defvar nnrss-group-alist)
2879 (eval-when-compile
2880 (defun nnrss-discover-feed (arg))
2881 (defun nnrss-save-server-data (arg)))
2882 (defun gnus-group-make-rss-group (&optional url)
2883 "Given a URL, discover if there is an RSS feed.
2884 If there is, use Gnus to create an nnrss group"
2885 (interactive)
2886 (require 'nnrss)
2887 (if (not url)
2888 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2889 (let ((feedinfo (nnrss-discover-feed url)))
2890 (if feedinfo
2891 (let* ((title (gnus-newsgroup-savable-name
2892 (read-from-minibuffer "Title: "
2893 (gnus-newsgroup-savable-name
2894 (or (cdr (assoc 'title
2895 feedinfo))
2896 "")))))
2897 (desc (read-from-minibuffer "Description: "
2898 (cdr (assoc 'description
2899 feedinfo))))
2900 (href (cdr (assoc 'href feedinfo)))
2901 (coding (gnus-group-name-charset '(nnrss "") title)))
2902 (when coding
2903 ;; Unify non-ASCII text.
2904 (setq title (mm-decode-coding-string
2905 (mm-encode-coding-string title coding)
2906 coding)))
2907 (gnus-group-make-group title '(nnrss ""))
2908 (push (list title href desc) nnrss-group-alist)
2909 (nnrss-save-server-data nil))
2910 (error "No feeds found for %s" url))))
2912 (defvar nnwarchive-type-definition)
2913 (defvar gnus-group-warchive-type-history nil)
2914 (defvar gnus-group-warchive-login-history nil)
2915 (defvar gnus-group-warchive-address-history nil)
2917 (defun gnus-group-make-warchive-group ()
2918 "Create a nnwarchive group."
2919 (interactive)
2920 (require 'nnwarchive)
2921 (let* ((group (gnus-read-group "Group name: "))
2922 (default-type (or (car gnus-group-warchive-type-history)
2923 (symbol-name (caar nnwarchive-type-definition))))
2924 (type
2925 (gnus-string-or
2926 (completing-read
2927 (format "Warchive type (default %s): " default-type)
2928 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2929 nnwarchive-type-definition)
2930 nil t nil 'gnus-group-warchive-type-history)
2931 default-type))
2932 (address (read-string "Warchive address: "
2933 nil 'gnus-group-warchive-address-history))
2934 (default-login (or (car gnus-group-warchive-login-history)
2935 user-mail-address))
2936 (login
2937 (gnus-string-or
2938 (read-string
2939 (format "Warchive login (default %s): " user-mail-address)
2940 default-login 'gnus-group-warchive-login-history)
2941 user-mail-address))
2942 (method
2943 `(nnwarchive ,address
2944 (nnwarchive-type ,(intern type))
2945 (nnwarchive-login ,login))))
2946 (gnus-group-make-group group method)))
2948 (defun gnus-group-make-archive-group (&optional all)
2949 "Create the (ding) Gnus archive group of the most recent articles.
2950 Given a prefix, create a full group."
2951 (interactive "P")
2952 (let ((group (gnus-group-prefixed-name
2953 (if all "ding.archives" "ding.recent") '(nndir ""))))
2954 (when (gnus-group-entry group)
2955 (error "Archive group already exists"))
2956 (gnus-group-make-group
2957 (gnus-group-real-name group)
2958 (list 'nndir (if all "hpc" "edu")
2959 (list 'nndir-directory
2960 (if all gnus-group-archive-directory
2961 gnus-group-recent-archive-directory))))
2962 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2964 (defun gnus-group-make-directory-group (dir)
2965 "Create an nndir group.
2966 The user will be prompted for a directory. The contents of this
2967 directory will be used as a newsgroup. The directory should contain
2968 mail messages or news articles in files that have numeric names."
2969 (interactive
2970 (list (read-file-name "Create group from directory: ")))
2971 (unless (file-exists-p dir)
2972 (error "No such directory"))
2973 (unless (file-directory-p dir)
2974 (error "Not a directory"))
2975 (let ((ext "")
2976 (i 0)
2977 group)
2978 (while (or (not group) (gnus-group-entry group))
2979 (setq group
2980 (gnus-group-prefixed-name
2981 (expand-file-name ext dir)
2982 '(nndir "")))
2983 (setq ext (format "<%d>" (setq i (1+ i)))))
2984 (gnus-group-make-group
2985 (gnus-group-real-name group)
2986 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2988 (defvar nnkiboze-score-file)
2989 (defun gnus-group-make-kiboze-group (group address scores)
2990 "Create an nnkiboze group.
2991 The user will be prompted for a name, a regexp to match groups, and
2992 score file entries for articles to include in the group."
2993 (interactive
2994 (list
2995 (read-string "nnkiboze group name: ")
2996 (read-string "Source groups (regexp): ")
2997 (let ((headers (mapcar 'list
2998 '("subject" "from" "number" "date" "message-id"
2999 "references" "chars" "lines" "xref"
3000 "followup" "all" "body" "head")))
3001 scores header regexp regexps)
3002 (while (not (equal "" (setq header (completing-read
3003 "Match on header: " headers nil t))))
3004 (setq regexps nil)
3005 (while (not (equal "" (setq regexp (read-string
3006 (format "Match on %s (regexp): "
3007 header)))))
3008 (push (list regexp nil nil 'r) regexps))
3009 (push (cons header regexps) scores))
3010 scores)))
3011 (gnus-group-make-group group "nnkiboze" address)
3012 (let* ((nnkiboze-current-group group)
3013 (score-file (car (nnkiboze-score-file "")))
3014 (score-dir (file-name-directory score-file)))
3015 (unless (file-exists-p score-dir)
3016 (make-directory score-dir))
3017 (with-temp-file score-file
3018 (let (emacs-lisp-mode-hook)
3019 (gnus-pp scores)))))
3021 (defun gnus-group-add-to-virtual (n vgroup)
3022 "Add the current group to a virtual group."
3023 (interactive
3024 (list current-prefix-arg
3025 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
3026 "nnvirtual:")))
3027 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
3028 (error "%s is not an nnvirtual group" vgroup))
3029 (gnus-close-group vgroup)
3030 (let* ((groups (gnus-group-process-prefix n))
3031 (method (gnus-info-method (gnus-get-info vgroup))))
3032 (setcar (cdr method)
3033 (concat
3034 (nth 1 method) "\\|"
3035 (mapconcat
3036 (lambda (s)
3037 (gnus-group-remove-mark s)
3038 (concat "\\(^" (regexp-quote s) "$\\)"))
3039 groups "\\|"))))
3040 (gnus-group-position-point))
3042 (defun gnus-group-make-empty-virtual (group)
3043 "Create a new, fresh, empty virtual group."
3044 (interactive "sCreate new, empty virtual group: ")
3045 (let* ((method (list 'nnvirtual "^$"))
3046 (pgroup (gnus-group-prefixed-name group method)))
3047 ;; Check whether it exists already.
3048 (when (gnus-group-entry pgroup)
3049 (error "Group %s already exists" pgroup))
3050 ;; Subscribe the new group after the group on the current line.
3051 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
3052 (gnus-group-update-group pgroup)
3053 (forward-line -1)
3054 (gnus-group-position-point)))
3056 (defun gnus-group-enter-directory (dir)
3057 "Enter an ephemeral nneething group."
3058 (interactive "DDirectory to read: ")
3059 (let* ((method (list 'nneething dir '(nneething-read-only t)))
3060 (leaf (gnus-group-prefixed-name
3061 (file-name-nondirectory (directory-file-name dir))
3062 method))
3063 (name (gnus-generate-new-group-name leaf)))
3064 (unless (gnus-group-read-ephemeral-group
3065 name method t
3066 (cons (current-buffer)
3067 (if (eq major-mode 'gnus-summary-mode)
3068 'summary 'group)))
3069 (error "Couldn't enter %s" dir))))
3071 (eval-and-compile
3072 (autoload 'nnimap-expunge "nnimap")
3073 (autoload 'nnimap-acl-get "nnimap")
3074 (autoload 'nnimap-acl-edit "nnimap"))
3076 (defun gnus-group-nnimap-expunge (group)
3077 "Expunge deleted articles in current nnimap GROUP."
3078 (interactive (list (gnus-group-group-name)))
3079 (let ((mailbox (gnus-group-real-name group)) method)
3080 (unless group
3081 (error "No group on current line"))
3082 (unless (gnus-get-info group)
3083 (error "Killed group; can't be edited"))
3084 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
3085 (error "%s is not an nnimap group" group))
3086 (nnimap-expunge mailbox (cadr method))))
3088 (defun gnus-group-nnimap-edit-acl (group)
3089 "Edit the Access Control List of current nnimap GROUP."
3090 (interactive (list (gnus-group-group-name)))
3091 (let ((mailbox (gnus-group-real-name group)) method acl)
3092 (unless group
3093 (error "No group on current line"))
3094 (unless (gnus-get-info group)
3095 (error "Killed group; can't be edited"))
3096 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
3097 (error "%s is not an nnimap group" group))
3098 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
3099 (error "Server does not support ACL's"))
3100 (gnus-edit-form acl (format "Editing the access control list for `%s'.
3102 An access control list is a list of (identifier . rights) elements.
3104 The identifier string specifies the corresponding user. The
3105 identifier \"anyone\" is reserved to refer to the universal identity.
3107 Rights is a string listing a (possibly empty) set of alphanumeric
3108 characters, each character listing a set of operations which is being
3109 controlled. Letters are reserved for ``standard'' rights, listed
3110 below. Digits are reserved for implementation or site defined rights.
3112 l - lookup (mailbox is visible to LIST/LSUB commands)
3113 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
3114 SEARCH, COPY from mailbox)
3115 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
3116 w - write (STORE flags other than \\SEEN and \\DELETED)
3117 i - insert (perform APPEND, COPY into mailbox)
3118 p - post (send mail to submission address for mailbox,
3119 not enforced by IMAP4 itself)
3120 c - create and delete mailbox (CREATE new sub-mailboxes in any
3121 implementation-defined hierarchy, RENAME or DELETE mailbox)
3122 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
3123 a - administer (perform SETACL)" group)
3124 `(lambda (form)
3125 (nnimap-acl-edit
3126 ,mailbox ',method ',acl form)))))
3128 ;; Group sorting commands
3129 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3131 (defun gnus-group-sort-groups (func &optional reverse)
3132 "Sort the group buffer according to FUNC.
3133 When used interactively, the sorting function used will be
3134 determined by the `gnus-group-sort-function' variable.
3135 If REVERSE (the prefix), reverse the sorting order."
3136 (interactive (list gnus-group-sort-function current-prefix-arg))
3137 (funcall gnus-group-sort-alist-function
3138 (gnus-make-sort-function func) reverse)
3139 (gnus-group-unmark-all-groups)
3140 (gnus-group-list-groups)
3141 (gnus-dribble-touch))
3143 (defun gnus-group-sort-flat (func reverse)
3144 ;; We peel off the dummy group from the alist.
3145 (when func
3146 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
3147 (pop gnus-newsrc-alist))
3148 ;; Do the sorting.
3149 (setq gnus-newsrc-alist
3150 (sort gnus-newsrc-alist func))
3151 (when reverse
3152 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
3153 ;; Regenerate the hash table.
3154 (gnus-make-hashtable-from-newsrc-alist)))
3156 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
3157 "Sort the group buffer alphabetically by group name.
3158 If REVERSE, sort in reverse order."
3159 (interactive "P")
3160 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
3162 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
3163 "Sort the group buffer alphabetically by real (unprefixed) group name.
3164 If REVERSE, sort in reverse order."
3165 (interactive "P")
3166 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
3168 (defun gnus-group-sort-groups-by-unread (&optional reverse)
3169 "Sort the group buffer by number of unread articles.
3170 If REVERSE, sort in reverse order."
3171 (interactive "P")
3172 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
3174 (defun gnus-group-sort-groups-by-level (&optional reverse)
3175 "Sort the group buffer by group level.
3176 If REVERSE, sort in reverse order."
3177 (interactive "P")
3178 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
3180 (defun gnus-group-sort-groups-by-score (&optional reverse)
3181 "Sort the group buffer by group score.
3182 If REVERSE, sort in reverse order."
3183 (interactive "P")
3184 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
3186 (defun gnus-group-sort-groups-by-rank (&optional reverse)
3187 "Sort the group buffer by group rank.
3188 If REVERSE, sort in reverse order."
3189 (interactive "P")
3190 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
3192 (defun gnus-group-sort-groups-by-method (&optional reverse)
3193 "Sort the group buffer alphabetically by back end name.
3194 If REVERSE, sort in reverse order."
3195 (interactive "P")
3196 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
3198 (defun gnus-group-sort-groups-by-server (&optional reverse)
3199 "Sort the group buffer alphabetically by server name.
3200 If REVERSE, sort in reverse order."
3201 (interactive "P")
3202 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
3204 ;;; Selected group sorting.
3206 (defun gnus-group-sort-selected-groups (n func &optional reverse)
3207 "Sort the process/prefixed groups."
3208 (interactive (list current-prefix-arg gnus-group-sort-function))
3209 (let ((groups (gnus-group-process-prefix n)))
3210 (funcall gnus-group-sort-selected-function
3211 groups (gnus-make-sort-function func) reverse)
3212 (gnus-group-unmark-all-groups)
3213 (gnus-group-list-groups)
3214 (gnus-dribble-touch)))
3216 (defun gnus-group-sort-selected-flat (groups func reverse)
3217 (let (entries infos)
3218 ;; First find all the group entries for these groups.
3219 (while groups
3220 (push (nthcdr 2 (gnus-group-entry (pop groups)))
3221 entries))
3222 ;; Then sort the infos.
3223 (setq infos
3224 (sort
3225 (mapcar
3226 (lambda (entry) (car entry))
3227 (setq entries (nreverse entries)))
3228 func))
3229 (when reverse
3230 (setq infos (nreverse infos)))
3231 ;; Go through all the infos and replace the old entries
3232 ;; with the new infos.
3233 (while infos
3234 (setcar (car entries) (pop infos))
3235 (pop entries))
3236 ;; Update the hashtable.
3237 (gnus-make-hashtable-from-newsrc-alist)))
3239 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3240 "Sort the group buffer alphabetically by group name.
3241 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3242 sort in reverse order."
3243 (interactive (gnus-interactive "P\ny"))
3244 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3246 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3247 "Sort the group buffer alphabetically by real group name.
3248 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3249 sort in reverse order."
3250 (interactive (gnus-interactive "P\ny"))
3251 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3253 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3254 "Sort the group buffer by number of unread articles.
3255 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3256 sort in reverse order."
3257 (interactive (gnus-interactive "P\ny"))
3258 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3260 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3261 "Sort the group buffer by group level.
3262 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3263 sort in reverse order."
3264 (interactive (gnus-interactive "P\ny"))
3265 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3267 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3268 "Sort the group buffer by group score.
3269 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3270 sort in reverse order."
3271 (interactive (gnus-interactive "P\ny"))
3272 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3274 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3275 "Sort the group buffer by group rank.
3276 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3277 sort in reverse order."
3278 (interactive (gnus-interactive "P\ny"))
3279 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3281 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3282 "Sort the group buffer alphabetically by back end name.
3283 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3284 sort in reverse order."
3285 (interactive (gnus-interactive "P\ny"))
3286 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3288 ;;; Sorting predicates.
3290 (defun gnus-group-sort-by-alphabet (info1 info2)
3291 "Sort alphabetically."
3292 (string< (gnus-info-group info1) (gnus-info-group info2)))
3294 (defun gnus-group-sort-by-real-name (info1 info2)
3295 "Sort alphabetically on real (unprefixed) names."
3296 (string< (gnus-group-real-name (gnus-info-group info1))
3297 (gnus-group-real-name (gnus-info-group info2))))
3299 (defun gnus-group-sort-by-unread (info1 info2)
3300 "Sort by number of unread articles."
3301 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3302 (n2 (gnus-group-unread (gnus-info-group info2))))
3303 (< (or (and (numberp n1) n1) 0)
3304 (or (and (numberp n2) n2) 0))))
3306 (defun gnus-group-sort-by-level (info1 info2)
3307 "Sort by level."
3308 (< (gnus-info-level info1) (gnus-info-level info2)))
3310 (defun gnus-group-sort-by-method (info1 info2)
3311 "Sort alphabetically by back end name."
3312 (string< (car (gnus-find-method-for-group
3313 (gnus-info-group info1) info1))
3314 (car (gnus-find-method-for-group
3315 (gnus-info-group info2) info2))))
3317 (defun gnus-group-sort-by-server (info1 info2)
3318 "Sort alphabetically by server name."
3319 (string< (gnus-method-to-full-server-name
3320 (gnus-find-method-for-group
3321 (gnus-info-group info1) info1))
3322 (gnus-method-to-full-server-name
3323 (gnus-find-method-for-group
3324 (gnus-info-group info2) info2))))
3326 (defun gnus-group-sort-by-score (info1 info2)
3327 "Sort by group score."
3328 (> (gnus-info-score info1) (gnus-info-score info2)))
3330 (defun gnus-group-sort-by-rank (info1 info2)
3331 "Sort by level and score."
3332 (let ((level1 (gnus-info-level info1))
3333 (level2 (gnus-info-level info2)))
3334 (or (< level1 level2)
3335 (and (= level1 level2)
3336 (> (gnus-info-score info1) (gnus-info-score info2))))))
3338 ;;; Clearing data
3340 (defun gnus-group-clear-data (&optional arg)
3341 "Clear all marks and read ranges from the current group.
3342 Obeys the process/prefix convention."
3343 (interactive "P")
3344 (gnus-group-iterate arg
3345 (lambda (group)
3346 (let (info)
3347 (gnus-info-clear-data (setq info (gnus-get-info group)))
3348 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3349 (when (gnus-group-goto-group group)
3350 (gnus-group-update-group-line))))))
3352 (defun gnus-group-clear-data-on-native-groups ()
3353 "Clear all marks and read ranges from all native groups."
3354 (interactive)
3355 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3356 (let ((alist (cdr gnus-newsrc-alist))
3357 info)
3358 (while (setq info (pop alist))
3359 (when (gnus-group-native-p (gnus-info-group info))
3360 (gnus-info-clear-data info)))
3361 (gnus-get-unread-articles)
3362 (gnus-dribble-touch)
3363 (when (gnus-y-or-n-p
3364 "Move the cache away to avoid problems in the future? ")
3365 (call-interactively 'gnus-cache-move-cache)))))
3367 (defun gnus-info-clear-data (info)
3368 "Clear all marks and read ranges from INFO."
3369 (let ((group (gnus-info-group info))
3370 action)
3371 (dolist (el (gnus-info-marks info))
3372 (push `(,(cdr el) add (,(car el))) action))
3373 (push `(,(gnus-info-read info) add (read)) action)
3374 (gnus-undo-register
3375 `(progn
3376 (gnus-request-set-mark ,group ',action)
3377 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3378 (gnus-info-set-read ',info ',(gnus-info-read info))
3379 (when (gnus-group-goto-group ,group)
3380 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3381 (gnus-group-update-group-line))))
3382 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3383 action))
3384 (gnus-request-set-mark group action)
3385 (gnus-info-set-read info nil)
3386 (when (gnus-info-marks info)
3387 (gnus-info-set-marks info nil))))
3389 ;; Group catching up.
3391 (defun gnus-group-catchup-current (&optional n all)
3392 "Mark all unread articles in the current newsgroup as read.
3393 If prefix argument N is numeric, the next N newsgroups will be
3394 caught up. If ALL is non-nil, marked articles will also be marked as
3395 read. Cross references (Xref: header) of articles are ignored.
3396 The number of newsgroups that this function was unable to catch
3397 up is returned."
3398 (interactive "P")
3399 (let ((groups (gnus-group-process-prefix n))
3400 (ret 0)
3401 group)
3402 (unless groups (error "No groups selected"))
3403 (if (not
3404 (or (not gnus-interactive-catchup) ;Without confirmation?
3405 gnus-expert-user
3406 (gnus-y-or-n-p
3407 (format
3408 (if all
3409 "Do you really want to mark all articles in %s as read? "
3410 "Mark all unread articles in %s as read? ")
3411 (if (= (length groups) 1)
3412 (gnus-group-decoded-name (car groups))
3413 (format "these %d groups" (length groups)))))))
3415 (while (setq group (pop groups))
3416 (gnus-group-remove-mark group)
3417 ;; Virtual groups have to be given special treatment.
3418 (let ((method (gnus-find-method-for-group group)))
3419 (when (eq 'nnvirtual (car method))
3420 (nnvirtual-catchup-group
3421 (gnus-group-real-name group) (nth 1 method) all)))
3422 (cond
3423 ((>= (gnus-group-level group) gnus-level-zombie)
3424 (gnus-message 2 "Dead groups can't be caught up"))
3425 ((prog1
3426 (gnus-group-goto-group group)
3427 (gnus-group-catchup group all))
3428 (gnus-group-update-group-line))
3430 (setq ret (1+ ret)))))
3431 (gnus-group-next-unread-group 1)
3432 ret)))
3434 (defun gnus-group-catchup-current-all (&optional n)
3435 "Mark all articles in current newsgroup as read.
3436 Cross references (Xref: header) of articles are ignored."
3437 (interactive "P")
3438 (gnus-group-catchup-current n 'all))
3440 (defun gnus-group-catchup (group &optional all)
3441 "Mark all articles in GROUP as read.
3442 If ALL is non-nil, all articles are marked as read.
3443 The return value is the number of articles that were marked as read,
3444 or nil if no action could be taken."
3445 (let* ((entry (gnus-group-entry group))
3446 (num (car entry))
3447 (marks (gnus-info-marks (nth 2 entry)))
3448 (unread (gnus-sequence-of-unread-articles group)))
3449 ;; Remove entries for this group.
3450 (nnmail-purge-split-history (gnus-group-real-name group))
3451 ;; Do the updating only if the newsgroup isn't killed.
3452 (if (not (numberp (car entry)))
3453 (gnus-message 1 "Can't catch up %s; non-active group" group)
3454 (gnus-update-read-articles group nil)
3455 (when all
3456 ;; Nix out the lists of marks and dormants.
3457 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3458 'del '(tick))
3459 (list (cdr (assq 'dormant marks))
3460 'del '(dormant))))
3461 (setq unread (gnus-range-add (gnus-range-add
3462 unread (cdr (assq 'dormant marks)))
3463 (cdr (assq 'tick marks))))
3464 (gnus-add-marked-articles group 'tick nil nil 'force)
3465 (gnus-add-marked-articles group 'dormant nil nil 'force))
3466 ;; Do auto-expirable marks if that's required.
3467 (when (gnus-group-auto-expirable-p group)
3468 (gnus-range-map
3469 (lambda (article)
3470 (gnus-add-marked-articles group 'expire (list article))
3471 (gnus-request-set-mark group (list (list (list article)
3472 'add '(expire)))))
3473 unread))
3474 (let ((gnus-newsgroup-name group))
3475 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3476 num)))
3478 (defun gnus-group-expire-articles (&optional n)
3479 "Expire all expirable articles in the current newsgroup.
3480 Uses the process/prefix convention."
3481 (interactive "P")
3482 (let ((groups (gnus-group-process-prefix n))
3483 group)
3484 (unless groups
3485 (error "No groups to expire"))
3486 (while (setq group (pop groups))
3487 (gnus-group-remove-mark group)
3488 (gnus-group-expire-articles-1 group)
3489 (gnus-dribble-touch)
3490 (gnus-group-position-point))))
3492 (defun gnus-group-expire-articles-1 (group)
3493 (when (gnus-check-backend-function 'request-expire-articles group)
3494 (gnus-message 6 "Expiring articles in %s..."
3495 (gnus-group-decoded-name group))
3496 (let* ((info (gnus-get-info group))
3497 (expirable (if (gnus-group-total-expirable-p group)
3498 (cons nil (gnus-list-of-read-articles group))
3499 (assq 'expire (gnus-info-marks info))))
3500 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3501 (nnmail-expiry-target
3502 (or (gnus-group-find-parameter group 'expiry-target)
3503 nnmail-expiry-target)))
3504 (when expirable
3505 (gnus-check-group group)
3506 (setcdr
3507 expirable
3508 (gnus-compress-sequence
3509 (if expiry-wait
3510 ;; We set the expiry variables to the group
3511 ;; parameter.
3512 (let ((nnmail-expiry-wait-function nil)
3513 (nnmail-expiry-wait expiry-wait))
3514 (gnus-request-expire-articles
3515 (gnus-uncompress-sequence (cdr expirable)) group))
3516 ;; Just expire using the normal expiry values.
3517 (gnus-request-expire-articles
3518 (gnus-uncompress-sequence (cdr expirable)) group))))
3519 (gnus-close-group group))
3520 (gnus-message 6 "Expiring articles in %s...done"
3521 (gnus-group-decoded-name group))
3522 ;; Return the list of un-expired articles.
3523 (cdr expirable))))
3525 (defun gnus-group-expire-all-groups ()
3526 "Expire all expirable articles in all newsgroups."
3527 (interactive)
3528 (save-excursion
3529 (gnus-message 5 "Expiring...")
3530 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3531 (cdr gnus-newsrc-alist))))
3532 (gnus-group-expire-articles nil)))
3533 (gnus-group-position-point)
3534 (gnus-message 5 "Expiring...done"))
3536 (defun gnus-group-set-current-level (n level)
3537 "Set the level of the next N groups to LEVEL."
3538 (interactive
3539 (list
3540 current-prefix-arg
3541 (progn
3542 (unless (gnus-group-process-prefix current-prefix-arg)
3543 (error "No group on the current line"))
3544 (string-to-number
3545 (let ((s (read-string
3546 (format "Level (default %s): "
3547 (or (gnus-group-group-level)
3548 gnus-level-default-subscribed)))))
3549 (if (string-match "^\\s-*$" s)
3550 (int-to-string (or (gnus-group-group-level)
3551 gnus-level-default-subscribed))
3552 s))))))
3553 (unless (and (>= level 1) (<= level gnus-level-killed))
3554 (error "Invalid level: %d" level))
3555 (dolist (group (gnus-group-process-prefix n))
3556 (gnus-group-remove-mark group)
3557 (gnus-message 6 "Changed level of %s from %d to %d"
3558 (gnus-group-decoded-name group)
3559 (or (gnus-group-group-level) gnus-level-killed)
3560 level)
3561 (gnus-group-change-level
3562 group level (or (gnus-group-group-level) gnus-level-killed))
3563 (gnus-group-update-group-line))
3564 (gnus-group-position-point))
3566 (defun gnus-group-unsubscribe (&optional n)
3567 "Unsubscribe the current group."
3568 (interactive "P")
3569 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3571 (defun gnus-group-subscribe (&optional n)
3572 "Subscribe the current group."
3573 (interactive "P")
3574 (gnus-group-unsubscribe-current-group n 'subscribe))
3576 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3577 "Toggle subscription of the current group.
3578 If given numerical prefix, toggle the N next groups."
3579 (interactive "P")
3580 (dolist (group (gnus-group-process-prefix n))
3581 (gnus-group-remove-mark group)
3582 (gnus-group-unsubscribe-group
3583 group
3584 (cond
3585 ((eq do-sub 'unsubscribe)
3586 gnus-level-default-unsubscribed)
3587 ((eq do-sub 'subscribe)
3588 gnus-level-default-subscribed)
3589 ((<= (gnus-group-group-level) gnus-level-subscribed)
3590 gnus-level-default-unsubscribed)
3592 gnus-level-default-subscribed))
3594 (gnus-group-update-group-line))
3595 (gnus-group-next-group 1))
3597 (defun gnus-group-unsubscribe-group (group &optional level silent)
3598 "Toggle subscription to GROUP.
3599 Killed newsgroups are subscribed. If SILENT, don't try to update the
3600 group line."
3601 (interactive (list (gnus-group-completing-read
3602 "Group: " nil nil (gnus-read-active-file-p))))
3603 (let ((newsrc (gnus-group-entry group)))
3604 (cond
3605 ((string-match "^[ \t]*$" group)
3606 (error "Empty group name"))
3607 (newsrc
3608 ;; Toggle subscription flag.
3609 (gnus-group-change-level
3610 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3611 gnus-level-subscribed)
3612 (1+ gnus-level-subscribed)
3613 gnus-level-default-subscribed)))
3614 (unless silent
3615 (gnus-group-update-group group)))
3616 ((and (stringp group)
3617 (or (not (gnus-read-active-file-p))
3618 (gnus-active group)))
3619 ;; Add new newsgroup.
3620 (gnus-group-change-level
3621 group
3622 (if level level gnus-level-default-subscribed)
3623 (or (and (member group gnus-zombie-list)
3624 gnus-level-zombie)
3625 gnus-level-killed)
3626 (when (gnus-group-group-name)
3627 (gnus-group-entry (gnus-group-group-name))))
3628 (unless silent
3629 (gnus-group-update-group group)))
3630 (t (error "No such newsgroup: %s" group)))
3631 (gnus-group-position-point)))
3633 (defun gnus-group-transpose-groups (n)
3634 "Move the current newsgroup up N places.
3635 If given a negative prefix, move down instead. The difference between
3636 N and the number of steps taken is returned."
3637 (interactive "p")
3638 (unless (gnus-group-group-name)
3639 (error "No group on current line"))
3640 (gnus-group-kill-group 1)
3641 (prog1
3642 (forward-line (- n))
3643 (gnus-group-yank-group)
3644 (gnus-group-position-point)))
3646 (defun gnus-group-kill-all-zombies (&optional dummy)
3647 "Kill all zombie newsgroups.
3648 The optional DUMMY should always be nil."
3649 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3650 (unless dummy
3651 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3652 (setq gnus-zombie-list nil)
3653 (gnus-dribble-touch)
3654 (gnus-group-list-groups)))
3656 (defun gnus-group-kill-region (begin end)
3657 "Kill newsgroups in current region (excluding current point).
3658 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3659 (interactive "r")
3660 (let ((lines
3661 ;; Count lines.
3662 (save-excursion
3663 (count-lines
3664 (progn
3665 (goto-char begin)
3666 (point-at-bol))
3667 (progn
3668 (goto-char end)
3669 (point-at-bol))))))
3670 (goto-char begin)
3671 (beginning-of-line) ;Important when LINES < 1
3672 (gnus-group-kill-group lines)))
3674 (defun gnus-group-kill-group (&optional n discard)
3675 "Kill the next N groups.
3676 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3677 However, only groups that were alive can be yanked; already killed
3678 groups or zombie groups can't be yanked.
3679 The return value is the name of the group that was killed, or a list
3680 of groups killed."
3681 (interactive "P")
3682 (let ((buffer-read-only nil)
3683 (groups (gnus-group-process-prefix n))
3684 group entry level out)
3685 (if (< (length groups) 10)
3686 ;; This is faster when there are few groups.
3687 (while groups
3688 (push (setq group (pop groups)) out)
3689 (gnus-group-remove-mark group)
3690 (setq level (gnus-group-group-level))
3691 (gnus-delete-line)
3692 (when (and (not discard)
3693 (setq entry (gnus-group-entry group)))
3694 (gnus-undo-register
3695 `(progn
3696 (gnus-group-goto-group ,(gnus-group-group-name))
3697 (gnus-group-yank-group)))
3698 (push (cons (car entry) (nth 2 entry))
3699 gnus-list-of-killed-groups))
3700 (gnus-group-change-level
3701 (if entry entry group) gnus-level-killed (if entry nil level))
3702 (message "Killed group %s" (gnus-group-decoded-name group)))
3703 ;; If there are lots and lots of groups to be killed, we use
3704 ;; this thing instead.
3705 (dolist (group (nreverse groups))
3706 (gnus-group-remove-mark group)
3707 (gnus-delete-line)
3708 (push group gnus-killed-list)
3709 (setq gnus-newsrc-alist
3710 (delq (assoc group gnus-newsrc-alist)
3711 gnus-newsrc-alist))
3712 (when gnus-group-change-level-function
3713 (funcall gnus-group-change-level-function
3714 group gnus-level-killed 3))
3715 (cond
3716 ((setq entry (gnus-group-entry group))
3717 (push (cons (car entry) (nth 2 entry))
3718 gnus-list-of-killed-groups)
3719 (setcdr (cdr entry) (cdddr entry)))
3720 ((member group gnus-zombie-list)
3721 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3722 ;; There may be more than one instance displayed.
3723 (while (gnus-group-goto-group group)
3724 (gnus-delete-line)))
3725 (gnus-make-hashtable-from-newsrc-alist))
3727 (gnus-group-position-point)
3728 (if (< (length out) 2) (car out) (nreverse out))))
3730 (defun gnus-group-yank-group (&optional arg)
3731 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3732 The numeric ARG specifies how many newsgroups are to be yanked. The
3733 name of the newsgroup yanked is returned, or (if several groups are
3734 yanked) a list of yanked groups is returned."
3735 (interactive "p")
3736 (setq arg (or arg 1))
3737 (let (info group prev out)
3738 (while (>= (decf arg) 0)
3739 (when (not (setq info (pop gnus-list-of-killed-groups)))
3740 (error "No more newsgroups to yank"))
3741 (push (setq group (nth 1 info)) out)
3742 ;; Find which newsgroup to insert this one before - search
3743 ;; backward until something suitable is found. If there are no
3744 ;; other newsgroups in this buffer, just make this newsgroup the
3745 ;; first newsgroup.
3746 (setq prev (gnus-group-group-name))
3747 (gnus-group-change-level
3748 info (gnus-info-level (cdr info)) gnus-level-killed
3749 (and prev (gnus-group-entry prev))
3751 (gnus-group-insert-group-line-info group)
3752 (gnus-undo-register
3753 `(when (gnus-group-goto-group ,group)
3754 (gnus-group-kill-group 1))))
3755 (forward-line -1)
3756 (gnus-group-position-point)
3757 (if (< (length out) 2) (car out) (nreverse out))))
3759 (defun gnus-group-kill-level (level)
3760 "Kill all groups that is on a certain LEVEL."
3761 (interactive "nKill all groups on level: ")
3762 (cond
3763 ((= level gnus-level-zombie)
3764 (setq gnus-killed-list
3765 (nconc gnus-zombie-list gnus-killed-list))
3766 (setq gnus-zombie-list nil))
3767 ((and (< level gnus-level-zombie)
3768 (> level 0)
3769 (or gnus-expert-user
3770 (gnus-yes-or-no-p
3771 (format
3772 "Do you really want to kill all groups on level %d? "
3773 level))))
3774 (let* ((prev gnus-newsrc-alist)
3775 (alist (cdr prev)))
3776 (while alist
3777 (if (= (gnus-info-level (car alist)) level)
3778 (progn
3779 (push (gnus-info-group (car alist)) gnus-killed-list)
3780 (setcdr prev (cdr alist)))
3781 (setq prev alist))
3782 (setq alist (cdr alist)))
3783 (gnus-make-hashtable-from-newsrc-alist)
3784 (gnus-group-list-groups)))
3786 (error "Can't kill; invalid level: %d" level))))
3788 (defun gnus-group-list-all-groups (&optional arg)
3789 "List all newsgroups with level ARG or lower.
3790 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3791 unsubscribed groups."
3792 (interactive "P")
3793 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3795 ;; Redefine this to list ALL killed groups if prefix arg used.
3796 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3797 (defun gnus-group-list-killed (&optional arg)
3798 "List all killed newsgroups in the group buffer.
3799 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3800 entail asking the server for the groups."
3801 (interactive "P")
3802 ;; Find all possible killed newsgroups if arg.
3803 (when arg
3804 (gnus-get-killed-groups))
3805 (if (not gnus-killed-list)
3806 (gnus-message 6 "No killed groups")
3807 (let (gnus-group-list-mode)
3808 (funcall gnus-group-prepare-function
3809 gnus-level-killed t gnus-level-killed))
3810 (goto-char (point-min)))
3811 (gnus-group-position-point))
3813 (defun gnus-group-list-zombies ()
3814 "List all zombie newsgroups in the group buffer."
3815 (interactive)
3816 (if (not gnus-zombie-list)
3817 (gnus-message 6 "No zombie groups")
3818 (let (gnus-group-list-mode)
3819 (funcall gnus-group-prepare-function
3820 gnus-level-zombie t gnus-level-zombie))
3821 (goto-char (point-min)))
3822 (gnus-group-position-point))
3824 (defun gnus-group-list-active ()
3825 "List all groups that are available from the server(s)."
3826 (interactive)
3827 ;; First we make sure that we have really read the active file.
3828 (unless (gnus-read-active-file-p)
3829 (let ((gnus-read-active-file t)
3830 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3831 (gnus-read-active-file)))
3832 ;; Find all groups and sort them.
3833 (let ((groups
3834 (sort
3835 (let (list)
3836 (mapatoms
3837 (lambda (sym)
3838 (and (boundp sym)
3839 (symbol-value sym)
3840 (push (symbol-name sym) list)))
3841 gnus-active-hashtb)
3842 list)
3843 'string<))
3844 (buffer-read-only nil)
3845 group)
3846 (erase-buffer)
3847 (while groups
3848 (setq group (pop groups))
3849 (gnus-add-text-properties
3850 (point) (prog1 (1+ (point))
3851 (insert " *: "
3852 (gnus-group-decoded-name group)
3853 "\n"))
3854 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3855 'gnus-unread t
3856 'gnus-level (inline (gnus-group-level group)))))
3857 (goto-char (point-min))))
3859 (defun gnus-activate-all-groups (level)
3860 "Activate absolutely all groups."
3861 (interactive (list gnus-level-unsubscribed))
3862 (let ((gnus-activate-level level)
3863 (gnus-activate-foreign-newsgroups level))
3864 (gnus-group-get-new-news)))
3866 (defun gnus-group-get-new-news (&optional arg)
3867 "Get newly arrived articles.
3868 If ARG is a number, it specifies which levels you are interested in
3869 re-scanning. If ARG is non-nil and not a number, this will force
3870 \"hard\" re-reading of the active files from all servers."
3871 (interactive "P")
3872 (require 'nnmail)
3873 (let ((gnus-inhibit-demon t)
3874 ;; Binding this variable will inhibit multiple fetchings
3875 ;; of the same mail source.
3876 (nnmail-fetched-sources (list t)))
3877 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3878 (gnus-run-hooks 'gnus-get-new-news-hook)
3880 ;; Read any slave files.
3881 (unless gnus-slave
3882 (gnus-master-read-slave-newsrc))
3884 ;; We might read in new NoCeM messages here.
3885 (when (and gnus-use-nocem
3886 (or (and (numberp gnus-use-nocem)
3887 (numberp arg)
3888 (>= arg gnus-use-nocem))
3889 (not arg)))
3890 (gnus-nocem-scan-groups))
3891 ;; If ARG is not a number, then we read the active file.
3892 (when (and arg (not (numberp arg)))
3893 (let ((gnus-read-active-file t))
3894 (gnus-read-active-file))
3895 (setq arg nil)
3897 ;; If the user wants it, we scan for new groups.
3898 (when (eq gnus-check-new-newsgroups 'always)
3899 (gnus-find-new-newsgroups)))
3901 (setq arg (gnus-group-default-level arg t))
3902 (if (and gnus-read-active-file (not arg))
3903 (progn
3904 (gnus-read-active-file)
3905 (gnus-get-unread-articles arg))
3906 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3907 (gnus-get-unread-articles arg)))
3908 (gnus-check-reasonable-setup)
3909 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3910 (gnus-group-list-groups (and (numberp arg)
3911 (max (car gnus-group-list-mode) arg)))))
3913 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3914 "Check for newly arrived news in the current group (and the N-1 next groups).
3915 The difference between N and the number of newsgroup checked is returned.
3916 If N is negative, this group and the N-1 previous groups will be checked.
3917 If DONT-SCAN is non-nil, scan non-activated groups as well."
3918 (interactive "P")
3919 (let* ((groups (gnus-group-process-prefix n))
3920 (ret (if (numberp n) (- n (length groups)) 0))
3921 (beg (unless n
3922 (point)))
3923 group method
3924 (gnus-inhibit-demon t)
3925 ;; Binding this variable will inhibit multiple fetchings
3926 ;; of the same mail source.
3927 (nnmail-fetched-sources (list t)))
3928 (gnus-run-hooks 'gnus-get-new-news-hook)
3929 (while (setq group (pop groups))
3930 (gnus-group-remove-mark group)
3931 ;; Bypass any previous denials from the server.
3932 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3933 (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
3934 (let ((info (gnus-get-info group))
3935 (active (gnus-active group)))
3936 (when info
3937 (gnus-request-update-info info method))
3938 (gnus-get-unread-articles-in-group info active)
3939 (unless (gnus-virtual-group-p group)
3940 (gnus-close-group group))
3941 (when gnus-agent
3942 (gnus-agent-save-group-info
3943 method (gnus-group-real-name group) active))
3944 (gnus-group-update-group group))
3945 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3946 'denied)
3947 (gnus-error 3 "Server denied access")
3948 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3949 (when beg
3950 (goto-char beg))
3951 (when gnus-goto-next-group-when-activating
3952 (gnus-group-next-unread-group 1 t))
3953 (gnus-summary-position-point)
3954 ret))
3956 (defun gnus-group-fetch-faq (group &optional faq-dir)
3957 "Fetch the FAQ for the current group.
3958 If given a prefix argument, prompt for the FAQ dir
3959 to use."
3960 (interactive
3961 (list
3962 (gnus-group-group-name)
3963 (when current-prefix-arg
3964 (completing-read
3965 "FAQ dir: " (and (listp gnus-group-faq-directory)
3966 (mapcar #'list
3967 gnus-group-faq-directory))))))
3968 (unless group
3969 (error "No group name given"))
3970 (let ((dirs (or faq-dir gnus-group-faq-directory))
3971 dir found file)
3972 (unless (listp dirs)
3973 (setq dirs (list dirs)))
3974 (while (and (not found)
3975 (setq dir (pop dirs)))
3976 (let ((name (gnus-group-real-name group)))
3977 (setq file (expand-file-name name dir)))
3978 (if (not (file-exists-p file))
3979 (gnus-message 1 "No such file: %s" file)
3980 (let ((enable-local-variables nil))
3981 (find-file file)
3982 (setq found t))))))
3984 (defun gnus-group-fetch-charter (group)
3985 "Fetch the charter for the current group.
3986 If given a prefix argument, prompt for a group."
3987 (interactive
3988 (list (or (when current-prefix-arg
3989 (gnus-group-completing-read "Group: "))
3990 (gnus-group-group-name)
3991 gnus-newsgroup-name)))
3992 (unless group
3993 (error "No group name given"))
3994 (require 'mm-url)
3995 (condition-case nil (require 'url-http) (error nil))
3996 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3997 url hierarchy)
3998 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3999 (setq hierarchy (match-string 1 name))
4000 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
4001 (if (fboundp 'url-http-file-exists-p)
4002 (url-http-file-exists-p (eval url))
4004 (browse-url (eval url))
4005 (setq url (concat "http://" hierarchy
4006 ".news-admin.org/charters/" name))
4007 (if (and (fboundp 'url-http-file-exists-p)
4008 (url-http-file-exists-p url))
4009 (browse-url url)
4010 (gnus-group-fetch-control group))))))
4012 (defun gnus-group-fetch-control (group)
4013 "Fetch the archived control messages for the current group.
4014 If given a prefix argument, prompt for a group."
4015 (interactive
4016 (list (or (when current-prefix-arg
4017 (gnus-group-completing-read "Group: "))
4018 (gnus-group-group-name)
4019 gnus-newsgroup-name)))
4020 (unless group
4021 (error "No group name given"))
4022 (let ((name (gnus-group-real-name group))
4023 hierarchy)
4024 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
4025 (setq hierarchy (match-string 1 name))
4026 (if gnus-group-fetch-control-use-browse-url
4027 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
4028 hierarchy "/" name ".gz"))
4029 (let ((enable-local-variables nil))
4030 (gnus-group-read-ephemeral-group
4031 group
4032 `(nndoc ,group (nndoc-address
4033 ,(find-file-noselect
4034 (concat "/ftp@ftp.isc.org:/usenet/control/"
4035 hierarchy "/" name ".gz")))
4036 (nndoc-article-type mbox)) t nil nil))))))
4038 (defun gnus-group-describe-group (force &optional group)
4039 "Display a description of the current newsgroup."
4040 (interactive (list current-prefix-arg (gnus-group-group-name)))
4041 (let* ((method (gnus-find-method-for-group group))
4042 (mname (gnus-group-prefixed-name "" method))
4043 desc)
4044 (when (and force
4045 gnus-description-hashtb)
4046 (gnus-sethash mname nil gnus-description-hashtb))
4047 (unless group
4048 (error "No group name given"))
4049 (when (or (and gnus-description-hashtb
4050 ;; We check whether this group's method has been
4051 ;; queried for a description file.
4052 (gnus-gethash mname gnus-description-hashtb))
4053 (setq desc (gnus-group-get-description group))
4054 (gnus-read-descriptions-file method))
4055 (gnus-message 1
4056 (or desc (gnus-gethash group gnus-description-hashtb)
4057 "No description available")))))
4059 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4060 (defun gnus-group-describe-all-groups (&optional force)
4061 "Pop up a buffer with descriptions of all newsgroups."
4062 (interactive "P")
4063 (when force
4064 (setq gnus-description-hashtb nil))
4065 (when (not (or gnus-description-hashtb
4066 (gnus-read-all-descriptions-files)))
4067 (error "Couldn't request descriptions file"))
4068 (let ((buffer-read-only nil)
4070 (erase-buffer)
4071 (mapatoms
4072 (lambda (group)
4073 (setq b (point))
4074 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
4075 (insert (format " *: %-20s %s\n"
4076 (gnus-group-name-decode
4077 (symbol-name group) charset)
4078 (gnus-group-name-decode
4079 (symbol-value group) charset))))
4080 (gnus-add-text-properties
4081 b (1+ b) (list 'gnus-group group
4082 'gnus-unread t 'gnus-marked nil
4083 'gnus-level (1+ gnus-level-subscribed))))
4084 gnus-description-hashtb)
4085 (goto-char (point-min))
4086 (gnus-group-position-point)))
4088 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
4089 (defun gnus-group-apropos (regexp &optional search-description)
4090 "List all newsgroups that have names that match a regexp."
4091 (interactive "sGnus apropos (regexp): ")
4092 (let ((prev "")
4093 (obuf (current-buffer))
4094 groups des)
4095 ;; Go through all newsgroups that are known to Gnus.
4096 (mapatoms
4097 (lambda (group)
4098 (and (symbol-name group)
4099 (string-match regexp (symbol-name group))
4100 (symbol-value group)
4101 (push (symbol-name group) groups)))
4102 gnus-active-hashtb)
4103 ;; Also go through all descriptions that are known to Gnus.
4104 (when search-description
4105 (mapatoms
4106 (lambda (group)
4107 (and (string-match regexp (symbol-value group))
4108 (push (symbol-name group) groups)))
4109 gnus-description-hashtb))
4110 (if (not groups)
4111 (gnus-message 3 "No groups matched \"%s\"." regexp)
4112 ;; Print out all the groups.
4113 (save-excursion
4114 (pop-to-buffer "*Gnus Help*")
4115 (buffer-disable-undo)
4116 (erase-buffer)
4117 (setq groups (sort groups 'string<))
4118 (while groups
4119 ;; Groups may be entered twice into the list of groups.
4120 (when (not (string= (car groups) prev))
4121 (setq prev (car groups))
4122 (let ((charset (gnus-group-name-charset nil prev)))
4123 (insert (gnus-group-name-decode prev charset) "\n")
4124 (when (and gnus-description-hashtb
4125 (setq des (gnus-gethash (car groups)
4126 gnus-description-hashtb)))
4127 (insert " " (gnus-group-name-decode des charset) "\n"))))
4128 (setq groups (cdr groups)))
4129 (goto-char (point-min))))
4130 (pop-to-buffer obuf)))
4132 (defun gnus-group-description-apropos (regexp)
4133 "List all newsgroups that have names or descriptions that match REGEXP."
4134 (interactive "sGnus description apropos (regexp): ")
4135 (when (not (or gnus-description-hashtb
4136 (gnus-read-all-descriptions-files)))
4137 (error "Couldn't request descriptions file"))
4138 (gnus-group-apropos regexp t))
4140 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4141 (defun gnus-group-list-matching (level regexp &optional all lowest)
4142 "List all groups with unread articles that match REGEXP.
4143 If the prefix LEVEL is non-nil, it should be a number that says which
4144 level to cut off listing groups.
4145 If ALL, also list groups with no unread articles.
4146 If LOWEST, don't list groups with level lower than LOWEST.
4148 This command may read the active file."
4149 (interactive "P\nsList newsgroups matching: ")
4150 ;; First make sure active file has been read.
4151 (when (and level
4152 (> (prefix-numeric-value level) gnus-level-killed))
4153 (gnus-get-killed-groups))
4154 (funcall gnus-group-prepare-function
4155 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
4156 (goto-char (point-min))
4157 (gnus-group-position-point))
4159 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4160 "List all groups that match REGEXP.
4161 If the prefix LEVEL is non-nil, it should be a number that says which
4162 level to cut off listing groups.
4163 If LOWEST, don't list groups with level lower than LOWEST."
4164 (interactive "P\nsList newsgroups matching: ")
4165 (when level
4166 (setq level (prefix-numeric-value level)))
4167 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4169 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4170 (defun gnus-group-save-newsrc (&optional force)
4171 "Save the Gnus startup files.
4172 If FORCE, force saving whether it is necessary or not."
4173 (interactive "P")
4174 (gnus-save-newsrc-file force))
4176 (defun gnus-group-restart (&optional arg)
4177 "Force Gnus to read the .newsrc file."
4178 (interactive "P")
4179 (when (gnus-yes-or-no-p
4180 (format "Are you sure you want to restart Gnus? "))
4181 (gnus-save-newsrc-file)
4182 (gnus-clear-system)
4183 (gnus)))
4185 (defun gnus-group-read-init-file ()
4186 "Read the Gnus elisp init file."
4187 (interactive)
4188 (gnus-read-init-file)
4189 (gnus-message 5 "Read %s" gnus-init-file))
4191 (defun gnus-group-check-bogus-groups (&optional silent)
4192 "Check bogus newsgroups.
4193 If given a prefix, don't ask for confirmation before removing a bogus
4194 group."
4195 (interactive "P")
4196 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4197 (gnus-group-list-groups))
4199 (defun gnus-group-find-new-groups (&optional arg)
4200 "Search for new groups and add them.
4201 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
4202 With 1 C-u, use the `ask-server' method to query the server for new
4203 groups.
4204 With 2 C-u's, use most complete method possible to query the server
4205 for new groups, and subscribe the new groups as zombies."
4206 (interactive "p")
4207 (gnus-find-new-newsgroups (or arg 1))
4208 (gnus-group-list-groups))
4210 (defun gnus-group-edit-global-kill (&optional article group)
4211 "Edit the global kill file.
4212 If GROUP, edit that local kill file instead."
4213 (interactive "P")
4214 (setq gnus-current-kill-article article)
4215 (gnus-kill-file-edit-file group)
4216 (gnus-message
4218 (substitute-command-keys
4219 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
4220 (if group "local" "global")))))
4222 (defun gnus-group-edit-local-kill (article group)
4223 "Edit a local kill file."
4224 (interactive (list nil (gnus-group-group-name)))
4225 (gnus-group-edit-global-kill article group))
4227 (defun gnus-group-force-update ()
4228 "Update `.newsrc' file."
4229 (interactive)
4230 (gnus-save-newsrc-file))
4232 (defvar gnus-backlog-articles)
4234 (defun gnus-group-suspend ()
4235 "Suspend the current Gnus session.
4236 In fact, cleanup buffers except for group mode buffer.
4237 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4238 (interactive)
4239 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4240 (gnus-offer-save-summaries)
4241 ;; Kill Gnus buffers except for group mode buffer.
4242 (let ((group-buf (get-buffer gnus-group-buffer)))
4243 (dolist (buf (gnus-buffers))
4244 (unless (or (eq buf group-buf)
4245 (eq buf gnus-dribble-buffer)
4246 (with-current-buffer buf
4247 (eq major-mode 'message-mode)))
4248 (gnus-kill-buffer buf)))
4249 (setq gnus-backlog-articles nil)
4250 (gnus-kill-gnus-frames)
4251 (when group-buf
4252 (bury-buffer group-buf)
4253 (delete-windows-on group-buf t))))
4255 (defun gnus-group-clear-dribble ()
4256 "Clear all information from the dribble buffer."
4257 (interactive)
4258 (gnus-dribble-clear)
4259 (gnus-message 7 "Cleared dribble buffer"))
4261 (defun gnus-group-exit ()
4262 "Quit reading news after updating .newsrc.eld and .newsrc.
4263 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4264 (interactive)
4265 (when
4266 (or noninteractive ;For gnus-batch-kill
4267 (not gnus-interactive-exit) ;Without confirmation
4268 gnus-expert-user
4269 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4270 (gnus-run-hooks 'gnus-exit-gnus-hook)
4271 ;; Offer to save data from non-quitted summary buffers.
4272 (gnus-offer-save-summaries)
4273 ;; Save the newsrc file(s).
4274 (gnus-save-newsrc-file)
4275 ;; Kill-em-all.
4276 (gnus-close-backends)
4277 ;; Reset everything.
4278 (gnus-clear-system)
4279 ;; Allow the user to do things after cleaning up.
4280 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4282 (defun gnus-group-quit ()
4283 "Quit reading news without updating .newsrc.eld or .newsrc.
4284 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4285 (interactive)
4286 (when (or noninteractive ;For gnus-batch-kill
4287 (zerop (buffer-size))
4288 (not (gnus-server-opened gnus-select-method))
4289 gnus-expert-user
4290 (not gnus-current-startup-file)
4291 (gnus-yes-or-no-p
4292 (format "Quit reading news without saving %s? "
4293 (file-name-nondirectory gnus-current-startup-file))))
4294 (gnus-run-hooks 'gnus-exit-gnus-hook)
4295 (gnus-configure-windows 'group t)
4296 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4297 (not (zerop (save-excursion
4298 (set-buffer gnus-dribble-buffer)
4299 (buffer-size)))))
4300 (gnus-dribble-enter
4301 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4302 (gnus-dribble-save)
4303 (gnus-close-backends)
4304 (gnus-clear-system)
4305 (gnus-kill-buffer gnus-group-buffer)
4306 ;; Allow the user to do things after cleaning up.
4307 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4309 (defun gnus-group-describe-briefly ()
4310 "Give a one line description of the group mode commands."
4311 (interactive)
4312 (gnus-message 7 (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-read-group]:Select \\[gnus-group-next-unread-group]:Forward \\[gnus-group-prev-unread-group]:Backward \\[gnus-group-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-group-describe-briefly]:This help")))
4314 (defun gnus-group-browse-foreign-server (method)
4315 "Browse a foreign news server.
4316 If called interactively, this function will ask for a select method
4317 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4318 If not, METHOD should be a list where the first element is the method
4319 and the second element is the address."
4320 (interactive
4321 (list (let ((how (completing-read
4322 "Which back end: "
4323 (append gnus-valid-select-methods gnus-server-alist)
4324 nil t (cons "nntp" 0) 'gnus-method-history)))
4325 ;; We either got a back end name or a virtual server name.
4326 ;; If the first, we also need an address.
4327 (if (assoc how gnus-valid-select-methods)
4328 (list (intern how)
4329 ;; Suggested by mapjph@bath.ac.uk.
4330 (completing-read
4331 "Address: "
4332 (mapcar 'list gnus-secondary-servers)))
4333 ;; We got a server name.
4334 how))))
4335 (gnus-browse-foreign-server method))
4337 (defun gnus-group-set-info (info &optional method-only-group part)
4338 (when (or info part)
4339 (let* ((entry (gnus-group-entry
4340 (or method-only-group (gnus-info-group info))))
4341 (part-info info)
4342 (info (if method-only-group (nth 2 entry) info))
4343 method)
4344 (when method-only-group
4345 (unless entry
4346 (error "Trying to change non-existent group %s" method-only-group))
4347 ;; We have received parts of the actual group info - either the
4348 ;; select method or the group parameters. We first check
4349 ;; whether we have to extend the info, and if so, do that.
4350 (let ((len (length info))
4351 (total (if (eq part 'method) 5 6)))
4352 (when (< len total)
4353 (setcdr (nthcdr (1- len) info)
4354 (make-list (- total len) nil)))
4355 ;; Then we enter the new info.
4356 (setcar (nthcdr (1- total) info) part-info)))
4357 (unless entry
4358 ;; This is a new group, so we just create it.
4359 (save-excursion
4360 (set-buffer gnus-group-buffer)
4361 (setq method (gnus-info-method info))
4362 (when (gnus-server-equal method "native")
4363 (setq method nil))
4364 (save-excursion
4365 (set-buffer gnus-group-buffer)
4366 (if method
4367 ;; It's a foreign group...
4368 (gnus-group-make-group
4369 (gnus-group-real-name (gnus-info-group info))
4370 (if (stringp method) method
4371 (prin1-to-string (car method)))
4372 (and (consp method)
4373 (nth 1 (gnus-info-method info)))
4374 nil t)
4375 ;; It's a native group.
4376 (gnus-group-make-group (gnus-info-group info) nil nil nil t)))
4377 (gnus-message 6 "Note: New group created")
4378 (setq entry
4379 (gnus-group-entry (gnus-group-prefixed-name
4380 (gnus-group-real-name (gnus-info-group info))
4381 (or (gnus-info-method info) gnus-select-method))))))
4382 ;; Whether it was a new group or not, we now have the entry, so we
4383 ;; can do the update.
4384 (if entry
4385 (progn
4386 (setcar (nthcdr 2 entry) info)
4387 (when (and (not (eq (car entry) t))
4388 (gnus-active (gnus-info-group info)))
4389 (setcar entry (length
4390 (gnus-list-of-unread-articles (car info))))))
4391 (error "No such group: %s" (gnus-info-group info))))))
4393 (defun gnus-group-set-method-info (group select-method)
4394 (gnus-group-set-info select-method group 'method))
4396 (defun gnus-group-set-params-info (group params)
4397 (gnus-group-set-info params group 'params))
4399 (defun gnus-add-marked-articles (group type articles &optional info force)
4400 ;; Add ARTICLES of TYPE to the info of GROUP.
4401 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4402 ;; add, but replace marked articles of TYPE with ARTICLES.
4403 (let ((info (or info (gnus-get-info group)))
4404 marked m)
4405 (or (not info)
4406 (and (not (setq marked (nthcdr 3 info)))
4407 (or (null articles)
4408 (setcdr (nthcdr 2 info)
4409 (list (list (cons type (gnus-compress-sequence
4410 articles t)))))))
4411 (and (not (setq m (assq type (car marked))))
4412 (or (null articles)
4413 (setcar marked
4414 (cons (cons type (gnus-compress-sequence articles t) )
4415 (car marked)))))
4416 (if force
4417 (if (null articles)
4418 (setcar (nthcdr 3 info)
4419 (gnus-delete-alist type (car marked)))
4420 (setcdr m (gnus-compress-sequence articles t)))
4421 (setcdr m (gnus-compress-sequence
4422 (sort (nconc (gnus-uncompress-range (cdr m))
4423 (copy-sequence articles)) '<) t))))))
4425 (defun gnus-add-mark (group mark article)
4426 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4427 (let ((buffer (gnus-summary-buffer-name group)))
4428 (if (gnus-buffer-live-p buffer)
4429 (save-excursion
4430 (set-buffer (get-buffer buffer))
4431 (gnus-summary-add-mark article mark))
4432 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4433 (list article)))))
4436 ;;; Group timestamps
4439 (defun gnus-group-set-timestamp ()
4440 "Change the timestamp of the current group to the current time.
4441 This function can be used in hooks like `gnus-select-group-hook'
4442 or `gnus-group-catchup-group-hook'."
4443 (when gnus-newsgroup-name
4444 (let ((time (current-time)))
4445 (setcdr (cdr time) nil)
4446 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4448 (defsubst gnus-group-timestamp (group)
4449 "Return the timestamp for GROUP."
4450 (gnus-group-get-parameter group 'timestamp t))
4452 (defun gnus-group-timestamp-delta (group)
4453 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4454 (let* ((time (or (gnus-group-timestamp group)
4455 (list 0 0)))
4456 (delta (subtract-time (current-time) time)))
4457 (+ (* (nth 0 delta) 65536.0)
4458 (nth 1 delta))))
4460 (defun gnus-group-timestamp-string (group)
4461 "Return a string of the timestamp for GROUP."
4462 (let ((time (gnus-group-timestamp group)))
4463 (if (not time)
4465 (gnus-time-iso8601 time))))
4467 (defun gnus-group-list-cached (level &optional lowest)
4468 "List all groups with cached articles.
4469 If the prefix LEVEL is non-nil, it should be a number that says which
4470 level to cut off listing groups.
4471 If LOWEST, don't list groups with level lower than LOWEST.
4473 This command may read the active file."
4474 (interactive "P")
4475 (when level
4476 (setq level (prefix-numeric-value level)))
4477 (when (or (not level) (>= level gnus-level-zombie))
4478 (gnus-cache-open))
4479 (funcall gnus-group-prepare-function
4480 (or level gnus-level-subscribed)
4481 #'(lambda (info)
4482 (let ((marks (gnus-info-marks info)))
4483 (assq 'cache marks)))
4484 lowest
4485 #'(lambda (group)
4486 (or (gnus-gethash group
4487 gnus-cache-active-hashtb)
4488 ;; Cache active file might use "."
4489 ;; instead of ":".
4490 (gnus-gethash
4491 (mapconcat 'identity
4492 (split-string group ":")
4493 ".")
4494 gnus-cache-active-hashtb))))
4495 (goto-char (point-min))
4496 (gnus-group-position-point))
4498 (defun gnus-group-list-dormant (level &optional lowest)
4499 "List all groups with dormant articles.
4500 If the prefix LEVEL is non-nil, it should be a number that says which
4501 level to cut off listing groups.
4502 If LOWEST, don't list groups with level lower than LOWEST.
4504 This command may read the active file."
4505 (interactive "P")
4506 (when level
4507 (setq level (prefix-numeric-value level)))
4508 (when (or (not level) (>= level gnus-level-zombie))
4509 (gnus-cache-open))
4510 (funcall gnus-group-prepare-function
4511 (or level gnus-level-subscribed)
4512 #'(lambda (info)
4513 (let ((marks (gnus-info-marks info)))
4514 (assq 'dormant marks)))
4515 lowest
4516 'ignore)
4517 (goto-char (point-min))
4518 (gnus-group-position-point))
4520 (defun gnus-group-listed-groups ()
4521 "Return a list of listed groups."
4522 (let (point groups)
4523 (goto-char (point-min))
4524 (while (setq point (text-property-not-all (point) (point-max)
4525 'gnus-group nil))
4526 (goto-char point)
4527 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4528 (forward-char 1))
4529 groups))
4531 (defun gnus-group-list-plus (&optional args)
4532 "List groups plus the current selection."
4533 (interactive "P")
4534 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4535 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4536 func)
4537 (push last-command-event unread-command-events)
4538 (if (featurep 'xemacs)
4539 (push (make-event 'key-press '(key ?A)) unread-command-events)
4540 (push ?A unread-command-events))
4541 (let (gnus-pick-mode keys)
4542 (setq keys (if (featurep 'xemacs)
4543 (events-to-keys (read-key-sequence nil))
4544 (read-key-sequence nil)))
4545 (setq func (lookup-key (current-local-map) keys)))
4546 (if (or (not func)
4547 (numberp func))
4548 (ding)
4549 (call-interactively func))))
4551 (defun gnus-group-list-flush (&optional args)
4552 "Flush groups from the current selection."
4553 (interactive "P")
4554 (let ((gnus-group-list-option 'flush))
4555 (gnus-group-list-plus args)))
4557 (defun gnus-group-list-limit (&optional args)
4558 "List groups limited within the current selection."
4559 (interactive "P")
4560 (let ((gnus-group-list-option 'limit))
4561 (gnus-group-list-plus args)))
4563 (defun gnus-group-mark-article-read (group article)
4564 "Mark ARTICLE read."
4565 (let ((buffer (gnus-summary-buffer-name group))
4566 (mark gnus-read-mark)
4567 active n)
4568 (if (get-buffer buffer)
4569 (with-current-buffer buffer
4570 (setq active gnus-newsgroup-active)
4571 (gnus-activate-group group)
4572 (when gnus-newsgroup-prepared
4573 (when (and gnus-newsgroup-auto-expire
4574 (memq mark gnus-auto-expirable-marks))
4575 (setq mark gnus-expirable-mark))
4576 (setq mark (gnus-request-update-mark
4577 group article mark))
4578 (gnus-mark-article-as-read article mark)
4579 (setq gnus-newsgroup-active (gnus-active group))
4580 (when active
4581 (setq n (1+ (cdr active)))
4582 (while (<= n (cdr gnus-newsgroup-active))
4583 (unless (eq n article)
4584 (push n gnus-newsgroup-unselected))
4585 (setq n (1+ n)))
4586 (setq gnus-newsgroup-unselected
4587 (nreverse gnus-newsgroup-unselected)))))
4588 (gnus-activate-group group)
4589 (gnus-group-make-articles-read group (list article))
4590 (when (gnus-group-auto-expirable-p group)
4591 (gnus-add-marked-articles
4592 group 'expire (list article))))))
4596 ;;; Group compaction. -- dvl
4599 (defun gnus-group-compact-group (group)
4600 "Compact the current group.
4601 Compaction means removing gaps between article numbers. Hence, this
4602 operation is only meaningful for back ends using one file per article
4603 \(e.g. nnml).
4605 Note: currently only implemented in nnml."
4606 (interactive (list (gnus-group-group-name)))
4607 (unless group
4608 (error "No group to compact"))
4609 (unless (gnus-check-backend-function 'request-compact-group group)
4610 (error "This back end does not support group compaction"))
4611 (let ((group-decoded (gnus-group-decoded-name group)))
4612 (gnus-message 6 "\
4613 Compacting group %s... (this may take a long time)"
4614 group-decoded)
4615 (prog1
4616 (if (not (gnus-request-compact-group group))
4617 (gnus-error 3 "Couldn't compact group %s" group-decoded)
4618 (gnus-message 6 "Compacting group %s...done" group-decoded)
4620 ;; Invalidate the "original article" buffer which might be out of date.
4621 ;; #### NOTE: Yes, this might be a bit rude, but since compaction
4622 ;; #### will not happen very often, I think this is acceptable.
4623 (let ((original (get-buffer gnus-original-article-buffer)))
4624 (and original (gnus-kill-buffer original)))
4625 ;; Update the group line to reflect new information (art number etc).
4626 (gnus-group-update-group-line))))
4628 (provide 'gnus-group)
4630 ;;; arch-tag: 2eb5440f-0bca-4091-814c-e37817536af6
4631 ;;; gnus-group.el ends here