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