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