1 ;;; gnus-group.el --- group mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
30 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
34 (defvar tool-bar-mode)
50 (let ((features (cons 'gnus-group features)))
52 (unless (boundp 'gnus-cache-active-hashtb)
53 (defvar gnus-cache-active-hashtb nil)))
55 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
56 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
58 (defcustom gnus-group-archive-directory
59 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
60 "*The address of the (ding) archives."
61 :group 'gnus-group-foreign
64 (defcustom gnus-group-recent-archive-directory
65 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
66 "*The address of the most recent (ding) articles."
67 :group 'gnus-group-foreign
70 (defcustom gnus-no-groups-message "No Gnus is good news"
71 "*Message displayed by Gnus when no groups are available."
75 (defcustom gnus-keep-same-level nil
76 "*Non-nil means that the next newsgroup after the current will be on the same level.
77 When you type, for instance, `n' after reading the last article in the
78 current newsgroup, you will go to the next newsgroup. If this variable
79 is nil, the next newsgroup will be the next from the group
81 If this variable is non-nil, Gnus will either put you in the
82 next newsgroup with the same level, or, if no such newsgroup is
83 available, the next newsgroup with the lowest possible level higher
84 than the current level.
85 If this variable is `best', Gnus will make the next newsgroup the one
87 :group 'gnus-group-levels
88 :type '(choice (const nil)
90 (sexp :tag "other" t)))
92 (defcustom gnus-group-goto-unread t
93 "*If non-nil, movement commands will go to the next unread and subscribed group."
94 :link '(custom-manual "(gnus)Group Maneuvering")
95 :group 'gnus-group-various
98 (defcustom gnus-goto-next-group-when-activating t
99 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
100 :link '(custom-manual "(gnus)Scanning New Messages")
101 :group 'gnus-group-various
104 (defcustom gnus-permanently-visible-groups nil
105 "*Regexp to match groups that should always be listed in the group buffer.
106 This means that they will still be listed even when there are no
107 unread articles in the groups.
109 If nil, no groups are permanently visible."
110 :group 'gnus-group-listing
111 :type '(choice regexp (const nil)))
113 (defcustom gnus-safe-html-newsgroups "\\`nnrss[+:]"
114 "Groups in which links in html articles are considered all safe.
115 The value may be a regexp matching those groups, a list of group names,
116 or nil. This overrides `mm-w3m-safe-url-regexp' (which see). This is
117 effective only when emacs-w3m renders html articles, i.e., in the case
118 `mm-text-html-renderer' is set to `w3m'."
120 :group 'gnus-group-various
121 :type '(choice regexp
122 (repeat :tag "List of group names" (string :tag "Group"))
125 (defcustom gnus-list-groups-with-ticked-articles t
126 "*If non-nil, list groups that have only ticked articles.
127 If nil, only list groups that have unread articles."
128 :group 'gnus-group-listing
131 (defcustom gnus-group-default-list-level gnus-level-subscribed
132 "*Default listing level.
133 Ignored if `gnus-group-use-permanent-levels' is non-nil."
134 :group 'gnus-group-listing
137 (defcustom gnus-group-list-inactive-groups t
138 "*If non-nil, inactive groups will be listed."
139 :group 'gnus-group-listing
140 :group 'gnus-group-levels
143 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
144 "*Function used for sorting the group buffer.
145 This function will be called with group info entries as the arguments
146 for the groups to be sorted. Pre-made functions include
147 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
148 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
149 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
150 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
152 This variable can also be a list of sorting functions. In that case,
153 the most significant sort function should be the last function in the
155 :group 'gnus-group-listing
156 :link '(custom-manual "(gnus)Sorting Groups")
157 :type '(repeat :value-to-internal (lambda (widget value)
158 (if (listp value) value (list value)))
159 :match (lambda (widget value)
161 (widget-editable-list-match widget value)))
162 (choice (function-item gnus-group-sort-by-alphabet)
163 (function-item gnus-group-sort-by-real-name)
164 (function-item gnus-group-sort-by-unread)
165 (function-item gnus-group-sort-by-level)
166 (function-item gnus-group-sort-by-score)
167 (function-item gnus-group-sort-by-method)
168 (function-item gnus-group-sort-by-server)
169 (function-item gnus-group-sort-by-rank)
170 (function :tag "other" nil))))
172 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)\n"
173 "*Format of group lines.
174 It works along the same lines as a normal formatting string,
175 with some simple extensions.
177 %M Only marked articles (character, \"*\" or \" \")
178 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
179 %L Level of subscribedness (integer)
180 %N Number of unread articles (integer)
181 %I Number of dormant articles (integer)
182 %i Number of ticked and dormant (integer)
183 %T Number of ticked articles (integer)
184 %R Number of read articles (integer)
185 %U Number of unseen articles (integer)
186 %t Estimated total number of articles (integer)
187 %y Number of unread, unticked articles (integer)
188 %G Group name (string)
189 %g Qualified group name (string)
190 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
191 %C Group comment (string)
192 %D Group description (string)
193 %s Select method (string)
194 %o Moderated group (char, \"m\")
195 %p Process mark (char)
196 %B Whether a summary buffer for the group is open (char, \"*\")
197 %O Moderated group (string, \"(m)\" or \"\")
198 %P Topic indentation (string)
199 %m Whether there is new(ish) mail in the group (char, \"%\")
200 %n Select from where (string)
201 %z A string that look like `<%s:%n>' if a foreign select method is used
202 %d The date the group was last entered.
203 %E Icon as defined by `gnus-group-icon-list'.
204 %F The disk space used by the articles fetched by both the cache and agent.
205 %u User defined specifier. The next character in the format string should
206 be a letter. Gnus will call the function gnus-user-format-function-X,
207 where X is the letter following %u. The function will be passed a
208 single dummy parameter as argument. The function should return a
209 string, which will be inserted into the buffer just like information
210 from any other group specifier.
212 Note that this format specification is not always respected. For
213 reasons of efficiency, when listing killed groups, this specification
214 is ignored altogether. If the spec is changed considerably, your
215 output may end up looking strange when listing both alive and killed
218 If you use %o or %O, reading the active file will be slower and quite
219 a bit of extra memory will be used. %D and %F will also worsen
220 performance. Also note that if you change the format specification to
221 include any of these specs, you must probably re-start Gnus to see
224 General format specifiers can also be used.
225 See Info node `(gnus)Formatting Variables'."
226 :link '(custom-manual "(gnus)Formatting Variables")
227 :group 'gnus-group-visual
230 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
231 "*The format specification for the group mode line.
232 It works along the same lines as a normal formatting string,
233 with some simple extensions:
235 %S The native news server.
236 %M The native select method.
237 %: \":\" if %S isn't \"\"."
238 :group 'gnus-group-visual
241 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
242 (when (featurep 'xemacs)
243 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
244 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
246 (defcustom gnus-group-menu-hook nil
247 "Hook run after the creation of the group mode menu."
248 :group 'gnus-group-various
251 (defcustom gnus-group-catchup-group-hook nil
252 "Hook run when catching up a group from the group buffer."
253 :group 'gnus-group-various
254 :link '(custom-manual "(gnus)Group Data")
257 (defcustom gnus-group-update-group-hook nil
258 "Hook called when updating group lines."
259 :group 'gnus-group-visual
262 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
263 "*A function that is called to generate the group buffer.
264 The function is called with three arguments: The first is a number;
265 all group with a level less or equal to that number should be listed,
266 if the second is non-nil, empty groups should also be displayed. If
267 the third is non-nil, it is a number. No groups with a level lower
268 than this number should be displayed.
270 The only current function implemented is `gnus-group-prepare-flat'."
271 :group 'gnus-group-listing
274 (defcustom gnus-group-prepare-hook nil
275 "Hook called after the group buffer has been generated.
276 If you want to modify the group buffer, you can use this hook."
277 :group 'gnus-group-listing
280 (defcustom gnus-suspend-gnus-hook nil
281 "Hook called when suspending (not exiting) Gnus."
285 (defcustom gnus-exit-gnus-hook nil
286 "Hook called when exiting Gnus."
290 (defcustom gnus-after-exiting-gnus-hook nil
291 "Hook called after exiting Gnus."
295 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
296 "Hook called when a group line is changed.
297 The hook will not be called if `gnus-visual' is nil.
299 The default function `gnus-group-highlight-line' will highlight
300 the line according to the `gnus-group-highlight' variable."
301 :group 'gnus-group-visual
304 (defcustom gnus-useful-groups
305 '(("(ding) mailing list mirrored at gmane.org"
306 "gmane.emacs.gnus.general"
308 (nntp-address "news.gmane.org")))
311 (nntp "news.gnus.org"
312 (nntp-address "news.gnus.org")))
313 ("Local Gnus help group"
316 (nndoc-article-type mbox)
317 (eval `(nndoc-address
318 ,(let ((file (nnheader-find-etc-directory
321 (error "Couldn't find doc group"))
323 "*Alist of useful group-server pairs."
324 :group 'gnus-group-listing
325 :type '(repeat (list (string :tag "Description")
327 (sexp :tag "Method"))))
329 (defcustom gnus-group-highlight
331 ((and mailp (= unread 0) (eq level 1)) .
332 gnus-group-mail-1-empty)
333 ((and mailp (eq level 1)) .
335 ((and mailp (= unread 0) (eq level 2)) .
336 gnus-group-mail-2-empty)
337 ((and mailp (eq level 2)) .
339 ((and mailp (= unread 0) (eq level 3)) .
340 gnus-group-mail-3-empty)
341 ((and mailp (eq level 3)) .
343 ((and mailp (= unread 0)) .
344 gnus-group-mail-low-empty)
348 ((and (= unread 0) (eq level 1)) .
349 gnus-group-news-1-empty)
350 ((and (eq level 1)) .
352 ((and (= unread 0) (eq level 2)) .
353 gnus-group-news-2-empty)
354 ((and (eq level 2)) .
356 ((and (= unread 0) (eq level 3)) .
357 gnus-group-news-3-empty)
358 ((and (eq level 3)) .
360 ((and (= unread 0) (eq level 4)) .
361 gnus-group-news-4-empty)
362 ((and (eq level 4)) .
364 ((and (= unread 0) (eq level 5)) .
365 gnus-group-news-5-empty)
366 ((and (eq level 5)) .
368 ((and (= unread 0) (eq level 6)) .
369 gnus-group-news-6-empty)
370 ((and (eq level 6)) .
372 ((and (= unread 0)) .
373 gnus-group-news-low-empty)
375 gnus-group-news-low))
376 "*Controls the highlighting of group buffer lines.
378 Below is a list of `Form'/`Face' pairs. When deciding how a a
379 particular group line should be displayed, each form is
380 evaluated. The content of the face field after the first true form is
381 used. You can change how those group lines are displayed by
382 editing the face field.
384 It is also possible to change and add form fields, but currently that
385 requires an understanding of Lisp expressions. Hopefully this will
386 change in a future release. For now, you can use the following
387 variables in the Lisp expression:
389 group: The name of the group.
390 unread: The number of unread articles in the group.
391 method: The select method used.
392 mailp: Whether it's a mail group or not.
393 level: The level of the group.
394 score: The score of the group.
395 ticked: The number of ticked articles."
396 :group 'gnus-group-visual
397 :type '(repeat (cons (sexp :tag "Form") face)))
398 (put 'gnus-group-highlight 'risky-local-variable t)
400 (defcustom gnus-new-mail-mark ?%
401 "Mark used for groups with new mail."
402 :group 'gnus-group-visual
405 (defgroup gnus-group-icons nil
406 "Add Icons to your group buffer."
407 :group 'gnus-group-visual)
409 (defcustom gnus-group-icon-list
411 "*Controls the insertion of icons into group buffer lines.
413 Below is a list of `Form'/`File' pairs. When deciding how a
414 particular group line should be displayed, each form is evaluated.
415 The icon from the file field after the first true form is used. You
416 can change how those group lines are displayed by editing the file
417 field. The File will either be found in the
418 `gnus-group-glyph-directory' or by designating absolute name of the
421 It is also possible to change and add form fields, but currently that
422 requires an understanding of Lisp expressions. Hopefully this will
423 change in a future release. For now, you can use the following
424 variables in the Lisp expression:
426 group: The name of the group.
427 unread: The number of unread articles in the group.
428 method: The select method used.
429 mailp: Whether it's a mail group or not.
430 level: The level of the group.
431 score: The score of the group.
432 ticked: The number of ticked articles."
433 :group 'gnus-group-icons
434 :type '(repeat (cons (sexp :tag "Form") file)))
435 (put 'gnus-group-icon-list 'risky-local-variable t)
437 (defcustom gnus-group-name-charset-method-alist nil
438 "Alist of method and the charset for group names.
441 (((nntp \"news.com.cn\") . cn-gb-2312))"
444 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
446 (defcustom gnus-group-name-charset-group-alist
447 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
448 (mm-coding-system-p 'utf-8))
451 "Alist of group regexp and the charset for group names.
454 ((\"\\.com\\.cn:\" . cn-gb-2312))"
456 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
458 (defcustom gnus-group-jump-to-group-prompt nil
459 "Default prompt for `gnus-group-jump-to-group'.
461 If non-nil, the value should be a string or an alist. If it is a string,
462 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
463 nnml:\" in the minibuffer prompt.
465 If it is an alist, it must consist of \(NUMBER . PROMPT\) pairs, for example:
466 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
467 used when no prefix argument is given to `gnus-group-jump-to-group'."
469 :group 'gnus-group-various
470 :type '(choice (string :tag "Prompt string")
471 (const :tag "Empty" nil)
472 (repeat (cons (integer :tag "Argument")
473 (string :tag "Prompt string")))))
475 (defvar gnus-group-listing-limit 1000
476 "*A limit of the number of groups when listing.
477 If the number of groups is larger than the limit, list them in a
480 ;;; Internal variables
482 (defvar gnus-group-is-exiting-p nil)
483 (defvar gnus-group-is-exiting-without-update-p nil)
484 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
485 "Function for sorting the group buffer.")
487 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
488 "Function for sorting the selected groups in the group buffer.")
490 (defvar gnus-group-indentation-function nil)
491 (defvar gnus-goto-missing-group-function nil)
492 (defvar gnus-group-update-group-function nil)
493 (defvar gnus-group-goto-next-group-function nil
494 "Function to override finding the next group after listing groups.")
496 (defvar gnus-group-edit-buffer nil)
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) "*" )
506 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
507 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
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)
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
524 (?G gnus-tmp-qualified-group ?s)
525 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
526 gnus-tmp-decoded-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 ,(if (featurep 'xemacs)
536 '(symbol-name gnus-tmp-news-method)
537 'gnus-tmp-news-method)
539 (?P gnus-group-indentation ?s)
540 (?E gnus-tmp-group-icon ?s)
541 (?B gnus-tmp-summary-live ?c)
542 (?z gnus-tmp-news-method-string ?s)
543 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
544 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
545 (?u gnus-tmp-user-defined ?s)
546 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
549 (defvar gnus-group-mode-line-format-alist
550 `((?S gnus-tmp-news-server ?s)
551 (?M gnus-tmp-news-method ?s)
552 (?u gnus-tmp-user-defined ?s)
553 (?: gnus-tmp-colon ?s)))
555 (defvar gnus-topic-topology nil
556 "The complete topic hierarchy.")
558 (defvar gnus-topic-alist nil
559 "The complete topic-group alist.")
561 (defvar gnus-group-marked nil)
563 (defvar gnus-group-list-mode nil)
566 (defvar gnus-group-icon-cache nil)
568 (defvar gnus-group-listed-groups nil)
569 (defvar gnus-group-list-option nil)
575 (put 'gnus-group-mode 'mode-class 'special)
577 (gnus-define-keys gnus-group-mode-map
578 " " gnus-group-read-group
579 "=" gnus-group-select-group
580 "\r" gnus-group-select-group
581 "\M-\r" gnus-group-quick-select-group
582 "\M- " gnus-group-visible-select-group
583 [(meta control return)] gnus-group-select-group-ephemerally
584 "j" gnus-group-jump-to-group
585 "n" gnus-group-next-unread-group
586 "p" gnus-group-prev-unread-group
587 "\177" gnus-group-prev-unread-group
588 [delete] gnus-group-prev-unread-group
589 [backspace] gnus-group-prev-unread-group
590 "N" gnus-group-next-group
591 "P" gnus-group-prev-group
592 "\M-n" gnus-group-next-unread-group-same-level
593 "\M-p" gnus-group-prev-unread-group-same-level
594 "," gnus-group-best-unread-group
595 "." gnus-group-first-unread-group
596 "u" gnus-group-unsubscribe-current-group
597 "U" gnus-group-unsubscribe-group
598 "c" gnus-group-catchup-current
599 "C" gnus-group-catchup-current-all
600 "\M-c" gnus-group-clear-data
601 "l" gnus-group-list-groups
602 "L" gnus-group-list-all-groups
605 "g" gnus-group-get-new-news
606 "\M-g" gnus-group-get-new-news-this-group
607 "R" gnus-group-restart
608 "r" gnus-group-read-init-file
609 "B" gnus-group-browse-foreign-server
610 "b" gnus-group-check-bogus-groups
611 "F" gnus-group-find-new-groups
612 "\C-c\C-d" gnus-group-describe-group
613 "\M-d" gnus-group-describe-all-groups
614 "\C-c\C-a" gnus-group-apropos
615 "\C-c\M-\C-a" gnus-group-description-apropos
616 "a" gnus-group-post-news
617 "\ek" gnus-group-edit-local-kill
618 "\eK" gnus-group-edit-global-kill
619 "\C-k" gnus-group-kill-group
620 "\C-y" gnus-group-yank-group
621 "\C-w" gnus-group-kill-region
622 "\C-x\C-t" gnus-group-transpose-groups
623 "\C-c\C-l" gnus-group-list-killed
624 "\C-c\C-x" gnus-group-expire-articles
625 "\C-c\M-\C-x" gnus-group-expire-all-groups
627 "s" gnus-group-save-newsrc
628 "z" gnus-group-suspend
631 "?" gnus-group-describe-briefly
632 "\C-c\C-i" gnus-info-find-node
633 "\M-e" gnus-group-edit-group-method
634 "^" gnus-group-enter-server-mode
635 gnus-mouse-2 gnus-mouse-pick-group
636 [follow-link] mouse-face
637 "<" beginning-of-buffer
640 "\C-c\C-s" gnus-group-sort-groups
642 "\C-c\M-g" gnus-activate-all-groups
643 "\M-&" gnus-group-universal-argument
644 "#" gnus-group-mark-group
645 "\M-#" gnus-group-unmark-group)
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 "a" gnus-group-make-archive-group
664 "l" gnus-group-nnimap-edit-acl
665 "m" gnus-group-make-group
666 "E" gnus-group-edit-group
667 "e" gnus-group-edit-group-method
668 "p" gnus-group-edit-group-parameters
669 "v" gnus-group-add-to-virtual
670 "V" gnus-group-make-empty-virtual
671 "D" gnus-group-enter-directory
672 "f" gnus-group-make-doc-group
673 "w" gnus-group-make-web-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)
717 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
718 "k" gnus-group-list-limit
719 "z" gnus-group-list-limit
720 "s" gnus-group-list-limit
721 "u" gnus-group-list-limit
722 "A" gnus-group-list-limit
723 "m" gnus-group-list-limit
724 "M" gnus-group-list-limit
725 "l" gnus-group-list-limit
726 "c" gnus-group-list-limit
727 "?" gnus-group-list-limit)
729 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
730 "k" gnus-group-list-flush
731 "z" gnus-group-list-flush
732 "s" gnus-group-list-flush
733 "u" gnus-group-list-flush
734 "A" gnus-group-list-flush
735 "m" gnus-group-list-flush
736 "M" gnus-group-list-flush
737 "l" gnus-group-list-flush
738 "c" gnus-group-list-flush
739 "?" gnus-group-list-flush)
741 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
742 "k" gnus-group-list-plus
743 "z" gnus-group-list-plus
744 "s" gnus-group-list-plus
745 "u" gnus-group-list-plus
746 "A" gnus-group-list-plus
747 "m" gnus-group-list-plus
748 "M" gnus-group-list-plus
749 "l" gnus-group-list-plus
750 "c" gnus-group-list-plus
751 "?" gnus-group-list-plus)
753 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
754 "f" gnus-score-flush-cache
755 "e" gnus-score-edit-all-score)
757 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
758 "c" gnus-group-fetch-charter
759 "C" gnus-group-fetch-control
760 "d" gnus-group-describe-group
761 "f" gnus-group-fetch-faq
764 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
765 "l" gnus-group-set-current-level
766 "t" gnus-group-unsubscribe-current-group
767 "s" gnus-group-unsubscribe-group
768 "k" gnus-group-kill-group
769 "y" gnus-group-yank-group
770 "w" gnus-group-kill-region
771 "\C-k" gnus-group-kill-level
772 "z" gnus-group-kill-all-zombies)
774 (defun gnus-topic-mode-p ()
775 "Return non-nil in `gnus-topic-mode'."
776 (and (boundp 'gnus-topic-mode)
777 (symbol-value 'gnus-topic-mode)))
779 (defun gnus-group-make-menu-bar ()
780 (gnus-turn-off-edit-menu 'group)
781 (unless (boundp 'gnus-group-reading-menu)
784 gnus-group-reading-menu gnus-group-mode-map ""
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 ,@(if (featurep 'xemacs) nil
802 '(:help "Mark unread articles in the current group as read"))]
803 ["Catch up " gnus-topic-catchup-articles
804 :included (gnus-topic-mode-p)
805 ,@(if (featurep 'xemacs) nil
806 '(:help "Mark unread articles in the current group or topic as read"))]
807 ["Catch up all articles" gnus-group-catchup-current-all
808 (gnus-group-group-name)]
809 ["Check for new articles" gnus-group-get-new-news-this-group
810 :included (not (gnus-topic-mode-p))
811 :active (gnus-group-group-name)
812 ,@(if (featurep 'xemacs) nil
813 '(:help "Check for new messages in current group"))]
814 ["Check for new articles " gnus-topic-get-new-news-this-topic
815 :included (gnus-topic-mode-p)
816 ,@(if (featurep 'xemacs) nil
817 '(:help "Check for new messages in current group or topic"))]
818 ["Toggle subscription" gnus-group-unsubscribe-current-group
819 (gnus-group-group-name)]
820 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
821 ,@(if (featurep 'xemacs) nil
822 '(:help "Kill (remove) current group"))]
823 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
824 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
825 ,@(if (featurep 'xemacs) nil
826 '(:help "Display description of the current group"))]
827 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
828 ["Fetch charter" gnus-group-fetch-charter
829 :active (gnus-group-group-name)
830 ,@(if (featurep 'xemacs) nil
831 '(:help "Display the charter of the current group"))]
832 ["Fetch control message" gnus-group-fetch-control
833 :active (gnus-group-group-name)
834 ,@(if (featurep 'xemacs) nil
835 '(:help "Display the archived control message for the current group"))]
836 ;; Actually one should check, if any of the marked groups gives t for
837 ;; (gnus-check-backend-function 'request-expire-articles ...)
838 ["Expire articles" gnus-group-expire-articles
839 :included (not (gnus-topic-mode-p))
840 :active (or (and (gnus-group-group-name)
841 (gnus-check-backend-function
842 'request-expire-articles
843 (gnus-group-group-name))) gnus-group-marked)]
844 ["Expire articles " gnus-topic-expire-articles
845 :included (gnus-topic-mode-p)]
846 ["Set group level..." gnus-group-set-current-level
847 (gnus-group-group-name)]
848 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
849 ["Customize" gnus-group-customize (gnus-group-group-name)]
850 ["Compact" gnus-group-compact-group
851 :active (gnus-group-group-name)]
853 ["Parameters" gnus-group-edit-group-parameters
854 :included (not (gnus-topic-mode-p))
855 :active (gnus-group-group-name)]
856 ["Parameters " gnus-topic-edit-parameters
857 :included (gnus-topic-mode-p)]
858 ["Select method" gnus-group-edit-group-method
859 (gnus-group-group-name)]
860 ["Info" gnus-group-edit-group (gnus-group-group-name)]
861 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
862 ["Global kill file" gnus-group-edit-global-kill t])))
865 gnus-group-group-menu gnus-group-mode-map ""
868 ["List unread subscribed groups" gnus-group-list-groups t]
869 ["List (un)subscribed groups" gnus-group-list-all-groups t]
870 ["List killed groups" gnus-group-list-killed gnus-killed-list]
871 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
872 ["List level..." gnus-group-list-level t]
873 ["Describe all groups" gnus-group-describe-all-groups t]
874 ["Group apropos..." gnus-group-apropos t]
875 ["Group and description apropos..." gnus-group-description-apropos t]
876 ["List groups matching..." gnus-group-list-matching t]
877 ["List all groups matching..." gnus-group-list-all-matching t]
878 ["List active file" gnus-group-list-active t]
879 ["List groups with cached" gnus-group-list-cached t]
880 ["List groups with dormant" gnus-group-list-dormant t])
882 ["Default sort" gnus-group-sort-groups t]
883 ["Sort by method" gnus-group-sort-groups-by-method t]
884 ["Sort by rank" gnus-group-sort-groups-by-rank t]
885 ["Sort by score" gnus-group-sort-groups-by-score t]
886 ["Sort by level" gnus-group-sort-groups-by-level t]
887 ["Sort by unread" gnus-group-sort-groups-by-unread t]
888 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
889 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
890 ("Sort process/prefixed"
891 ["Default sort" gnus-group-sort-selected-groups
892 (not (gnus-topic-mode-p))]
893 ["Sort by method" gnus-group-sort-selected-groups-by-method
894 (not (gnus-topic-mode-p))]
895 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
896 (not (gnus-topic-mode-p))]
897 ["Sort by score" gnus-group-sort-selected-groups-by-score
898 (not (gnus-topic-mode-p))]
899 ["Sort by level" gnus-group-sort-selected-groups-by-level
900 (not (gnus-topic-mode-p))]
901 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
902 (not (gnus-topic-mode-p))]
903 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
904 (not (gnus-topic-mode-p))]
905 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
906 (not (gnus-topic-mode-p))])
908 ["Mark group" gnus-group-mark-group
909 (and (gnus-group-group-name)
910 (not (memq (gnus-group-group-name) gnus-group-marked)))]
911 ["Unmark group" gnus-group-unmark-group
912 (and (gnus-group-group-name)
913 (memq (gnus-group-group-name) gnus-group-marked))]
914 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
915 ["Mark regexp..." gnus-group-mark-regexp t]
916 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
917 ["Mark buffer" gnus-group-mark-buffer t]
918 ["Execute command" gnus-group-universal-argument
919 (or gnus-group-marked (gnus-group-group-name))])
921 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
922 ["Kill all newsgroups in region" gnus-group-kill-region
923 :active (gnus-mark-active-p)]
924 ["Kill all zombie groups" gnus-group-kill-all-zombies
926 ["Kill all groups on level..." gnus-group-kill-level t])
928 ["Make a foreign group..." gnus-group-make-group t]
929 ["Add a directory group..." gnus-group-make-directory-group t]
930 ["Add the help group" gnus-group-make-help-group t]
931 ["Add the archive group" gnus-group-make-archive-group t]
932 ["Make a doc group..." gnus-group-make-doc-group t]
933 ["Make a web group..." gnus-group-make-web-group t]
934 ["Make a virtual group..." gnus-group-make-empty-virtual t]
935 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
936 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
937 ["Make an RSS group..." gnus-group-make-rss-group t]
938 ["Rename group..." gnus-group-rename-group
939 (gnus-check-backend-function
940 'request-rename-group (gnus-group-group-name))]
941 ["Delete group" gnus-group-delete-group
942 (gnus-check-backend-function
943 'request-delete-group (gnus-group-group-name))])
945 ["Next" gnus-group-next-group t]
946 ["Previous" gnus-group-prev-group t]
947 ["Next unread" gnus-group-next-unread-group t]
948 ["Previous unread" gnus-group-prev-unread-group t]
949 ["Next unread same level" gnus-group-next-unread-group-same-level t]
950 ["Previous unread same level"
951 gnus-group-prev-unread-group-same-level t]
952 ["Jump to group..." gnus-group-jump-to-group t]
953 ["First unread group" gnus-group-first-unread-group t]
954 ["Best unread group" gnus-group-best-unread-group t])
956 ["Generate" gnus-sieve-generate t]
957 ["Generate and update" gnus-sieve-update t])
958 ["Delete bogus groups" gnus-group-check-bogus-groups t]
959 ["Find new newsgroups" gnus-group-find-new-groups t]
960 ["Transpose" gnus-group-transpose-groups
961 (gnus-group-group-name)]
962 ["Read a directory as a group..." gnus-group-enter-directory t]))
965 gnus-group-misc-menu gnus-group-mode-map ""
967 ["Send a mail" gnus-group-mail t]
968 ["Send a message (mail or news)" gnus-group-post-news t]
969 ["Create a local message" gnus-group-news t]
970 ["Check for new news" gnus-group-get-new-news
971 ,@(if (featurep 'xemacs) '(t)
972 '(:help "Get newly arrived articles"))
974 ["Send queued messages" gnus-delay-send-queue
975 ,@(if (featurep 'xemacs) '(t)
976 '(:help "Send all messages that are scheduled to be sent now"))
978 ["Activate all groups" gnus-activate-all-groups t]
979 ["Restart Gnus" gnus-group-restart t]
980 ["Read init file" gnus-group-read-init-file t]
981 ["Browse foreign server..." gnus-group-browse-foreign-server t]
982 ["Enter server buffer" gnus-group-enter-server-mode t]
983 ["Expire all expirable articles" gnus-group-expire-all-groups t]
984 ["Gnus version" gnus-version t]
985 ["Save .newsrc files" gnus-group-save-newsrc t]
986 ["Suspend Gnus" gnus-group-suspend t]
987 ["Clear dribble buffer" gnus-group-clear-dribble t]
988 ["Read manual" gnus-info-find-node t]
989 ["Flush score cache" gnus-score-flush-cache t]
990 ["Toggle topics" gnus-topic-mode t]
991 ["Send a bug report" gnus-bug t]
992 ["Exit from Gnus" gnus-group-exit
993 ,@(if (featurep 'xemacs) '(t)
994 '(:help "Quit reading news"))]
995 ["Exit without saving" gnus-group-quit t]))
997 (gnus-run-hooks 'gnus-group-menu-hook)))
1000 (defvar gnus-group-tool-bar-map nil)
1002 (defun gnus-group-tool-bar-update (&optional symbol value)
1003 "Update group buffer toolbar.
1004 Setter function for custom variables."
1006 (set-default symbol value))
1007 ;; (setq-default gnus-group-tool-bar-map nil)
1008 ;; (use-local-map gnus-group-mode-map)
1009 (when (gnus-alive-p)
1010 (with-current-buffer gnus-group-buffer
1011 (gnus-group-make-tool-bar t))))
1013 (defcustom gnus-group-tool-bar (if (eq gmm-tool-bar-style 'gnome)
1014 'gnus-group-tool-bar-gnome
1015 'gnus-group-tool-bar-retro)
1016 "Specifies the Gnus group tool bar.
1018 It can be either a list or a symbol refering to a list. See
1019 `gmm-tool-bar-from-list' for the format of the list. The
1020 default key map is `gnus-group-mode-map'.
1022 Pre-defined symbols include `gnus-group-tool-bar-gnome' and
1023 `gnus-group-tool-bar-retro'."
1024 :type '(choice (const :tag "GNOME style" gnus-group-tool-bar-gnome)
1025 (const :tag "Retro look" gnus-group-tool-bar-retro)
1026 (repeat :tag "User defined list" gmm-tool-bar-item)
1028 :version "23.1" ;; No Gnus
1029 :initialize 'custom-initialize-default
1030 :set 'gnus-group-tool-bar-update
1033 (defcustom gnus-group-tool-bar-gnome
1034 '((gnus-group-post-news "mail/compose")
1035 ;; Some useful agent icons? I don't use the agent so agent users should
1036 ;; suggest useful commands:
1037 (gnus-agent-toggle-plugged "disconnect" t
1038 :help "Gnus is currently unplugged. Click to work online."
1039 :visible (and gnus-agent (not gnus-plugged)))
1040 (gnus-agent-toggle-plugged "connect" t
1041 :help "Gnus is currently plugged. Click to work offline."
1042 :visible (and gnus-agent gnus-plugged))
1043 ;; FIXME: gnus-agent-toggle-plugged (in gnus-agent-group-make-menu-bar)
1044 ;; should have a better help text.
1045 (gnus-group-send-queue "mail/outbox" t
1046 :visible (and gnus-agent gnus-plugged)
1047 :help "Send articles from the queue group")
1048 (gnus-group-get-new-news "mail/inbox" nil
1049 :visible (or (not gnus-agent)
1051 ;; FIXME: gnus-*-read-group should have a better help text.
1052 (gnus-topic-read-group "open" nil
1053 :visible (and (boundp 'gnus-topic-mode)
1055 (gnus-group-read-group "open" nil
1056 :visible (not (and (boundp 'gnus-topic-mode)
1058 ;; (gnus-group-find-new-groups "???" nil)
1059 (gnus-group-save-newsrc "save")
1060 (gnus-group-describe-group "describe")
1061 (gnus-group-unsubscribe-current-group "gnus/toggle-subscription")
1062 (gnus-group-prev-unread-group "left-arrow")
1063 (gnus-group-next-unread-group "right-arrow")
1064 (gnus-group-exit "exit")
1065 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
1066 (gnus-info-find-node "help"))
1067 "List of functions for the group tool bar (GNOME style).
1069 See `gmm-tool-bar-from-list' for the format of the list."
1070 :type '(repeat gmm-tool-bar-item)
1071 :version "23.1" ;; No Gnus
1072 :initialize 'custom-initialize-default
1073 :set 'gnus-group-tool-bar-update
1076 (defcustom gnus-group-tool-bar-retro
1077 '((gnus-group-get-new-news "gnus/get-news")
1078 (gnus-group-get-new-news-this-group "gnus/gnntg")
1079 (gnus-group-catchup-current "gnus/catchup")
1080 (gnus-group-describe-group "gnus/describe-group")
1081 (gnus-group-subscribe "gnus/subscribe" t
1082 :help "Subscribe to the current group")
1083 (gnus-group-unsubscribe "gnus/unsubscribe" t
1084 :help "Unsubscribe from the current group")
1085 (gnus-group-exit "gnus/exit-gnus" gnus-group-mode-map))
1086 "List of functions for the group tool bar (retro look).
1088 See `gmm-tool-bar-from-list' for the format of the list."
1089 :type '(repeat gmm-tool-bar-item)
1090 :version "23.1" ;; No Gnus
1091 :initialize 'custom-initialize-default
1092 :set 'gnus-group-tool-bar-update
1095 (defcustom gnus-group-tool-bar-zap-list t
1096 "List of icon items from the global tool bar.
1097 These items are not displayed in the Gnus group mode tool bar.
1099 See `gmm-tool-bar-from-list' for the format of the list."
1100 :type 'gmm-tool-bar-zap-list
1101 :version "23.1" ;; No Gnus
1102 :initialize 'custom-initialize-default
1103 :set 'gnus-group-tool-bar-update
1106 (defvar image-load-path)
1107 (defvar tool-bar-map)
1109 (defun gnus-group-make-tool-bar (&optional force)
1110 "Make a group mode tool bar from `gnus-group-tool-bar'.
1111 When FORCE, rebuild the tool bar."
1112 (when (and (not (featurep 'xemacs))
1113 (boundp 'tool-bar-mode)
1115 ;; The Gnus 5.10.6 code checked (default-value 'tool-bar-mode).
1117 (or (not gnus-group-tool-bar-map) force))
1119 (gmm-image-load-path-for-library "gnus"
1120 "gnus/toggle-subscription.xpm"
1122 (image-load-path (cons (car load-path)
1123 (when (boundp 'image-load-path)
1125 (map (gmm-tool-bar-from-list gnus-group-tool-bar
1126 gnus-group-tool-bar-zap-list
1127 'gnus-group-mode-map)))
1129 (set (make-local-variable 'tool-bar-map) map))))
1130 gnus-group-tool-bar-map)
1132 (defun gnus-group-mode ()
1133 "Major mode for reading news.
1135 All normal editing commands are switched off.
1136 \\<gnus-group-mode-map>
1137 The group buffer lists (some of) the groups available. For instance,
1138 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1139 lists all zombie groups.
1141 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1142 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1144 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1146 The following commands are available:
1148 \\{gnus-group-mode-map}"
1150 (kill-all-local-variables)
1151 (when (gnus-visual-p 'group-menu 'menu)
1152 (gnus-group-make-menu-bar)
1153 (gnus-group-make-tool-bar))
1154 (gnus-simplify-mode-line)
1155 (setq major-mode 'gnus-group-mode)
1156 (setq mode-name "Group")
1157 (gnus-group-set-mode-line)
1158 (setq mode-line-process nil)
1159 (use-local-map gnus-group-mode-map)
1160 (buffer-disable-undo)
1161 (setq truncate-lines t)
1162 (setq buffer-read-only t
1163 show-trailing-whitespace nil)
1164 (gnus-set-default-directory)
1165 (gnus-update-format-specifications nil 'group 'group-mode)
1166 (gnus-update-group-mark-positions)
1171 (gnus-run-mode-hooks 'gnus-group-mode-hook))
1173 (defun gnus-update-group-mark-positions ()
1175 (let ((gnus-process-mark ?\200)
1176 (gnus-group-update-hook nil)
1177 (gnus-group-marked '("dummy.group"))
1178 (gnus-active-hashtb (make-vector 10 0))
1180 (gnus-set-active "dummy.group" '(0 . 0))
1181 (gnus-set-work-buffer)
1182 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1183 (goto-char (point-min))
1184 (setq gnus-group-mark-positions
1185 (list (cons 'process (and (search-forward
1186 (mm-string-to-multibyte "\200") nil t)
1187 (- (point) (point-min) 1))))))))
1189 (defun gnus-mouse-pick-group (e)
1190 "Enter the group under the mouse pointer."
1193 (gnus-group-read-group nil))
1195 ;; Look at LEVEL and find out what the level is really supposed to be.
1196 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1197 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1198 (defun gnus-group-default-level (&optional level number-or-nil)
1200 (gnus-group-use-permanent-levels
1201 (or (setq gnus-group-use-permanent-levels
1202 (or level (if (numberp gnus-group-use-permanent-levels)
1203 gnus-group-use-permanent-levels
1204 (or gnus-group-default-list-level
1205 gnus-level-subscribed))))
1206 gnus-group-default-list-level gnus-level-subscribed))
1210 (or level gnus-group-default-list-level gnus-level-subscribed))))
1212 (defun gnus-group-setup-buffer ()
1213 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1214 (unless (eq major-mode 'gnus-group-mode)
1217 (gnus-carpal-setup-buffer 'group))))
1219 (defun gnus-group-name-charset (method group)
1221 (setq method (gnus-find-method-for-group group)))
1222 (let ((item (or (assoc method gnus-group-name-charset-method-alist)
1224 (assoc (list (car method) (cadr method))
1225 gnus-group-name-charset-method-alist))))
1226 (alist gnus-group-name-charset-group-alist)
1230 (while (setq item (pop alist))
1231 (if (string-match (car item) group)
1233 result (cdr item))))
1236 (defun gnus-group-name-decode (string charset)
1237 ;; Fixme: Don't decode in unibyte mode.
1238 (if (and string charset (featurep 'mule))
1239 (mm-decode-coding-string string charset)
1242 (defun gnus-group-decoded-name (string)
1243 (let ((charset (gnus-group-name-charset nil string)))
1244 (gnus-group-name-decode string charset)))
1246 (defun gnus-group-list-groups (&optional level unread lowest)
1247 "List newsgroups with level LEVEL or lower that have unread articles.
1248 Default is all subscribed groups.
1249 If argument UNREAD is non-nil, groups with no unread articles are also
1252 Also see the `gnus-group-use-permanent-levels' variable."
1254 (list (if current-prefix-arg
1255 (prefix-numeric-value current-prefix-arg)
1257 (gnus-group-default-level nil t)
1258 gnus-group-default-list-level
1259 gnus-level-subscribed))))
1261 (setq level (car gnus-group-list-mode)
1262 unread (cdr gnus-group-list-mode)))
1263 (setq level (gnus-group-default-level level))
1264 (gnus-group-setup-buffer)
1265 (gnus-update-format-specifications nil 'group 'group-mode)
1266 (let ((case-fold-search nil)
1267 (props (text-properties-at (point-at-bol)))
1268 (empty (= (point-min) (point-max)))
1269 (group (gnus-group-group-name))
1271 (set-buffer gnus-group-buffer)
1272 (setq number (funcall gnus-group-prepare-function level unread lowest))
1273 (when (or (and (numberp number)
1275 (zerop (buffer-size)))
1276 ;; No groups in the buffer.
1277 (gnus-message 5 "%s" gnus-no-groups-message))
1278 ;; We have some groups displayed.
1279 (goto-char (point-max))
1280 (when (or (not gnus-group-goto-next-group-function)
1281 (not (funcall gnus-group-goto-next-group-function
1285 (goto-char (point-min)))
1287 ;; Go to the first group with unread articles.
1288 (gnus-group-search-forward t))
1290 ;; Find the right group to put point on. If the current group
1291 ;; has disappeared in the new listing, try to find the next
1292 ;; one. If no next one can be found, just leave point at the
1293 ;; first newsgroup in the buffer.
1294 (when (not (gnus-goto-char
1296 (point-min) (point-max)
1297 'gnus-group (gnus-intern-safe
1298 group gnus-active-hashtb))))
1299 (let ((newsrc (cdddr (gnus-group-entry group))))
1301 (not (gnus-goto-char
1303 (point-min) (point-max) 'gnus-group
1305 (caar newsrc) gnus-active-hashtb)))))
1306 (setq newsrc (cdr newsrc)))
1308 (goto-char (point-max))
1309 (forward-line -1)))))))
1310 ;; Adjust cursor point.
1311 (gnus-group-position-point)))
1313 (defun gnus-group-list-level (level &optional all)
1314 "List groups on LEVEL.
1315 If ALL (the prefix), also list groups that have no unread articles."
1316 (interactive "nList groups on level: \nP")
1317 (gnus-group-list-groups level all level))
1319 (defun gnus-group-prepare-logic (group test)
1320 (or (and gnus-group-listed-groups
1321 (null gnus-group-list-option)
1322 (member group gnus-group-listed-groups))
1324 ((null gnus-group-listed-groups) test)
1325 ((null gnus-group-list-option) test)
1326 (t (and (member group gnus-group-listed-groups)
1327 (if (eq gnus-group-list-option 'flush)
1331 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1332 "List all newsgroups with unread articles of level LEVEL or lower.
1333 If PREDICATE is a function, list groups that the function returns non-nil;
1334 if it is t, list groups that have no unread articles.
1335 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1336 If REGEXP is a function, list dead groups that the function returns non-nil;
1337 if it is a string, only list groups matching REGEXP."
1338 (set-buffer gnus-group-buffer)
1339 (let ((buffer-read-only nil)
1340 (newsrc (cdr gnus-newsrc-alist))
1341 (lowest (or lowest 1))
1342 (not-in-list (and gnus-group-listed-groups
1343 (copy-sequence gnus-group-listed-groups)))
1344 info clevel unread group params)
1346 (when (or (< lowest gnus-level-zombie)
1347 gnus-group-listed-groups)
1348 ;; List living groups.
1350 (setq info (car newsrc)
1351 group (gnus-info-group info)
1352 params (gnus-info-params info)
1354 unread (gnus-group-unread group))
1356 (setq not-in-list (delete group not-in-list)))
1357 (when (gnus-group-prepare-logic
1359 (and (or unread ; This group might be unchecked
1360 predicate) ; Check if this group should be listed
1361 (or (not (stringp regexp))
1362 (string-match regexp group))
1363 (<= (setq clevel (gnus-info-level info)) level)
1366 ((functionp predicate)
1367 (funcall predicate info))
1368 (predicate t) ; We list all groups?
1371 (if (eq unread t) ; Unactivated?
1372 gnus-group-list-inactive-groups
1373 ; We list unactivated
1374 (and (numberp unread) (> unread 0)))
1375 ; We list groups with unread articles
1376 (and gnus-list-groups-with-ticked-articles
1377 (cdr (assq 'tick (gnus-info-marks info))))
1378 ; And groups with tickeds
1379 ;; Check for permanent visibility.
1380 (and gnus-permanently-visible-groups
1381 (string-match gnus-permanently-visible-groups
1383 (memq 'visible params)
1384 (cdr (assq 'visible params)))))))
1385 (gnus-group-insert-group-line
1386 group (gnus-info-level info)
1387 (gnus-info-marks info) unread (gnus-info-method info)))))
1389 ;; List dead groups.
1390 (when (or gnus-group-listed-groups
1391 (and (>= level gnus-level-zombie)
1392 (<= lowest gnus-level-zombie)))
1393 (gnus-group-prepare-flat-list-dead
1394 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1395 gnus-level-zombie ?Z
1398 (dolist (group gnus-zombie-list)
1399 (setq not-in-list (delete group not-in-list))))
1400 (when (or gnus-group-listed-groups
1401 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1402 (gnus-group-prepare-flat-list-dead
1405 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1406 gnus-level-killed ?K regexp))
1408 (gnus-group-set-mode-line)
1409 (setq gnus-group-list-mode (cons level predicate))
1410 (gnus-run-hooks 'gnus-group-prepare-hook)
1413 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1414 ;; List zombies and killed lists somewhat faster, which was
1415 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1416 ;; this by ignoring the group format specification altogether.
1418 (if (> (length groups) gnus-group-listing-limit)
1420 (setq group (pop groups))
1421 (when (gnus-group-prepare-logic
1424 (and (stringp regexp) (string-match regexp group))
1425 (and (functionp regexp) (funcall regexp group))))
1426 (gnus-add-text-properties
1427 (point) (prog1 (1+ (point))
1428 (insert " " mark " *: "
1429 (gnus-group-decoded-name group)
1431 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1433 'gnus-level level))))
1435 (setq group (pop groups))
1436 (when (gnus-group-prepare-logic
1439 (and (stringp regexp) (string-match regexp group))
1440 (and (functionp regexp) (funcall regexp group))))
1441 (gnus-group-insert-group-line
1443 (let ((active (gnus-active group)))
1445 (if (zerop (cdr active))
1447 (- (1+ (cdr active)) (car active)))
1449 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1451 (defun gnus-group-update-group-line ()
1452 "Update the current line in the group buffer."
1453 (let* ((buffer-read-only nil)
1454 (group (gnus-group-group-name))
1455 (entry (and group (gnus-group-entry group)))
1456 gnus-group-indentation)
1459 (not (gnus-ephemeral-group-p group))
1461 (concat "(gnus-group-set-info '"
1462 (gnus-prin1-to-string (nth 2 entry))
1464 (setq gnus-group-indentation (gnus-group-group-indentation))
1466 (gnus-group-insert-group-line-info group)
1468 (gnus-group-position-point))))
1470 (defun gnus-group-insert-group-line-info (group)
1471 "Insert GROUP on the current line."
1472 (let ((entry (gnus-group-entry group))
1473 (gnus-group-indentation (gnus-group-group-indentation))
1477 ;; (Un)subscribed group.
1478 (setq info (nth 2 entry))
1479 (gnus-group-insert-group-line
1480 group (gnus-info-level info) (gnus-info-marks info)
1481 (or (car entry) t) (gnus-info-method info)))
1482 ;; This group is dead.
1483 (gnus-group-insert-group-line
1485 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1487 (if (setq active (gnus-active group))
1488 (if (zerop (cdr active))
1490 (- (1+ (cdr active)) (car active)))
1492 (gnus-method-simplify (gnus-find-method-for-group group))))))
1494 (defun gnus-number-of-unseen-articles-in-group (group)
1495 (let* ((info (nth 2 (gnus-group-entry group)))
1496 (marked (gnus-info-marks info))
1497 (seen (cdr (assq 'seen marked)))
1498 (active (gnus-active group)))
1501 (length (gnus-uncompress-range
1502 (gnus-range-difference
1503 (gnus-range-difference (list active) (gnus-info-read info))
1506 ;; Moving through the Group buffer (in topic mode) e.g. with C-n doesn't
1507 ;; update the state (enabled/disabled) of the icon `gnus-group-describe-group'
1508 ;; automatically. After `C-l' the state is correct. See the following report
1510 ;; <http://thread.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de>:
1511 ;; From: Reiner Steib
1512 ;; Subject: tool bar icons not updated according to :active condition
1513 ;; Newsgroups: gmane.emacs.devel
1514 ;; Date: Mon, 23 Jan 2006 19:59:13 +0100
1515 ;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
1517 (defcustom gnus-group-update-tool-bar
1518 (and (not (featurep 'xemacs))
1519 (boundp 'tool-bar-mode)
1521 ;; Using `redraw-frame' (see `gnus-tool-bar-update') in Emacs 21 might
1522 ;; be confusing, so maybe we shouldn't call it by default.
1523 (fboundp 'force-window-update))
1524 "Force updating the group buffer tool bar."
1527 :initialize 'custom-initialize-default
1528 :set (lambda (symbol value)
1529 (set-default symbol value)
1530 (when (gnus-alive-p)
1531 (with-current-buffer gnus-group-buffer
1532 ;; FIXME: Is there a better way to redraw the group buffer?
1533 (gnus-group-get-new-news 0))))
1536 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1537 gnus-tmp-marked number
1539 "Insert a group line in the group buffer."
1540 (let* ((gnus-tmp-method
1541 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1542 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1544 (gnus-tmp-active (gnus-active gnus-tmp-group))
1545 (gnus-tmp-number-total
1547 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1549 (gnus-tmp-number-of-unread
1550 (if (numberp number) (int-to-string (max 0 number))
1552 (gnus-tmp-number-of-read
1553 (if (numberp number)
1554 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1556 (gnus-tmp-subscribed
1557 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1558 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1559 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1561 (gnus-tmp-qualified-group
1562 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1563 group-name-charset))
1565 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1567 (gnus-tmp-newsgroup-description
1568 (if gnus-description-hashtb
1569 (or (gnus-group-name-decode
1570 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1571 group-name-charset) "")
1574 (if (and gnus-moderated-hashtb
1575 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1577 (gnus-tmp-moderated-string
1578 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1579 (gnus-tmp-group-icon (gnus-group-get-icon gnus-tmp-qualified-group))
1580 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1581 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1582 (gnus-tmp-news-method-string
1584 (format "(%s:%s)" (car gnus-tmp-method)
1585 (cadr gnus-tmp-method)) ""))
1586 (gnus-tmp-marked-mark
1587 (if (and (numberp number)
1589 (cdr (assq 'tick gnus-tmp-marked)))
1591 (gnus-tmp-summary-live
1592 (if (and (not gnus-group-is-exiting-p)
1593 (gnus-buffer-live-p (gnus-summary-buffer-name
1596 (gnus-tmp-process-marked
1597 (if (member gnus-tmp-group gnus-group-marked)
1598 gnus-process-mark ? ))
1599 (buffer-read-only nil)
1601 header gnus-tmp-header) ; passed as parameter to user-funcs.
1604 (gnus-add-text-properties
1608 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1609 gnus-tmp-group group-name-charset)))
1610 (eval gnus-group-line-format-spec)))
1611 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1612 gnus-unread ,(if (numberp number)
1613 (string-to-number gnus-tmp-number-of-unread)
1615 gnus-marked ,gnus-tmp-marked-mark
1616 gnus-indentation ,gnus-group-indentation
1617 gnus-level ,gnus-tmp-level))
1619 (when gnus-group-update-tool-bar
1620 (gnus-put-text-property beg end 'point-entered
1621 'gnus-tool-bar-update)
1622 (gnus-put-text-property beg end 'point-left
1623 'gnus-tool-bar-update))
1625 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1626 (gnus-run-hooks 'gnus-group-update-hook))
1628 ;; Allow XEmacs to remove front-sticky text properties.
1629 (gnus-group-remove-excess-properties)))
1631 (defun gnus-group-highlight-line ()
1632 "Highlight the current line according to `gnus-group-highlight'."
1633 (let* ((list gnus-group-highlight)
1635 (end (point-at-eol))
1636 ;; now find out where the line starts and leave point there.
1637 (beg (progn (beginning-of-line) (point)))
1638 (group (gnus-group-group-name))
1639 (entry (gnus-group-entry group))
1640 (unread (if (numberp (car entry)) (car entry) 0))
1641 (active (gnus-active group))
1642 (total (if active (1+ (- (cdr active) (car active))) 0))
1643 (info (nth 2 entry))
1644 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1645 (marked (gnus-info-marks info))
1646 (mailp (apply 'append
1649 (memq x (assoc (symbol-name
1650 (car (or method gnus-select-method)))
1651 gnus-valid-select-methods)))
1652 '(mail post-mail))))
1653 (level (or (gnus-info-level info) gnus-level-killed))
1654 (score (or (gnus-info-score info) 0))
1655 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1656 (group-age (gnus-group-timestamp-delta group))
1657 (inhibit-read-only t))
1658 ;; FIXME: http://thread.gmane.org/gmane.emacs.gnus.general/65451/focus=65465
1659 ;; ======================================================================
1660 ;; From: Richard Stallman
1661 ;; Subject: Re: Rewriting gnus-group-highlight-line (was: [...])
1662 ;; Cc: ding@gnus.org
1663 ;; Date: Sat, 27 Oct 2007 19:41:20 -0400
1664 ;; Message-ID: <E1IlvHM-0006TS-7t@fencepost.gnu.org>
1667 ;; The kludge is that the alist elements contain expressions that refer
1668 ;; to local variables with short names. Perhaps write your own tiny
1669 ;; evaluator that handles just `and', `or', and numeric comparisons
1670 ;; and just a few specific variables.
1671 ;; ======================================================================
1673 ;; Similar for other evaluated variables. Grep for risky-local-variable
1674 ;; to find them! -- rsteib
1676 ;; Eval the cars of the lists until we find a match.
1678 (not (eval (caar list))))
1679 (setq list (cdr list)))
1680 (let ((face (cdar list)))
1681 (unless (eq face (get-text-property beg 'face))
1682 (gnus-put-text-property-excluding-characters-with-faces
1684 (setq face (if (boundp face) (symbol-value face) face)))
1685 (gnus-extent-start-open beg)))
1688 (defun gnus-group-get-icon (group)
1689 "Return an icon for GROUP according to `gnus-group-icon-list'."
1690 (if gnus-group-icon-list
1691 (let* ((entry (gnus-group-entry group))
1692 (unread (if (numberp (car entry)) (car entry) 0))
1693 (active (gnus-active group))
1694 (total (if active (1+ (- (cdr active) (car active))) 0))
1695 (info (nth 2 entry))
1696 (method (gnus-server-get-method group (gnus-info-method info)))
1697 (marked (gnus-info-marks info))
1698 (mailp (memq 'mail (assoc (symbol-name
1699 (car (or method gnus-select-method)))
1700 gnus-valid-select-methods)))
1701 (level (or (gnus-info-level info) gnus-level-killed))
1702 (score (or (gnus-info-score info) 0))
1703 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1704 (group-age (gnus-group-timestamp-delta group))
1705 (inhibit-read-only t)
1706 (list gnus-group-icon-list))
1708 (not (eval (caar list))))
1709 (setq list (cdr list)))
1714 (gnus-create-image (expand-file-name (cdar list)))
1719 (defun gnus-group-update-group (group &optional visible-only)
1720 "Update all lines where GROUP appear.
1721 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1723 (with-current-buffer gnus-group-buffer
1725 ;; The buffer may be narrowed.
1728 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1730 found buffer-read-only)
1731 ;; Enter the current status into the dribble buffer.
1732 (let ((entry (gnus-group-entry group)))
1734 (not (gnus-ephemeral-group-p group)))
1736 (concat "(gnus-group-set-info '"
1737 (gnus-prin1-to-string (nth 2 entry))
1739 ;; Find all group instances. If topics are in use, each group
1740 ;; may be listed in more than once.
1741 (while (setq loc (text-property-any
1742 loc (point-max) 'gnus-group ident))
1745 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1747 (gnus-group-insert-group-line-info group)
1750 (gnus-run-hooks 'gnus-group-update-group-hook)))
1751 (setq loc (1+ loc)))
1752 (unless (or found visible-only)
1753 ;; No such line in the buffer, find out where it's supposed to
1754 ;; go, and insert it there (or at the end of the buffer).
1755 (if gnus-goto-missing-group-function
1756 (funcall gnus-goto-missing-group-function group)
1757 (let ((entry (cddr (gnus-group-entry group))))
1758 (while (and entry (car entry)
1762 (point-min) (point-max)
1763 'gnus-group (gnus-intern-safe
1765 gnus-active-hashtb)))))
1766 (setq entry (cdr entry)))
1767 (or entry (goto-char (point-max)))))
1768 ;; Finally insert the line.
1769 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1770 (gnus-group-insert-group-line-info group)
1773 (gnus-run-hooks 'gnus-group-update-group-hook))))
1774 (when gnus-group-update-group-function
1775 (funcall gnus-group-update-group-function group))
1776 (gnus-group-set-mode-line))))))
1778 (defun gnus-group-set-mode-line ()
1779 "Update the mode line in the group buffer."
1780 (when (memq 'group gnus-updated-mode-lines)
1781 ;; Yes, we want to keep this mode line updated.
1782 (with-current-buffer gnus-group-buffer
1783 (let* ((gformat (or gnus-group-mode-line-format-spec
1784 (gnus-set-format 'group-mode)))
1785 (gnus-tmp-news-server (cadr gnus-select-method))
1786 (gnus-tmp-news-method (car gnus-select-method))
1787 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1789 gnus-tmp-header ;Dummy binding for user-defined formats
1790 ;; Get the resulting string.
1792 (and gnus-dribble-buffer
1793 (buffer-name gnus-dribble-buffer)
1794 (buffer-modified-p gnus-dribble-buffer)
1795 (with-current-buffer gnus-dribble-buffer
1796 (not (zerop (buffer-size))))))
1797 (mode-string (eval gformat)))
1798 ;; Say whether the dribble buffer has been modified.
1799 (setq mode-line-modified
1800 (if modified (car gnus-mode-line-modified)
1801 (cdr gnus-mode-line-modified)))
1802 ;; If the line is too long, we chop it off.
1803 (when (> (length mode-string) max-len)
1804 (setq mode-string (substring mode-string 0 (- max-len 4))))
1806 (setq mode-line-buffer-identification
1807 (gnus-mode-line-buffer-identification
1808 (list mode-string)))
1809 (set-buffer-modified-p modified))))))
1811 (defun gnus-group-group-name ()
1812 "Get the name of the newsgroup on the current line."
1813 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1815 (symbol-name group))))
1817 (defun gnus-group-group-level ()
1818 "Get the level of the newsgroup on the current line."
1819 (get-text-property (point-at-bol) 'gnus-level))
1821 (defun gnus-group-group-indentation ()
1822 "Get the indentation of the newsgroup on the current line."
1823 (or (get-text-property (point-at-bol) 'gnus-indentation)
1824 (and gnus-group-indentation-function
1825 (funcall gnus-group-indentation-function))
1828 (defun gnus-group-group-unread ()
1829 "Get the number of unread articles of the newsgroup on the current line."
1830 (get-text-property (point-at-bol) 'gnus-unread))
1832 (defun gnus-group-new-mail (group)
1833 (if (nnmail-new-mail-p (gnus-group-real-name group))
1837 (defun gnus-group-level (group)
1838 "Return the estimated level of GROUP."
1839 (or (gnus-info-level (gnus-get-info group))
1840 (and (member group gnus-zombie-list) gnus-level-zombie)
1843 (defun gnus-group-search-forward (&optional backward all level first-too)
1844 "Find the next newsgroup with unread articles.
1845 If BACKWARD is non-nil, find the previous newsgroup instead.
1846 If ALL is non-nil, just find any newsgroup.
1847 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1849 If FIRST-TOO, the current line is also eligible as a target."
1850 (let ((way (if backward -1 1))
1851 (low gnus-level-killed)
1854 (if (and backward (progn (beginning-of-line)) (bobp))
1863 (get-text-property (point) 'gnus-group)
1867 (get-text-property (point) 'gnus-unread)))
1868 (and (numberp unread) (> unread 0)))
1869 (setq lev (get-text-property (point)
1871 (<= lev gnus-level-subscribed)))
1873 (and (setq lev (get-text-property (point)
1882 (zerop (forward-line way)))))
1884 (progn (gnus-group-position-point) t)
1885 (goto-char (or pos beg))
1888 (defun gnus-total-fetched-for (group)
1889 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1890 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1891 (size (+ size-in-cache size-in-agent))
1892 (suffix '("B" "K" "M" "G"))
1895 (while (> size cutoff)
1896 (setq size (/ size scale)
1897 suffix (cdr suffix)))
1898 (format "%5.1f%s" size (car suffix))))
1900 ;;; Gnus group mode commands
1904 (defun gnus-group-mark-line-p ()
1907 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1908 (eq (char-after) gnus-process-mark)))
1910 (defun gnus-group-mark-group (n &optional unmark no-advance)
1911 "Mark the current group."
1913 (let ((buffer-read-only nil)
1917 (when (setq group (gnus-group-group-name))
1918 ;; Go to the mark position.
1920 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1924 (setq gnus-group-marked (delete group gnus-group-marked))
1925 (insert-char ? 1 t))
1926 (setq gnus-group-marked
1927 (cons group (delete group gnus-group-marked)))
1928 (insert-char gnus-process-mark 1 t)))
1930 (gnus-group-next-group 1))
1932 (gnus-summary-position-point)
1935 (defun gnus-group-unmark-group (n)
1936 "Remove the mark from the current group."
1938 (gnus-group-mark-group n 'unmark)
1939 (gnus-group-position-point))
1941 (defun gnus-group-unmark-all-groups ()
1942 "Unmark all groups."
1945 (mapc 'gnus-group-remove-mark gnus-group-marked))
1946 (gnus-group-position-point))
1948 (defun gnus-group-mark-region (unmark beg end)
1949 "Mark all groups between point and mark.
1950 If UNMARK, remove the mark instead."
1951 (interactive "P\nr")
1952 (let ((num (count-lines beg end)))
1955 (- num (gnus-group-mark-group num unmark)))))
1957 (defun gnus-group-mark-buffer (&optional unmark)
1958 "Mark all groups in the buffer.
1959 If UNMARK, remove the mark instead."
1961 (gnus-group-mark-region unmark (point-min) (point-max)))
1963 (defun gnus-group-mark-regexp (regexp)
1964 "Mark all groups that match some regexp."
1965 (interactive "sMark (regexp): ")
1966 (let ((alist (cdr gnus-newsrc-alist))
1970 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1971 (gnus-group-jump-to-group group)
1972 (gnus-group-set-mark group)))))
1973 (gnus-group-position-point))
1975 (defun gnus-group-remove-mark (group &optional test-marked)
1976 "Remove the process mark from GROUP and move point there.
1977 Return nil if the group isn't displayed."
1978 (if (gnus-group-goto-group group nil test-marked)
1980 (gnus-group-mark-group 1 'unmark t)
1982 (setq gnus-group-marked
1983 (delete group gnus-group-marked))
1986 (defun gnus-group-set-mark (group)
1987 "Set the process mark on GROUP."
1988 (if (gnus-group-goto-group group)
1990 (gnus-group-mark-group 1 nil t))
1991 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1993 (defun gnus-group-universal-argument (arg &optional groups func)
1994 "Perform any command on all groups according to the process/prefix convention."
1996 (if (eq (setq func (or func
1999 (substitute-command-keys
2000 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
2002 (gnus-error 1 "Undefined key")
2003 (gnus-group-iterate arg
2005 (command-execute func))))
2006 (gnus-group-position-point))
2008 (defun gnus-group-process-prefix (n)
2009 "Return a list of groups to work on.
2010 Take into consideration N (the prefix) and the list of marked groups."
2013 (setq n (prefix-numeric-value n))
2014 ;; There is a prefix, so we return a list of the N next
2016 (let ((way (if (< n 0) -1 1))
2021 (if (setq group (gnus-group-group-name))
2022 (push group groups))
2024 (gnus-group-next-group way)))
2026 ((and (gnus-region-active-p) (mark))
2027 ;; Work on the region between point and mark.
2028 (let ((max (max (point) (mark)))
2031 (goto-char (min (point) (mark)))
2034 (push (gnus-group-group-name) groups)
2035 (zerop (gnus-group-next-group 1))
2037 (nreverse groups))))
2039 ;; No prefix, but a list of marked articles.
2040 (reverse gnus-group-marked))
2042 ;; Neither marked articles or a prefix, so we return the
2044 (let ((group (gnus-group-group-name)))
2045 (and group (list group))))))
2047 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
2048 ;;; imagine why I went through these contortions...
2050 (let ((function (make-symbol "gnus-group-iterate-function"))
2051 (window (make-symbol "gnus-group-iterate-window"))
2052 (groups (make-symbol "gnus-group-iterate-groups"))
2053 (group (make-symbol "gnus-group-iterate-group")))
2055 `(defun gnus-group-iterate (arg ,function)
2056 "Iterate FUNCTION over all process/prefixed groups.
2057 FUNCTION will be called with the group name as the parameter
2058 and with point over the group in question."
2059 (let ((,groups (gnus-group-process-prefix arg))
2060 (,window (selected-window))
2063 (setq ,group (car ,groups)
2064 ,groups (cdr ,groups))
2065 (select-window ,window)
2066 (gnus-group-remove-mark ,group)
2067 (save-selected-window
2069 (funcall ,function ,group)))))))))
2071 (put 'gnus-group-iterate 'lisp-indent-function 1)
2073 ;; Selecting groups.
2075 (defun gnus-group-read-group (&optional all no-article group select-articles)
2076 "Read news in this newsgroup.
2077 If the prefix argument ALL is non-nil, already read articles become
2080 If ALL is a positive number, fetch this number of the latest
2081 articles in the group. If ALL is a negative number, fetch this
2082 number of the earliest articles in the group.
2084 If the optional argument NO-ARTICLE is non-nil, no article will
2085 be auto-selected upon group entry. If GROUP is non-nil, fetch
2088 (let ((no-display (eq all 0))
2089 (group (or group (gnus-group-group-name)))
2090 number active marked entry)
2094 (error "No group on current line"))
2095 (setq marked (gnus-info-marks
2096 (nth 2 (setq entry (gnus-group-entry group)))))
2097 ;; This group might be a dead group. In that case we have to get
2098 ;; the number of unread articles from `gnus-active-hashtb'.
2100 (cond ((numberp all) all)
2102 ((setq active (gnus-active group))
2103 (- (1+ (cdr active)) (car active)))))
2104 (gnus-summary-read-group
2105 group (or all (and (numberp number)
2106 (zerop (+ number (gnus-range-length
2107 (cdr (assq 'tick marked)))
2109 (cdr (assq 'dormant marked)))))))
2110 no-article nil no-display nil select-articles)))
2112 (defun gnus-group-select-group (&optional all)
2113 "Select this newsgroup.
2114 No article is selected automatically.
2115 If the group is opened, just switch the summary buffer.
2116 If ALL is non-nil, already read articles become readable.
2117 If ALL is a positive number, fetch this number of the latest
2118 articles in the group.
2119 If ALL is a negative number, fetch this number of the earliest
2120 articles in the group."
2122 (when (and (eobp) (not (gnus-group-group-name)))
2124 (gnus-group-read-group all t))
2126 (defun gnus-group-quick-select-group (&optional all group)
2127 "Select the GROUP \"quickly\".
2128 This means that no highlighting or scoring will be performed. If
2129 ALL (the prefix argument) is 0, don't even generate the summary
2130 buffer. If GROUP is nil, use current group.
2132 This might be useful if you want to toggle threading
2133 before entering the group."
2135 (require 'gnus-score)
2137 gnus-score-find-score-files-function
2138 gnus-home-score-file
2139 gnus-apply-kill-hook
2140 gnus-summary-expunge-below)
2141 (gnus-group-read-group all t group)))
2143 (defun gnus-group-visible-select-group (&optional all)
2144 "Select the current group without hiding any articles."
2146 (let ((gnus-inhibit-limiting t))
2147 (gnus-group-read-group all t)))
2149 (defun gnus-group-select-group-ephemerally ()
2150 "Select the current group without doing any processing whatsoever.
2151 You will actually be entered into a group that's a copy of
2152 the current group; no changes you make while in this group will
2155 (require 'gnus-score)
2157 gnus-score-find-score-files-function gnus-apply-kill-hook
2158 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2159 gnus-summary-mode-hook gnus-select-group-hook
2160 (group (gnus-group-group-name))
2161 (method (gnus-find-method-for-group group)))
2162 (gnus-group-read-ephemeral-group
2163 (gnus-group-prefixed-name group method) method)))
2165 (defun gnus-group-name-at-point ()
2166 "Return a group name from around point if it exists, or nil."
2167 (if (eq major-mode 'gnus-group-mode)
2168 (let ((group (gnus-group-group-name)))
2170 (gnus-group-decoded-name group)))
2171 (let ((regexp "[][\C-@-\t\v-*,/:-@\\^`{-\C-?]*\
2172 \\(nn[a-z]+\\(?:\\+[^][\C-@-*,/:-@\\^`{-\C-?]+\\)?:\
2173 \[^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)*\
2174 \\|[^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)+\\)")
2176 (case-fold-search nil))
2178 (if (or (and (not (or (eobp)
2179 (looking-at "[][\C-@-*,/;-@\\^`{-\C-?]")))
2181 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2183 (and (looking-at "[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*$")
2185 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2186 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2188 (string-match "\\`[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*\\'"
2189 (buffer-substring (point-at-bol) (point))))
2190 (when (looking-at regexp)
2192 (let (group distance)
2193 (when (looking-at regexp)
2194 (setq group (match-string 1)
2195 distance (- (match-beginning 1) (match-beginning 0))))
2196 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2197 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2199 (if (looking-at regexp)
2200 (if (and group (<= distance (- start (match-end 0))))
2204 (goto-char start)))))
2206 (defun gnus-group-completing-read (prompt &optional collection predicate
2207 require-match initial-input hist def
2209 "Read a group name with completion. Non-ASCII group names are allowed.
2210 The arguments are the same as `completing-read' except that COLLECTION
2211 and HIST default to `gnus-active-hashtb' and `gnus-group-history'
2212 respectively if they are omitted."
2213 (let ((completion-styles (and (boundp 'completion-styles)
2216 (push 'substring completion-styles)
2217 (mapatoms (lambda (symbol)
2218 (setq group (symbol-name symbol))
2219 (set (intern (if (string-match "[^\000-\177]" group)
2220 (gnus-group-decoded-name group)
2226 (setq collection (or gnus-active-hashtb [0])))
2227 (setq collection (gnus-make-hashtable (length collection)))))
2228 (setq group (apply 'completing-read prompt collection predicate
2229 require-match initial-input
2230 (or hist 'gnus-group-history)
2233 (symbol-value (intern-soft group collection))
2234 (setq collection nil))
2235 (mm-encode-coding-string group (gnus-group-name-charset nil group)))))
2238 (defun gnus-fetch-group (group &optional articles)
2239 "Start Gnus if necessary and enter GROUP.
2240 If ARTICLES, display those articles.
2241 Returns whether the fetching was successful or not."
2242 (interactive (list (gnus-group-completing-read "Group name: "
2244 (gnus-group-name-at-point))))
2245 (unless (gnus-alive-p)
2247 (gnus-group-read-group (if articles nil t) nil group articles))
2250 (defun gnus-fetch-group-other-frame (group)
2251 "Pop up a frame and enter GROUP."
2253 (let ((window (get-buffer-window gnus-group-buffer)))
2255 (select-frame (window-frame window)))
2256 ((= (length (frame-list)) 1)
2257 (select-frame (make-frame)))
2260 (gnus-fetch-group group))
2262 (defvar gnus-ephemeral-group-server 0)
2264 (defcustom gnus-large-ephemeral-newsgroup 200
2265 "The number of articles which indicates a large ephemeral newsgroup.
2266 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2268 If the number of articles in a newsgroup is greater than this value,
2269 confirmation is required for selecting the newsgroup. If it is nil, no
2270 confirmation is required."
2272 :group 'gnus-group-select
2273 :type '(choice (const :tag "No limit" nil)
2276 (defcustom gnus-fetch-old-ephemeral-headers nil
2277 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2280 :type '(choice (const :tag "off" nil)
2283 (sexp :menu-tag "other" t)))
2285 ;; Enter a group that is not in the group buffer. Non-nil is returned
2286 ;; if selection was successful.
2287 (defun gnus-group-read-ephemeral-group (group method &optional activate
2288 quit-config request-only
2292 "Read GROUP from METHOD as an ephemeral group.
2293 If ACTIVATE, request the group first.
2294 If QUIT-CONFIG, use that window configuration when exiting from the
2296 If REQUEST-ONLY, don't actually read the group; just request it.
2297 If SELECT-ARTICLES, only select those articles.
2298 If PARAMETERS, use those as the group parameters.
2299 If NUMBER, fetch this number of articles.
2301 Return the name of the group if selection was successful."
2304 ;; (gnus-read-group "Group name: ")
2305 (gnus-group-completing-read "Group: ")
2306 (gnus-read-method "From method: ")))
2307 ;; Transform the select method into a unique server.
2308 (when (stringp method)
2309 (setq method (gnus-server-to-method method)))
2311 `(,(car method) ,(concat (cadr method) "-ephemeral")
2312 (,(intern (format "%s-address" (car method))) ,(cadr method))
2314 (let ((group (if (gnus-group-foreign-p group) group
2315 (gnus-group-prefixed-name (gnus-group-real-name group)
2320 ,gnus-level-default-subscribed nil nil ,method
2323 (cons 'quit-config quit-config)
2325 (cons gnus-summary-buffer
2326 gnus-current-window-configuration)))
2329 (push method gnus-ephemeral-servers)
2330 (set-buffer gnus-group-buffer)
2331 (unless (gnus-check-server method)
2332 (error "Unable to contact server: %s" (gnus-status-message method)))
2334 (gnus-activate-group group 'scan)
2335 (unless (gnus-request-group group)
2336 (error "Couldn't request group: %s"
2337 (nnheader-get-report (car method)))))
2341 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2342 (gnus-fetch-old-headers
2343 gnus-fetch-old-ephemeral-headers))
2344 (gnus-group-read-group (or number t) t group select-articles))
2348 (message "Quit reading the ephemeral group")
2351 (defcustom gnus-gmane-group-download-format
2352 "http://download.gmane.org/%s/%s/%s"
2353 "URL for downloading mbox files.
2354 It must contain three \"%s\". They correspond to the group, the
2355 minimal and maximal article numbers, respectively."
2356 :group 'gnus-group-foreign
2357 :version "23.1" ;; No Gnus
2360 (autoload 'url-insert-file-contents "url-handlers")
2362 ;; - Add documentation, menu, key bindings, ...
2364 (defun gnus-read-ephemeral-gmane-group (group start &optional range)
2365 "Read articles from Gmane group GROUP as an ephemeral group.
2366 START is the first article. RANGE specifies how many articles
2367 are fetched. The articles are downloaded via HTTP using the URL
2368 specified by `gnus-gmane-group-download-format'."
2369 ;; See <http://gmane.org/export.php> for more information.
2372 (gnus-group-completing-read "Gmane group: ")
2373 (read-number "Start article number: ")
2374 (read-number "How many articles: ")))
2375 (unless range (setq range 500))
2377 (error "Invalid range: %s" range))
2378 (let ((tmpfile (mm-make-temp-file
2379 (format "%s.start-%s.range-%s." group start range)))
2380 (gnus-thread-sort-functions '(gnus-thread-sort-by-number)))
2381 (with-temp-file tmpfile
2382 (url-insert-file-contents
2383 (format gnus-gmane-group-download-format
2384 group start (+ start range)))
2385 (write-region (point-min) (point-max) tmpfile)
2386 (gnus-group-read-ephemeral-group
2387 (format "%s.start-%s.range-%s" group start range)
2389 (nndoc-article-type mbox))))
2390 (delete-file tmpfile)))
2392 (defun gnus-read-ephemeral-gmane-group-url (url)
2393 "Create an ephemeral Gmane group from URL.
2395 Valid input formats include:
2396 \"http://thread.gmane.org/gmane.foo.bar/12300/focus=12399\",
2397 \"http://thread.gmane.org/gmane.foo.bar/12345/\",
2398 \"http://article.gmane.org/gmane.foo.bar/12345/\",
2399 \"http://news.gmane.org/group/gmane.foo.bar/thread=12345\""
2400 ;; - Feel free to add other useful Gmane URLs here! Maybe the URLs should
2402 ;; - The URLs should be added to `gnus-button-alist'. Probably we should
2403 ;; prompt the user to decide: "View via `browse-url' or in Gnus? "
2404 ;; (`gnus-read-ephemeral-gmane-group-url')
2406 (list (gnus-group-completing-read "Gmane URL: ")))
2407 (let (group start range)
2409 ;; URLs providing `group', `start' and `range':
2411 ;; http://thread.gmane.org/gmane.emacs.devel/86326/focus=86525
2412 "^http://thread\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)/focus=\\([0-9]+\\)$"
2414 (setq group (match-string 1 url)
2415 start (string-to-number (match-string 2 url))
2416 ;; Ensure that `range' is large enough to ensure focus article is
2418 range (- (string-to-number (match-string 3 url))
2420 ;; URLs providing `group' and `start':
2422 ;; http://article.gmane.org/gmane.comp.gnu.make.bugs/3584
2423 "^http://\\(?:thread\\|article\\|permalink\\)\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)"
2426 ;; Don't advertise these in the doc string yet:
2427 "^\\(?:nntp\\|news\\)://news\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)"
2430 ;; http://news.gmane.org/group/gmane.emacs.gnus.general/thread=65099/force_load=t
2431 "^http://news\.gmane\.org/group/\\([^/]+\\)/thread=\\([0-9]+\\)"
2433 (setq group (match-string 1 url)
2434 start (string-to-number (match-string 2 url))))
2436 (error "Can't parse URL %s" url)))
2437 (gnus-read-ephemeral-gmane-group group start range)))
2439 (defcustom gnus-bug-group-download-format-alist
2440 '((emacs . "http://debbugs.gnu.org/%s;mbox=yes")
2442 . "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%s&mbox=yes"))
2443 "Alist of symbols for bug trackers and the corresponding URL format string.
2444 The URL format string must contain a single \"%s\", specifying
2445 the bug number, and browsing the URL must return mbox output."
2446 :group 'gnus-group-foreign
2447 :version "23.2" ;; No Gnus
2448 :type '(repeat (cons (symbol) (string :tag "URL format string"))))
2450 (defun gnus-read-ephemeral-bug-group (number mbox-url)
2451 "Browse bug NUMBER as ephemeral group."
2452 (interactive (list (read-string "Enter bug number: "
2453 (thing-at-point 'word) nil)
2454 ;; FIXME: Add completing-read from
2455 ;; `gnus-emacs-bug-group-download-format' ...
2456 (cdr (assoc 'emacs gnus-bug-group-download-format-alist))))
2457 (when (stringp number)
2458 (setq number (string-to-number number)))
2459 (let ((tmpfile (mm-make-temp-file "gnus-temp-group-")))
2460 (with-temp-file tmpfile
2461 (url-insert-file-contents (format mbox-url number))
2462 (write-region (point-min) (point-max) tmpfile)
2463 (gnus-group-read-ephemeral-group
2464 "gnus-read-ephemeral-bug"
2466 (nndoc-article-type mbox))))
2467 (delete-file tmpfile)))
2469 (defun gnus-read-ephemeral-debian-bug-group (number)
2470 "Browse Debian bug NUMBER as ephemeral group."
2471 (interactive (list (read-string "Enter bug number: "
2472 (thing-at-point 'word) nil)))
2473 (gnus-read-ephemeral-bug-group
2475 (cdr (assoc 'debian gnus-bug-group-download-format-alist))))
2477 (defun gnus-read-ephemeral-emacs-bug-group (number)
2478 "Browse Emacs bug NUMBER as ephemeral group."
2479 (interactive (list (read-string "Enter bug number: "
2480 (thing-at-point 'word) nil)))
2481 (gnus-read-ephemeral-bug-group
2483 (cdr (assoc 'emacs gnus-bug-group-download-format-alist))))
2485 (defun gnus-group-jump-to-group (group &optional prompt)
2486 "Jump to newsgroup GROUP.
2488 If PROMPT (the prefix) is a number, use the prompt specified in
2489 `gnus-group-jump-to-group-prompt'."
2491 (list (gnus-group-completing-read
2492 "Group: " nil nil (gnus-read-active-file-p)
2493 (if current-prefix-arg
2494 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2495 (or (and (stringp gnus-group-jump-to-group-prompt)
2496 gnus-group-jump-to-group-prompt)
2497 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2498 (and (stringp p) p)))))))
2500 (when (equal group "")
2501 (error "Empty group name"))
2503 (unless (gnus-ephemeral-group-p group)
2504 ;; Either go to the line in the group buffer...
2505 (unless (gnus-group-goto-group group)
2506 ;; ... or insert the line.
2507 (gnus-group-update-group group)
2508 (gnus-group-goto-group group)))
2509 ;; Adjust cursor point.
2510 (gnus-group-position-point))
2512 (defun gnus-group-goto-group (group &optional far test-marked)
2513 "Goto to newsgroup GROUP.
2514 If FAR, it is likely that the group is not on the current line.
2515 If TEST-MARKED, the line must be marked."
2519 ;; It's quite likely that we are on the right line, so
2520 ;; we check the current line first.
2522 (eq (get-text-property (point) 'gnus-group)
2523 (gnus-intern-safe group gnus-active-hashtb))
2524 (or (not test-marked) (gnus-group-mark-line-p)))
2526 ;; Previous and next line are also likely, so we check them as well.
2530 (and (eq (get-text-property (point) 'gnus-group)
2531 (gnus-intern-safe group gnus-active-hashtb))
2532 (or (not test-marked) (gnus-group-mark-line-p)))))
2538 (and (eq (get-text-property (point) 'gnus-group)
2539 (gnus-intern-safe group gnus-active-hashtb))
2540 (or (not test-marked) (gnus-group-mark-line-p)))))
2544 (goto-char (point-min))
2546 (while (and (not found)
2551 (gnus-intern-safe group gnus-active-hashtb))))
2552 (if (gnus-group-mark-line-p)
2557 ;; Search through the entire buffer.
2560 (point-min) (point-max)
2561 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2563 (defun gnus-group-next-group (n &optional silent)
2564 "Go to next N'th newsgroup.
2565 If N is negative, search backward instead.
2566 Returns the difference between N and the number of skips actually
2569 (gnus-group-next-unread-group n t nil silent))
2571 (defun gnus-group-next-unread-group (n &optional all level silent)
2572 "Go to next N'th unread newsgroup.
2573 If N is negative, search backward instead.
2574 If ALL is non-nil, choose any newsgroup, unread or not.
2575 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2576 such group can be found, the next group with a level higher than
2578 Returns the difference between N and the number of skips actually
2581 (let ((backward (< n 0))
2584 (gnus-group-search-forward
2585 backward (or (not gnus-group-goto-unread) all) level))
2589 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2590 (if level " on this level or higher" "")))
2593 (defun gnus-group-prev-group (n)
2594 "Go to previous N'th newsgroup.
2595 Returns the difference between N and the number of skips actually
2598 (gnus-group-next-unread-group (- n) t))
2600 (defun gnus-group-prev-unread-group (n)
2601 "Go to previous N'th unread newsgroup.
2602 Returns the difference between N and the number of skips actually
2605 (gnus-group-next-unread-group (- n)))
2607 (defun gnus-group-next-unread-group-same-level (n)
2608 "Go to next N'th unread newsgroup on the same level.
2609 If N is negative, search backward instead.
2610 Returns the difference between N and the number of skips actually
2613 (gnus-group-next-unread-group n t (gnus-group-group-level))
2614 (gnus-group-position-point))
2616 (defun gnus-group-prev-unread-group-same-level (n)
2617 "Go to next N'th unread newsgroup on the same level.
2618 Returns the difference between N and the number of skips actually
2621 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2622 (gnus-group-position-point))
2624 (defun gnus-group-best-unread-group (&optional exclude-group)
2625 "Go to the group with the highest level.
2626 If EXCLUDE-GROUP, do not go to that group."
2628 (goto-char (point-min))
2632 (setq unread (get-text-property (point) 'gnus-unread))
2633 (when (and (numberp unread) (> unread 0))
2634 (when (and (get-text-property (point) 'gnus-level)
2635 (< (get-text-property (point) 'gnus-level) best)
2636 (or (not exclude-group)
2637 (not (equal exclude-group (gnus-group-group-name)))))
2638 (setq best (get-text-property (point) 'gnus-level))
2639 (setq best-point (point))))
2642 (goto-char best-point))
2643 (gnus-group-position-point)
2644 (and best-point (gnus-group-group-name))))
2646 ;; Is there something like an after-point-motion-hook?
2647 ;; (inhibit-point-motion-hooks?). Is there a tool-bar-update function?
2649 ;; (defun gnus-group-menu-bar-update ()
2650 ;; (let* ((buf (list (with-current-buffer gnus-group-buffer
2651 ;; (current-buffer))))
2652 ;; (name (buffer-name (car buf))))
2654 ;; (if (> (length name) 27)
2655 ;; (concat (substring name 0 12)
2657 ;; (substring name -12))
2659 ;; (menu-bar-update-buffers-1 buf)))
2661 ;; (defun gnus-group-position-point ()
2662 ;; (gnus-goto-colon)
2663 ;; (gnus-group-menu-bar-update))
2665 (defun gnus-group-first-unread-group ()
2666 "Go to the first group with unread articles."
2669 (let ((opoint (point))
2671 (goto-char (point-min))
2672 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2673 (and (numberp unread) ; Not a topic.
2674 (not (zerop unread))) ; Has unread articles.
2675 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2678 nil)) ; Not success.
2679 (gnus-group-position-point)))
2681 (defun gnus-group-enter-server-mode ()
2682 "Jump to the server buffer."
2684 (gnus-enter-server-buffer))
2686 (defun gnus-group-make-group-simple (&optional group)
2687 "Add a new newsgroup.
2688 The user will be prompted for GROUP."
2689 (interactive (list (gnus-group-completing-read "Group: ")))
2690 (gnus-group-make-group (gnus-group-real-name group)
2691 (gnus-group-server group)
2694 (defun gnus-group-make-group (name &optional method address args encoded)
2695 "Add a new newsgroup.
2696 The user will be prompted for a NAME, for a select METHOD, and an
2697 ADDRESS. NAME should be a human-readable string (i.e., not be encoded
2698 even if it contains non-ASCII characters) unless ENCODED is non-nil."
2701 (gnus-read-group "Group name: ")
2702 (gnus-read-method "From method: ")))
2704 (when (stringp method)
2705 (setq method (or (gnus-server-to-method method) method)))
2707 (setq name (mm-encode-coding-string
2709 (gnus-group-name-charset method name))))
2710 (let* ((meth (gnus-method-simplify
2712 (not (gnus-server-equal method gnus-select-method)))
2713 (if address (list (intern method) address)
2715 (nname (if method (gnus-group-prefixed-name name meth) name))
2717 (when (gnus-group-entry nname)
2718 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2719 ;; Subscribe to the new group.
2720 (gnus-group-change-level
2721 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2722 gnus-level-default-subscribed gnus-level-killed
2723 (and (gnus-group-group-name)
2724 (gnus-group-entry (gnus-group-group-name)))
2727 (gnus-set-active nname (cons 1 0))
2728 (unless (gnus-ephemeral-group-p name)
2730 (concat "(gnus-group-set-info '"
2731 (gnus-prin1-to-string (cdr info)) ")")))
2733 (gnus-group-insert-group-line-info nname)
2735 (gnus-group-position-point)
2737 ;; Load the back end and try to make the back end create
2738 ;; the group as well.
2739 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2741 gnus-valid-select-methods)
2743 (gnus-check-server meth)
2744 (when (gnus-check-backend-function 'request-create-group nname)
2745 (unless (gnus-request-create-group nname nil args)
2746 (error "Could not create group on server: %s"
2747 (nnheader-get-report backend))))
2750 (defun gnus-group-delete-groups (&optional arg)
2751 "Delete the current group. Only meaningful with editable groups."
2753 (let ((n (length (gnus-group-process-prefix arg))))
2754 (when (gnus-yes-or-no-p
2756 "Delete this 1 group? "
2757 (format "Delete these %d groups? " n)))
2758 (gnus-group-iterate arg
2760 (gnus-group-delete-group group nil t))))))
2762 (defun gnus-group-delete-group (group &optional force no-prompt)
2763 "Delete the current group. Only meaningful with editable groups.
2764 If FORCE (the prefix) is non-nil, all the articles in the group will
2765 be deleted. This is \"deleted\" as in \"removed forever from the face
2766 of the Earth\". There is no undo. The user will be prompted before
2768 Note that you also have to specify FORCE if you want the group to
2769 be removed from the server, even when it's empty."
2771 (list (gnus-group-group-name)
2772 current-prefix-arg))
2774 (error "No group to delete"))
2775 (unless (gnus-check-backend-function 'request-delete-group group)
2776 (error "This back end does not support group deletion"))
2778 (let ((group-decoded (gnus-group-decoded-name group)))
2779 (if (and (not no-prompt)
2780 (not (gnus-yes-or-no-p
2782 "Do you really want to delete %s%s? "
2783 group-decoded (if force " and all its contents" "")))))
2785 (gnus-message 6 "Deleting group %s..." group-decoded)
2786 (if (not (gnus-request-delete-group group force))
2787 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2788 (gnus-message 6 "Deleting group %s...done" group-decoded)
2789 (gnus-group-goto-group group)
2790 (gnus-group-kill-group 1 t)
2791 (gnus-set-active group nil)
2793 (gnus-group-position-point)))
2795 (defun gnus-group-rename-group (group new-name)
2796 "Rename group from GROUP to NEW-NAME.
2797 When used interactively, GROUP is the group under point
2798 and NEW-NAME will be prompted for."
2800 (let ((group (gnus-group-group-name))
2802 (unless (gnus-check-backend-function 'request-rename-group group)
2803 (error "This back end does not support renaming groups"))
2804 (setq new-name (gnus-read-group
2806 (gnus-group-real-name (gnus-group-decoded-name group)))
2807 method (gnus-info-method (gnus-get-info group)))
2808 (list group (mm-encode-coding-string
2810 (gnus-group-name-charset
2812 (gnus-group-prefixed-name new-name method))))))
2814 (unless (gnus-check-backend-function 'request-rename-group group)
2815 (error "This back end does not support renaming groups"))
2817 (error "No group to rename"))
2818 (when (equal (gnus-group-real-name group) new-name)
2819 (error "Can't rename to the same name"))
2821 ;; We find the proper prefixed name.
2823 (if (gnus-group-native-p group)
2827 (gnus-group-prefixed-name
2828 (gnus-group-real-name new-name)
2829 (gnus-info-method (gnus-get-info group)))))
2831 (let ((decoded-group (gnus-group-decoded-name group))
2832 (decoded-new-name (gnus-group-decoded-name new-name)))
2833 (when (gnus-active new-name)
2834 (error "The group %s already exists" decoded-new-name))
2836 (gnus-message 6 "Renaming group %s to %s..."
2837 decoded-group decoded-new-name)
2840 (gnus-group-goto-group group)
2841 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2842 (gnus-request-rename-group group new-name))))
2843 (gnus-error 3 "Couldn't rename group %s to %s"
2844 decoded-group decoded-new-name)
2845 ;; We rename the group internally by killing it...
2846 (gnus-group-kill-group)
2847 ;; ... changing its name ...
2848 (setcar (cdar gnus-list-of-killed-groups) new-name)
2849 ;; ... and then yanking it. Magic!
2850 (gnus-group-yank-group)
2851 (gnus-set-active new-name (gnus-active group))
2852 (gnus-message 6 "Renaming group %s to %s...done"
2853 decoded-group decoded-new-name)
2855 (setq gnus-killed-list (delete group gnus-killed-list))
2856 (gnus-set-active group nil)
2857 (gnus-dribble-touch)
2858 (gnus-group-position-point))))
2860 (defun gnus-group-edit-group (group &optional part)
2861 "Edit the group on the current line."
2862 (interactive (list (gnus-group-group-name)))
2863 (let ((part (or part 'info))
2866 (error "No group on current line"))
2867 (unless (setq info (gnus-get-info group))
2868 (error "Killed group; can't be edited"))
2870 (gnus-close-group group))
2872 ;; Find the proper form to edit.
2873 (cond ((eq part 'method)
2874 (or (gnus-info-method info) "native"))
2876 (gnus-info-params info))
2878 ;; The proper documentation.
2880 "Editing the %s for `%s'."
2882 ((eq part 'method) "select method")
2883 ((eq part 'params) "group parameters")
2885 (gnus-group-decoded-name group))
2887 (gnus-group-edit-group-done ',part ,group form)))
2890 (gnus-create-info-command
2893 "(gnus)Select Methods")
2895 "(gnus)Group Parameters")
2897 "(gnus)Group Info"))))))
2899 (defun gnus-group-edit-group-method (group)
2900 "Edit the select method of GROUP."
2901 (interactive (list (gnus-group-group-name)))
2902 (gnus-group-edit-group group 'method))
2904 (defun gnus-group-edit-group-parameters (group)
2905 "Edit the group parameters of GROUP."
2906 (interactive (list (gnus-group-group-name)))
2907 (gnus-group-edit-group group 'params))
2909 (defun gnus-group-edit-group-done (part group form)
2911 (let* ((method (cond ((eq part 'info) (nth 4 form))
2912 ((eq part 'method) form)
2914 (info (cond ((eq part 'info) form)
2915 ((eq part 'method) (gnus-get-info group))
2918 (if (or (not method)
2920 gnus-select-method method))
2921 (gnus-group-real-name (car info))
2922 (gnus-group-prefixed-name
2923 (gnus-group-real-name (car info)) method))
2925 (when (and new-group
2926 (not (equal new-group group)))
2927 (when (gnus-group-goto-group group)
2928 (gnus-group-kill-group 1))
2929 (gnus-activate-group new-group))
2931 (if (not (and info new-group))
2932 (gnus-group-set-info form (or new-group group) part)
2933 (setq info (gnus-copy-sequence info))
2934 (setcar info new-group)
2935 (unless (gnus-server-equal method "native")
2936 (unless (nthcdr 3 info)
2937 (nconc info (list nil nil)))
2938 (unless (nthcdr 4 info)
2939 (nconc info (list nil)))
2940 (gnus-info-set-method info method))
2941 (gnus-group-set-info info))
2942 (gnus-group-update-group (or new-group group))
2943 (gnus-group-position-point)))
2945 (defun gnus-group-make-useful-group (group method)
2946 "Create one of the groups described in `gnus-useful-groups'."
2948 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2950 gnus-useful-groups)))
2952 ;; Don't use `caddr' here since macros within the `interactive'
2953 ;; form won't be expanded.
2954 (car (cddr entry)))))
2955 (setq method (gnus-copy-sequence method))
2957 (while (setq entry (memq (assq 'eval method) method))
2958 (setcar entry (eval (cadar entry)))))
2959 (gnus-group-make-group group method))
2961 (defun gnus-group-make-help-group (&optional noerror)
2962 "Create the Gnus documentation group.
2963 Optional argument NOERROR modifies the behavior of this function when the
2964 group already exists:
2965 - if not given, and error is signaled,
2966 - if t, stay silent,
2967 - if anything else, just print a message."
2969 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2970 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2971 (if (gnus-group-entry name)
2972 (cond ((eq noerror nil)
2973 (error "Documentation group already exists"))
2978 (gnus-message 1 "Documentation group already exists")))
2981 (gnus-message 1 "Couldn't find doc group")
2982 (gnus-group-make-group
2983 (gnus-group-real-name name)
2984 (list 'nndoc "gnus-help"
2985 (list 'nndoc-address file)
2986 (list 'nndoc-article-type 'mbox))))
2988 (gnus-group-position-point))
2990 (defun gnus-group-make-doc-group (file type)
2991 "Create a group that uses a single file as the source.
2993 If called with a prefix argument, ask for the file type."
2995 (list (read-file-name "File name: ")
2996 (and current-prefix-arg 'ask)))
2997 (when (eq type 'ask)
3002 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
3004 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
3005 ((= char ?b) 'babyl)
3006 ((= char ?d) 'digest)
3007 ((= char ?f) 'forward)
3009 ((= char ?g) 'guess)
3010 (t (setq err (format "%c unknown. " char))
3013 (setq file (expand-file-name file))
3014 (let* ((name (gnus-generate-new-group-name
3015 (gnus-group-prefixed-name
3016 (file-name-nondirectory file) '(nndoc ""))))
3017 (method (list 'nndoc file
3018 (list 'nndoc-address file)
3019 (list 'nndoc-article-type (or type 'guess))))
3020 (coding (gnus-group-name-charset method name)))
3021 (setcar (cdr method) (mm-encode-coding-string file coding))
3022 (gnus-group-make-group
3023 (mm-encode-coding-string (gnus-group-real-name name) coding)
3026 (defvar nnweb-type-definition)
3027 (defvar gnus-group-web-type-history nil)
3028 (defvar gnus-group-web-search-history nil)
3029 (defun gnus-group-make-web-group (&optional solid)
3030 "Create an ephemeral nnweb group.
3031 If SOLID (the prefix), create a solid group."
3035 (if solid (gnus-read-group "Group name: ")
3036 (message-unique-id)))
3037 (default-type (or (car gnus-group-web-type-history)
3038 (symbol-name (caar nnweb-type-definition))))
3042 (format "Search engine type (default %s): " default-type)
3043 (mapcar (lambda (elem) (list (symbol-name (car elem))))
3044 nnweb-type-definition)
3045 nil t nil 'gnus-group-web-type-history)
3050 (cons (or (car gnus-group-web-search-history) "") 0)
3051 'gnus-group-web-search-history))
3053 `(nnweb ,group (nnweb-search ,search)
3054 (nnweb-type ,(intern type))
3055 (nnweb-ephemeral-p t))))
3058 (gnus-pull 'nnweb-ephemeral-p method)
3059 (gnus-group-make-group group method))
3060 (gnus-group-read-ephemeral-group
3062 (cons (current-buffer)
3063 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
3065 (defvar nnrss-group-alist)
3067 (defun nnrss-discover-feed (arg))
3068 (defun nnrss-save-server-data (arg)))
3069 (defun gnus-group-make-rss-group (&optional url)
3070 "Given a URL, discover if there is an RSS feed.
3071 If there is, use Gnus to create an nnrss group"
3075 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
3076 (let ((feedinfo (nnrss-discover-feed url)))
3078 (let* ((title (gnus-newsgroup-savable-name
3079 (read-from-minibuffer "Title: "
3080 (gnus-newsgroup-savable-name
3084 (or (cdr (assoc 'title
3088 (desc (read-from-minibuffer "Description: "
3092 (or (cdr (assoc 'description
3096 (href (cdr (assoc 'href feedinfo)))
3097 (coding (gnus-group-name-charset '(nnrss "") title)))
3099 ;; Unify non-ASCII text.
3100 (setq title (mm-decode-coding-string
3101 (mm-encode-coding-string title coding)
3103 (gnus-group-make-group title '(nnrss ""))
3104 (push (list title href desc) nnrss-group-alist)
3105 (nnrss-save-server-data nil))
3106 (error "No feeds found for %s" url))))
3108 (defun gnus-group-make-archive-group (&optional all)
3109 "Create the (ding) Gnus archive group of the most recent articles.
3110 Given a prefix, create a full group."
3112 (let ((group (gnus-group-prefixed-name
3113 (if all "ding.archives" "ding.recent") '(nndir ""))))
3114 (when (gnus-group-entry group)
3115 (error "Archive group already exists"))
3116 (gnus-group-make-group
3117 (gnus-group-real-name group)
3118 (list 'nndir (if all "hpc" "edu")
3119 (list 'nndir-directory
3120 (if all gnus-group-archive-directory
3121 gnus-group-recent-archive-directory))))
3122 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
3124 (defun gnus-group-make-directory-group (dir)
3125 "Create an nndir group.
3126 The user will be prompted for a directory. The contents of this
3127 directory will be used as a newsgroup. The directory should contain
3128 mail messages or news articles in files that have numeric names."
3130 (list (read-file-name "Create group from directory: ")))
3131 (unless (file-exists-p dir)
3132 (error "No such directory"))
3133 (unless (file-directory-p dir)
3134 (error "Not a directory"))
3138 (while (or (not group) (gnus-group-entry group))
3140 (gnus-group-prefixed-name
3141 (expand-file-name ext dir)
3143 (setq ext (format "<%d>" (setq i (1+ i)))))
3144 (gnus-group-make-group
3145 (gnus-group-real-name group)
3146 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
3148 (defun gnus-group-add-to-virtual (n vgroup)
3149 "Add the current group to a virtual group."
3151 (list current-prefix-arg
3152 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
3154 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
3155 (error "%s is not an nnvirtual group" vgroup))
3156 (gnus-close-group vgroup)
3157 (let* ((groups (gnus-group-process-prefix n))
3158 (method (gnus-info-method (gnus-get-info vgroup))))
3159 (setcar (cdr method)
3161 (nth 1 method) "\\|"
3164 (gnus-group-remove-mark s)
3165 (concat "\\(^" (regexp-quote s) "$\\)"))
3167 (gnus-group-position-point))
3169 (defun gnus-group-make-empty-virtual (group)
3170 "Create a new, fresh, empty virtual group."
3171 (interactive "sCreate new, empty virtual group: ")
3172 (let* ((method (list 'nnvirtual "^$"))
3173 (pgroup (gnus-group-prefixed-name group method)))
3174 ;; Check whether it exists already.
3175 (when (gnus-group-entry pgroup)
3176 (error "Group %s already exists" pgroup))
3177 ;; Subscribe the new group after the group on the current line.
3178 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
3179 (gnus-group-update-group pgroup)
3181 (gnus-group-position-point)))
3183 (defun gnus-group-enter-directory (dir)
3184 "Enter an ephemeral nneething group."
3185 (interactive "DDirectory to read: ")
3186 (let* ((method (list 'nneething dir '(nneething-read-only t)))
3187 (leaf (gnus-group-prefixed-name
3188 (file-name-nondirectory (directory-file-name dir))
3190 (name (gnus-generate-new-group-name leaf)))
3191 (unless (gnus-group-read-ephemeral-group
3193 (cons (current-buffer)
3194 (if (eq major-mode 'gnus-summary-mode)
3196 (error "Couldn't enter %s" dir))))
3198 (defun gnus-group-expunge-group (group)
3199 "Expunge deleted articles in current nnimap GROUP."
3200 (interactive (list (gnus-group-group-name)))
3201 (let ((method (gnus-find-method-for-group group)))
3202 (if (not (gnus-check-backend-function
3203 'request-expunge-group (car method)))
3204 (error "%s does not support expunging" (car method))
3205 (gnus-request-expunge-group group method))))
3207 (autoload 'nnimap-acl-get "nnimap")
3208 (autoload 'nnimap-acl-edit "nnimap")
3210 (defun gnus-group-nnimap-edit-acl (group)
3211 "Edit the Access Control List of current nnimap GROUP."
3212 (interactive (list (gnus-group-group-name)))
3213 (let ((mailbox (gnus-group-real-name group)) method acl)
3215 (error "No group on current line"))
3216 (unless (gnus-get-info group)
3217 (error "Killed group; can't be edited"))
3218 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
3219 (error "%s is not an nnimap group" group))
3220 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
3221 (error "Server does not support ACL's"))
3222 (gnus-edit-form acl (format "Editing the access control list for `%s'.
3224 An access control list is a list of (identifier . rights) elements.
3226 The identifier string specifies the corresponding user. The
3227 identifier \"anyone\" is reserved to refer to the universal identity.
3229 Rights is a string listing a (possibly empty) set of alphanumeric
3230 characters, each character listing a set of operations which is being
3231 controlled. Letters are reserved for ``standard'' rights, listed
3232 below. Digits are reserved for implementation or site defined rights.
3234 l - lookup (mailbox is visible to LIST/LSUB commands)
3235 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
3236 SEARCH, COPY from mailbox)
3237 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
3238 w - write (STORE flags other than \\SEEN and \\DELETED)
3239 i - insert (perform APPEND, COPY into mailbox)
3240 p - post (send mail to submission address for mailbox,
3241 not enforced by IMAP4 itself)
3242 c - create and delete mailbox (CREATE new sub-mailboxes in any
3243 implementation-defined hierarchy, RENAME or DELETE mailbox)
3244 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
3245 a - administer (perform SETACL)" group)
3248 ,mailbox ',method ',acl form)))))
3250 ;; Group sorting commands
3251 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3253 (defun gnus-group-sort-groups (func &optional reverse)
3254 "Sort the group buffer according to FUNC.
3255 When used interactively, the sorting function used will be
3256 determined by the `gnus-group-sort-function' variable.
3257 If REVERSE (the prefix), reverse the sorting order."
3258 (interactive (list gnus-group-sort-function current-prefix-arg))
3259 (funcall gnus-group-sort-alist-function
3260 (gnus-make-sort-function func) reverse)
3261 (gnus-group-unmark-all-groups)
3262 (gnus-group-list-groups)
3263 (gnus-dribble-touch))
3265 (defun gnus-group-sort-flat (func reverse)
3266 ;; We peel off the dummy group from the alist.
3268 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
3269 (pop gnus-newsrc-alist))
3271 (setq gnus-newsrc-alist
3272 (sort gnus-newsrc-alist func))
3274 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
3275 ;; Regenerate the hash table.
3276 (gnus-make-hashtable-from-newsrc-alist)))
3278 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
3279 "Sort the group buffer alphabetically by group name.
3280 If REVERSE, sort in reverse order."
3282 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
3284 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
3285 "Sort the group buffer alphabetically by real (unprefixed) group name.
3286 If REVERSE, sort in reverse order."
3288 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
3290 (defun gnus-group-sort-groups-by-unread (&optional reverse)
3291 "Sort the group buffer by number of unread articles.
3292 If REVERSE, sort in reverse order."
3294 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
3296 (defun gnus-group-sort-groups-by-level (&optional reverse)
3297 "Sort the group buffer by group level.
3298 If REVERSE, sort in reverse order."
3300 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
3302 (defun gnus-group-sort-groups-by-score (&optional reverse)
3303 "Sort the group buffer by group score.
3304 If REVERSE, sort in reverse order."
3306 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
3308 (defun gnus-group-sort-groups-by-rank (&optional reverse)
3309 "Sort the group buffer by group rank.
3310 If REVERSE, sort in reverse order."
3312 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
3314 (defun gnus-group-sort-groups-by-method (&optional reverse)
3315 "Sort the group buffer alphabetically by back end name.
3316 If REVERSE, sort in reverse order."
3318 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
3320 (defun gnus-group-sort-groups-by-server (&optional reverse)
3321 "Sort the group buffer alphabetically by server name.
3322 If REVERSE, sort in reverse order."
3324 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
3326 ;;; Selected group sorting.
3328 (defun gnus-group-sort-selected-groups (n func &optional reverse)
3329 "Sort the process/prefixed groups."
3330 (interactive (list current-prefix-arg gnus-group-sort-function))
3331 (let ((groups (gnus-group-process-prefix n)))
3332 (funcall gnus-group-sort-selected-function
3333 groups (gnus-make-sort-function func) reverse)
3334 (gnus-group-unmark-all-groups)
3335 (gnus-group-list-groups)
3336 (gnus-dribble-touch)))
3338 (defun gnus-group-sort-selected-flat (groups func reverse)
3339 (let (entries infos)
3340 ;; First find all the group entries for these groups.
3342 (push (nthcdr 2 (gnus-group-entry (pop groups)))
3344 ;; Then sort the infos.
3348 (lambda (entry) (car entry))
3349 (setq entries (nreverse entries)))
3352 (setq infos (nreverse infos)))
3353 ;; Go through all the infos and replace the old entries
3354 ;; with the new infos.
3356 (setcar (car entries) (pop infos))
3358 ;; Update the hashtable.
3359 (gnus-make-hashtable-from-newsrc-alist)))
3361 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3362 "Sort the group buffer alphabetically by group name.
3363 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3364 sort in reverse order."
3365 (interactive (gnus-interactive "P\ny"))
3366 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3368 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3369 "Sort the group buffer alphabetically by real group name.
3370 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3371 sort in reverse order."
3372 (interactive (gnus-interactive "P\ny"))
3373 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3375 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3376 "Sort the group buffer by number of unread articles.
3377 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3378 sort in reverse order."
3379 (interactive (gnus-interactive "P\ny"))
3380 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3382 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3383 "Sort the group buffer by group level.
3384 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3385 sort in reverse order."
3386 (interactive (gnus-interactive "P\ny"))
3387 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3389 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3390 "Sort the group buffer by group score.
3391 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3392 sort in reverse order."
3393 (interactive (gnus-interactive "P\ny"))
3394 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3396 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3397 "Sort the group buffer by group rank.
3398 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3399 sort in reverse order."
3400 (interactive (gnus-interactive "P\ny"))
3401 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3403 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3404 "Sort the group buffer alphabetically by back end name.
3405 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3406 sort in reverse order."
3407 (interactive (gnus-interactive "P\ny"))
3408 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3410 ;;; Sorting predicates.
3412 (defun gnus-group-sort-by-alphabet (info1 info2)
3413 "Sort alphabetically."
3414 (string< (gnus-info-group info1) (gnus-info-group info2)))
3416 (defun gnus-group-sort-by-real-name (info1 info2)
3417 "Sort alphabetically on real (unprefixed) names."
3418 (string< (gnus-group-real-name (gnus-info-group info1))
3419 (gnus-group-real-name (gnus-info-group info2))))
3421 (defun gnus-group-sort-by-unread (info1 info2)
3422 "Sort by number of unread articles."
3423 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3424 (n2 (gnus-group-unread (gnus-info-group info2))))
3425 (< (or (and (numberp n1) n1) 0)
3426 (or (and (numberp n2) n2) 0))))
3428 (defun gnus-group-sort-by-level (info1 info2)
3430 (< (gnus-info-level info1) (gnus-info-level info2)))
3432 (defun gnus-group-sort-by-method (info1 info2)
3433 "Sort alphabetically by back end name."
3434 (string< (car (gnus-find-method-for-group
3435 (gnus-info-group info1) info1))
3436 (car (gnus-find-method-for-group
3437 (gnus-info-group info2) info2))))
3439 (defun gnus-group-sort-by-server (info1 info2)
3440 "Sort alphabetically by server name."
3441 (string< (gnus-method-to-full-server-name
3442 (gnus-find-method-for-group
3443 (gnus-info-group info1) info1))
3444 (gnus-method-to-full-server-name
3445 (gnus-find-method-for-group
3446 (gnus-info-group info2) info2))))
3448 (defun gnus-group-sort-by-score (info1 info2)
3449 "Sort by group score."
3450 (> (gnus-info-score info1) (gnus-info-score info2)))
3452 (defun gnus-group-sort-by-rank (info1 info2)
3453 "Sort by level and score."
3454 (let ((level1 (gnus-info-level info1))
3455 (level2 (gnus-info-level info2)))
3456 (or (< level1 level2)
3457 (and (= level1 level2)
3458 (> (gnus-info-score info1) (gnus-info-score info2))))))
3462 (defun gnus-group-clear-data (&optional arg)
3463 "Clear all marks and read ranges from the current group.
3464 Obeys the process/prefix convention."
3466 (gnus-group-iterate arg
3469 (gnus-info-clear-data (setq info (gnus-get-info group)))
3470 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3471 (when (gnus-group-goto-group group)
3472 (gnus-group-update-group-line))))))
3474 (defun gnus-group-clear-data-on-native-groups ()
3475 "Clear all marks and read ranges from all native groups."
3477 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3478 (let ((alist (cdr gnus-newsrc-alist))
3480 (while (setq info (pop alist))
3481 (when (gnus-group-native-p (gnus-info-group info))
3482 (gnus-info-clear-data info)))
3483 (gnus-get-unread-articles)
3484 (gnus-dribble-touch)
3485 (when (gnus-y-or-n-p
3486 "Move the cache away to avoid problems in the future? ")
3487 (call-interactively 'gnus-cache-move-cache)))))
3489 (defun gnus-info-clear-data (info)
3490 "Clear all marks and read ranges from INFO."
3491 (let ((group (gnus-info-group info))
3493 (dolist (el (gnus-info-marks info))
3494 (push `(,(cdr el) add (,(car el))) action))
3495 (push `(,(gnus-info-read info) add (read)) action)
3498 (gnus-request-set-mark ,group ',action)
3499 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3500 (gnus-info-set-read ',info ',(gnus-info-read info))
3501 (when (gnus-group-goto-group ,group)
3502 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3503 (gnus-group-update-group-line))))
3504 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3506 (gnus-request-set-mark group action)
3507 (gnus-info-set-read info nil)
3508 (when (gnus-info-marks info)
3509 (gnus-info-set-marks info nil))))
3511 ;; Group catching up.
3513 (defun gnus-group-catchup-current (&optional n all)
3514 "Mark all unread articles in the current newsgroup as read.
3515 If prefix argument N is numeric, the next N newsgroups will be
3516 caught up. If ALL is non-nil, marked articles will also be marked as
3517 read. Cross references (Xref: header) of articles are ignored.
3518 The number of newsgroups that this function was unable to catch
3521 (let ((groups (gnus-group-process-prefix n))
3524 (unless groups (error "No groups selected"))
3526 (or (not gnus-interactive-catchup) ;Without confirmation?
3531 "Do you really want to mark all articles in %s as read? "
3532 "Mark all unread articles in %s as read? ")
3533 (if (= (length groups) 1)
3534 (gnus-group-decoded-name (car groups))
3535 (format "these %d groups" (length groups)))))))
3537 (while (setq group (pop groups))
3538 (gnus-group-remove-mark group)
3539 ;; Virtual groups have to be given special treatment.
3540 (let ((method (gnus-find-method-for-group group)))
3541 (when (eq 'nnvirtual (car method))
3542 (nnvirtual-catchup-group
3543 (gnus-group-real-name group) (nth 1 method) all)))
3545 ((>= (gnus-group-level group) gnus-level-zombie)
3546 (gnus-message 2 "Dead groups can't be caught up"))
3548 (gnus-group-goto-group group)
3549 (gnus-group-catchup group all))
3550 (gnus-group-update-group-line))
3552 (setq ret (1+ ret)))))
3553 (gnus-group-next-unread-group 1)
3556 (defun gnus-group-catchup-current-all (&optional n)
3557 "Mark all articles in current newsgroup as read.
3558 Cross references (Xref: header) of articles are ignored."
3560 (gnus-group-catchup-current n 'all))
3562 (defun gnus-group-catchup (group &optional all)
3563 "Mark all articles in GROUP as read.
3564 If ALL is non-nil, all articles are marked as read.
3565 The return value is the number of articles that were marked as read,
3566 or nil if no action could be taken."
3567 (let* ((entry (gnus-group-entry group))
3569 (marks (gnus-info-marks (nth 2 entry)))
3570 (unread (gnus-sequence-of-unread-articles group)))
3571 ;; Remove entries for this group.
3572 (nnmail-purge-split-history (gnus-group-real-name group))
3573 ;; Do the updating only if the newsgroup isn't killed.
3574 (if (not (numberp (car entry)))
3575 (gnus-message 1 "Can't catch up %s; non-active group" group)
3576 (gnus-update-read-articles group nil)
3578 ;; Nix out the lists of marks and dormants.
3579 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3581 (list (cdr (assq 'dormant marks))
3583 (setq unread (gnus-range-add (gnus-range-add
3584 unread (cdr (assq 'dormant marks)))
3585 (cdr (assq 'tick marks))))
3586 (gnus-add-marked-articles group 'tick nil nil 'force)
3587 (gnus-add-marked-articles group 'dormant nil nil 'force))
3588 ;; Do auto-expirable marks if that's required.
3589 (when (gnus-group-auto-expirable-p group)
3592 (gnus-add-marked-articles group 'expire (list article))
3593 (gnus-request-set-mark group (list (list (list article)
3596 (let ((gnus-newsgroup-name group))
3597 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3600 (defun gnus-group-expire-articles (&optional n)
3601 "Expire all expirable articles in the current newsgroup.
3602 Uses the process/prefix convention."
3604 (let ((groups (gnus-group-process-prefix n))
3607 (error "No groups to expire"))
3608 (while (setq group (pop groups))
3609 (gnus-group-remove-mark group)
3610 (gnus-group-expire-articles-1 group)
3611 (gnus-dribble-touch)
3612 (gnus-group-position-point))))
3614 (defun gnus-group-expire-articles-1 (group)
3615 (when (gnus-check-backend-function 'request-expire-articles group)
3616 (gnus-message 6 "Expiring articles in %s..."
3617 (gnus-group-decoded-name group))
3618 (let* ((info (gnus-get-info group))
3619 (expirable (if (gnus-group-total-expirable-p group)
3620 (cons nil (gnus-list-of-read-articles group))
3621 (assq 'expire (gnus-info-marks info))))
3622 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3623 (nnmail-expiry-target
3624 (or (gnus-group-find-parameter group 'expiry-target)
3625 nnmail-expiry-target)))
3627 (gnus-check-group group)
3630 (gnus-compress-sequence
3632 ;; We set the expiry variables to the group
3634 (let ((nnmail-expiry-wait-function nil)
3635 (nnmail-expiry-wait expiry-wait))
3636 (gnus-request-expire-articles
3637 (gnus-uncompress-sequence (cdr expirable)) group))
3638 ;; Just expire using the normal expiry values.
3639 (gnus-request-expire-articles
3640 (gnus-uncompress-sequence (cdr expirable)) group))))
3641 (gnus-close-group group))
3642 (gnus-message 6 "Expiring articles in %s...done"
3643 (gnus-group-decoded-name group))
3644 ;; Return the list of un-expired articles.
3647 (defun gnus-group-expire-all-groups ()
3648 "Expire all expirable articles in all newsgroups."
3651 (gnus-message 5 "Expiring...")
3652 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3653 (cdr gnus-newsrc-alist))))
3654 (gnus-group-expire-articles nil)))
3655 (gnus-group-position-point)
3656 (gnus-message 5 "Expiring...done"))
3658 (defun gnus-group-set-current-level (n level)
3659 "Set the level of the next N groups to LEVEL."
3664 (unless (gnus-group-process-prefix current-prefix-arg)
3665 (error "No group on the current line"))
3667 (let ((s (read-string
3668 (format "Level (default %s): "
3669 (or (gnus-group-group-level)
3670 gnus-level-default-subscribed)))))
3671 (if (string-match "^\\s-*$" s)
3672 (int-to-string (or (gnus-group-group-level)
3673 gnus-level-default-subscribed))
3675 (unless (and (>= level 1) (<= level gnus-level-killed))
3676 (error "Invalid level: %d" level))
3677 (dolist (group (gnus-group-process-prefix n))
3678 (gnus-group-remove-mark group)
3679 (gnus-message 6 "Changed level of %s from %d to %d"
3680 (gnus-group-decoded-name group)
3681 (or (gnus-group-group-level) gnus-level-killed)
3683 (gnus-group-change-level
3684 group level (or (gnus-group-group-level) gnus-level-killed))
3685 (gnus-group-update-group-line))
3686 (gnus-group-position-point))
3688 (defun gnus-group-unsubscribe (&optional n)
3689 "Unsubscribe the current group."
3691 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3693 (defun gnus-group-subscribe (&optional n)
3694 "Subscribe the current group."
3696 (gnus-group-unsubscribe-current-group n 'subscribe))
3698 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3699 "Toggle subscription of the current group.
3700 If given numerical prefix, toggle the N next groups."
3702 (dolist (group (gnus-group-process-prefix n))
3703 (gnus-group-remove-mark group)
3704 (gnus-group-unsubscribe-group
3707 ((eq do-sub 'unsubscribe)
3708 gnus-level-default-unsubscribed)
3709 ((eq do-sub 'subscribe)
3710 gnus-level-default-subscribed)
3711 ((<= (gnus-group-group-level) gnus-level-subscribed)
3712 gnus-level-default-unsubscribed)
3714 gnus-level-default-subscribed))
3716 (gnus-group-update-group-line))
3717 (gnus-group-next-group 1))
3719 (defun gnus-group-unsubscribe-group (group &optional level silent)
3720 "Toggle subscription to GROUP.
3721 Killed newsgroups are subscribed. If SILENT, don't try to update the
3723 (interactive (list (gnus-group-completing-read
3724 "Group: " nil nil (gnus-read-active-file-p))))
3725 (let ((newsrc (gnus-group-entry group)))
3727 ((string-match "^[ \t]*$" group)
3728 (error "Empty group name"))
3730 ;; Toggle subscription flag.
3731 (gnus-group-change-level
3732 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3733 gnus-level-subscribed)
3734 (1+ gnus-level-subscribed)
3735 gnus-level-default-subscribed)))
3737 (gnus-group-update-group group)))
3738 ((and (stringp group)
3739 (or (not (gnus-read-active-file-p))
3740 (gnus-active group)))
3741 ;; Add new newsgroup.
3742 (gnus-group-change-level
3744 (if level level gnus-level-default-subscribed)
3745 (or (and (member group gnus-zombie-list)
3748 (when (gnus-group-group-name)
3749 (gnus-group-entry (gnus-group-group-name))))
3751 (gnus-group-update-group group)))
3752 (t (error "No such newsgroup: %s" group)))
3753 (gnus-group-position-point)))
3755 (defun gnus-group-transpose-groups (n)
3756 "Move the current newsgroup up N places.
3757 If given a negative prefix, move down instead. The difference between
3758 N and the number of steps taken is returned."
3760 (unless (gnus-group-group-name)
3761 (error "No group on current line"))
3762 (gnus-group-kill-group 1)
3764 (forward-line (- n))
3765 (gnus-group-yank-group)
3766 (gnus-group-position-point)))
3768 (defun gnus-group-kill-all-zombies (&optional dummy)
3769 "Kill all zombie newsgroups.
3770 The optional DUMMY should always be nil."
3771 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3773 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3774 (setq gnus-zombie-list nil)
3775 (gnus-dribble-touch)
3776 (gnus-group-list-groups)))
3778 (defun gnus-group-kill-region (begin end)
3779 "Kill newsgroups in current region (excluding current point).
3780 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3793 (beginning-of-line) ;Important when LINES < 1
3794 (gnus-group-kill-group lines)))
3796 (defun gnus-group-kill-group (&optional n discard)
3797 "Kill the next N groups.
3798 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3799 However, only groups that were alive can be yanked; already killed
3800 groups or zombie groups can't be yanked.
3801 The return value is the name of the group that was killed, or a list
3804 (let ((buffer-read-only nil)
3805 (groups (gnus-group-process-prefix n))
3806 group entry level out)
3807 (if (< (length groups) 10)
3808 ;; This is faster when there are few groups.
3810 (push (setq group (pop groups)) out)
3811 (gnus-group-remove-mark group)
3812 (setq level (gnus-group-group-level))
3814 (when (and (not discard)
3815 (setq entry (gnus-group-entry group)))
3818 (gnus-group-goto-group ,(gnus-group-group-name))
3819 (gnus-group-yank-group)))
3820 (push (cons (car entry) (nth 2 entry))
3821 gnus-list-of-killed-groups))
3822 (gnus-group-change-level
3823 (if entry entry group) gnus-level-killed (if entry nil level))
3824 (message "Killed group %s" (gnus-group-decoded-name group)))
3825 ;; If there are lots and lots of groups to be killed, we use
3826 ;; this thing instead.
3827 (dolist (group (nreverse groups))
3828 (gnus-group-remove-mark group)
3830 (push group gnus-killed-list)
3831 (setq gnus-newsrc-alist
3832 (delq (assoc group gnus-newsrc-alist)
3834 (when gnus-group-change-level-function
3835 (funcall gnus-group-change-level-function
3836 group gnus-level-killed 3))
3838 ((setq entry (gnus-group-entry group))
3839 (push (cons (car entry) (nth 2 entry))
3840 gnus-list-of-killed-groups)
3841 (setcdr (cdr entry) (cdddr entry)))
3842 ((member group gnus-zombie-list)
3843 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3844 ;; There may be more than one instance displayed.
3845 (while (gnus-group-goto-group group)
3846 (gnus-delete-line)))
3847 (gnus-make-hashtable-from-newsrc-alist))
3849 (gnus-group-position-point)
3850 (if (< (length out) 2) (car out) (nreverse out))))
3852 (defun gnus-group-yank-group (&optional arg)
3853 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3854 The numeric ARG specifies how many newsgroups are to be yanked. The
3855 name of the newsgroup yanked is returned, or (if several groups are
3856 yanked) a list of yanked groups is returned."
3858 (setq arg (or arg 1))
3859 (let (info group prev out)
3860 (while (>= (decf arg) 0)
3861 (when (not (setq info (pop gnus-list-of-killed-groups)))
3862 (error "No more newsgroups to yank"))
3863 (push (setq group (nth 1 info)) out)
3864 ;; Find which newsgroup to insert this one before - search
3865 ;; backward until something suitable is found. If there are no
3866 ;; other newsgroups in this buffer, just make this newsgroup the
3868 (setq prev (gnus-group-group-name))
3869 (gnus-group-change-level
3870 info (gnus-info-level (cdr info)) gnus-level-killed
3871 (and prev (gnus-group-entry prev))
3873 (gnus-group-insert-group-line-info group)
3875 `(when (gnus-group-goto-group ,group)
3876 (gnus-group-kill-group 1))))
3878 (gnus-group-position-point)
3879 (if (< (length out) 2) (car out) (nreverse out))))
3881 (defun gnus-group-kill-level (level)
3882 "Kill all groups that is on a certain LEVEL."
3883 (interactive "nKill all groups on level: ")
3885 ((= level gnus-level-zombie)
3886 (setq gnus-killed-list
3887 (nconc gnus-zombie-list gnus-killed-list))
3888 (setq gnus-zombie-list nil))
3889 ((and (< level gnus-level-zombie)
3891 (or gnus-expert-user
3894 "Do you really want to kill all groups on level %d? "
3896 (let* ((prev gnus-newsrc-alist)
3899 (if (= (gnus-info-level (car alist)) level)
3901 (push (gnus-info-group (car alist)) gnus-killed-list)
3902 (setcdr prev (cdr alist)))
3904 (setq alist (cdr alist)))
3905 (gnus-make-hashtable-from-newsrc-alist)
3906 (gnus-group-list-groups)))
3908 (error "Can't kill; invalid level: %d" level))))
3910 (defun gnus-group-list-all-groups (&optional arg)
3911 "List all newsgroups with level ARG or lower.
3912 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3913 unsubscribed groups."
3915 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3917 ;; Redefine this to list ALL killed groups if prefix arg used.
3918 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3919 (defun gnus-group-list-killed (&optional arg)
3920 "List all killed newsgroups in the group buffer.
3921 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3922 entail asking the server for the groups."
3924 ;; Find all possible killed newsgroups if arg.
3926 (gnus-get-killed-groups))
3927 (if (not gnus-killed-list)
3928 (gnus-message 6 "No killed groups")
3929 (let (gnus-group-list-mode)
3930 (funcall gnus-group-prepare-function
3931 gnus-level-killed t gnus-level-killed))
3932 (goto-char (point-min)))
3933 (gnus-group-position-point))
3935 (defun gnus-group-list-zombies ()
3936 "List all zombie newsgroups in the group buffer."
3938 (if (not gnus-zombie-list)
3939 (gnus-message 6 "No zombie groups")
3940 (let (gnus-group-list-mode)
3941 (funcall gnus-group-prepare-function
3942 gnus-level-zombie t gnus-level-zombie))
3943 (goto-char (point-min)))
3944 (gnus-group-position-point))
3946 (defun gnus-group-list-active ()
3947 "List all groups that are available from the server(s)."
3949 ;; First we make sure that we have really read the active file.
3950 (unless (gnus-read-active-file-p)
3951 (let ((gnus-read-active-file t)
3952 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3953 (gnus-read-active-file)))
3954 ;; Find all groups and sort them.
3962 (push (symbol-name sym) list)))
3966 (buffer-read-only nil)
3970 (setq group (pop groups))
3971 (gnus-add-text-properties
3972 (point) (prog1 (1+ (point))
3974 (gnus-group-decoded-name group)
3976 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3978 'gnus-level (inline (gnus-group-level group)))))
3979 (goto-char (point-min))))
3981 (defun gnus-activate-all-groups (level)
3982 "Activate absolutely all groups."
3983 (interactive (list gnus-level-unsubscribed))
3984 (let ((gnus-activate-level level)
3985 (gnus-activate-foreign-newsgroups level))
3986 (gnus-group-get-new-news)))
3988 (defun gnus-group-get-new-news (&optional arg)
3989 "Get newly arrived articles.
3990 If ARG is a number, it specifies which levels you are interested in
3991 re-scanning. If ARG is non-nil and not a number, this will force
3992 \"hard\" re-reading of the active files from all servers."
3995 (let ((gnus-inhibit-demon t)
3996 ;; Binding this variable will inhibit multiple fetchings
3997 ;; of the same mail source.
3998 (nnmail-fetched-sources (list t)))
3999 (gnus-run-hooks 'gnus-get-top-new-news-hook)
4000 (gnus-run-hooks 'gnus-get-new-news-hook)
4002 ;; Read any slave files.
4004 (gnus-master-read-slave-newsrc))
4006 ;; We might read in new NoCeM messages here.
4007 (when (and gnus-use-nocem
4008 (or (and (numberp gnus-use-nocem)
4010 (>= arg gnus-use-nocem))
4012 (gnus-nocem-scan-groups))
4014 (gnus-get-unread-articles arg)
4016 ;; If the user wants it, we scan for new groups.
4017 (when (eq gnus-check-new-newsgroups 'always)
4018 (gnus-find-new-newsgroups))
4020 (gnus-check-reasonable-setup)
4021 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
4022 (gnus-group-list-groups (and (numberp arg)
4023 (max (car gnus-group-list-mode) arg)))))
4025 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
4026 "Check for newly arrived news in the current group (and the N-1 next groups).
4027 The difference between N and the number of newsgroup checked is returned.
4028 If N is negative, this group and the N-1 previous groups will be checked.
4029 If DONT-SCAN is non-nil, scan non-activated groups as well."
4031 (let* ((groups (gnus-group-process-prefix n))
4032 (ret (if (numberp n) (- n (length groups)) 0))
4036 (gnus-inhibit-demon t)
4037 ;; Binding this variable will inhibit multiple fetchings
4038 ;; of the same mail source.
4039 (nnmail-fetched-sources (list t)))
4040 (gnus-run-hooks 'gnus-get-new-news-hook)
4041 (while (setq group (pop groups))
4042 (gnus-group-remove-mark group)
4043 ;; Bypass any previous denials from the server.
4044 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
4045 (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
4046 (let ((info (gnus-get-info group))
4047 (active (gnus-active group)))
4049 (gnus-request-update-info info method))
4050 (gnus-get-unread-articles-in-group info active)
4051 (unless (gnus-virtual-group-p group)
4052 (gnus-close-group group))
4054 (gnus-agent-save-group-info
4055 method (gnus-group-real-name group) active))
4056 (gnus-group-update-group group))
4057 (if (eq (gnus-server-status (gnus-find-method-for-group group))
4059 (gnus-error 3 "Server denied access")
4060 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
4063 (when gnus-goto-next-group-when-activating
4064 (gnus-group-next-unread-group 1 t))
4065 (gnus-summary-position-point)
4068 (defun gnus-group-fetch-faq (group &optional faq-dir)
4069 "Fetch the FAQ for the current group.
4070 If given a prefix argument, prompt for the FAQ dir
4074 (gnus-group-group-name)
4075 (when current-prefix-arg
4077 "FAQ dir: " (and (listp gnus-group-faq-directory)
4079 gnus-group-faq-directory))))))
4081 (error "No group name given"))
4082 (let ((dirs (or faq-dir gnus-group-faq-directory))
4084 (unless (listp dirs)
4085 (setq dirs (list dirs)))
4086 (while (and (not found)
4087 (setq dir (pop dirs)))
4088 (let ((name (gnus-group-real-name group)))
4089 (setq file (expand-file-name name dir)))
4090 (if (not (file-exists-p file))
4091 (gnus-message 1 "No such file: %s" file)
4092 (let ((enable-local-variables nil))
4096 (defun gnus-group-fetch-charter (group)
4097 "Fetch the charter for the current group.
4098 If given a prefix argument, prompt for a group."
4100 (list (or (when current-prefix-arg
4101 (gnus-group-completing-read "Group: "))
4102 (gnus-group-group-name)
4103 gnus-newsgroup-name)))
4105 (error "No group name given"))
4107 (condition-case nil (require 'url-http) (error nil))
4108 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
4110 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
4111 (setq hierarchy (match-string 1 name))
4112 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
4113 (if (fboundp 'url-http-file-exists-p)
4114 (url-http-file-exists-p (eval url))
4116 (browse-url (eval url))
4117 (setq url (concat "http://" hierarchy
4118 ".news-admin.org/charters/" name))
4119 (if (and (fboundp 'url-http-file-exists-p)
4120 (url-http-file-exists-p url))
4122 (gnus-group-fetch-control group))))))
4124 (defun gnus-group-fetch-control (group)
4125 "Fetch the archived control messages for the current group.
4126 If given a prefix argument, prompt for a group."
4128 (list (or (when current-prefix-arg
4129 (gnus-group-completing-read "Group: "))
4130 (gnus-group-group-name)
4131 gnus-newsgroup-name)))
4133 (error "No group name given"))
4134 (let ((name (gnus-group-real-name group))
4136 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
4137 (setq hierarchy (match-string 1 name))
4138 (if gnus-group-fetch-control-use-browse-url
4139 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
4140 hierarchy "/" name ".gz"))
4141 (let ((enable-local-variables nil))
4142 (gnus-group-read-ephemeral-group
4144 `(nndoc ,group (nndoc-address
4145 ,(find-file-noselect
4146 (concat "/ftp@ftp.isc.org:/usenet/control/"
4147 hierarchy "/" name ".gz")))
4148 (nndoc-article-type mbox)) t nil nil))))))
4150 (defun gnus-group-describe-group (force &optional group)
4151 "Display a description of the current newsgroup."
4152 (interactive (list current-prefix-arg (gnus-group-group-name)))
4153 (let* ((method (gnus-find-method-for-group group))
4154 (mname (gnus-group-prefixed-name "" method))
4157 gnus-description-hashtb)
4158 (gnus-sethash mname nil gnus-description-hashtb))
4160 (error "No group name given"))
4161 (when (or (and gnus-description-hashtb
4162 ;; We check whether this group's method has been
4163 ;; queried for a description file.
4164 (gnus-gethash mname gnus-description-hashtb))
4165 (setq desc (gnus-group-get-description group))
4166 (gnus-read-descriptions-file method))
4167 (gnus-message 1 "%s"
4168 (or desc (gnus-gethash group gnus-description-hashtb)
4169 "No description available")))))
4171 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4172 (defun gnus-group-describe-all-groups (&optional force)
4173 "Pop up a buffer with descriptions of all newsgroups."
4176 (setq gnus-description-hashtb nil))
4177 (when (not (or gnus-description-hashtb
4178 (gnus-read-all-descriptions-files)))
4179 (error "Couldn't request descriptions file"))
4180 (let ((buffer-read-only nil)
4186 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
4187 (insert (format " *: %-20s %s\n"
4188 (gnus-group-name-decode
4189 (symbol-name group) charset)
4190 (gnus-group-name-decode
4191 (symbol-value group) charset))))
4192 (gnus-add-text-properties
4193 b (1+ b) (list 'gnus-group group
4194 'gnus-unread t 'gnus-marked nil
4195 'gnus-level (1+ gnus-level-subscribed))))
4196 gnus-description-hashtb)
4197 (goto-char (point-min))
4198 (gnus-group-position-point)))
4200 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
4201 (defun gnus-group-apropos (regexp &optional search-description)
4202 "List all newsgroups that have names that match a regexp."
4203 (interactive "sGnus apropos (regexp): ")
4205 (obuf (current-buffer))
4207 ;; Go through all newsgroups that are known to Gnus.
4210 (and (symbol-name group)
4211 (string-match regexp (symbol-name group))
4212 (symbol-value group)
4213 (push (symbol-name group) groups)))
4215 ;; Also go through all descriptions that are known to Gnus.
4216 (when search-description
4219 (and (string-match regexp (symbol-value group))
4220 (push (symbol-name group) groups)))
4221 gnus-description-hashtb))
4223 (gnus-message 3 "No groups matched \"%s\"." regexp)
4224 ;; Print out all the groups.
4226 (pop-to-buffer "*Gnus Help*")
4227 (buffer-disable-undo)
4229 (setq groups (sort groups 'string<))
4231 ;; Groups may be entered twice into the list of groups.
4232 (when (not (string= (car groups) prev))
4233 (setq prev (car groups))
4234 (let ((charset (gnus-group-name-charset nil prev)))
4235 (insert (gnus-group-name-decode prev charset) "\n")
4236 (when (and gnus-description-hashtb
4237 (setq des (gnus-gethash (car groups)
4238 gnus-description-hashtb)))
4239 (insert " " (gnus-group-name-decode des charset) "\n"))))
4240 (setq groups (cdr groups)))
4241 (goto-char (point-min))))
4242 (pop-to-buffer obuf)))
4244 (defun gnus-group-description-apropos (regexp)
4245 "List all newsgroups that have names or descriptions that match REGEXP."
4246 (interactive "sGnus description apropos (regexp): ")
4247 (when (not (or gnus-description-hashtb
4248 (gnus-read-all-descriptions-files)))
4249 (error "Couldn't request descriptions file"))
4250 (gnus-group-apropos regexp t))
4252 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4253 (defun gnus-group-list-matching (level regexp &optional all lowest)
4254 "List all groups with unread articles that match REGEXP.
4255 If the prefix LEVEL is non-nil, it should be a number that says which
4256 level to cut off listing groups.
4257 If ALL, also list groups with no unread articles.
4258 If LOWEST, don't list groups with level lower than LOWEST.
4260 This command may read the active file."
4261 (interactive "P\nsList newsgroups matching: ")
4262 ;; First make sure active file has been read.
4264 (> (prefix-numeric-value level) gnus-level-killed))
4265 (gnus-get-killed-groups))
4266 (funcall gnus-group-prepare-function
4267 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
4268 (goto-char (point-min))
4269 (gnus-group-position-point))
4271 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4272 "List all groups that match REGEXP.
4273 If the prefix LEVEL is non-nil, it should be a number that says which
4274 level to cut off listing groups.
4275 If LOWEST, don't list groups with level lower than LOWEST."
4276 (interactive "P\nsList newsgroups matching: ")
4278 (setq level (prefix-numeric-value level)))
4279 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4281 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4282 (defun gnus-group-save-newsrc (&optional force)
4283 "Save the Gnus startup files.
4284 If FORCE, force saving whether it is necessary or not."
4286 (gnus-save-newsrc-file force))
4288 (defun gnus-group-restart (&optional arg)
4289 "Force Gnus to read the .newsrc file."
4291 (when (gnus-yes-or-no-p
4292 (format "Are you sure you want to restart Gnus? "))
4293 (gnus-save-newsrc-file)
4297 (defun gnus-group-read-init-file ()
4298 "Read the Gnus elisp init file."
4300 (gnus-read-init-file)
4301 (gnus-message 5 "Read %s" gnus-init-file))
4303 (defun gnus-group-check-bogus-groups (&optional silent)
4304 "Check bogus newsgroups.
4305 If given a prefix, don't ask for confirmation before removing a bogus
4308 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4309 (gnus-group-list-groups))
4311 (defun gnus-group-find-new-groups (&optional arg)
4312 "Search for new groups and add them.
4313 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
4314 With 1 C-u, use the `ask-server' method to query the server for new
4316 With 2 C-u's, use most complete method possible to query the server
4317 for new groups, and subscribe the new groups as zombies."
4319 (gnus-find-new-newsgroups (or arg 1))
4320 (gnus-group-list-groups))
4322 (defun gnus-group-edit-global-kill (&optional article group)
4323 "Edit the global kill file.
4324 If GROUP, edit that local kill file instead."
4326 (setq gnus-current-kill-article article)
4327 (gnus-kill-file-edit-file group)
4328 (gnus-message 6 "Editing a %s kill file (Type %s to exit)"
4329 (if group "local" "global")
4330 (substitute-command-keys "\\[gnus-kill-file-exit]")))
4332 (defun gnus-group-edit-local-kill (article group)
4333 "Edit a local kill file."
4334 (interactive (list nil (gnus-group-group-name)))
4335 (gnus-group-edit-global-kill article group))
4337 (defun gnus-group-force-update ()
4338 "Update `.newsrc' file."
4340 (gnus-save-newsrc-file))
4342 (defvar gnus-backlog-articles)
4344 (defun gnus-group-suspend ()
4345 "Suspend the current Gnus session.
4346 In fact, cleanup buffers except for group mode buffer.
4347 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4349 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4350 (gnus-offer-save-summaries)
4351 ;; Kill Gnus buffers except for group mode buffer.
4352 (let ((group-buf (get-buffer gnus-group-buffer)))
4353 (dolist (buf (gnus-buffers))
4354 (unless (or (eq buf group-buf)
4355 (eq buf gnus-dribble-buffer)
4356 (with-current-buffer buf
4357 (eq major-mode 'message-mode)))
4358 (gnus-kill-buffer buf)))
4359 (setq gnus-backlog-articles nil)
4360 (gnus-kill-gnus-frames)
4362 (bury-buffer group-buf)
4363 (delete-windows-on group-buf t))))
4365 (defun gnus-group-clear-dribble ()
4366 "Clear all information from the dribble buffer."
4368 (gnus-dribble-clear)
4369 (gnus-message 7 "Cleared dribble buffer"))
4371 (defun gnus-group-exit ()
4372 "Quit reading news after updating .newsrc.eld and .newsrc.
4373 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4376 (or noninteractive ;For gnus-batch-kill
4377 (not gnus-interactive-exit) ;Without confirmation
4379 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4380 (gnus-run-hooks 'gnus-exit-gnus-hook)
4381 ;; Offer to save data from non-quitted summary buffers.
4382 (gnus-offer-save-summaries)
4383 ;; Save the newsrc file(s).
4384 (gnus-save-newsrc-file)
4386 (gnus-close-backends)
4387 ;; Reset everything.
4389 ;; Allow the user to do things after cleaning up.
4390 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4392 (defun gnus-group-quit ()
4393 "Quit reading news without updating .newsrc.eld or .newsrc.
4394 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4396 (when (or noninteractive ;For gnus-batch-kill
4397 (zerop (buffer-size))
4398 (not (gnus-server-opened gnus-select-method))
4400 (not gnus-current-startup-file)
4402 (format "Quit reading news without saving %s? "
4403 (file-name-nondirectory gnus-current-startup-file))))
4404 (gnus-run-hooks 'gnus-exit-gnus-hook)
4405 (gnus-configure-windows 'group t)
4406 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4407 (not (zerop (with-current-buffer gnus-dribble-buffer
4410 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4412 (gnus-close-backends)
4414 (gnus-kill-buffer gnus-group-buffer)
4415 ;; Allow the user to do things after cleaning up.
4416 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4418 (defun gnus-group-describe-briefly ()
4419 "Give a one line description of the group mode commands."
4421 (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")))
4423 (defun gnus-group-browse-foreign-server (method)
4424 "Browse a foreign news server.
4425 If called interactively, this function will ask for a select method
4426 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4427 If not, METHOD should be a list where the first element is the method
4428 and the second element is the address."
4430 (list (let ((how (completing-read
4432 (append gnus-valid-select-methods gnus-server-alist)
4433 nil t (cons "nntp" 0) 'gnus-method-history)))
4434 ;; We either got a back end name or a virtual server name.
4435 ;; If the first, we also need an address.
4436 (if (assoc how gnus-valid-select-methods)
4438 ;; Suggested by mapjph@bath.ac.uk.
4441 (mapcar 'list gnus-secondary-servers)))
4442 ;; We got a server name.
4444 (gnus-browse-foreign-server method))
4446 (defun gnus-group-set-info (info &optional method-only-group part)
4447 (when (or info part)
4448 (let* ((entry (gnus-group-entry
4449 (or method-only-group (gnus-info-group info))))
4451 (info (if method-only-group (nth 2 entry) info))
4453 (when method-only-group
4455 (error "Trying to change non-existent group %s" method-only-group))
4456 ;; We have received parts of the actual group info - either the
4457 ;; select method or the group parameters. We first check
4458 ;; whether we have to extend the info, and if so, do that.
4459 (let ((len (length info))
4460 (total (if (eq part 'method) 5 6)))
4462 (setcdr (nthcdr (1- len) info)
4463 (make-list (- total len) nil)))
4464 ;; Then we enter the new info.
4465 (setcar (nthcdr (1- total) info) part-info)))
4467 ;; This is a new group, so we just create it.
4468 (with-current-buffer gnus-group-buffer
4469 (setq method (gnus-info-method info))
4470 (when (gnus-server-equal method "native")
4472 (with-current-buffer gnus-group-buffer
4474 ;; It's a foreign group...
4475 (gnus-group-make-group
4476 (gnus-group-real-name (gnus-info-group info))
4477 (if (stringp method) method
4478 (prin1-to-string (car method)))
4480 (nth 1 (gnus-info-method info)))
4482 ;; It's a native group.
4483 (gnus-group-make-group (gnus-info-group info) nil nil nil t)))
4484 (gnus-message 6 "Note: New group created")
4486 (gnus-group-entry (gnus-group-prefixed-name
4487 (gnus-group-real-name (gnus-info-group info))
4488 (or (gnus-info-method info) gnus-select-method))))))
4489 ;; Whether it was a new group or not, we now have the entry, so we
4490 ;; can do the update.
4493 (setcar (nthcdr 2 entry) info)
4494 (when (and (not (eq (car entry) t))
4495 (gnus-active (gnus-info-group info)))
4496 (setcar entry (length
4497 (gnus-list-of-unread-articles (car info))))))
4498 (error "No such group: %s" (gnus-info-group info))))))
4500 (defun gnus-group-set-method-info (group select-method)
4501 (gnus-group-set-info select-method group 'method))
4503 (defun gnus-group-set-params-info (group params)
4504 (gnus-group-set-info params group 'params))
4506 (defun gnus-add-marked-articles (group type articles &optional info force)
4507 ;; Add ARTICLES of TYPE to the info of GROUP.
4508 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4509 ;; add, but replace marked articles of TYPE with ARTICLES.
4510 (let ((info (or info (gnus-get-info group)))
4513 (and (not (setq marked (nthcdr 3 info)))
4515 (setcdr (nthcdr 2 info)
4516 (list (list (cons type (gnus-compress-sequence
4518 (and (not (setq m (assq type (car marked))))
4521 (cons (cons type (gnus-compress-sequence articles t) )
4525 (setcar (nthcdr 3 info)
4526 (gnus-delete-alist type (car marked)))
4527 (setcdr m (gnus-compress-sequence articles t)))
4528 (setcdr m (gnus-compress-sequence
4529 (sort (nconc (gnus-uncompress-range (cdr m))
4530 (copy-sequence articles)) '<) t))))))
4532 (defun gnus-add-mark (group mark article)
4533 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4534 (let ((buffer (gnus-summary-buffer-name group)))
4535 (if (gnus-buffer-live-p buffer)
4536 (with-current-buffer (get-buffer buffer)
4537 (gnus-summary-add-mark article mark))
4538 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4542 ;;; Group timestamps
4545 (defun gnus-group-set-timestamp ()
4546 "Change the timestamp of the current group to the current time.
4547 This function can be used in hooks like `gnus-select-group-hook'
4548 or `gnus-group-catchup-group-hook'."
4549 (when gnus-newsgroup-name
4550 (let ((time (current-time)))
4551 (setcdr (cdr time) nil)
4552 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4554 (defsubst gnus-group-timestamp (group)
4555 "Return the timestamp for GROUP."
4556 (gnus-group-get-parameter group 'timestamp t))
4558 (defun gnus-group-timestamp-delta (group)
4559 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4560 (let* ((time (or (gnus-group-timestamp group)
4562 (delta (subtract-time (current-time) time)))
4563 (+ (* (nth 0 delta) 65536.0)
4566 (defun gnus-group-timestamp-string (group)
4567 "Return a string of the timestamp for GROUP."
4568 (let ((time (gnus-group-timestamp group)))
4571 (gnus-time-iso8601 time))))
4573 (defun gnus-group-list-cached (level &optional lowest)
4574 "List all groups with cached articles.
4575 If the prefix LEVEL is non-nil, it should be a number that says which
4576 level to cut off listing groups.
4577 If LOWEST, don't list groups with level lower than LOWEST.
4579 This command may read the active file."
4582 (setq level (prefix-numeric-value level)))
4583 (when (or (not level) (>= level gnus-level-zombie))
4585 (funcall gnus-group-prepare-function
4586 (or level gnus-level-subscribed)
4588 (let ((marks (gnus-info-marks info)))
4589 (assq 'cache marks)))
4592 (or (gnus-gethash group
4593 gnus-cache-active-hashtb)
4594 ;; Cache active file might use "."
4597 (mapconcat 'identity
4598 (split-string group ":")
4600 gnus-cache-active-hashtb))))
4601 (goto-char (point-min))
4602 (gnus-group-position-point))
4604 (defun gnus-group-list-dormant (level &optional lowest)
4605 "List all groups with dormant articles.
4606 If the prefix LEVEL is non-nil, it should be a number that says which
4607 level to cut off listing groups.
4608 If LOWEST, don't list groups with level lower than LOWEST.
4610 This command may read the active file."
4613 (setq level (prefix-numeric-value level)))
4614 (when (or (not level) (>= level gnus-level-zombie))
4616 (funcall gnus-group-prepare-function
4617 (or level gnus-level-subscribed)
4619 (let ((marks (gnus-info-marks info)))
4620 (assq 'dormant marks)))
4623 (goto-char (point-min))
4624 (gnus-group-position-point))
4626 (defun gnus-group-listed-groups ()
4627 "Return a list of listed groups."
4629 (goto-char (point-min))
4630 (while (setq point (text-property-not-all (point) (point-max)
4633 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4637 (defun gnus-group-list-plus (&optional args)
4638 "List groups plus the current selection."
4640 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4641 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4643 (push last-command-event unread-command-events)
4644 (if (featurep 'xemacs)
4645 (push (make-event 'key-press '(key ?A)) unread-command-events)
4646 (push ?A unread-command-events))
4647 (let (gnus-pick-mode keys)
4648 (setq keys (if (featurep 'xemacs)
4649 (events-to-keys (read-key-sequence nil))
4650 (read-key-sequence nil)))
4651 (setq func (lookup-key (current-local-map) keys)))
4655 (call-interactively func))))
4657 (defun gnus-group-list-flush (&optional args)
4658 "Flush groups from the current selection."
4660 (let ((gnus-group-list-option 'flush))
4661 (gnus-group-list-plus args)))
4663 (defun gnus-group-list-limit (&optional args)
4664 "List groups limited within the current selection."
4666 (let ((gnus-group-list-option 'limit))
4667 (gnus-group-list-plus args)))
4669 (defun gnus-group-mark-article-read (group article)
4670 "Mark ARTICLE read."
4671 (let ((buffer (gnus-summary-buffer-name group))
4672 (mark gnus-read-mark)
4674 (if (get-buffer buffer)
4675 (with-current-buffer buffer
4676 (setq active gnus-newsgroup-active)
4677 (gnus-activate-group group)
4678 (when gnus-newsgroup-prepared
4679 (when (and gnus-newsgroup-auto-expire
4680 (memq mark gnus-auto-expirable-marks))
4681 (setq mark gnus-expirable-mark))
4682 (setq mark (gnus-request-update-mark
4683 group article mark))
4684 (gnus-mark-article-as-read article mark)
4685 (setq gnus-newsgroup-active (gnus-active group))
4687 (setq n (1+ (cdr active)))
4688 (while (<= n (cdr gnus-newsgroup-active))
4689 (unless (eq n article)
4690 (push n gnus-newsgroup-unselected))
4692 (setq gnus-newsgroup-unselected
4693 (nreverse gnus-newsgroup-unselected)))))
4694 (gnus-activate-group group)
4695 (gnus-group-make-articles-read group (list article))
4696 (when (gnus-group-auto-expirable-p group)
4697 (gnus-add-marked-articles
4698 group 'expire (list article))))))
4702 ;;; Group compaction. -- dvl
4705 (defun gnus-group-compact-group (group)
4706 "Compact the current group.
4707 Compaction means removing gaps between article numbers. Hence, this
4708 operation is only meaningful for back ends using one file per article
4711 Note: currently only implemented in nnml."
4712 (interactive (list (gnus-group-group-name)))
4714 (error "No group to compact"))
4715 (unless (gnus-check-backend-function 'request-compact-group group)
4716 (error "This back end does not support group compaction"))
4717 (let ((group-decoded (gnus-group-decoded-name group)))
4719 Compacting group %s... (this may take a long time)"
4722 (if (not (gnus-request-compact-group group))
4723 (gnus-error 3 "Couldn't compact group %s" group-decoded)
4724 (gnus-message 6 "Compacting group %s...done" group-decoded)
4726 ;; Invalidate the "original article" buffer which might be out of date.
4727 ;; #### NOTE: Yes, this might be a bit rude, but since compaction
4728 ;; #### will not happen very often, I think this is acceptable.
4729 (let ((original (get-buffer gnus-original-article-buffer)))
4730 (and original (gnus-kill-buffer original)))
4731 ;; Update the group line to reflect new information (art number etc).
4732 (gnus-group-update-group-line))))
4734 (provide 'gnus-group)
4736 ;;; gnus-group.el ends here