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