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 newsp: Whether it's a news group or not
431 level: The level of the group.
432 score: The score of the group.
433 ticked: The number of ticked articles."
434 :group 'gnus-group-icons
435 :type '(repeat (cons (sexp :tag "Form") file)))
436 (put 'gnus-group-icon-list 'risky-local-variable t)
438 (defcustom gnus-group-name-charset-method-alist nil
439 "Alist of method and the charset for group names.
442 (((nntp \"news.com.cn\") . cn-gb-2312))"
445 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
447 (defcustom gnus-group-name-charset-group-alist
448 (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
449 (mm-coding-system-p 'utf-8))
452 "Alist of group regexp and the charset for group names.
455 ((\"\\.com\\.cn:\" . cn-gb-2312))"
457 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
459 (defcustom gnus-group-jump-to-group-prompt nil
460 "Default prompt for `gnus-group-jump-to-group'.
462 If non-nil, the value should be a string or an alist. If it is a string,
463 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
464 nnml:\" in the minibuffer prompt.
466 If it is an alist, it must consist of \(NUMBER . PROMPT\) pairs, for example:
467 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
468 used when no prefix argument is given to `gnus-group-jump-to-group'."
470 :group 'gnus-group-various
471 :type '(choice (string :tag "Prompt string")
472 (const :tag "Empty" nil)
473 (repeat (cons (integer :tag "Argument")
474 (string :tag "Prompt string")))))
476 (defvar gnus-group-listing-limit 1000
477 "*A limit of the number of groups when listing.
478 If the number of groups is larger than the limit, list them in a
481 ;;; Internal variables
483 (defvar gnus-group-is-exiting-p nil)
484 (defvar gnus-group-is-exiting-without-update-p nil)
485 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
486 "Function for sorting the group buffer.")
488 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
489 "Function for sorting the selected groups in the group buffer.")
491 (defvar gnus-group-indentation-function nil)
492 (defvar gnus-goto-missing-group-function nil)
493 (defvar gnus-group-update-group-function nil)
494 (defvar gnus-group-goto-next-group-function nil
495 "Function to override finding the next group after listing groups.")
497 (defvar gnus-group-edit-buffer nil)
499 (defvar gnus-group-line-format-alist
500 `((?M gnus-tmp-marked-mark ?c)
501 (?S gnus-tmp-subscribed ?c)
502 (?L gnus-tmp-level ?d)
503 (?N (cond ((eq number t) "*" )
507 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
508 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
510 (?R gnus-tmp-number-of-read ?s)
511 (?U (if (gnus-active gnus-tmp-group)
512 (gnus-number-of-unseen-articles-in-group gnus-tmp-group)
515 (?t gnus-tmp-number-total ?d)
516 (?y gnus-tmp-number-of-unread ?s)
517 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
518 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
519 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
520 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
521 (?g (if (boundp 'gnus-tmp-decoded-group)
522 gnus-tmp-decoded-group
525 (?G gnus-tmp-qualified-group ?s)
526 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
527 gnus-tmp-decoded-group
530 (?C gnus-tmp-comment ?s)
531 (?D gnus-tmp-newsgroup-description ?s)
532 (?o gnus-tmp-moderated ?c)
533 (?O gnus-tmp-moderated-string ?s)
534 (?p gnus-tmp-process-marked ?c)
535 (?s gnus-tmp-news-server ?s)
536 (?n ,(if (featurep 'xemacs)
537 '(symbol-name gnus-tmp-news-method)
538 'gnus-tmp-news-method)
540 (?P gnus-group-indentation ?s)
541 (?E gnus-tmp-group-icon ?s)
542 (?B gnus-tmp-summary-live ?c)
543 (?z gnus-tmp-news-method-string ?s)
544 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
545 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
546 (?u gnus-tmp-user-defined ?s)
547 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
550 (defvar gnus-group-mode-line-format-alist
551 `((?S gnus-tmp-news-server ?s)
552 (?M gnus-tmp-news-method ?s)
553 (?u gnus-tmp-user-defined ?s)
554 (?: gnus-tmp-colon ?s)))
556 (defvar gnus-topic-topology nil
557 "The complete topic hierarchy.")
559 (defvar gnus-topic-alist nil
560 "The complete topic-group alist.")
562 (defvar gnus-group-marked nil)
564 (defvar gnus-group-list-mode nil)
567 (defvar gnus-group-icon-cache nil)
569 (defvar gnus-group-listed-groups nil)
570 (defvar gnus-group-list-option nil)
576 (put 'gnus-group-mode 'mode-class 'special)
578 (gnus-define-keys gnus-group-mode-map
579 " " gnus-group-read-group
580 "=" gnus-group-select-group
581 "\r" gnus-group-select-group
582 "\M-\r" gnus-group-quick-select-group
583 "\M- " gnus-group-visible-select-group
584 [(meta control return)] gnus-group-select-group-ephemerally
585 "j" gnus-group-jump-to-group
586 "n" gnus-group-next-unread-group
587 "p" gnus-group-prev-unread-group
588 "\177" gnus-group-prev-unread-group
589 [delete] gnus-group-prev-unread-group
590 [backspace] gnus-group-prev-unread-group
591 "N" gnus-group-next-group
592 "P" gnus-group-prev-group
593 "\M-n" gnus-group-next-unread-group-same-level
594 "\M-p" gnus-group-prev-unread-group-same-level
595 "," gnus-group-best-unread-group
596 "." gnus-group-first-unread-group
597 "u" gnus-group-unsubscribe-current-group
598 "U" gnus-group-unsubscribe-group
599 "c" gnus-group-catchup-current
600 "C" gnus-group-catchup-current-all
601 "\M-c" gnus-group-clear-data
602 "l" gnus-group-list-groups
603 "L" gnus-group-list-all-groups
606 "g" gnus-group-get-new-news
607 "\M-g" gnus-group-get-new-news-this-group
608 "R" gnus-group-restart
609 "r" gnus-group-read-init-file
610 "B" gnus-group-browse-foreign-server
611 "b" gnus-group-check-bogus-groups
612 "F" gnus-group-find-new-groups
613 "\C-c\C-d" gnus-group-describe-group
614 "\M-d" gnus-group-describe-all-groups
615 "\C-c\C-a" gnus-group-apropos
616 "\C-c\M-\C-a" gnus-group-description-apropos
617 "a" gnus-group-post-news
618 "\ek" gnus-group-edit-local-kill
619 "\eK" gnus-group-edit-global-kill
620 "\C-k" gnus-group-kill-group
621 "\C-y" gnus-group-yank-group
622 "\C-w" gnus-group-kill-region
623 "\C-x\C-t" gnus-group-transpose-groups
624 "\C-c\C-l" gnus-group-list-killed
625 "\C-c\C-x" gnus-group-expire-articles
626 "\C-c\M-\C-x" gnus-group-expire-all-groups
628 "s" gnus-group-save-newsrc
629 "z" gnus-group-suspend
632 "?" gnus-group-describe-briefly
633 "\C-c\C-i" gnus-info-find-node
634 "\M-e" gnus-group-edit-group-method
635 "^" gnus-group-enter-server-mode
636 gnus-mouse-2 gnus-mouse-pick-group
637 [follow-link] mouse-face
638 "<" beginning-of-buffer
641 "\C-c\C-s" gnus-group-sort-groups
643 "\C-c\M-g" gnus-activate-all-groups
644 "\M-&" gnus-group-universal-argument
645 "#" gnus-group-mark-group
646 "\M-#" gnus-group-unmark-group)
648 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
649 "m" gnus-group-mark-group
650 "u" gnus-group-unmark-group
651 "w" gnus-group-mark-region
652 "b" gnus-group-mark-buffer
653 "r" gnus-group-mark-regexp
654 "U" gnus-group-unmark-all-groups)
656 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
657 "u" gnus-sieve-update
658 "g" gnus-sieve-generate)
660 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
661 "d" gnus-group-make-directory-group
662 "h" gnus-group-make-help-group
663 "u" gnus-group-make-useful-group
664 "a" gnus-group-make-archive-group
665 "l" gnus-group-nnimap-edit-acl
666 "m" gnus-group-make-group
667 "E" gnus-group-edit-group
668 "e" gnus-group-edit-group-method
669 "p" gnus-group-edit-group-parameters
670 "v" gnus-group-add-to-virtual
671 "V" gnus-group-make-empty-virtual
672 "D" gnus-group-enter-directory
673 "f" gnus-group-make-doc-group
674 "w" gnus-group-make-web-group
675 "M" gnus-group-read-ephemeral-group
676 "r" gnus-group-rename-group
677 "R" gnus-group-make-rss-group
678 "c" gnus-group-customize
679 "z" gnus-group-compact-group
680 "x" gnus-group-expunge-group
681 "\177" gnus-group-delete-group
682 [delete] gnus-group-delete-group)
684 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
685 "s" gnus-group-sort-groups
686 "a" gnus-group-sort-groups-by-alphabet
687 "u" gnus-group-sort-groups-by-unread
688 "l" gnus-group-sort-groups-by-level
689 "v" gnus-group-sort-groups-by-score
690 "r" gnus-group-sort-groups-by-rank
691 "m" gnus-group-sort-groups-by-method
692 "n" gnus-group-sort-groups-by-real-name)
694 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
695 "s" gnus-group-sort-selected-groups
696 "a" gnus-group-sort-selected-groups-by-alphabet
697 "u" gnus-group-sort-selected-groups-by-unread
698 "l" gnus-group-sort-selected-groups-by-level
699 "v" gnus-group-sort-selected-groups-by-score
700 "r" gnus-group-sort-selected-groups-by-rank
701 "m" gnus-group-sort-selected-groups-by-method
702 "n" gnus-group-sort-selected-groups-by-real-name)
704 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
705 "k" gnus-group-list-killed
706 "z" gnus-group-list-zombies
707 "s" gnus-group-list-groups
708 "u" gnus-group-list-all-groups
709 "A" gnus-group-list-active
710 "a" gnus-group-apropos
711 "d" gnus-group-description-apropos
712 "m" gnus-group-list-matching
713 "M" gnus-group-list-all-matching
714 "l" gnus-group-list-level
715 "c" gnus-group-list-cached
716 "?" gnus-group-list-dormant)
718 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
719 "k" gnus-group-list-limit
720 "z" gnus-group-list-limit
721 "s" gnus-group-list-limit
722 "u" gnus-group-list-limit
723 "A" gnus-group-list-limit
724 "m" gnus-group-list-limit
725 "M" gnus-group-list-limit
726 "l" gnus-group-list-limit
727 "c" gnus-group-list-limit
728 "?" gnus-group-list-limit)
730 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
731 "k" gnus-group-list-flush
732 "z" gnus-group-list-flush
733 "s" gnus-group-list-flush
734 "u" gnus-group-list-flush
735 "A" gnus-group-list-flush
736 "m" gnus-group-list-flush
737 "M" gnus-group-list-flush
738 "l" gnus-group-list-flush
739 "c" gnus-group-list-flush
740 "?" gnus-group-list-flush)
742 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
743 "k" gnus-group-list-plus
744 "z" gnus-group-list-plus
745 "s" gnus-group-list-plus
746 "u" gnus-group-list-plus
747 "A" gnus-group-list-plus
748 "m" gnus-group-list-plus
749 "M" gnus-group-list-plus
750 "l" gnus-group-list-plus
751 "c" gnus-group-list-plus
752 "?" gnus-group-list-plus)
754 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
755 "f" gnus-score-flush-cache
756 "e" gnus-score-edit-all-score)
758 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
759 "c" gnus-group-fetch-charter
760 "C" gnus-group-fetch-control
761 "d" gnus-group-describe-group
762 "f" gnus-group-fetch-faq
765 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
766 "l" gnus-group-set-current-level
767 "t" gnus-group-unsubscribe-current-group
768 "s" gnus-group-unsubscribe-group
769 "k" gnus-group-kill-group
770 "y" gnus-group-yank-group
771 "w" gnus-group-kill-region
772 "\C-k" gnus-group-kill-level
773 "z" gnus-group-kill-all-zombies)
775 (defun gnus-topic-mode-p ()
776 "Return non-nil in `gnus-topic-mode'."
777 (and (boundp 'gnus-topic-mode)
778 (symbol-value 'gnus-topic-mode)))
780 (defun gnus-group-make-menu-bar ()
781 (gnus-turn-off-edit-menu 'group)
782 (unless (boundp 'gnus-group-reading-menu)
785 gnus-group-reading-menu gnus-group-mode-map ""
787 ["Read" gnus-group-read-group
788 :included (not (gnus-topic-mode-p))
789 :active (gnus-group-group-name)]
790 ["Read " gnus-topic-read-group
791 :included (gnus-topic-mode-p)]
792 ["Select" gnus-group-select-group
793 :included (not (gnus-topic-mode-p))
794 :active (gnus-group-group-name)]
795 ["Select " gnus-topic-select-group
796 :included (gnus-topic-mode-p)]
797 ["See old articles" (gnus-group-select-group 'all)
798 :keys "C-u SPC" :active (gnus-group-group-name)]
799 ["Catch up" gnus-group-catchup-current
800 :included (not (gnus-topic-mode-p))
801 :active (gnus-group-group-name)
802 ,@(if (featurep 'xemacs) nil
803 '(:help "Mark unread articles in the current group as read"))]
804 ["Catch up " gnus-topic-catchup-articles
805 :included (gnus-topic-mode-p)
806 ,@(if (featurep 'xemacs) nil
807 '(:help "Mark unread articles in the current group or topic as read"))]
808 ["Catch up all articles" gnus-group-catchup-current-all
809 (gnus-group-group-name)]
810 ["Check for new articles" gnus-group-get-new-news-this-group
811 :included (not (gnus-topic-mode-p))
812 :active (gnus-group-group-name)
813 ,@(if (featurep 'xemacs) nil
814 '(:help "Check for new messages in current group"))]
815 ["Check for new articles " gnus-topic-get-new-news-this-topic
816 :included (gnus-topic-mode-p)
817 ,@(if (featurep 'xemacs) nil
818 '(:help "Check for new messages in current group or topic"))]
819 ["Toggle subscription" gnus-group-unsubscribe-current-group
820 (gnus-group-group-name)]
821 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
822 ,@(if (featurep 'xemacs) nil
823 '(:help "Kill (remove) current group"))]
824 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
825 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
826 ,@(if (featurep 'xemacs) nil
827 '(:help "Display description of the current group"))]
828 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
829 ["Fetch charter" gnus-group-fetch-charter
830 :active (gnus-group-group-name)
831 ,@(if (featurep 'xemacs) nil
832 '(:help "Display the charter of the current group"))]
833 ["Fetch control message" gnus-group-fetch-control
834 :active (gnus-group-group-name)
835 ,@(if (featurep 'xemacs) nil
836 '(:help "Display the archived control message for the current group"))]
837 ;; Actually one should check, if any of the marked groups gives t for
838 ;; (gnus-check-backend-function 'request-expire-articles ...)
839 ["Expire articles" gnus-group-expire-articles
840 :included (not (gnus-topic-mode-p))
841 :active (or (and (gnus-group-group-name)
842 (gnus-check-backend-function
843 'request-expire-articles
844 (gnus-group-group-name))) gnus-group-marked)]
845 ["Expire articles " gnus-topic-expire-articles
846 :included (gnus-topic-mode-p)]
847 ["Set group level..." gnus-group-set-current-level
848 (gnus-group-group-name)]
849 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
850 ["Customize" gnus-group-customize (gnus-group-group-name)]
851 ["Compact" gnus-group-compact-group
852 :active (gnus-group-group-name)]
854 ["Parameters" gnus-group-edit-group-parameters
855 :included (not (gnus-topic-mode-p))
856 :active (gnus-group-group-name)]
857 ["Parameters " gnus-topic-edit-parameters
858 :included (gnus-topic-mode-p)]
859 ["Select method" gnus-group-edit-group-method
860 (gnus-group-group-name)]
861 ["Info" gnus-group-edit-group (gnus-group-group-name)]
862 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
863 ["Global kill file" gnus-group-edit-global-kill t])))
866 gnus-group-group-menu gnus-group-mode-map ""
869 ["List unread subscribed groups" gnus-group-list-groups t]
870 ["List (un)subscribed groups" gnus-group-list-all-groups t]
871 ["List killed groups" gnus-group-list-killed gnus-killed-list]
872 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
873 ["List level..." gnus-group-list-level t]
874 ["Describe all groups" gnus-group-describe-all-groups t]
875 ["Group apropos..." gnus-group-apropos t]
876 ["Group and description apropos..." gnus-group-description-apropos t]
877 ["List groups matching..." gnus-group-list-matching t]
878 ["List all groups matching..." gnus-group-list-all-matching t]
879 ["List active file" gnus-group-list-active t]
880 ["List groups with cached" gnus-group-list-cached t]
881 ["List groups with dormant" gnus-group-list-dormant t])
883 ["Default sort" gnus-group-sort-groups t]
884 ["Sort by method" gnus-group-sort-groups-by-method t]
885 ["Sort by rank" gnus-group-sort-groups-by-rank t]
886 ["Sort by score" gnus-group-sort-groups-by-score t]
887 ["Sort by level" gnus-group-sort-groups-by-level t]
888 ["Sort by unread" gnus-group-sort-groups-by-unread t]
889 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
890 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
891 ("Sort process/prefixed"
892 ["Default sort" gnus-group-sort-selected-groups
893 (not (gnus-topic-mode-p))]
894 ["Sort by method" gnus-group-sort-selected-groups-by-method
895 (not (gnus-topic-mode-p))]
896 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
897 (not (gnus-topic-mode-p))]
898 ["Sort by score" gnus-group-sort-selected-groups-by-score
899 (not (gnus-topic-mode-p))]
900 ["Sort by level" gnus-group-sort-selected-groups-by-level
901 (not (gnus-topic-mode-p))]
902 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
903 (not (gnus-topic-mode-p))]
904 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
905 (not (gnus-topic-mode-p))]
906 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
907 (not (gnus-topic-mode-p))])
909 ["Mark group" gnus-group-mark-group
910 (and (gnus-group-group-name)
911 (not (memq (gnus-group-group-name) gnus-group-marked)))]
912 ["Unmark group" gnus-group-unmark-group
913 (and (gnus-group-group-name)
914 (memq (gnus-group-group-name) gnus-group-marked))]
915 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
916 ["Mark regexp..." gnus-group-mark-regexp t]
917 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
918 ["Mark buffer" gnus-group-mark-buffer t]
919 ["Execute command" gnus-group-universal-argument
920 (or gnus-group-marked (gnus-group-group-name))])
922 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
923 ["Kill all newsgroups in region" gnus-group-kill-region
924 :active (gnus-mark-active-p)]
925 ["Kill all zombie groups" gnus-group-kill-all-zombies
927 ["Kill all groups on level..." gnus-group-kill-level t])
929 ["Make a foreign group..." gnus-group-make-group t]
930 ["Add a directory group..." gnus-group-make-directory-group t]
931 ["Add the help group" gnus-group-make-help-group t]
932 ["Add the archive group" gnus-group-make-archive-group t]
933 ["Make a doc group..." gnus-group-make-doc-group t]
934 ["Make a web group..." gnus-group-make-web-group t]
935 ["Make a virtual group..." gnus-group-make-empty-virtual t]
936 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
937 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
938 ["Make an RSS group..." gnus-group-make-rss-group t]
939 ["Rename group..." gnus-group-rename-group
940 (gnus-check-backend-function
941 'request-rename-group (gnus-group-group-name))]
942 ["Delete group" gnus-group-delete-group
943 (gnus-check-backend-function
944 'request-delete-group (gnus-group-group-name))])
946 ["Next" gnus-group-next-group t]
947 ["Previous" gnus-group-prev-group t]
948 ["Next unread" gnus-group-next-unread-group t]
949 ["Previous unread" gnus-group-prev-unread-group t]
950 ["Next unread same level" gnus-group-next-unread-group-same-level t]
951 ["Previous unread same level"
952 gnus-group-prev-unread-group-same-level t]
953 ["Jump to group..." gnus-group-jump-to-group t]
954 ["First unread group" gnus-group-first-unread-group t]
955 ["Best unread group" gnus-group-best-unread-group t])
957 ["Generate" gnus-sieve-generate t]
958 ["Generate and update" gnus-sieve-update t])
959 ["Delete bogus groups" gnus-group-check-bogus-groups t]
960 ["Find new newsgroups" gnus-group-find-new-groups t]
961 ["Transpose" gnus-group-transpose-groups
962 (gnus-group-group-name)]
963 ["Read a directory as a group..." gnus-group-enter-directory t]))
966 gnus-group-misc-menu gnus-group-mode-map ""
968 ["Send a mail" gnus-group-mail t]
969 ["Send a message (mail or news)" gnus-group-post-news t]
970 ["Create a local message" gnus-group-news t]
971 ["Check for new news" gnus-group-get-new-news
972 ,@(if (featurep 'xemacs) '(t)
973 '(:help "Get newly arrived articles"))
975 ["Send queued messages" gnus-delay-send-queue
976 ,@(if (featurep 'xemacs) '(t)
977 '(:help "Send all messages that are scheduled to be sent now"))
979 ["Activate all groups" gnus-activate-all-groups t]
980 ["Restart Gnus" gnus-group-restart t]
981 ["Read init file" gnus-group-read-init-file t]
982 ["Browse foreign server..." gnus-group-browse-foreign-server t]
983 ["Enter server buffer" gnus-group-enter-server-mode t]
984 ["Expire all expirable articles" gnus-group-expire-all-groups t]
985 ["Gnus version" gnus-version t]
986 ["Save .newsrc files" gnus-group-save-newsrc t]
987 ["Suspend Gnus" gnus-group-suspend t]
988 ["Clear dribble buffer" gnus-group-clear-dribble t]
989 ["Read manual" gnus-info-find-node t]
990 ["Flush score cache" gnus-score-flush-cache t]
991 ["Toggle topics" gnus-topic-mode t]
992 ["Send a bug report" gnus-bug t]
993 ["Exit from Gnus" gnus-group-exit
994 ,@(if (featurep 'xemacs) '(t)
995 '(:help "Quit reading news"))]
996 ["Exit without saving" gnus-group-quit t]))
998 (gnus-run-hooks 'gnus-group-menu-hook)))
1001 (defvar gnus-group-tool-bar-map nil)
1003 (defun gnus-group-tool-bar-update (&optional symbol value)
1004 "Update group buffer toolbar.
1005 Setter function for custom variables."
1007 (set-default symbol value))
1008 ;; (setq-default gnus-group-tool-bar-map nil)
1009 ;; (use-local-map gnus-group-mode-map)
1010 (when (gnus-alive-p)
1011 (with-current-buffer gnus-group-buffer
1012 (gnus-group-make-tool-bar t))))
1014 (defcustom gnus-group-tool-bar (if (eq gmm-tool-bar-style 'gnome)
1015 'gnus-group-tool-bar-gnome
1016 'gnus-group-tool-bar-retro)
1017 "Specifies the Gnus group tool bar.
1019 It can be either a list or a symbol refering to a list. See
1020 `gmm-tool-bar-from-list' for the format of the list. The
1021 default key map is `gnus-group-mode-map'.
1023 Pre-defined symbols include `gnus-group-tool-bar-gnome' and
1024 `gnus-group-tool-bar-retro'."
1025 :type '(choice (const :tag "GNOME style" gnus-group-tool-bar-gnome)
1026 (const :tag "Retro look" gnus-group-tool-bar-retro)
1027 (repeat :tag "User defined list" gmm-tool-bar-item)
1029 :version "23.1" ;; No Gnus
1030 :initialize 'custom-initialize-default
1031 :set 'gnus-group-tool-bar-update
1034 (defcustom gnus-group-tool-bar-gnome
1035 '((gnus-group-post-news "mail/compose")
1036 ;; Some useful agent icons? I don't use the agent so agent users should
1037 ;; suggest useful commands:
1038 (gnus-agent-toggle-plugged "disconnect" t
1039 :help "Gnus is currently unplugged. Click to work online."
1040 :visible (and gnus-agent (not gnus-plugged)))
1041 (gnus-agent-toggle-plugged "connect" t
1042 :help "Gnus is currently plugged. Click to work offline."
1043 :visible (and gnus-agent gnus-plugged))
1044 ;; FIXME: gnus-agent-toggle-plugged (in gnus-agent-group-make-menu-bar)
1045 ;; should have a better help text.
1046 (gnus-group-send-queue "mail/outbox" t
1047 :visible (and gnus-agent gnus-plugged)
1048 :help "Send articles from the queue group")
1049 (gnus-group-get-new-news "mail/inbox" nil
1050 :visible (or (not gnus-agent)
1052 ;; FIXME: gnus-*-read-group should have a better help text.
1053 (gnus-topic-read-group "open" nil
1054 :visible (and (boundp 'gnus-topic-mode)
1056 (gnus-group-read-group "open" nil
1057 :visible (not (and (boundp 'gnus-topic-mode)
1059 ;; (gnus-group-find-new-groups "???" nil)
1060 (gnus-group-save-newsrc "save")
1061 (gnus-group-describe-group "describe")
1062 (gnus-group-unsubscribe-current-group "gnus/toggle-subscription")
1063 (gnus-group-prev-unread-group "left-arrow")
1064 (gnus-group-next-unread-group "right-arrow")
1065 (gnus-group-exit "exit")
1066 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
1067 (gnus-info-find-node "help"))
1068 "List of functions for the group tool bar (GNOME style).
1070 See `gmm-tool-bar-from-list' for the format of the list."
1071 :type '(repeat gmm-tool-bar-item)
1072 :version "23.1" ;; No Gnus
1073 :initialize 'custom-initialize-default
1074 :set 'gnus-group-tool-bar-update
1077 (defcustom gnus-group-tool-bar-retro
1078 '((gnus-group-get-new-news "gnus/get-news")
1079 (gnus-group-get-new-news-this-group "gnus/gnntg")
1080 (gnus-group-catchup-current "gnus/catchup")
1081 (gnus-group-describe-group "gnus/describe-group")
1082 (gnus-group-subscribe "gnus/subscribe" t
1083 :help "Subscribe to the current group")
1084 (gnus-group-unsubscribe "gnus/unsubscribe" t
1085 :help "Unsubscribe from the current group")
1086 (gnus-group-exit "gnus/exit-gnus" gnus-group-mode-map))
1087 "List of functions for the group tool bar (retro look).
1089 See `gmm-tool-bar-from-list' for the format of the list."
1090 :type '(repeat gmm-tool-bar-item)
1091 :version "23.1" ;; No Gnus
1092 :initialize 'custom-initialize-default
1093 :set 'gnus-group-tool-bar-update
1096 (defcustom gnus-group-tool-bar-zap-list t
1097 "List of icon items from the global tool bar.
1098 These items are not displayed in the Gnus group mode tool bar.
1100 See `gmm-tool-bar-from-list' for the format of the list."
1101 :type 'gmm-tool-bar-zap-list
1102 :version "23.1" ;; No Gnus
1103 :initialize 'custom-initialize-default
1104 :set 'gnus-group-tool-bar-update
1107 (defvar image-load-path)
1108 (defvar tool-bar-map)
1110 (defun gnus-group-make-tool-bar (&optional force)
1111 "Make a group mode tool bar from `gnus-group-tool-bar'.
1112 When FORCE, rebuild the tool bar."
1113 (when (and (not (featurep 'xemacs))
1114 (boundp 'tool-bar-mode)
1116 ;; The Gnus 5.10.6 code checked (default-value 'tool-bar-mode).
1118 (or (not gnus-group-tool-bar-map) force))
1120 (gmm-image-load-path-for-library "gnus"
1121 "gnus/toggle-subscription.xpm"
1123 (image-load-path (cons (car load-path)
1124 (when (boundp 'image-load-path)
1126 (map (gmm-tool-bar-from-list gnus-group-tool-bar
1127 gnus-group-tool-bar-zap-list
1128 'gnus-group-mode-map)))
1130 (set (make-local-variable 'tool-bar-map) map))))
1131 gnus-group-tool-bar-map)
1133 (defun gnus-group-mode ()
1134 "Major mode for reading news.
1136 All normal editing commands are switched off.
1137 \\<gnus-group-mode-map>
1138 The group buffer lists (some of) the groups available. For instance,
1139 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1140 lists all zombie groups.
1142 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1143 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1145 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1147 The following commands are available:
1149 \\{gnus-group-mode-map}"
1151 (kill-all-local-variables)
1152 (when (gnus-visual-p 'group-menu 'menu)
1153 (gnus-group-make-menu-bar)
1154 (gnus-group-make-tool-bar))
1155 (gnus-simplify-mode-line)
1156 (setq major-mode 'gnus-group-mode)
1157 (setq mode-name "Group")
1158 (gnus-group-set-mode-line)
1159 (setq mode-line-process nil)
1160 (use-local-map gnus-group-mode-map)
1161 (buffer-disable-undo)
1162 (setq truncate-lines t)
1163 (setq buffer-read-only t
1164 show-trailing-whitespace nil)
1165 (gnus-set-default-directory)
1166 (gnus-update-format-specifications nil 'group 'group-mode)
1167 (gnus-update-group-mark-positions)
1172 (gnus-run-mode-hooks 'gnus-group-mode-hook))
1174 (defun gnus-update-group-mark-positions ()
1176 (let ((gnus-process-mark ?\200)
1177 (gnus-group-update-hook nil)
1178 (gnus-group-marked '("dummy.group"))
1179 (gnus-active-hashtb (make-vector 10 0))
1181 (gnus-set-active "dummy.group" '(0 . 0))
1182 (gnus-set-work-buffer)
1183 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1184 (goto-char (point-min))
1185 (setq gnus-group-mark-positions
1186 (list (cons 'process (and (search-forward
1187 (mm-string-to-multibyte "\200") nil t)
1188 (- (point) (point-min) 1))))))))
1190 (defun gnus-mouse-pick-group (e)
1191 "Enter the group under the mouse pointer."
1194 (gnus-group-read-group nil))
1196 ;; Look at LEVEL and find out what the level is really supposed to be.
1197 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1198 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1199 (defun gnus-group-default-level (&optional level number-or-nil)
1201 (gnus-group-use-permanent-levels
1202 (or (setq gnus-group-use-permanent-levels
1203 (or level (if (numberp gnus-group-use-permanent-levels)
1204 gnus-group-use-permanent-levels
1205 (or gnus-group-default-list-level
1206 gnus-level-subscribed))))
1207 gnus-group-default-list-level gnus-level-subscribed))
1211 (or level gnus-group-default-list-level gnus-level-subscribed))))
1213 (defun gnus-group-setup-buffer ()
1214 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1215 (unless (eq major-mode 'gnus-group-mode)
1218 (gnus-carpal-setup-buffer 'group))))
1220 (defun gnus-group-name-charset (method group)
1222 (setq method (gnus-find-method-for-group group)))
1223 (let ((item (or (assoc method gnus-group-name-charset-method-alist)
1225 (assoc (list (car method) (cadr method))
1226 gnus-group-name-charset-method-alist))))
1227 (alist gnus-group-name-charset-group-alist)
1231 (while (setq item (pop alist))
1232 (if (string-match (car item) group)
1234 result (cdr item))))
1237 (defun gnus-group-name-decode (string charset)
1238 ;; Fixme: Don't decode in unibyte mode.
1239 (if (and string charset (featurep 'mule))
1240 (mm-decode-coding-string string charset)
1243 (defun gnus-group-decoded-name (string)
1244 (let ((charset (gnus-group-name-charset nil string)))
1245 (gnus-group-name-decode string charset)))
1247 (defun gnus-group-list-groups (&optional level unread lowest)
1248 "List newsgroups with level LEVEL or lower that have unread articles.
1249 Default is all subscribed groups.
1250 If argument UNREAD is non-nil, groups with no unread articles are also
1253 Also see the `gnus-group-use-permanent-levels' variable."
1255 (list (if current-prefix-arg
1256 (prefix-numeric-value current-prefix-arg)
1258 (gnus-group-default-level nil t)
1259 gnus-group-default-list-level
1260 gnus-level-subscribed))))
1262 (setq level (car gnus-group-list-mode)
1263 unread (cdr gnus-group-list-mode)))
1264 (setq level (gnus-group-default-level level))
1265 (gnus-group-setup-buffer)
1266 (gnus-update-format-specifications nil 'group 'group-mode)
1267 (let ((case-fold-search nil)
1268 (props (text-properties-at (point-at-bol)))
1269 (empty (= (point-min) (point-max)))
1270 (group (gnus-group-group-name))
1272 (set-buffer gnus-group-buffer)
1273 (setq number (funcall gnus-group-prepare-function level unread lowest))
1274 (when (or (and (numberp number)
1276 (zerop (buffer-size)))
1277 ;; No groups in the buffer.
1278 (gnus-message 5 "%s" gnus-no-groups-message))
1279 ;; We have some groups displayed.
1280 (goto-char (point-max))
1281 (when (or (not gnus-group-goto-next-group-function)
1282 (not (funcall gnus-group-goto-next-group-function
1286 (goto-char (point-min)))
1288 ;; Go to the first group with unread articles.
1289 (gnus-group-search-forward t))
1291 ;; Find the right group to put point on. If the current group
1292 ;; has disappeared in the new listing, try to find the next
1293 ;; one. If no next one can be found, just leave point at the
1294 ;; first newsgroup in the buffer.
1295 (when (not (gnus-goto-char
1297 (point-min) (point-max)
1298 'gnus-group (gnus-intern-safe
1299 group gnus-active-hashtb))))
1300 (let ((newsrc (cdddr (gnus-group-entry group))))
1302 (not (gnus-goto-char
1304 (point-min) (point-max) 'gnus-group
1306 (caar newsrc) gnus-active-hashtb)))))
1307 (setq newsrc (cdr newsrc)))
1309 (goto-char (point-max))
1310 (forward-line -1)))))))
1311 ;; Adjust cursor point.
1312 (gnus-group-position-point)))
1314 (defun gnus-group-list-level (level &optional all)
1315 "List groups on LEVEL.
1316 If ALL (the prefix), also list groups that have no unread articles."
1317 (interactive "nList groups on level: \nP")
1318 (gnus-group-list-groups level all level))
1320 (defun gnus-group-prepare-logic (group test)
1321 (or (and gnus-group-listed-groups
1322 (null gnus-group-list-option)
1323 (member group gnus-group-listed-groups))
1325 ((null gnus-group-listed-groups) test)
1326 ((null gnus-group-list-option) test)
1327 (t (and (member group gnus-group-listed-groups)
1328 (if (eq gnus-group-list-option 'flush)
1332 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1333 "List all newsgroups with unread articles of level LEVEL or lower.
1334 If PREDICATE is a function, list groups that the function returns non-nil;
1335 if it is t, list groups that have no unread articles.
1336 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1337 If REGEXP is a function, list dead groups that the function returns non-nil;
1338 if it is a string, only list groups matching REGEXP."
1339 (set-buffer gnus-group-buffer)
1340 (let ((buffer-read-only nil)
1341 (newsrc (cdr gnus-newsrc-alist))
1342 (lowest (or lowest 1))
1343 (not-in-list (and gnus-group-listed-groups
1344 (copy-sequence gnus-group-listed-groups)))
1345 info clevel unread group params)
1347 (when (or (< lowest gnus-level-zombie)
1348 gnus-group-listed-groups)
1349 ;; List living groups.
1351 (setq info (car newsrc)
1352 group (gnus-info-group info)
1353 params (gnus-info-params info)
1355 unread (gnus-group-unread group))
1357 (setq not-in-list (delete group not-in-list)))
1358 (when (gnus-group-prepare-logic
1360 (and (or unread ; This group might be unchecked
1361 predicate) ; Check if this group should be listed
1362 (or (not (stringp regexp))
1363 (string-match regexp group))
1364 (<= (setq clevel (gnus-info-level info)) level)
1367 ((functionp predicate)
1368 (funcall predicate info))
1369 (predicate t) ; We list all groups?
1372 (if (eq unread t) ; Unactivated?
1373 gnus-group-list-inactive-groups
1374 ; We list unactivated
1375 (and (numberp unread) (> unread 0)))
1376 ; We list groups with unread articles
1377 (and gnus-list-groups-with-ticked-articles
1378 (cdr (assq 'tick (gnus-info-marks info))))
1379 ; And groups with tickeds
1380 ;; Check for permanent visibility.
1381 (and gnus-permanently-visible-groups
1382 (string-match gnus-permanently-visible-groups
1384 (memq 'visible params)
1385 (cdr (assq 'visible params)))))))
1386 (gnus-group-insert-group-line
1387 group (gnus-info-level info)
1388 (gnus-info-marks info) unread (gnus-info-method info)))))
1390 ;; List dead groups.
1391 (when (or gnus-group-listed-groups
1392 (and (>= level gnus-level-zombie)
1393 (<= lowest gnus-level-zombie)))
1394 (gnus-group-prepare-flat-list-dead
1395 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1396 gnus-level-zombie ?Z
1399 (dolist (group gnus-zombie-list)
1400 (setq not-in-list (delete group not-in-list))))
1401 (when (or gnus-group-listed-groups
1402 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1403 (gnus-group-prepare-flat-list-dead
1406 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1407 gnus-level-killed ?K regexp))
1409 (gnus-group-set-mode-line)
1410 (setq gnus-group-list-mode (cons level predicate))
1411 (gnus-run-hooks 'gnus-group-prepare-hook)
1414 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1415 ;; List zombies and killed lists somewhat faster, which was
1416 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1417 ;; this by ignoring the group format specification altogether.
1419 (if (> (length groups) gnus-group-listing-limit)
1421 (setq group (pop groups))
1422 (when (gnus-group-prepare-logic
1425 (and (stringp regexp) (string-match regexp group))
1426 (and (functionp regexp) (funcall regexp group))))
1427 (gnus-add-text-properties
1428 (point) (prog1 (1+ (point))
1429 (insert " " mark " *: "
1430 (gnus-group-decoded-name group)
1432 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1434 'gnus-level level))))
1436 (setq group (pop groups))
1437 (when (gnus-group-prepare-logic
1440 (and (stringp regexp) (string-match regexp group))
1441 (and (functionp regexp) (funcall regexp group))))
1442 (gnus-group-insert-group-line
1444 (let ((active (gnus-active group)))
1446 (if (zerop (cdr active))
1448 (- (1+ (cdr active)) (car active)))
1450 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1452 (defun gnus-group-update-group-line ()
1453 "Update the current line in the group buffer."
1454 (let* ((buffer-read-only nil)
1455 (group (gnus-group-group-name))
1456 (entry (and group (gnus-group-entry group)))
1457 gnus-group-indentation)
1460 (not (gnus-ephemeral-group-p group))
1462 (concat "(gnus-group-set-info '"
1463 (gnus-prin1-to-string (nth 2 entry))
1465 (setq gnus-group-indentation (gnus-group-group-indentation))
1467 (gnus-group-insert-group-line-info group)
1469 (gnus-group-position-point))))
1471 (defun gnus-group-insert-group-line-info (group)
1472 "Insert GROUP on the current line."
1473 (let ((entry (gnus-group-entry group))
1474 (gnus-group-indentation (gnus-group-group-indentation))
1478 ;; (Un)subscribed group.
1479 (setq info (nth 2 entry))
1480 (gnus-group-insert-group-line
1481 group (gnus-info-level info) (gnus-info-marks info)
1482 (or (car entry) t) (gnus-info-method info)))
1483 ;; This group is dead.
1484 (gnus-group-insert-group-line
1486 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1488 (if (setq active (gnus-active group))
1489 (if (zerop (cdr active))
1491 (- (1+ (cdr active)) (car active)))
1493 (gnus-method-simplify (gnus-find-method-for-group group))))))
1495 (defun gnus-number-of-unseen-articles-in-group (group)
1496 (let* ((info (nth 2 (gnus-group-entry group)))
1497 (marked (gnus-info-marks info))
1498 (seen (cdr (assq 'seen marked)))
1499 (active (gnus-active group)))
1502 (length (gnus-uncompress-range
1503 (gnus-range-difference
1504 (gnus-range-difference (list active) (gnus-info-read info))
1507 ;; Moving through the Group buffer (in topic mode) e.g. with C-n doesn't
1508 ;; update the state (enabled/disabled) of the icon `gnus-group-describe-group'
1509 ;; automatically. After `C-l' the state is correct. See the following report
1511 ;; <http://thread.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de>:
1512 ;; From: Reiner Steib
1513 ;; Subject: tool bar icons not updated according to :active condition
1514 ;; Newsgroups: gmane.emacs.devel
1515 ;; Date: Mon, 23 Jan 2006 19:59:13 +0100
1516 ;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
1518 (defcustom gnus-group-update-tool-bar
1519 (and (not (featurep 'xemacs))
1520 (boundp 'tool-bar-mode)
1522 ;; Using `redraw-frame' (see `gnus-tool-bar-update') in Emacs 21 might
1523 ;; be confusing, so maybe we shouldn't call it by default.
1524 (fboundp 'force-window-update))
1525 "Force updating the group buffer tool bar."
1528 :initialize 'custom-initialize-default
1529 :set (lambda (symbol value)
1530 (set-default symbol value)
1531 (when (gnus-alive-p)
1532 (with-current-buffer gnus-group-buffer
1533 ;; FIXME: Is there a better way to redraw the group buffer?
1534 (gnus-group-get-new-news 0))))
1537 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1538 gnus-tmp-marked number
1540 "Insert a group line in the group buffer."
1541 (let* ((gnus-tmp-method
1542 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1543 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1545 (gnus-tmp-active (gnus-active gnus-tmp-group))
1546 (gnus-tmp-number-total
1548 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1550 (gnus-tmp-number-of-unread
1551 (if (numberp number) (int-to-string (max 0 number))
1553 (gnus-tmp-number-of-read
1554 (if (numberp number)
1555 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1557 (gnus-tmp-subscribed
1558 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1559 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1560 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1562 (gnus-tmp-qualified-group
1563 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1564 group-name-charset))
1566 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1568 (gnus-tmp-newsgroup-description
1569 (if gnus-description-hashtb
1570 (or (gnus-group-name-decode
1571 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1572 group-name-charset) "")
1575 (if (and gnus-moderated-hashtb
1576 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1578 (gnus-tmp-moderated-string
1579 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1580 (gnus-tmp-group-icon (gnus-group-get-icon gnus-tmp-qualified-group))
1581 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1582 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1583 (gnus-tmp-news-method-string
1585 (format "(%s:%s)" (car gnus-tmp-method)
1586 (cadr gnus-tmp-method)) ""))
1587 (gnus-tmp-marked-mark
1588 (if (and (numberp number)
1590 (cdr (assq 'tick gnus-tmp-marked)))
1592 (gnus-tmp-summary-live
1593 (if (and (not gnus-group-is-exiting-p)
1594 (gnus-buffer-live-p (gnus-summary-buffer-name
1597 (gnus-tmp-process-marked
1598 (if (member gnus-tmp-group gnus-group-marked)
1599 gnus-process-mark ? ))
1600 (buffer-read-only nil)
1602 header gnus-tmp-header) ; passed as parameter to user-funcs.
1605 (gnus-add-text-properties
1609 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1610 gnus-tmp-group group-name-charset)))
1611 (eval gnus-group-line-format-spec)))
1612 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1613 gnus-unread ,(if (numberp number)
1614 (string-to-number gnus-tmp-number-of-unread)
1616 gnus-marked ,gnus-tmp-marked-mark
1617 gnus-indentation ,gnus-group-indentation
1618 gnus-level ,gnus-tmp-level))
1620 (when gnus-group-update-tool-bar
1621 (gnus-put-text-property beg end 'point-entered
1622 'gnus-tool-bar-update)
1623 (gnus-put-text-property beg end 'point-left
1624 'gnus-tool-bar-update))
1626 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1627 (gnus-run-hooks 'gnus-group-update-hook))
1629 ;; Allow XEmacs to remove front-sticky text properties.
1630 (gnus-group-remove-excess-properties)))
1632 (defun gnus-group-highlight-line ()
1633 "Highlight the current line according to `gnus-group-highlight'."
1634 (let* ((list gnus-group-highlight)
1636 (end (point-at-eol))
1637 ;; now find out where the line starts and leave point there.
1638 (beg (progn (beginning-of-line) (point)))
1639 (group (gnus-group-group-name))
1640 (entry (gnus-group-entry group))
1641 (unread (if (numberp (car entry)) (car entry) 0))
1642 (active (gnus-active group))
1643 (total (if active (1+ (- (cdr active) (car active))) 0))
1644 (info (nth 2 entry))
1645 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1646 (marked (gnus-info-marks info))
1647 (mailp (apply 'append
1650 (memq x (assoc (symbol-name
1651 (car (or method gnus-select-method)))
1652 gnus-valid-select-methods)))
1653 '(mail post-mail))))
1654 (level (or (gnus-info-level info) gnus-level-killed))
1655 (score (or (gnus-info-score info) 0))
1656 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1657 (group-age (gnus-group-timestamp-delta group))
1658 (inhibit-read-only t))
1659 ;; FIXME: http://thread.gmane.org/gmane.emacs.gnus.general/65451/focus=65465
1660 ;; ======================================================================
1661 ;; From: Richard Stallman
1662 ;; Subject: Re: Rewriting gnus-group-highlight-line (was: [...])
1663 ;; Cc: ding@gnus.org
1664 ;; Date: Sat, 27 Oct 2007 19:41:20 -0400
1665 ;; Message-ID: <E1IlvHM-0006TS-7t@fencepost.gnu.org>
1668 ;; The kludge is that the alist elements contain expressions that refer
1669 ;; to local variables with short names. Perhaps write your own tiny
1670 ;; evaluator that handles just `and', `or', and numeric comparisons
1671 ;; and just a few specific variables.
1672 ;; ======================================================================
1674 ;; Similar for other evaluated variables. Grep for risky-local-variable
1675 ;; to find them! -- rsteib
1677 ;; Eval the cars of the lists until we find a match.
1679 (not (eval (caar list))))
1680 (setq list (cdr list)))
1681 (let ((face (cdar list)))
1682 (unless (eq face (get-text-property beg 'face))
1683 (gnus-put-text-property-excluding-characters-with-faces
1685 (setq face (if (boundp face) (symbol-value face) face)))
1686 (gnus-extent-start-open beg)))
1689 (defun gnus-group-get-icon (group)
1690 "Return an icon for GROUP according to `gnus-group-icon-list'."
1691 (if gnus-group-icon-list
1692 (let* ((entry (gnus-group-entry group))
1693 (unread (if (numberp (car entry)) (car entry) 0))
1694 (active (gnus-active group))
1695 (total (if active (1+ (- (cdr active) (car active))) 0))
1696 (info (nth 2 entry))
1697 (method (gnus-server-get-method group (gnus-info-method info)))
1698 (marked (gnus-info-marks info))
1699 (mailp (memq 'mail (assoc (symbol-name
1700 (car (or method gnus-select-method)))
1701 gnus-valid-select-methods)))
1702 (level (or (gnus-info-level info) gnus-level-killed))
1703 (score (or (gnus-info-score info) 0))
1704 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1705 (group-age (gnus-group-timestamp-delta group))
1706 (inhibit-read-only t)
1707 (list gnus-group-icon-list))
1709 (not (eval (caar list))))
1710 (setq list (cdr list)))
1715 (gnus-create-image (expand-file-name (cdar list)))
1720 (defun gnus-group-update-group (group &optional visible-only)
1721 "Update all lines where GROUP appear.
1722 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1724 (with-current-buffer gnus-group-buffer
1726 ;; The buffer may be narrowed.
1729 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1731 found buffer-read-only)
1732 ;; Enter the current status into the dribble buffer.
1733 (let ((entry (gnus-group-entry group)))
1735 (not (gnus-ephemeral-group-p group)))
1737 (concat "(gnus-group-set-info '"
1738 (gnus-prin1-to-string (nth 2 entry))
1740 ;; Find all group instances. If topics are in use, each group
1741 ;; may be listed in more than once.
1742 (while (setq loc (text-property-any
1743 loc (point-max) 'gnus-group ident))
1746 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1748 (gnus-group-insert-group-line-info group)
1751 (gnus-run-hooks 'gnus-group-update-group-hook)))
1752 (setq loc (1+ loc)))
1753 (unless (or found visible-only)
1754 ;; No such line in the buffer, find out where it's supposed to
1755 ;; go, and insert it there (or at the end of the buffer).
1756 (if gnus-goto-missing-group-function
1757 (funcall gnus-goto-missing-group-function group)
1758 (let ((entry (cddr (gnus-group-entry group))))
1759 (while (and entry (car entry)
1763 (point-min) (point-max)
1764 'gnus-group (gnus-intern-safe
1766 gnus-active-hashtb)))))
1767 (setq entry (cdr entry)))
1768 (or entry (goto-char (point-max)))))
1769 ;; Finally insert the line.
1770 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1771 (gnus-group-insert-group-line-info group)
1774 (gnus-run-hooks 'gnus-group-update-group-hook))))
1775 (when gnus-group-update-group-function
1776 (funcall gnus-group-update-group-function group))
1777 (gnus-group-set-mode-line))))))
1779 (defun gnus-group-set-mode-line ()
1780 "Update the mode line in the group buffer."
1781 (when (memq 'group gnus-updated-mode-lines)
1782 ;; Yes, we want to keep this mode line updated.
1783 (with-current-buffer gnus-group-buffer
1784 (let* ((gformat (or gnus-group-mode-line-format-spec
1785 (gnus-set-format 'group-mode)))
1786 (gnus-tmp-news-server (cadr gnus-select-method))
1787 (gnus-tmp-news-method (car gnus-select-method))
1788 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1790 gnus-tmp-header ;Dummy binding for user-defined formats
1791 ;; Get the resulting string.
1793 (and gnus-dribble-buffer
1794 (buffer-name gnus-dribble-buffer)
1795 (buffer-modified-p gnus-dribble-buffer)
1796 (with-current-buffer gnus-dribble-buffer
1797 (not (zerop (buffer-size))))))
1798 (mode-string (eval gformat)))
1799 ;; Say whether the dribble buffer has been modified.
1800 (setq mode-line-modified
1801 (if modified (car gnus-mode-line-modified)
1802 (cdr gnus-mode-line-modified)))
1803 ;; If the line is too long, we chop it off.
1804 (when (> (length mode-string) max-len)
1805 (setq mode-string (substring mode-string 0 (- max-len 4))))
1807 (setq mode-line-buffer-identification
1808 (gnus-mode-line-buffer-identification
1809 (list mode-string)))
1810 (set-buffer-modified-p modified))))))
1812 (defun gnus-group-group-name ()
1813 "Get the name of the newsgroup on the current line."
1814 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1816 (symbol-name group))))
1818 (defun gnus-group-group-level ()
1819 "Get the level of the newsgroup on the current line."
1820 (get-text-property (point-at-bol) 'gnus-level))
1822 (defun gnus-group-group-indentation ()
1823 "Get the indentation of the newsgroup on the current line."
1824 (or (get-text-property (point-at-bol) 'gnus-indentation)
1825 (and gnus-group-indentation-function
1826 (funcall gnus-group-indentation-function))
1829 (defun gnus-group-group-unread ()
1830 "Get the number of unread articles of the newsgroup on the current line."
1831 (get-text-property (point-at-bol) 'gnus-unread))
1833 (defun gnus-group-new-mail (group)
1834 (if (nnmail-new-mail-p (gnus-group-real-name group))
1838 (defun gnus-group-level (group)
1839 "Return the estimated level of GROUP."
1840 (or (gnus-info-level (gnus-get-info group))
1841 (and (member group gnus-zombie-list) gnus-level-zombie)
1844 (defun gnus-group-search-forward (&optional backward all level first-too)
1845 "Find the next newsgroup with unread articles.
1846 If BACKWARD is non-nil, find the previous newsgroup instead.
1847 If ALL is non-nil, just find any newsgroup.
1848 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1850 If FIRST-TOO, the current line is also eligible as a target."
1851 (let ((way (if backward -1 1))
1852 (low gnus-level-killed)
1855 (if (and backward (progn (beginning-of-line)) (bobp))
1864 (get-text-property (point) 'gnus-group)
1868 (get-text-property (point) 'gnus-unread)))
1869 (and (numberp unread) (> unread 0)))
1870 (setq lev (get-text-property (point)
1872 (<= lev gnus-level-subscribed)))
1874 (and (setq lev (get-text-property (point)
1883 (zerop (forward-line way)))))
1885 (progn (gnus-group-position-point) t)
1886 (goto-char (or pos beg))
1889 (defun gnus-total-fetched-for (group)
1890 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1891 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1892 (size (+ size-in-cache size-in-agent))
1893 (suffix '("B" "K" "M" "G"))
1896 (while (> size cutoff)
1897 (setq size (/ size scale)
1898 suffix (cdr suffix)))
1899 (format "%5.1f%s" size (car suffix))))
1901 ;;; Gnus group mode commands
1905 (defun gnus-group-mark-line-p ()
1908 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1909 (eq (char-after) gnus-process-mark)))
1911 (defun gnus-group-mark-group (n &optional unmark no-advance)
1912 "Mark the current group."
1914 (let ((buffer-read-only nil)
1918 (when (setq group (gnus-group-group-name))
1919 ;; Go to the mark position.
1921 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1925 (setq gnus-group-marked (delete group gnus-group-marked))
1926 (insert-char ? 1 t))
1927 (setq gnus-group-marked
1928 (cons group (delete group gnus-group-marked)))
1929 (insert-char gnus-process-mark 1 t)))
1931 (gnus-group-next-group 1))
1933 (gnus-summary-position-point)
1936 (defun gnus-group-unmark-group (n)
1937 "Remove the mark from the current group."
1939 (gnus-group-mark-group n 'unmark)
1940 (gnus-group-position-point))
1942 (defun gnus-group-unmark-all-groups ()
1943 "Unmark all groups."
1946 (mapc 'gnus-group-remove-mark gnus-group-marked))
1947 (gnus-group-position-point))
1949 (defun gnus-group-mark-region (unmark beg end)
1950 "Mark all groups between point and mark.
1951 If UNMARK, remove the mark instead."
1952 (interactive "P\nr")
1953 (let ((num (count-lines beg end)))
1956 (- num (gnus-group-mark-group num unmark)))))
1958 (defun gnus-group-mark-buffer (&optional unmark)
1959 "Mark all groups in the buffer.
1960 If UNMARK, remove the mark instead."
1962 (gnus-group-mark-region unmark (point-min) (point-max)))
1964 (defun gnus-group-mark-regexp (regexp)
1965 "Mark all groups that match some regexp."
1966 (interactive "sMark (regexp): ")
1967 (let ((alist (cdr gnus-newsrc-alist))
1971 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1972 (gnus-group-jump-to-group group)
1973 (gnus-group-set-mark group)))))
1974 (gnus-group-position-point))
1976 (defun gnus-group-remove-mark (group &optional test-marked)
1977 "Remove the process mark from GROUP and move point there.
1978 Return nil if the group isn't displayed."
1979 (if (gnus-group-goto-group group nil test-marked)
1981 (gnus-group-mark-group 1 'unmark t)
1983 (setq gnus-group-marked
1984 (delete group gnus-group-marked))
1987 (defun gnus-group-set-mark (group)
1988 "Set the process mark on GROUP."
1989 (if (gnus-group-goto-group group)
1991 (gnus-group-mark-group 1 nil t))
1992 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1994 (defun gnus-group-universal-argument (arg &optional groups func)
1995 "Perform any command on all groups according to the process/prefix convention."
1997 (if (eq (setq func (or func
2000 (substitute-command-keys
2001 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
2003 (gnus-error 1 "Undefined key")
2004 (gnus-group-iterate arg
2006 (command-execute func))))
2007 (gnus-group-position-point))
2009 (defun gnus-group-process-prefix (n)
2010 "Return a list of groups to work on.
2011 Take into consideration N (the prefix) and the list of marked groups."
2014 (setq n (prefix-numeric-value n))
2015 ;; There is a prefix, so we return a list of the N next
2017 (let ((way (if (< n 0) -1 1))
2022 (if (setq group (gnus-group-group-name))
2023 (push group groups))
2025 (gnus-group-next-group way)))
2027 ((and (gnus-region-active-p) (mark))
2028 ;; Work on the region between point and mark.
2029 (let ((max (max (point) (mark)))
2032 (goto-char (min (point) (mark)))
2035 (push (gnus-group-group-name) groups)
2036 (zerop (gnus-group-next-group 1))
2038 (nreverse groups))))
2040 ;; No prefix, but a list of marked articles.
2041 (reverse gnus-group-marked))
2043 ;; Neither marked articles or a prefix, so we return the
2045 (let ((group (gnus-group-group-name)))
2046 (and group (list group))))))
2048 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
2049 ;;; imagine why I went through these contortions...
2051 (let ((function (make-symbol "gnus-group-iterate-function"))
2052 (window (make-symbol "gnus-group-iterate-window"))
2053 (groups (make-symbol "gnus-group-iterate-groups"))
2054 (group (make-symbol "gnus-group-iterate-group")))
2056 `(defun gnus-group-iterate (arg ,function)
2057 "Iterate FUNCTION over all process/prefixed groups.
2058 FUNCTION will be called with the group name as the parameter
2059 and with point over the group in question."
2060 (let ((,groups (gnus-group-process-prefix arg))
2061 (,window (selected-window))
2064 (setq ,group (car ,groups)
2065 ,groups (cdr ,groups))
2066 (select-window ,window)
2067 (gnus-group-remove-mark ,group)
2068 (save-selected-window
2070 (funcall ,function ,group)))))))))
2072 (put 'gnus-group-iterate 'lisp-indent-function 1)
2074 ;; Selecting groups.
2076 (defun gnus-group-read-group (&optional all no-article group select-articles)
2077 "Read news in this newsgroup.
2078 If the prefix argument ALL is non-nil, already read articles become
2081 If ALL is a positive number, fetch this number of the latest
2082 articles in the group. If ALL is a negative number, fetch this
2083 number of the earliest articles in the group.
2085 If the optional argument NO-ARTICLE is non-nil, no article will
2086 be auto-selected upon group entry. If GROUP is non-nil, fetch
2089 (let ((no-display (eq all 0))
2090 (group (or group (gnus-group-group-name)))
2091 number active marked entry)
2095 (error "No group on current line"))
2096 (setq marked (gnus-info-marks
2097 (nth 2 (setq entry (gnus-group-entry group)))))
2098 ;; This group might be a dead group. In that case we have to get
2099 ;; the number of unread articles from `gnus-active-hashtb'.
2101 (cond ((numberp all) all)
2103 ((setq active (gnus-active group))
2104 (- (1+ (cdr active)) (car active)))))
2105 (gnus-summary-read-group
2106 group (or all (and (numberp number)
2107 (zerop (+ number (gnus-range-length
2108 (cdr (assq 'tick marked)))
2110 (cdr (assq 'dormant marked)))))))
2111 no-article nil no-display nil select-articles)))
2113 (defun gnus-group-select-group (&optional all)
2114 "Select this newsgroup.
2115 No article is selected automatically.
2116 If the group is opened, just switch the summary buffer.
2117 If ALL is non-nil, already read articles become readable.
2118 If ALL is a positive number, fetch this number of the latest
2119 articles in the group.
2120 If ALL is a negative number, fetch this number of the earliest
2121 articles in the group."
2123 (when (and (eobp) (not (gnus-group-group-name)))
2125 (gnus-group-read-group all t))
2127 (defun gnus-group-quick-select-group (&optional all group)
2128 "Select the GROUP \"quickly\".
2129 This means that no highlighting or scoring will be performed. If
2130 ALL (the prefix argument) is 0, don't even generate the summary
2131 buffer. If GROUP is nil, use current group.
2133 This might be useful if you want to toggle threading
2134 before entering the group."
2136 (require 'gnus-score)
2138 gnus-score-find-score-files-function
2139 gnus-home-score-file
2140 gnus-apply-kill-hook
2141 gnus-summary-expunge-below)
2142 (gnus-group-read-group all t group)))
2144 (defun gnus-group-visible-select-group (&optional all)
2145 "Select the current group without hiding any articles."
2147 (let ((gnus-inhibit-limiting t))
2148 (gnus-group-read-group all t)))
2150 (defun gnus-group-select-group-ephemerally ()
2151 "Select the current group without doing any processing whatsoever.
2152 You will actually be entered into a group that's a copy of
2153 the current group; no changes you make while in this group will
2156 (require 'gnus-score)
2158 gnus-score-find-score-files-function gnus-apply-kill-hook
2159 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2160 gnus-summary-mode-hook gnus-select-group-hook
2161 (group (gnus-group-group-name))
2162 (method (gnus-find-method-for-group group)))
2163 (gnus-group-read-ephemeral-group
2164 (gnus-group-prefixed-name group method) method)))
2166 (defun gnus-group-name-at-point ()
2167 "Return a group name from around point if it exists, or nil."
2168 (if (eq major-mode 'gnus-group-mode)
2169 (let ((group (gnus-group-group-name)))
2171 (gnus-group-decoded-name group)))
2172 (let ((regexp "[][\C-@-\t\v-*,/:-@\\^`{-\C-?]*\
2173 \\(nn[a-z]+\\(?:\\+[^][\C-@-*,/:-@\\^`{-\C-?]+\\)?:\
2174 \[^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)*\
2175 \\|[^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)+\\)")
2177 (case-fold-search nil))
2179 (if (or (and (not (or (eobp)
2180 (looking-at "[][\C-@-*,/;-@\\^`{-\C-?]")))
2182 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2184 (and (looking-at "[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*$")
2186 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2187 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2189 (string-match "\\`[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*\\'"
2190 (buffer-substring (point-at-bol) (point))))
2191 (when (looking-at regexp)
2193 (let (group distance)
2194 (when (looking-at regexp)
2195 (setq group (match-string 1)
2196 distance (- (match-beginning 1) (match-beginning 0))))
2197 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2198 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2200 (if (looking-at regexp)
2201 (if (and group (<= distance (- start (match-end 0))))
2205 (goto-char start)))))
2207 (defun gnus-group-completing-read (prompt &optional collection predicate
2208 require-match initial-input hist def
2210 "Read a group name with completion. Non-ASCII group names are allowed.
2211 The arguments are the same as `completing-read' except that COLLECTION
2212 and HIST default to `gnus-active-hashtb' and `gnus-group-history'
2213 respectively if they are omitted."
2214 (let ((completion-styles (and (boundp 'completion-styles)
2217 (push 'substring completion-styles)
2218 (mapatoms (lambda (symbol)
2219 (setq group (symbol-name symbol))
2220 (set (intern (if (string-match "[^\000-\177]" group)
2221 (gnus-group-decoded-name group)
2227 (setq collection (or gnus-active-hashtb [0])))
2228 (setq collection (gnus-make-hashtable (length collection)))))
2229 (setq group (apply 'completing-read prompt collection predicate
2230 require-match initial-input
2231 (or hist 'gnus-group-history)
2234 (symbol-value (intern-soft group collection))
2235 (setq collection nil))
2236 (mm-encode-coding-string group (gnus-group-name-charset nil group)))))
2239 (defun gnus-fetch-group (group &optional articles)
2240 "Start Gnus if necessary and enter GROUP.
2241 If ARTICLES, display those articles.
2242 Returns whether the fetching was successful or not."
2243 (interactive (list (gnus-group-completing-read "Group name: "
2245 (gnus-group-name-at-point))))
2246 (unless (gnus-alive-p)
2248 (gnus-group-read-group (if articles nil t) nil group articles))
2251 (defun gnus-fetch-group-other-frame (group)
2252 "Pop up a frame and enter GROUP."
2254 (let ((window (get-buffer-window gnus-group-buffer)))
2256 (select-frame (window-frame window)))
2257 ((= (length (frame-list)) 1)
2258 (select-frame (make-frame)))
2261 (gnus-fetch-group group))
2263 (defvar gnus-ephemeral-group-server 0)
2265 (defcustom gnus-large-ephemeral-newsgroup 200
2266 "The number of articles which indicates a large ephemeral newsgroup.
2267 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2269 If the number of articles in a newsgroup is greater than this value,
2270 confirmation is required for selecting the newsgroup. If it is nil, no
2271 confirmation is required."
2273 :group 'gnus-group-select
2274 :type '(choice (const :tag "No limit" nil)
2277 (defcustom gnus-fetch-old-ephemeral-headers nil
2278 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2281 :type '(choice (const :tag "off" nil)
2284 (sexp :menu-tag "other" t)))
2286 ;; Enter a group that is not in the group buffer. Non-nil is returned
2287 ;; if selection was successful.
2288 (defun gnus-group-read-ephemeral-group (group method &optional activate
2289 quit-config request-only
2293 "Read GROUP from METHOD as an ephemeral group.
2294 If ACTIVATE, request the group first.
2295 If QUIT-CONFIG, use that window configuration when exiting from the
2297 If REQUEST-ONLY, don't actually read the group; just request it.
2298 If SELECT-ARTICLES, only select those articles.
2299 If PARAMETERS, use those as the group parameters.
2300 If NUMBER, fetch this number of articles.
2302 Return the name of the group if selection was successful."
2305 ;; (gnus-read-group "Group name: ")
2306 (gnus-group-completing-read "Group: ")
2307 (gnus-read-method "From method: ")))
2308 ;; Transform the select method into a unique server.
2309 (when (stringp method)
2310 (setq method (gnus-server-to-method method)))
2312 `(,(car method) ,(concat (cadr method) "-ephemeral")
2313 (,(intern (format "%s-address" (car method))) ,(cadr method))
2315 (let ((group (if (gnus-group-foreign-p group) group
2316 (gnus-group-prefixed-name (gnus-group-real-name group)
2321 ,gnus-level-default-subscribed nil nil ,method
2324 (cons 'quit-config quit-config)
2326 (cons gnus-summary-buffer
2327 gnus-current-window-configuration)))
2330 (push method gnus-ephemeral-servers)
2331 (set-buffer gnus-group-buffer)
2332 (unless (gnus-check-server method)
2333 (error "Unable to contact server: %s" (gnus-status-message method)))
2335 (gnus-activate-group group 'scan)
2336 (unless (gnus-request-group group)
2337 (error "Couldn't request group: %s"
2338 (nnheader-get-report (car method)))))
2342 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2343 (gnus-fetch-old-headers
2344 gnus-fetch-old-ephemeral-headers))
2345 (gnus-group-read-group (or number t) t group select-articles))
2349 (message "Quit reading the ephemeral group")
2352 (defcustom gnus-gmane-group-download-format
2353 "http://download.gmane.org/%s/%s/%s"
2354 "URL for downloading mbox files.
2355 It must contain three \"%s\". They correspond to the group, the
2356 minimal and maximal article numbers, respectively."
2357 :group 'gnus-group-foreign
2358 :version "23.1" ;; No Gnus
2361 (autoload 'url-insert-file-contents "url-handlers")
2363 ;; - Add documentation, menu, key bindings, ...
2365 (defun gnus-read-ephemeral-gmane-group (group start &optional range)
2366 "Read articles from Gmane group GROUP as an ephemeral group.
2367 START is the first article. RANGE specifies how many articles
2368 are fetched. The articles are downloaded via HTTP using the URL
2369 specified by `gnus-gmane-group-download-format'."
2370 ;; See <http://gmane.org/export.php> for more information.
2373 (gnus-group-completing-read "Gmane group: ")
2374 (read-number "Start article number: ")
2375 (read-number "How many articles: ")))
2376 (unless range (setq range 500))
2378 (error "Invalid range: %s" range))
2379 (let ((tmpfile (mm-make-temp-file
2380 (format "%s.start-%s.range-%s." group start range)))
2381 (gnus-thread-sort-functions '(gnus-thread-sort-by-number)))
2382 (with-temp-file tmpfile
2383 (url-insert-file-contents
2384 (format gnus-gmane-group-download-format
2385 group start (+ start range)))
2386 (write-region (point-min) (point-max) tmpfile)
2387 (gnus-group-read-ephemeral-group
2388 (format "%s.start-%s.range-%s" group start range)
2390 (nndoc-article-type mbox))))
2391 (delete-file tmpfile)))
2393 (defun gnus-read-ephemeral-gmane-group-url (url)
2394 "Create an ephemeral Gmane group from URL.
2396 Valid input formats include:
2397 \"http://thread.gmane.org/gmane.foo.bar/12300/focus=12399\",
2398 \"http://thread.gmane.org/gmane.foo.bar/12345/\",
2399 \"http://article.gmane.org/gmane.foo.bar/12345/\",
2400 \"http://news.gmane.org/group/gmane.foo.bar/thread=12345\""
2401 ;; - Feel free to add other useful Gmane URLs here! Maybe the URLs should
2403 ;; - The URLs should be added to `gnus-button-alist'. Probably we should
2404 ;; prompt the user to decide: "View via `browse-url' or in Gnus? "
2405 ;; (`gnus-read-ephemeral-gmane-group-url')
2407 (list (gnus-group-completing-read "Gmane URL: ")))
2408 (let (group start range)
2410 ;; URLs providing `group', `start' and `range':
2412 ;; http://thread.gmane.org/gmane.emacs.devel/86326/focus=86525
2413 "^http://thread\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)/focus=\\([0-9]+\\)$"
2415 (setq group (match-string 1 url)
2416 start (string-to-number (match-string 2 url))
2417 ;; Ensure that `range' is large enough to ensure focus article is
2419 range (- (string-to-number (match-string 3 url))
2421 ;; URLs providing `group' and `start':
2423 ;; http://article.gmane.org/gmane.comp.gnu.make.bugs/3584
2424 "^http://\\(?:thread\\|article\\|permalink\\)\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)"
2427 ;; Don't advertise these in the doc string yet:
2428 "^\\(?:nntp\\|news\\)://news\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)"
2431 ;; http://news.gmane.org/group/gmane.emacs.gnus.general/thread=65099/force_load=t
2432 "^http://news\.gmane\.org/group/\\([^/]+\\)/thread=\\([0-9]+\\)"
2434 (setq group (match-string 1 url)
2435 start (string-to-number (match-string 2 url))))
2437 (error "Can't parse URL %s" url)))
2438 (gnus-read-ephemeral-gmane-group group start range)))
2440 (defcustom gnus-bug-group-download-format-alist
2441 '((emacs . "http://debbugs.gnu.org/%s;mbox=yes")
2443 . "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%s&mbox=yes"))
2444 "Alist of symbols for bug trackers and the corresponding URL format string.
2445 The URL format string must contain a single \"%s\", specifying
2446 the bug number, and browsing the URL must return mbox output."
2447 :group 'gnus-group-foreign
2448 :version "23.2" ;; No Gnus
2449 :type '(repeat (cons (symbol) (string :tag "URL format string"))))
2451 (defun gnus-read-ephemeral-bug-group (number mbox-url)
2452 "Browse bug NUMBER as ephemeral group."
2453 (interactive (list (read-string "Enter bug number: "
2454 (thing-at-point 'word) nil)
2455 ;; FIXME: Add completing-read from
2456 ;; `gnus-emacs-bug-group-download-format' ...
2457 (cdr (assoc 'emacs gnus-bug-group-download-format-alist))))
2458 (when (stringp number)
2459 (setq number (string-to-number number)))
2460 (let ((tmpfile (mm-make-temp-file "gnus-temp-group-")))
2461 (with-temp-file tmpfile
2462 (url-insert-file-contents (format mbox-url number))
2463 (write-region (point-min) (point-max) tmpfile)
2464 (gnus-group-read-ephemeral-group
2465 "gnus-read-ephemeral-bug"
2467 (nndoc-article-type mbox))))
2468 (delete-file tmpfile)))
2470 (defun gnus-read-ephemeral-debian-bug-group (number)
2471 "Browse Debian bug NUMBER as ephemeral group."
2472 (interactive (list (read-string "Enter bug number: "
2473 (thing-at-point 'word) nil)))
2474 (gnus-read-ephemeral-bug-group
2476 (cdr (assoc 'debian gnus-bug-group-download-format-alist))))
2478 (defun gnus-read-ephemeral-emacs-bug-group (number)
2479 "Browse Emacs bug NUMBER as ephemeral group."
2480 (interactive (list (read-string "Enter bug number: "
2481 (thing-at-point 'word) nil)))
2482 (gnus-read-ephemeral-bug-group
2484 (cdr (assoc 'emacs gnus-bug-group-download-format-alist))))
2486 (defun gnus-group-jump-to-group (group &optional prompt)
2487 "Jump to newsgroup GROUP.
2489 If PROMPT (the prefix) is a number, use the prompt specified in
2490 `gnus-group-jump-to-group-prompt'."
2492 (list (gnus-group-completing-read
2493 "Group: " nil nil (gnus-read-active-file-p)
2494 (if current-prefix-arg
2495 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2496 (or (and (stringp gnus-group-jump-to-group-prompt)
2497 gnus-group-jump-to-group-prompt)
2498 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2499 (and (stringp p) p)))))))
2501 (when (equal group "")
2502 (error "Empty group name"))
2504 (unless (gnus-ephemeral-group-p group)
2505 ;; Either go to the line in the group buffer...
2506 (unless (gnus-group-goto-group group)
2507 ;; ... or insert the line.
2508 (gnus-group-update-group group)
2509 (gnus-group-goto-group group)))
2510 ;; Adjust cursor point.
2511 (gnus-group-position-point))
2513 (defun gnus-group-goto-group (group &optional far test-marked)
2514 "Goto to newsgroup GROUP.
2515 If FAR, it is likely that the group is not on the current line.
2516 If TEST-MARKED, the line must be marked."
2520 ;; It's quite likely that we are on the right line, so
2521 ;; we check the current line first.
2523 (eq (get-text-property (point) 'gnus-group)
2524 (gnus-intern-safe group gnus-active-hashtb))
2525 (or (not test-marked) (gnus-group-mark-line-p)))
2527 ;; Previous and next line are also likely, so we check them as well.
2531 (and (eq (get-text-property (point) 'gnus-group)
2532 (gnus-intern-safe group gnus-active-hashtb))
2533 (or (not test-marked) (gnus-group-mark-line-p)))))
2539 (and (eq (get-text-property (point) 'gnus-group)
2540 (gnus-intern-safe group gnus-active-hashtb))
2541 (or (not test-marked) (gnus-group-mark-line-p)))))
2545 (goto-char (point-min))
2547 (while (and (not found)
2552 (gnus-intern-safe group gnus-active-hashtb))))
2553 (if (gnus-group-mark-line-p)
2558 ;; Search through the entire buffer.
2561 (point-min) (point-max)
2562 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2564 (defun gnus-group-next-group (n &optional silent)
2565 "Go to next N'th newsgroup.
2566 If N is negative, search backward instead.
2567 Returns the difference between N and the number of skips actually
2570 (gnus-group-next-unread-group n t nil silent))
2572 (defun gnus-group-next-unread-group (n &optional all level silent)
2573 "Go to next N'th unread newsgroup.
2574 If N is negative, search backward instead.
2575 If ALL is non-nil, choose any newsgroup, unread or not.
2576 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2577 such group can be found, the next group with a level higher than
2579 Returns the difference between N and the number of skips actually
2582 (let ((backward (< n 0))
2585 (gnus-group-search-forward
2586 backward (or (not gnus-group-goto-unread) all) level))
2590 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2591 (if level " on this level or higher" "")))
2594 (defun gnus-group-prev-group (n)
2595 "Go to previous N'th newsgroup.
2596 Returns the difference between N and the number of skips actually
2599 (gnus-group-next-unread-group (- n) t))
2601 (defun gnus-group-prev-unread-group (n)
2602 "Go to previous N'th unread newsgroup.
2603 Returns the difference between N and the number of skips actually
2606 (gnus-group-next-unread-group (- n)))
2608 (defun gnus-group-next-unread-group-same-level (n)
2609 "Go to next N'th unread newsgroup on the same level.
2610 If N is negative, search backward instead.
2611 Returns the difference between N and the number of skips actually
2614 (gnus-group-next-unread-group n t (gnus-group-group-level))
2615 (gnus-group-position-point))
2617 (defun gnus-group-prev-unread-group-same-level (n)
2618 "Go to next N'th unread newsgroup on the same level.
2619 Returns the difference between N and the number of skips actually
2622 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2623 (gnus-group-position-point))
2625 (defun gnus-group-best-unread-group (&optional exclude-group)
2626 "Go to the group with the highest level.
2627 If EXCLUDE-GROUP, do not go to that group."
2629 (goto-char (point-min))
2633 (setq unread (get-text-property (point) 'gnus-unread))
2634 (when (and (numberp unread) (> unread 0))
2635 (when (and (get-text-property (point) 'gnus-level)
2636 (< (get-text-property (point) 'gnus-level) best)
2637 (or (not exclude-group)
2638 (not (equal exclude-group (gnus-group-group-name)))))
2639 (setq best (get-text-property (point) 'gnus-level))
2640 (setq best-point (point))))
2643 (goto-char best-point))
2644 (gnus-group-position-point)
2645 (and best-point (gnus-group-group-name))))
2647 ;; Is there something like an after-point-motion-hook?
2648 ;; (inhibit-point-motion-hooks?). Is there a tool-bar-update function?
2650 ;; (defun gnus-group-menu-bar-update ()
2651 ;; (let* ((buf (list (with-current-buffer gnus-group-buffer
2652 ;; (current-buffer))))
2653 ;; (name (buffer-name (car buf))))
2655 ;; (if (> (length name) 27)
2656 ;; (concat (substring name 0 12)
2658 ;; (substring name -12))
2660 ;; (menu-bar-update-buffers-1 buf)))
2662 ;; (defun gnus-group-position-point ()
2663 ;; (gnus-goto-colon)
2664 ;; (gnus-group-menu-bar-update))
2666 (defun gnus-group-first-unread-group ()
2667 "Go to the first group with unread articles."
2670 (let ((opoint (point))
2672 (goto-char (point-min))
2673 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2674 (and (numberp unread) ; Not a topic.
2675 (not (zerop unread))) ; Has unread articles.
2676 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2679 nil)) ; Not success.
2680 (gnus-group-position-point)))
2682 (defun gnus-group-enter-server-mode ()
2683 "Jump to the server buffer."
2685 (gnus-enter-server-buffer))
2687 (defun gnus-group-make-group-simple (&optional group)
2688 "Add a new newsgroup.
2689 The user will be prompted for GROUP."
2690 (interactive (list (gnus-group-completing-read "Group: ")))
2691 (gnus-group-make-group (gnus-group-real-name group)
2692 (gnus-group-server group)
2695 (defun gnus-group-make-group (name &optional method address args encoded)
2696 "Add a new newsgroup.
2697 The user will be prompted for a NAME, for a select METHOD, and an
2698 ADDRESS. NAME should be a human-readable string (i.e., not be encoded
2699 even if it contains non-ASCII characters) unless ENCODED is non-nil."
2702 (gnus-read-group "Group name: ")
2703 (gnus-read-method "From method: ")))
2705 (when (stringp method)
2706 (setq method (or (gnus-server-to-method method) method)))
2708 (setq name (mm-encode-coding-string
2710 (gnus-group-name-charset method name))))
2711 (let* ((meth (gnus-method-simplify
2713 (not (gnus-server-equal method gnus-select-method)))
2714 (if address (list (intern method) address)
2716 (nname (if method (gnus-group-prefixed-name name meth) name))
2718 (when (gnus-group-entry nname)
2719 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2720 ;; Subscribe to the new group.
2721 (gnus-group-change-level
2722 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2723 gnus-level-default-subscribed gnus-level-killed
2724 (and (gnus-group-group-name)
2725 (gnus-group-entry (gnus-group-group-name)))
2728 (gnus-set-active nname (cons 1 0))
2729 (unless (gnus-ephemeral-group-p name)
2731 (concat "(gnus-group-set-info '"
2732 (gnus-prin1-to-string (cdr info)) ")")))
2734 (gnus-group-insert-group-line-info nname)
2736 (gnus-group-position-point)
2738 ;; Load the back end and try to make the back end create
2739 ;; the group as well.
2740 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2742 gnus-valid-select-methods)
2744 (gnus-check-server meth)
2745 (when (gnus-check-backend-function 'request-create-group nname)
2746 (unless (gnus-request-create-group nname nil args)
2747 (error "Could not create group on server: %s"
2748 (nnheader-get-report backend))))
2751 (defun gnus-group-delete-groups (&optional arg)
2752 "Delete the current group. Only meaningful with editable groups."
2754 (let ((n (length (gnus-group-process-prefix arg))))
2755 (when (gnus-yes-or-no-p
2757 "Delete this 1 group? "
2758 (format "Delete these %d groups? " n)))
2759 (gnus-group-iterate arg
2761 (gnus-group-delete-group group nil t))))))
2763 (defun gnus-group-delete-group (group &optional force no-prompt)
2764 "Delete the current group. Only meaningful with editable groups.
2765 If FORCE (the prefix) is non-nil, all the articles in the group will
2766 be deleted. This is \"deleted\" as in \"removed forever from the face
2767 of the Earth\". There is no undo. The user will be prompted before
2769 Note that you also have to specify FORCE if you want the group to
2770 be removed from the server, even when it's empty."
2772 (list (gnus-group-group-name)
2773 current-prefix-arg))
2775 (error "No group to delete"))
2776 (unless (gnus-check-backend-function 'request-delete-group group)
2777 (error "This back end does not support group deletion"))
2779 (let ((group-decoded (gnus-group-decoded-name group)))
2780 (if (and (not no-prompt)
2781 (not (gnus-yes-or-no-p
2783 "Do you really want to delete %s%s? "
2784 group-decoded (if force " and all its contents" "")))))
2786 (gnus-message 6 "Deleting group %s..." group-decoded)
2787 (if (not (gnus-request-delete-group group force))
2788 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2789 (gnus-message 6 "Deleting group %s...done" group-decoded)
2790 (gnus-group-goto-group group)
2791 (gnus-group-kill-group 1 t)
2792 (gnus-set-active group nil)
2794 (gnus-group-position-point)))
2796 (defun gnus-group-rename-group (group new-name)
2797 "Rename group from GROUP to NEW-NAME.
2798 When used interactively, GROUP is the group under point
2799 and NEW-NAME will be prompted for."
2801 (let ((group (gnus-group-group-name))
2803 (unless (gnus-check-backend-function 'request-rename-group group)
2804 (error "This back end does not support renaming groups"))
2805 (setq new-name (gnus-read-group
2807 (gnus-group-real-name (gnus-group-decoded-name group)))
2808 method (gnus-info-method (gnus-get-info group)))
2809 (list group (mm-encode-coding-string
2811 (gnus-group-name-charset
2813 (gnus-group-prefixed-name new-name method))))))
2815 (unless (gnus-check-backend-function 'request-rename-group group)
2816 (error "This back end does not support renaming groups"))
2818 (error "No group to rename"))
2819 (when (equal (gnus-group-real-name group) new-name)
2820 (error "Can't rename to the same name"))
2822 ;; We find the proper prefixed name.
2824 (if (gnus-group-native-p group)
2828 (gnus-group-prefixed-name
2829 (gnus-group-real-name new-name)
2830 (gnus-info-method (gnus-get-info group)))))
2832 (let ((decoded-group (gnus-group-decoded-name group))
2833 (decoded-new-name (gnus-group-decoded-name new-name)))
2834 (when (gnus-active new-name)
2835 (error "The group %s already exists" decoded-new-name))
2837 (gnus-message 6 "Renaming group %s to %s..."
2838 decoded-group decoded-new-name)
2841 (gnus-group-goto-group group)
2842 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2843 (gnus-request-rename-group group new-name))))
2844 (gnus-error 3 "Couldn't rename group %s to %s"
2845 decoded-group decoded-new-name)
2846 ;; We rename the group internally by killing it...
2847 (gnus-group-kill-group)
2848 ;; ... changing its name ...
2849 (setcar (cdar gnus-list-of-killed-groups) new-name)
2850 ;; ... and then yanking it. Magic!
2851 (gnus-group-yank-group)
2852 (gnus-set-active new-name (gnus-active group))
2853 (gnus-message 6 "Renaming group %s to %s...done"
2854 decoded-group decoded-new-name)
2856 (setq gnus-killed-list (delete group gnus-killed-list))
2857 (gnus-set-active group nil)
2858 (gnus-dribble-touch)
2859 (gnus-group-position-point))))
2861 (defun gnus-group-edit-group (group &optional part)
2862 "Edit the group on the current line."
2863 (interactive (list (gnus-group-group-name)))
2864 (let ((part (or part 'info))
2867 (error "No group on current line"))
2868 (unless (setq info (gnus-get-info group))
2869 (error "Killed group; can't be edited"))
2871 (gnus-close-group group))
2873 ;; Find the proper form to edit.
2874 (cond ((eq part 'method)
2875 (or (gnus-info-method info) "native"))
2877 (gnus-info-params info))
2879 ;; The proper documentation.
2881 "Editing the %s for `%s'."
2883 ((eq part 'method) "select method")
2884 ((eq part 'params) "group parameters")
2886 (gnus-group-decoded-name group))
2888 (gnus-group-edit-group-done ',part ,group form)))
2891 (gnus-create-info-command
2894 "(gnus)Select Methods")
2896 "(gnus)Group Parameters")
2898 "(gnus)Group Info"))))))
2900 (defun gnus-group-edit-group-method (group)
2901 "Edit the select method of GROUP."
2902 (interactive (list (gnus-group-group-name)))
2903 (gnus-group-edit-group group 'method))
2905 (defun gnus-group-edit-group-parameters (group)
2906 "Edit the group parameters of GROUP."
2907 (interactive (list (gnus-group-group-name)))
2908 (gnus-group-edit-group group 'params))
2910 (defun gnus-group-edit-group-done (part group form)
2912 (let* ((method (cond ((eq part 'info) (nth 4 form))
2913 ((eq part 'method) form)
2915 (info (cond ((eq part 'info) form)
2916 ((eq part 'method) (gnus-get-info group))
2919 (if (or (not method)
2921 gnus-select-method method))
2922 (gnus-group-real-name (car info))
2923 (gnus-group-prefixed-name
2924 (gnus-group-real-name (car info)) method))
2926 (when (and new-group
2927 (not (equal new-group group)))
2928 (when (gnus-group-goto-group group)
2929 (gnus-group-kill-group 1))
2930 (gnus-activate-group new-group))
2932 (if (not (and info new-group))
2933 (gnus-group-set-info form (or new-group group) part)
2934 (setq info (gnus-copy-sequence info))
2935 (setcar info new-group)
2936 (unless (gnus-server-equal method "native")
2937 (unless (nthcdr 3 info)
2938 (nconc info (list nil nil)))
2939 (unless (nthcdr 4 info)
2940 (nconc info (list nil)))
2941 (gnus-info-set-method info method))
2942 (gnus-group-set-info info))
2943 (gnus-group-update-group (or new-group group))
2944 (gnus-group-position-point)))
2946 (defun gnus-group-make-useful-group (group method)
2947 "Create one of the groups described in `gnus-useful-groups'."
2949 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2951 gnus-useful-groups)))
2953 ;; Don't use `caddr' here since macros within the `interactive'
2954 ;; form won't be expanded.
2955 (car (cddr entry)))))
2956 (setq method (gnus-copy-sequence method))
2958 (while (setq entry (memq (assq 'eval method) method))
2959 (setcar entry (eval (cadar entry)))))
2960 (gnus-group-make-group group method))
2962 (defun gnus-group-make-help-group (&optional noerror)
2963 "Create the Gnus documentation group.
2964 Optional argument NOERROR modifies the behavior of this function when the
2965 group already exists:
2966 - if not given, and error is signaled,
2967 - if t, stay silent,
2968 - if anything else, just print a message."
2970 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2971 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2972 (if (gnus-group-entry name)
2973 (cond ((eq noerror nil)
2974 (error "Documentation group already exists"))
2979 (gnus-message 1 "Documentation group already exists")))
2982 (gnus-message 1 "Couldn't find doc group")
2983 (gnus-group-make-group
2984 (gnus-group-real-name name)
2985 (list 'nndoc "gnus-help"
2986 (list 'nndoc-address file)
2987 (list 'nndoc-article-type 'mbox))))
2989 (gnus-group-position-point))
2991 (defun gnus-group-make-doc-group (file type)
2992 "Create a group that uses a single file as the source.
2994 If called with a prefix argument, ask for the file type."
2996 (list (read-file-name "File name: ")
2997 (and current-prefix-arg 'ask)))
2998 (when (eq type 'ask)
3003 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
3005 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
3006 ((= char ?b) 'babyl)
3007 ((= char ?d) 'digest)
3008 ((= char ?f) 'forward)
3010 ((= char ?g) 'guess)
3011 (t (setq err (format "%c unknown. " char))
3014 (setq file (expand-file-name file))
3015 (let* ((name (gnus-generate-new-group-name
3016 (gnus-group-prefixed-name
3017 (file-name-nondirectory file) '(nndoc ""))))
3018 (method (list 'nndoc file
3019 (list 'nndoc-address file)
3020 (list 'nndoc-article-type (or type 'guess))))
3021 (coding (gnus-group-name-charset method name)))
3022 (setcar (cdr method) (mm-encode-coding-string file coding))
3023 (gnus-group-make-group
3024 (mm-encode-coding-string (gnus-group-real-name name) coding)
3027 (defvar nnweb-type-definition)
3028 (defvar gnus-group-web-type-history nil)
3029 (defvar gnus-group-web-search-history nil)
3030 (defun gnus-group-make-web-group (&optional solid)
3031 "Create an ephemeral nnweb group.
3032 If SOLID (the prefix), create a solid group."
3036 (if solid (gnus-read-group "Group name: ")
3037 (message-unique-id)))
3038 (default-type (or (car gnus-group-web-type-history)
3039 (symbol-name (caar nnweb-type-definition))))
3043 (format "Search engine type (default %s): " default-type)
3044 (mapcar (lambda (elem) (list (symbol-name (car elem))))
3045 nnweb-type-definition)
3046 nil t nil 'gnus-group-web-type-history)
3051 (cons (or (car gnus-group-web-search-history) "") 0)
3052 'gnus-group-web-search-history))
3054 `(nnweb ,group (nnweb-search ,search)
3055 (nnweb-type ,(intern type))
3056 (nnweb-ephemeral-p t))))
3059 (gnus-pull 'nnweb-ephemeral-p method)
3060 (gnus-group-make-group group method))
3061 (gnus-group-read-ephemeral-group
3063 (cons (current-buffer)
3064 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
3066 (defvar nnrss-group-alist)
3068 (defun nnrss-discover-feed (arg))
3069 (defun nnrss-save-server-data (arg)))
3070 (defun gnus-group-make-rss-group (&optional url)
3071 "Given a URL, discover if there is an RSS feed.
3072 If there is, use Gnus to create an nnrss group"
3076 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
3077 (let ((feedinfo (nnrss-discover-feed url)))
3079 (let* ((title (gnus-newsgroup-savable-name
3080 (read-from-minibuffer "Title: "
3081 (gnus-newsgroup-savable-name
3085 (or (cdr (assoc 'title
3089 (desc (read-from-minibuffer "Description: "
3093 (or (cdr (assoc 'description
3097 (href (cdr (assoc 'href feedinfo)))
3098 (coding (gnus-group-name-charset '(nnrss "") title)))
3100 ;; Unify non-ASCII text.
3101 (setq title (mm-decode-coding-string
3102 (mm-encode-coding-string title coding)
3104 (gnus-group-make-group title '(nnrss ""))
3105 (push (list title href desc) nnrss-group-alist)
3106 (nnrss-save-server-data nil))
3107 (error "No feeds found for %s" url))))
3109 (defun gnus-group-make-archive-group (&optional all)
3110 "Create the (ding) Gnus archive group of the most recent articles.
3111 Given a prefix, create a full group."
3113 (let ((group (gnus-group-prefixed-name
3114 (if all "ding.archives" "ding.recent") '(nndir ""))))
3115 (when (gnus-group-entry group)
3116 (error "Archive group already exists"))
3117 (gnus-group-make-group
3118 (gnus-group-real-name group)
3119 (list 'nndir (if all "hpc" "edu")
3120 (list 'nndir-directory
3121 (if all gnus-group-archive-directory
3122 gnus-group-recent-archive-directory))))
3123 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
3125 (defun gnus-group-make-directory-group (dir)
3126 "Create an nndir group.
3127 The user will be prompted for a directory. The contents of this
3128 directory will be used as a newsgroup. The directory should contain
3129 mail messages or news articles in files that have numeric names."
3131 (list (read-file-name "Create group from directory: ")))
3132 (unless (file-exists-p dir)
3133 (error "No such directory"))
3134 (unless (file-directory-p dir)
3135 (error "Not a directory"))
3139 (while (or (not group) (gnus-group-entry group))
3141 (gnus-group-prefixed-name
3142 (expand-file-name ext dir)
3144 (setq ext (format "<%d>" (setq i (1+ i)))))
3145 (gnus-group-make-group
3146 (gnus-group-real-name group)
3147 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
3149 (defun gnus-group-add-to-virtual (n vgroup)
3150 "Add the current group to a virtual group."
3152 (list current-prefix-arg
3153 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
3155 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
3156 (error "%s is not an nnvirtual group" vgroup))
3157 (gnus-close-group vgroup)
3158 (let* ((groups (gnus-group-process-prefix n))
3159 (method (gnus-info-method (gnus-get-info vgroup))))
3160 (setcar (cdr method)
3162 (nth 1 method) "\\|"
3165 (gnus-group-remove-mark s)
3166 (concat "\\(^" (regexp-quote s) "$\\)"))
3168 (gnus-group-position-point))
3170 (defun gnus-group-make-empty-virtual (group)
3171 "Create a new, fresh, empty virtual group."
3172 (interactive "sCreate new, empty virtual group: ")
3173 (let* ((method (list 'nnvirtual "^$"))
3174 (pgroup (gnus-group-prefixed-name group method)))
3175 ;; Check whether it exists already.
3176 (when (gnus-group-entry pgroup)
3177 (error "Group %s already exists" pgroup))
3178 ;; Subscribe the new group after the group on the current line.
3179 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
3180 (gnus-group-update-group pgroup)
3182 (gnus-group-position-point)))
3184 (defun gnus-group-enter-directory (dir)
3185 "Enter an ephemeral nneething group."
3186 (interactive "DDirectory to read: ")
3187 (let* ((method (list 'nneething dir '(nneething-read-only t)))
3188 (leaf (gnus-group-prefixed-name
3189 (file-name-nondirectory (directory-file-name dir))
3191 (name (gnus-generate-new-group-name leaf)))
3192 (unless (gnus-group-read-ephemeral-group
3194 (cons (current-buffer)
3195 (if (eq major-mode 'gnus-summary-mode)
3197 (error "Couldn't enter %s" dir))))
3199 (defun gnus-group-expunge-group (group)
3200 "Expunge deleted articles in current nnimap GROUP."
3201 (interactive (list (gnus-group-group-name)))
3202 (let ((method (gnus-find-method-for-group group)))
3203 (if (not (gnus-check-backend-function
3204 'request-expunge-group (car method)))
3205 (error "%s does not support expunging" (car method))
3206 (gnus-request-expunge-group group method))))
3208 (autoload 'nnimap-acl-get "nnimap")
3209 (autoload 'nnimap-acl-edit "nnimap")
3211 (defun gnus-group-nnimap-edit-acl (group)
3212 "Edit the Access Control List of current nnimap GROUP."
3213 (interactive (list (gnus-group-group-name)))
3214 (let ((mailbox (gnus-group-real-name group)) method acl)
3216 (error "No group on current line"))
3217 (unless (gnus-get-info group)
3218 (error "Killed group; can't be edited"))
3219 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
3220 (error "%s is not an nnimap group" group))
3221 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
3222 (error "Server does not support ACL's"))
3223 (gnus-edit-form acl (format "Editing the access control list for `%s'.
3225 An access control list is a list of (identifier . rights) elements.
3227 The identifier string specifies the corresponding user. The
3228 identifier \"anyone\" is reserved to refer to the universal identity.
3230 Rights is a string listing a (possibly empty) set of alphanumeric
3231 characters, each character listing a set of operations which is being
3232 controlled. Letters are reserved for ``standard'' rights, listed
3233 below. Digits are reserved for implementation or site defined rights.
3235 l - lookup (mailbox is visible to LIST/LSUB commands)
3236 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
3237 SEARCH, COPY from mailbox)
3238 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
3239 w - write (STORE flags other than \\SEEN and \\DELETED)
3240 i - insert (perform APPEND, COPY into mailbox)
3241 p - post (send mail to submission address for mailbox,
3242 not enforced by IMAP4 itself)
3243 c - create and delete mailbox (CREATE new sub-mailboxes in any
3244 implementation-defined hierarchy, RENAME or DELETE mailbox)
3245 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
3246 a - administer (perform SETACL)" group)
3249 ,mailbox ',method ',acl form)))))
3251 ;; Group sorting commands
3252 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3254 (defun gnus-group-sort-groups (func &optional reverse)
3255 "Sort the group buffer according to FUNC.
3256 When used interactively, the sorting function used will be
3257 determined by the `gnus-group-sort-function' variable.
3258 If REVERSE (the prefix), reverse the sorting order."
3259 (interactive (list gnus-group-sort-function current-prefix-arg))
3260 (funcall gnus-group-sort-alist-function
3261 (gnus-make-sort-function func) reverse)
3262 (gnus-group-unmark-all-groups)
3263 (gnus-group-list-groups)
3264 (gnus-dribble-touch))
3266 (defun gnus-group-sort-flat (func reverse)
3267 ;; We peel off the dummy group from the alist.
3269 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
3270 (pop gnus-newsrc-alist))
3272 (setq gnus-newsrc-alist
3273 (sort gnus-newsrc-alist func))
3275 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
3276 ;; Regenerate the hash table.
3277 (gnus-make-hashtable-from-newsrc-alist)))
3279 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
3280 "Sort the group buffer alphabetically by group name.
3281 If REVERSE, sort in reverse order."
3283 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
3285 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
3286 "Sort the group buffer alphabetically by real (unprefixed) group name.
3287 If REVERSE, sort in reverse order."
3289 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
3291 (defun gnus-group-sort-groups-by-unread (&optional reverse)
3292 "Sort the group buffer by number of unread articles.
3293 If REVERSE, sort in reverse order."
3295 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
3297 (defun gnus-group-sort-groups-by-level (&optional reverse)
3298 "Sort the group buffer by group level.
3299 If REVERSE, sort in reverse order."
3301 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
3303 (defun gnus-group-sort-groups-by-score (&optional reverse)
3304 "Sort the group buffer by group score.
3305 If REVERSE, sort in reverse order."
3307 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
3309 (defun gnus-group-sort-groups-by-rank (&optional reverse)
3310 "Sort the group buffer by group rank.
3311 If REVERSE, sort in reverse order."
3313 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
3315 (defun gnus-group-sort-groups-by-method (&optional reverse)
3316 "Sort the group buffer alphabetically by back end name.
3317 If REVERSE, sort in reverse order."
3319 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
3321 (defun gnus-group-sort-groups-by-server (&optional reverse)
3322 "Sort the group buffer alphabetically by server name.
3323 If REVERSE, sort in reverse order."
3325 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
3327 ;;; Selected group sorting.
3329 (defun gnus-group-sort-selected-groups (n func &optional reverse)
3330 "Sort the process/prefixed groups."
3331 (interactive (list current-prefix-arg gnus-group-sort-function))
3332 (let ((groups (gnus-group-process-prefix n)))
3333 (funcall gnus-group-sort-selected-function
3334 groups (gnus-make-sort-function func) reverse)
3335 (gnus-group-unmark-all-groups)
3336 (gnus-group-list-groups)
3337 (gnus-dribble-touch)))
3339 (defun gnus-group-sort-selected-flat (groups func reverse)
3340 (let (entries infos)
3341 ;; First find all the group entries for these groups.
3343 (push (nthcdr 2 (gnus-group-entry (pop groups)))
3345 ;; Then sort the infos.
3349 (lambda (entry) (car entry))
3350 (setq entries (nreverse entries)))
3353 (setq infos (nreverse infos)))
3354 ;; Go through all the infos and replace the old entries
3355 ;; with the new infos.
3357 (setcar (car entries) (pop infos))
3359 ;; Update the hashtable.
3360 (gnus-make-hashtable-from-newsrc-alist)))
3362 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3363 "Sort the group buffer alphabetically by group name.
3364 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3365 sort in reverse order."
3366 (interactive (gnus-interactive "P\ny"))
3367 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3369 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3370 "Sort the group buffer alphabetically by real group name.
3371 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3372 sort in reverse order."
3373 (interactive (gnus-interactive "P\ny"))
3374 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3376 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3377 "Sort the group buffer by number of unread articles.
3378 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3379 sort in reverse order."
3380 (interactive (gnus-interactive "P\ny"))
3381 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3383 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3384 "Sort the group buffer by group level.
3385 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3386 sort in reverse order."
3387 (interactive (gnus-interactive "P\ny"))
3388 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3390 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3391 "Sort the group buffer by group score.
3392 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3393 sort in reverse order."
3394 (interactive (gnus-interactive "P\ny"))
3395 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3397 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3398 "Sort the group buffer by group rank.
3399 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3400 sort in reverse order."
3401 (interactive (gnus-interactive "P\ny"))
3402 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3404 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3405 "Sort the group buffer alphabetically by back end name.
3406 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3407 sort in reverse order."
3408 (interactive (gnus-interactive "P\ny"))
3409 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3411 ;;; Sorting predicates.
3413 (defun gnus-group-sort-by-alphabet (info1 info2)
3414 "Sort alphabetically."
3415 (string< (gnus-info-group info1) (gnus-info-group info2)))
3417 (defun gnus-group-sort-by-real-name (info1 info2)
3418 "Sort alphabetically on real (unprefixed) names."
3419 (string< (gnus-group-real-name (gnus-info-group info1))
3420 (gnus-group-real-name (gnus-info-group info2))))
3422 (defun gnus-group-sort-by-unread (info1 info2)
3423 "Sort by number of unread articles."
3424 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3425 (n2 (gnus-group-unread (gnus-info-group info2))))
3426 (< (or (and (numberp n1) n1) 0)
3427 (or (and (numberp n2) n2) 0))))
3429 (defun gnus-group-sort-by-level (info1 info2)
3431 (< (gnus-info-level info1) (gnus-info-level info2)))
3433 (defun gnus-group-sort-by-method (info1 info2)
3434 "Sort alphabetically by back end name."
3435 (string< (car (gnus-find-method-for-group
3436 (gnus-info-group info1) info1))
3437 (car (gnus-find-method-for-group
3438 (gnus-info-group info2) info2))))
3440 (defun gnus-group-sort-by-server (info1 info2)
3441 "Sort alphabetically by server name."
3442 (string< (gnus-method-to-full-server-name
3443 (gnus-find-method-for-group
3444 (gnus-info-group info1) info1))
3445 (gnus-method-to-full-server-name
3446 (gnus-find-method-for-group
3447 (gnus-info-group info2) info2))))
3449 (defun gnus-group-sort-by-score (info1 info2)
3450 "Sort by group score."
3451 (> (gnus-info-score info1) (gnus-info-score info2)))
3453 (defun gnus-group-sort-by-rank (info1 info2)
3454 "Sort by level and score."
3455 (let ((level1 (gnus-info-level info1))
3456 (level2 (gnus-info-level info2)))
3457 (or (< level1 level2)
3458 (and (= level1 level2)
3459 (> (gnus-info-score info1) (gnus-info-score info2))))))
3463 (defun gnus-group-clear-data (&optional arg)
3464 "Clear all marks and read ranges from the current group.
3465 Obeys the process/prefix convention."
3467 (gnus-group-iterate arg
3470 (gnus-info-clear-data (setq info (gnus-get-info group)))
3471 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3472 (when (gnus-group-goto-group group)
3473 (gnus-group-update-group-line))))))
3475 (defun gnus-group-clear-data-on-native-groups ()
3476 "Clear all marks and read ranges from all native groups."
3478 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3479 (let ((alist (cdr gnus-newsrc-alist))
3481 (while (setq info (pop alist))
3482 (when (gnus-group-native-p (gnus-info-group info))
3483 (gnus-info-clear-data info)))
3484 (gnus-get-unread-articles)
3485 (gnus-dribble-touch)
3486 (when (gnus-y-or-n-p
3487 "Move the cache away to avoid problems in the future? ")
3488 (call-interactively 'gnus-cache-move-cache)))))
3490 (defun gnus-info-clear-data (info)
3491 "Clear all marks and read ranges from INFO."
3492 (let ((group (gnus-info-group info))
3494 (dolist (el (gnus-info-marks info))
3495 (push `(,(cdr el) add (,(car el))) action))
3496 (push `(,(gnus-info-read info) add (read)) action)
3499 (gnus-request-set-mark ,group ',action)
3500 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3501 (gnus-info-set-read ',info ',(gnus-info-read info))
3502 (when (gnus-group-goto-group ,group)
3503 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3504 (gnus-group-update-group-line))))
3505 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3507 (gnus-request-set-mark group action)
3508 (gnus-info-set-read info nil)
3509 (when (gnus-info-marks info)
3510 (gnus-info-set-marks info nil))))
3512 ;; Group catching up.
3514 (defun gnus-group-catchup-current (&optional n all)
3515 "Mark all unread articles in the current newsgroup as read.
3516 If prefix argument N is numeric, the next N newsgroups will be
3517 caught up. If ALL is non-nil, marked articles will also be marked as
3518 read. Cross references (Xref: header) of articles are ignored.
3519 The number of newsgroups that this function was unable to catch
3522 (let ((groups (gnus-group-process-prefix n))
3525 (unless groups (error "No groups selected"))
3527 (or (not gnus-interactive-catchup) ;Without confirmation?
3532 "Do you really want to mark all articles in %s as read? "
3533 "Mark all unread articles in %s as read? ")
3534 (if (= (length groups) 1)
3535 (gnus-group-decoded-name (car groups))
3536 (format "these %d groups" (length groups)))))))
3538 (while (setq group (pop groups))
3539 (gnus-group-remove-mark group)
3540 ;; Virtual groups have to be given special treatment.
3541 (let ((method (gnus-find-method-for-group group)))
3542 (when (eq 'nnvirtual (car method))
3543 (nnvirtual-catchup-group
3544 (gnus-group-real-name group) (nth 1 method) all)))
3546 ((>= (gnus-group-level group) gnus-level-zombie)
3547 (gnus-message 2 "Dead groups can't be caught up"))
3549 (gnus-group-goto-group group)
3550 (gnus-group-catchup group all))
3551 (gnus-group-update-group-line))
3553 (setq ret (1+ ret)))))
3554 (gnus-group-next-unread-group 1)
3557 (defun gnus-group-catchup-current-all (&optional n)
3558 "Mark all articles in current newsgroup as read.
3559 Cross references (Xref: header) of articles are ignored."
3561 (gnus-group-catchup-current n 'all))
3563 (defun gnus-group-catchup (group &optional all)
3564 "Mark all articles in GROUP as read.
3565 If ALL is non-nil, all articles are marked as read.
3566 The return value is the number of articles that were marked as read,
3567 or nil if no action could be taken."
3568 (let* ((entry (gnus-group-entry group))
3570 (marks (gnus-info-marks (nth 2 entry)))
3571 (unread (gnus-sequence-of-unread-articles group)))
3572 ;; Remove entries for this group.
3573 (nnmail-purge-split-history (gnus-group-real-name group))
3574 ;; Do the updating only if the newsgroup isn't killed.
3575 (if (not (numberp (car entry)))
3576 (gnus-message 1 "Can't catch up %s; non-active group" group)
3577 (gnus-update-read-articles group nil)
3579 ;; Nix out the lists of marks and dormants.
3580 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3582 (list (cdr (assq 'dormant marks))
3584 (setq unread (gnus-range-add (gnus-range-add
3585 unread (cdr (assq 'dormant marks)))
3586 (cdr (assq 'tick marks))))
3587 (gnus-add-marked-articles group 'tick nil nil 'force)
3588 (gnus-add-marked-articles group 'dormant nil nil 'force))
3589 ;; Do auto-expirable marks if that's required.
3590 (when (gnus-group-auto-expirable-p group)
3593 (gnus-add-marked-articles group 'expire (list article))
3594 (gnus-request-set-mark group (list (list (list article)
3597 (let ((gnus-newsgroup-name group))
3598 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3601 (defun gnus-group-expire-articles (&optional n)
3602 "Expire all expirable articles in the current newsgroup.
3603 Uses the process/prefix convention."
3605 (let ((groups (gnus-group-process-prefix n))
3608 (error "No groups to expire"))
3609 (while (setq group (pop groups))
3610 (gnus-group-remove-mark group)
3611 (gnus-group-expire-articles-1 group)
3612 (gnus-dribble-touch)
3613 (gnus-group-position-point))))
3615 (defun gnus-group-expire-articles-1 (group)
3616 (when (gnus-check-backend-function 'request-expire-articles group)
3617 (gnus-message 6 "Expiring articles in %s..."
3618 (gnus-group-decoded-name group))
3619 (let* ((info (gnus-get-info group))
3620 (expirable (if (gnus-group-total-expirable-p group)
3621 (cons nil (gnus-list-of-read-articles group))
3622 (assq 'expire (gnus-info-marks info))))
3623 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3624 (nnmail-expiry-target
3625 (or (gnus-group-find-parameter group 'expiry-target)
3626 nnmail-expiry-target)))
3628 (gnus-check-group group)
3631 (gnus-compress-sequence
3633 ;; We set the expiry variables to the group
3635 (let ((nnmail-expiry-wait-function nil)
3636 (nnmail-expiry-wait expiry-wait))
3637 (gnus-request-expire-articles
3638 (gnus-uncompress-sequence (cdr expirable)) group))
3639 ;; Just expire using the normal expiry values.
3640 (gnus-request-expire-articles
3641 (gnus-uncompress-sequence (cdr expirable)) group))))
3642 (gnus-close-group group))
3643 (gnus-message 6 "Expiring articles in %s...done"
3644 (gnus-group-decoded-name group))
3645 ;; Return the list of un-expired articles.
3648 (defun gnus-group-expire-all-groups ()
3649 "Expire all expirable articles in all newsgroups."
3652 (gnus-message 5 "Expiring...")
3653 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3654 (cdr gnus-newsrc-alist))))
3655 (gnus-group-expire-articles nil)))
3656 (gnus-group-position-point)
3657 (gnus-message 5 "Expiring...done"))
3659 (defun gnus-group-set-current-level (n level)
3660 "Set the level of the next N groups to LEVEL."
3665 (unless (gnus-group-process-prefix current-prefix-arg)
3666 (error "No group on the current line"))
3668 (let ((s (read-string
3669 (format "Level (default %s): "
3670 (or (gnus-group-group-level)
3671 gnus-level-default-subscribed)))))
3672 (if (string-match "^\\s-*$" s)
3673 (int-to-string (or (gnus-group-group-level)
3674 gnus-level-default-subscribed))
3676 (unless (and (>= level 1) (<= level gnus-level-killed))
3677 (error "Invalid level: %d" level))
3678 (dolist (group (gnus-group-process-prefix n))
3679 (gnus-group-remove-mark group)
3680 (gnus-message 6 "Changed level of %s from %d to %d"
3681 (gnus-group-decoded-name group)
3682 (or (gnus-group-group-level) gnus-level-killed)
3684 (gnus-group-change-level
3685 group level (or (gnus-group-group-level) gnus-level-killed))
3686 (gnus-group-update-group-line))
3687 (gnus-group-position-point))
3689 (defun gnus-group-unsubscribe (&optional n)
3690 "Unsubscribe the current group."
3692 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3694 (defun gnus-group-subscribe (&optional n)
3695 "Subscribe the current group."
3697 (gnus-group-unsubscribe-current-group n 'subscribe))
3699 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3700 "Toggle subscription of the current group.
3701 If given numerical prefix, toggle the N next groups."
3703 (dolist (group (gnus-group-process-prefix n))
3704 (gnus-group-remove-mark group)
3705 (gnus-group-unsubscribe-group
3708 ((eq do-sub 'unsubscribe)
3709 gnus-level-default-unsubscribed)
3710 ((eq do-sub 'subscribe)
3711 gnus-level-default-subscribed)
3712 ((<= (gnus-group-group-level) gnus-level-subscribed)
3713 gnus-level-default-unsubscribed)
3715 gnus-level-default-subscribed))
3717 (gnus-group-update-group-line))
3718 (gnus-group-next-group 1))
3720 (defun gnus-group-unsubscribe-group (group &optional level silent)
3721 "Toggle subscription to GROUP.
3722 Killed newsgroups are subscribed. If SILENT, don't try to update the
3724 (interactive (list (gnus-group-completing-read
3725 "Group: " nil nil (gnus-read-active-file-p))))
3726 (let ((newsrc (gnus-group-entry group)))
3728 ((string-match "^[ \t]*$" group)
3729 (error "Empty group name"))
3731 ;; Toggle subscription flag.
3732 (gnus-group-change-level
3733 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3734 gnus-level-subscribed)
3735 (1+ gnus-level-subscribed)
3736 gnus-level-default-subscribed)))
3738 (gnus-group-update-group group)))
3739 ((and (stringp group)
3740 (or (not (gnus-read-active-file-p))
3741 (gnus-active group)))
3742 ;; Add new newsgroup.
3743 (gnus-group-change-level
3745 (if level level gnus-level-default-subscribed)
3746 (or (and (member group gnus-zombie-list)
3749 (when (gnus-group-group-name)
3750 (gnus-group-entry (gnus-group-group-name))))
3752 (gnus-group-update-group group)))
3753 (t (error "No such newsgroup: %s" group)))
3754 (gnus-group-position-point)))
3756 (defun gnus-group-transpose-groups (n)
3757 "Move the current newsgroup up N places.
3758 If given a negative prefix, move down instead. The difference between
3759 N and the number of steps taken is returned."
3761 (unless (gnus-group-group-name)
3762 (error "No group on current line"))
3763 (gnus-group-kill-group 1)
3765 (forward-line (- n))
3766 (gnus-group-yank-group)
3767 (gnus-group-position-point)))
3769 (defun gnus-group-kill-all-zombies (&optional dummy)
3770 "Kill all zombie newsgroups.
3771 The optional DUMMY should always be nil."
3772 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3774 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3775 (setq gnus-zombie-list nil)
3776 (gnus-dribble-touch)
3777 (gnus-group-list-groups)))
3779 (defun gnus-group-kill-region (begin end)
3780 "Kill newsgroups in current region (excluding current point).
3781 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3794 (beginning-of-line) ;Important when LINES < 1
3795 (gnus-group-kill-group lines)))
3797 (defun gnus-group-kill-group (&optional n discard)
3798 "Kill the next N groups.
3799 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3800 However, only groups that were alive can be yanked; already killed
3801 groups or zombie groups can't be yanked.
3802 The return value is the name of the group that was killed, or a list
3805 (let ((buffer-read-only nil)
3806 (groups (gnus-group-process-prefix n))
3807 group entry level out)
3808 (if (< (length groups) 10)
3809 ;; This is faster when there are few groups.
3811 (push (setq group (pop groups)) out)
3812 (gnus-group-remove-mark group)
3813 (setq level (gnus-group-group-level))
3815 (when (and (not discard)
3816 (setq entry (gnus-group-entry group)))
3819 (gnus-group-goto-group ,(gnus-group-group-name))
3820 (gnus-group-yank-group)))
3821 (push (cons (car entry) (nth 2 entry))
3822 gnus-list-of-killed-groups))
3823 (gnus-group-change-level
3824 (if entry entry group) gnus-level-killed (if entry nil level))
3825 (message "Killed group %s" (gnus-group-decoded-name group)))
3826 ;; If there are lots and lots of groups to be killed, we use
3827 ;; this thing instead.
3828 (dolist (group (nreverse groups))
3829 (gnus-group-remove-mark group)
3831 (push group gnus-killed-list)
3832 (setq gnus-newsrc-alist
3833 (delq (assoc group gnus-newsrc-alist)
3835 (when gnus-group-change-level-function
3836 (funcall gnus-group-change-level-function
3837 group gnus-level-killed 3))
3839 ((setq entry (gnus-group-entry group))
3840 (push (cons (car entry) (nth 2 entry))
3841 gnus-list-of-killed-groups)
3842 (setcdr (cdr entry) (cdddr entry)))
3843 ((member group gnus-zombie-list)
3844 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3845 ;; There may be more than one instance displayed.
3846 (while (gnus-group-goto-group group)
3847 (gnus-delete-line)))
3848 (gnus-make-hashtable-from-newsrc-alist))
3850 (gnus-group-position-point)
3851 (if (< (length out) 2) (car out) (nreverse out))))
3853 (defun gnus-group-yank-group (&optional arg)
3854 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3855 The numeric ARG specifies how many newsgroups are to be yanked. The
3856 name of the newsgroup yanked is returned, or (if several groups are
3857 yanked) a list of yanked groups is returned."
3859 (setq arg (or arg 1))
3860 (let (info group prev out)
3861 (while (>= (decf arg) 0)
3862 (when (not (setq info (pop gnus-list-of-killed-groups)))
3863 (error "No more newsgroups to yank"))
3864 (push (setq group (nth 1 info)) out)
3865 ;; Find which newsgroup to insert this one before - search
3866 ;; backward until something suitable is found. If there are no
3867 ;; other newsgroups in this buffer, just make this newsgroup the
3869 (setq prev (gnus-group-group-name))
3870 (gnus-group-change-level
3871 info (gnus-info-level (cdr info)) gnus-level-killed
3872 (and prev (gnus-group-entry prev))
3874 (gnus-group-insert-group-line-info group)
3876 `(when (gnus-group-goto-group ,group)
3877 (gnus-group-kill-group 1))))
3879 (gnus-group-position-point)
3880 (if (< (length out) 2) (car out) (nreverse out))))
3882 (defun gnus-group-kill-level (level)
3883 "Kill all groups that is on a certain LEVEL."
3884 (interactive "nKill all groups on level: ")
3886 ((= level gnus-level-zombie)
3887 (setq gnus-killed-list
3888 (nconc gnus-zombie-list gnus-killed-list))
3889 (setq gnus-zombie-list nil))
3890 ((and (< level gnus-level-zombie)
3892 (or gnus-expert-user
3895 "Do you really want to kill all groups on level %d? "
3897 (let* ((prev gnus-newsrc-alist)
3900 (if (= (gnus-info-level (car alist)) level)
3902 (push (gnus-info-group (car alist)) gnus-killed-list)
3903 (setcdr prev (cdr alist)))
3905 (setq alist (cdr alist)))
3906 (gnus-make-hashtable-from-newsrc-alist)
3907 (gnus-group-list-groups)))
3909 (error "Can't kill; invalid level: %d" level))))
3911 (defun gnus-group-list-all-groups (&optional arg)
3912 "List all newsgroups with level ARG or lower.
3913 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3914 unsubscribed groups."
3916 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3918 ;; Redefine this to list ALL killed groups if prefix arg used.
3919 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3920 (defun gnus-group-list-killed (&optional arg)
3921 "List all killed newsgroups in the group buffer.
3922 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3923 entail asking the server for the groups."
3925 ;; Find all possible killed newsgroups if arg.
3927 (gnus-get-killed-groups))
3928 (if (not gnus-killed-list)
3929 (gnus-message 6 "No killed groups")
3930 (let (gnus-group-list-mode)
3931 (funcall gnus-group-prepare-function
3932 gnus-level-killed t gnus-level-killed))
3933 (goto-char (point-min)))
3934 (gnus-group-position-point))
3936 (defun gnus-group-list-zombies ()
3937 "List all zombie newsgroups in the group buffer."
3939 (if (not gnus-zombie-list)
3940 (gnus-message 6 "No zombie groups")
3941 (let (gnus-group-list-mode)
3942 (funcall gnus-group-prepare-function
3943 gnus-level-zombie t gnus-level-zombie))
3944 (goto-char (point-min)))
3945 (gnus-group-position-point))
3947 (defun gnus-group-list-active ()
3948 "List all groups that are available from the server(s)."
3950 ;; First we make sure that we have really read the active file.
3951 (unless (gnus-read-active-file-p)
3952 (let ((gnus-read-active-file t)
3953 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3954 (gnus-read-active-file)))
3955 ;; Find all groups and sort them.
3963 (push (symbol-name sym) list)))
3967 (buffer-read-only nil)
3971 (setq group (pop groups))
3972 (gnus-add-text-properties
3973 (point) (prog1 (1+ (point))
3975 (gnus-group-decoded-name group)
3977 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3979 'gnus-level (inline (gnus-group-level group)))))
3980 (goto-char (point-min))))
3982 (defun gnus-activate-all-groups (level)
3983 "Activate absolutely all groups."
3984 (interactive (list gnus-level-unsubscribed))
3985 (let ((gnus-activate-level level)
3986 (gnus-activate-foreign-newsgroups level))
3987 (gnus-group-get-new-news)))
3989 (defun gnus-group-get-new-news (&optional arg)
3990 "Get newly arrived articles.
3991 If ARG is a number, it specifies which levels you are interested in
3992 re-scanning. If ARG is non-nil and not a number, this will force
3993 \"hard\" re-reading of the active files from all servers."
3996 (let ((gnus-inhibit-demon t)
3997 ;; Binding this variable will inhibit multiple fetchings
3998 ;; of the same mail source.
3999 (nnmail-fetched-sources (list t)))
4000 (gnus-run-hooks 'gnus-get-top-new-news-hook)
4001 (gnus-run-hooks 'gnus-get-new-news-hook)
4003 ;; Read any slave files.
4005 (gnus-master-read-slave-newsrc))
4007 ;; We might read in new NoCeM messages here.
4008 (when (and gnus-use-nocem
4009 (or (and (numberp gnus-use-nocem)
4011 (>= arg gnus-use-nocem))
4013 (gnus-nocem-scan-groups))
4015 (gnus-get-unread-articles arg)
4017 ;; If the user wants it, we scan for new groups.
4018 (when (eq gnus-check-new-newsgroups 'always)
4019 (gnus-find-new-newsgroups))
4021 (gnus-check-reasonable-setup)
4022 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
4023 (gnus-group-list-groups (and (numberp arg)
4024 (max (car gnus-group-list-mode) arg)))))
4026 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
4027 "Check for newly arrived news in the current group (and the N-1 next groups).
4028 The difference between N and the number of newsgroup checked is returned.
4029 If N is negative, this group and the N-1 previous groups will be checked.
4030 If DONT-SCAN is non-nil, scan non-activated groups as well."
4032 (let* ((groups (gnus-group-process-prefix n))
4033 (ret (if (numberp n) (- n (length groups)) 0))
4037 (gnus-inhibit-demon t)
4038 ;; Binding this variable will inhibit multiple fetchings
4039 ;; of the same mail source.
4040 (nnmail-fetched-sources (list t)))
4041 (gnus-run-hooks 'gnus-get-new-news-hook)
4042 (while (setq group (pop groups))
4043 (gnus-group-remove-mark group)
4044 ;; Bypass any previous denials from the server.
4045 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
4046 (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
4047 (let ((info (gnus-get-info group))
4048 (active (gnus-active group)))
4050 (gnus-request-update-info info method))
4051 (gnus-get-unread-articles-in-group info active)
4052 (unless (gnus-virtual-group-p group)
4053 (gnus-close-group group))
4055 (gnus-agent-save-group-info
4056 method (gnus-group-real-name group) active))
4057 (gnus-group-update-group group))
4058 (if (eq (gnus-server-status (gnus-find-method-for-group group))
4060 (gnus-error 3 "Server denied access")
4061 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
4064 (when gnus-goto-next-group-when-activating
4065 (gnus-group-next-unread-group 1 t))
4066 (gnus-summary-position-point)
4069 (defun gnus-group-fetch-faq (group &optional faq-dir)
4070 "Fetch the FAQ for the current group.
4071 If given a prefix argument, prompt for the FAQ dir
4075 (gnus-group-group-name)
4076 (when current-prefix-arg
4078 "FAQ dir: " (and (listp gnus-group-faq-directory)
4080 gnus-group-faq-directory))))))
4082 (error "No group name given"))
4083 (let ((dirs (or faq-dir gnus-group-faq-directory))
4085 (unless (listp dirs)
4086 (setq dirs (list dirs)))
4087 (while (and (not found)
4088 (setq dir (pop dirs)))
4089 (let ((name (gnus-group-real-name group)))
4090 (setq file (expand-file-name name dir)))
4091 (if (not (file-exists-p file))
4092 (gnus-message 1 "No such file: %s" file)
4093 (let ((enable-local-variables nil))
4097 (defun gnus-group-fetch-charter (group)
4098 "Fetch the charter for the current group.
4099 If given a prefix argument, prompt for a group."
4101 (list (or (when current-prefix-arg
4102 (gnus-group-completing-read "Group: "))
4103 (gnus-group-group-name)
4104 gnus-newsgroup-name)))
4106 (error "No group name given"))
4108 (condition-case nil (require 'url-http) (error nil))
4109 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
4111 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
4112 (setq hierarchy (match-string 1 name))
4113 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
4114 (if (fboundp 'url-http-file-exists-p)
4115 (url-http-file-exists-p (eval url))
4117 (browse-url (eval url))
4118 (setq url (concat "http://" hierarchy
4119 ".news-admin.org/charters/" name))
4120 (if (and (fboundp 'url-http-file-exists-p)
4121 (url-http-file-exists-p url))
4123 (gnus-group-fetch-control group))))))
4125 (defun gnus-group-fetch-control (group)
4126 "Fetch the archived control messages for the current group.
4127 If given a prefix argument, prompt for a group."
4129 (list (or (when current-prefix-arg
4130 (gnus-group-completing-read "Group: "))
4131 (gnus-group-group-name)
4132 gnus-newsgroup-name)))
4134 (error "No group name given"))
4135 (let ((name (gnus-group-real-name group))
4137 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
4138 (setq hierarchy (match-string 1 name))
4139 (if gnus-group-fetch-control-use-browse-url
4140 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
4141 hierarchy "/" name ".gz"))
4142 (let ((enable-local-variables nil))
4143 (gnus-group-read-ephemeral-group
4145 `(nndoc ,group (nndoc-address
4146 ,(find-file-noselect
4147 (concat "/ftp@ftp.isc.org:/usenet/control/"
4148 hierarchy "/" name ".gz")))
4149 (nndoc-article-type mbox)) t nil nil))))))
4151 (defun gnus-group-describe-group (force &optional group)
4152 "Display a description of the current newsgroup."
4153 (interactive (list current-prefix-arg (gnus-group-group-name)))
4154 (let* ((method (gnus-find-method-for-group group))
4155 (mname (gnus-group-prefixed-name "" method))
4158 gnus-description-hashtb)
4159 (gnus-sethash mname nil gnus-description-hashtb))
4161 (error "No group name given"))
4162 (when (or (and gnus-description-hashtb
4163 ;; We check whether this group's method has been
4164 ;; queried for a description file.
4165 (gnus-gethash mname gnus-description-hashtb))
4166 (setq desc (gnus-group-get-description group))
4167 (gnus-read-descriptions-file method))
4168 (gnus-message 1 "%s"
4169 (or desc (gnus-gethash group gnus-description-hashtb)
4170 "No description available")))))
4172 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4173 (defun gnus-group-describe-all-groups (&optional force)
4174 "Pop up a buffer with descriptions of all newsgroups."
4177 (setq gnus-description-hashtb nil))
4178 (when (not (or gnus-description-hashtb
4179 (gnus-read-all-descriptions-files)))
4180 (error "Couldn't request descriptions file"))
4181 (let ((buffer-read-only nil)
4187 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
4188 (insert (format " *: %-20s %s\n"
4189 (gnus-group-name-decode
4190 (symbol-name group) charset)
4191 (gnus-group-name-decode
4192 (symbol-value group) charset))))
4193 (gnus-add-text-properties
4194 b (1+ b) (list 'gnus-group group
4195 'gnus-unread t 'gnus-marked nil
4196 'gnus-level (1+ gnus-level-subscribed))))
4197 gnus-description-hashtb)
4198 (goto-char (point-min))
4199 (gnus-group-position-point)))
4201 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
4202 (defun gnus-group-apropos (regexp &optional search-description)
4203 "List all newsgroups that have names that match a regexp."
4204 (interactive "sGnus apropos (regexp): ")
4206 (obuf (current-buffer))
4208 ;; Go through all newsgroups that are known to Gnus.
4211 (and (symbol-name group)
4212 (string-match regexp (symbol-name group))
4213 (symbol-value group)
4214 (push (symbol-name group) groups)))
4216 ;; Also go through all descriptions that are known to Gnus.
4217 (when search-description
4220 (and (string-match regexp (symbol-value group))
4221 (push (symbol-name group) groups)))
4222 gnus-description-hashtb))
4224 (gnus-message 3 "No groups matched \"%s\"." regexp)
4225 ;; Print out all the groups.
4227 (pop-to-buffer "*Gnus Help*")
4228 (buffer-disable-undo)
4230 (setq groups (sort groups 'string<))
4232 ;; Groups may be entered twice into the list of groups.
4233 (when (not (string= (car groups) prev))
4234 (setq prev (car groups))
4235 (let ((charset (gnus-group-name-charset nil prev)))
4236 (insert (gnus-group-name-decode prev charset) "\n")
4237 (when (and gnus-description-hashtb
4238 (setq des (gnus-gethash (car groups)
4239 gnus-description-hashtb)))
4240 (insert " " (gnus-group-name-decode des charset) "\n"))))
4241 (setq groups (cdr groups)))
4242 (goto-char (point-min))))
4243 (pop-to-buffer obuf)))
4245 (defun gnus-group-description-apropos (regexp)
4246 "List all newsgroups that have names or descriptions that match REGEXP."
4247 (interactive "sGnus description apropos (regexp): ")
4248 (when (not (or gnus-description-hashtb
4249 (gnus-read-all-descriptions-files)))
4250 (error "Couldn't request descriptions file"))
4251 (gnus-group-apropos regexp t))
4253 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4254 (defun gnus-group-list-matching (level regexp &optional all lowest)
4255 "List all groups with unread articles that match REGEXP.
4256 If the prefix LEVEL is non-nil, it should be a number that says which
4257 level to cut off listing groups.
4258 If ALL, also list groups with no unread articles.
4259 If LOWEST, don't list groups with level lower than LOWEST.
4261 This command may read the active file."
4262 (interactive "P\nsList newsgroups matching: ")
4263 ;; First make sure active file has been read.
4265 (> (prefix-numeric-value level) gnus-level-killed))
4266 (gnus-get-killed-groups))
4267 (funcall gnus-group-prepare-function
4268 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
4269 (goto-char (point-min))
4270 (gnus-group-position-point))
4272 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4273 "List all groups that match REGEXP.
4274 If the prefix LEVEL is non-nil, it should be a number that says which
4275 level to cut off listing groups.
4276 If LOWEST, don't list groups with level lower than LOWEST."
4277 (interactive "P\nsList newsgroups matching: ")
4279 (setq level (prefix-numeric-value level)))
4280 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4282 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4283 (defun gnus-group-save-newsrc (&optional force)
4284 "Save the Gnus startup files.
4285 If FORCE, force saving whether it is necessary or not."
4287 (gnus-save-newsrc-file force))
4289 (defun gnus-group-restart (&optional arg)
4290 "Force Gnus to read the .newsrc file."
4292 (when (gnus-yes-or-no-p
4293 (format "Are you sure you want to restart Gnus? "))
4294 (gnus-save-newsrc-file)
4298 (defun gnus-group-read-init-file ()
4299 "Read the Gnus elisp init file."
4301 (gnus-read-init-file)
4302 (gnus-message 5 "Read %s" gnus-init-file))
4304 (defun gnus-group-check-bogus-groups (&optional silent)
4305 "Check bogus newsgroups.
4306 If given a prefix, don't ask for confirmation before removing a bogus
4309 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4310 (gnus-group-list-groups))
4312 (defun gnus-group-find-new-groups (&optional arg)
4313 "Search for new groups and add them.
4314 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
4315 With 1 C-u, use the `ask-server' method to query the server for new
4317 With 2 C-u's, use most complete method possible to query the server
4318 for new groups, and subscribe the new groups as zombies."
4320 (gnus-find-new-newsgroups (or arg 1))
4321 (gnus-group-list-groups))
4323 (defun gnus-group-edit-global-kill (&optional article group)
4324 "Edit the global kill file.
4325 If GROUP, edit that local kill file instead."
4327 (setq gnus-current-kill-article article)
4328 (gnus-kill-file-edit-file group)
4329 (gnus-message 6 "Editing a %s kill file (Type %s to exit)"
4330 (if group "local" "global")
4331 (substitute-command-keys "\\[gnus-kill-file-exit]")))
4333 (defun gnus-group-edit-local-kill (article group)
4334 "Edit a local kill file."
4335 (interactive (list nil (gnus-group-group-name)))
4336 (gnus-group-edit-global-kill article group))
4338 (defun gnus-group-force-update ()
4339 "Update `.newsrc' file."
4341 (gnus-save-newsrc-file))
4343 (defvar gnus-backlog-articles)
4345 (defun gnus-group-suspend ()
4346 "Suspend the current Gnus session.
4347 In fact, cleanup buffers except for group mode buffer.
4348 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4350 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4351 (gnus-offer-save-summaries)
4352 ;; Kill Gnus buffers except for group mode buffer.
4353 (let ((group-buf (get-buffer gnus-group-buffer)))
4354 (dolist (buf (gnus-buffers))
4355 (unless (or (eq buf group-buf)
4356 (eq buf gnus-dribble-buffer)
4357 (with-current-buffer buf
4358 (eq major-mode 'message-mode)))
4359 (gnus-kill-buffer buf)))
4360 (setq gnus-backlog-articles nil)
4361 (gnus-kill-gnus-frames)
4363 (bury-buffer group-buf)
4364 (delete-windows-on group-buf t))))
4366 (defun gnus-group-clear-dribble ()
4367 "Clear all information from the dribble buffer."
4369 (gnus-dribble-clear)
4370 (gnus-message 7 "Cleared dribble buffer"))
4372 (defun gnus-group-exit ()
4373 "Quit reading news after updating .newsrc.eld and .newsrc.
4374 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4377 (or noninteractive ;For gnus-batch-kill
4378 (not gnus-interactive-exit) ;Without confirmation
4380 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4381 (gnus-run-hooks 'gnus-exit-gnus-hook)
4382 ;; Offer to save data from non-quitted summary buffers.
4383 (gnus-offer-save-summaries)
4384 ;; Save the newsrc file(s).
4385 (gnus-save-newsrc-file)
4387 (gnus-close-backends)
4388 ;; Reset everything.
4390 ;; Allow the user to do things after cleaning up.
4391 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4393 (defun gnus-group-quit ()
4394 "Quit reading news without updating .newsrc.eld or .newsrc.
4395 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4397 (when (or noninteractive ;For gnus-batch-kill
4398 (zerop (buffer-size))
4399 (not (gnus-server-opened gnus-select-method))
4401 (not gnus-current-startup-file)
4403 (format "Quit reading news without saving %s? "
4404 (file-name-nondirectory gnus-current-startup-file))))
4405 (gnus-run-hooks 'gnus-exit-gnus-hook)
4406 (gnus-configure-windows 'group t)
4407 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4408 (not (zerop (with-current-buffer gnus-dribble-buffer
4411 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4413 (gnus-close-backends)
4415 (gnus-kill-buffer gnus-group-buffer)
4416 ;; Allow the user to do things after cleaning up.
4417 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4419 (defun gnus-group-describe-briefly ()
4420 "Give a one line description of the group mode commands."
4422 (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")))
4424 (defun gnus-group-browse-foreign-server (method)
4425 "Browse a foreign news server.
4426 If called interactively, this function will ask for a select method
4427 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4428 If not, METHOD should be a list where the first element is the method
4429 and the second element is the address."
4431 (list (let ((how (completing-read
4433 (append gnus-valid-select-methods gnus-server-alist)
4434 nil t (cons "nntp" 0) 'gnus-method-history)))
4435 ;; We either got a back end name or a virtual server name.
4436 ;; If the first, we also need an address.
4437 (if (assoc how gnus-valid-select-methods)
4439 ;; Suggested by mapjph@bath.ac.uk.
4442 (mapcar 'list gnus-secondary-servers)))
4443 ;; We got a server name.
4445 (gnus-browse-foreign-server method))
4447 (defun gnus-group-set-info (info &optional method-only-group part)
4448 (when (or info part)
4449 (let* ((entry (gnus-group-entry
4450 (or method-only-group (gnus-info-group info))))
4452 (info (if method-only-group (nth 2 entry) info))
4454 (when method-only-group
4456 (error "Trying to change non-existent group %s" method-only-group))
4457 ;; We have received parts of the actual group info - either the
4458 ;; select method or the group parameters. We first check
4459 ;; whether we have to extend the info, and if so, do that.
4460 (let ((len (length info))
4461 (total (if (eq part 'method) 5 6)))
4463 (setcdr (nthcdr (1- len) info)
4464 (make-list (- total len) nil)))
4465 ;; Then we enter the new info.
4466 (setcar (nthcdr (1- total) info) part-info)))
4468 ;; This is a new group, so we just create it.
4469 (with-current-buffer gnus-group-buffer
4470 (setq method (gnus-info-method info))
4471 (when (gnus-server-equal method "native")
4473 (with-current-buffer gnus-group-buffer
4475 ;; It's a foreign group...
4476 (gnus-group-make-group
4477 (gnus-group-real-name (gnus-info-group info))
4478 (if (stringp method) method
4479 (prin1-to-string (car method)))
4481 (nth 1 (gnus-info-method info)))
4483 ;; It's a native group.
4484 (gnus-group-make-group (gnus-info-group info) nil nil nil t)))
4485 (gnus-message 6 "Note: New group created")
4487 (gnus-group-entry (gnus-group-prefixed-name
4488 (gnus-group-real-name (gnus-info-group info))
4489 (or (gnus-info-method info) gnus-select-method))))))
4490 ;; Whether it was a new group or not, we now have the entry, so we
4491 ;; can do the update.
4494 (setcar (nthcdr 2 entry) info)
4495 (when (and (not (eq (car entry) t))
4496 (gnus-active (gnus-info-group info)))
4497 (setcar entry (length
4498 (gnus-list-of-unread-articles (car info))))))
4499 (error "No such group: %s" (gnus-info-group info))))))
4501 (defun gnus-group-set-method-info (group select-method)
4502 (gnus-group-set-info select-method group 'method))
4504 (defun gnus-group-set-params-info (group params)
4505 (gnus-group-set-info params group 'params))
4507 (defun gnus-add-marked-articles (group type articles &optional info force)
4508 ;; Add ARTICLES of TYPE to the info of GROUP.
4509 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4510 ;; add, but replace marked articles of TYPE with ARTICLES.
4511 (let ((info (or info (gnus-get-info group)))
4514 (and (not (setq marked (nthcdr 3 info)))
4516 (setcdr (nthcdr 2 info)
4517 (list (list (cons type (gnus-compress-sequence
4519 (and (not (setq m (assq type (car marked))))
4522 (cons (cons type (gnus-compress-sequence articles t) )
4526 (setcar (nthcdr 3 info)
4527 (gnus-delete-alist type (car marked)))
4528 (setcdr m (gnus-compress-sequence articles t)))
4529 (setcdr m (gnus-compress-sequence
4530 (sort (nconc (gnus-uncompress-range (cdr m))
4531 (copy-sequence articles)) '<) t))))))
4533 (defun gnus-add-mark (group mark article)
4534 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4535 (let ((buffer (gnus-summary-buffer-name group)))
4536 (if (gnus-buffer-live-p buffer)
4537 (with-current-buffer (get-buffer buffer)
4538 (gnus-summary-add-mark article mark))
4539 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4543 ;;; Group timestamps
4546 (defun gnus-group-set-timestamp ()
4547 "Change the timestamp of the current group to the current time.
4548 This function can be used in hooks like `gnus-select-group-hook'
4549 or `gnus-group-catchup-group-hook'."
4550 (when gnus-newsgroup-name
4551 (let ((time (current-time)))
4552 (setcdr (cdr time) nil)
4553 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4555 (defsubst gnus-group-timestamp (group)
4556 "Return the timestamp for GROUP."
4557 (gnus-group-get-parameter group 'timestamp t))
4559 (defun gnus-group-timestamp-delta (group)
4560 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4561 (let* ((time (or (gnus-group-timestamp group)
4563 (delta (subtract-time (current-time) time)))
4564 (+ (* (nth 0 delta) 65536.0)
4567 (defun gnus-group-timestamp-string (group)
4568 "Return a string of the timestamp for GROUP."
4569 (let ((time (gnus-group-timestamp group)))
4572 (gnus-time-iso8601 time))))
4574 (defun gnus-group-list-cached (level &optional lowest)
4575 "List all groups with cached articles.
4576 If the prefix LEVEL is non-nil, it should be a number that says which
4577 level to cut off listing groups.
4578 If LOWEST, don't list groups with level lower than LOWEST.
4580 This command may read the active file."
4583 (setq level (prefix-numeric-value level)))
4584 (when (or (not level) (>= level gnus-level-zombie))
4586 (funcall gnus-group-prepare-function
4587 (or level gnus-level-subscribed)
4589 (let ((marks (gnus-info-marks info)))
4590 (assq 'cache marks)))
4593 (or (gnus-gethash group
4594 gnus-cache-active-hashtb)
4595 ;; Cache active file might use "."
4598 (mapconcat 'identity
4599 (split-string group ":")
4601 gnus-cache-active-hashtb))))
4602 (goto-char (point-min))
4603 (gnus-group-position-point))
4605 (defun gnus-group-list-dormant (level &optional lowest)
4606 "List all groups with dormant articles.
4607 If the prefix LEVEL is non-nil, it should be a number that says which
4608 level to cut off listing groups.
4609 If LOWEST, don't list groups with level lower than LOWEST.
4611 This command may read the active file."
4614 (setq level (prefix-numeric-value level)))
4615 (when (or (not level) (>= level gnus-level-zombie))
4617 (funcall gnus-group-prepare-function
4618 (or level gnus-level-subscribed)
4620 (let ((marks (gnus-info-marks info)))
4621 (assq 'dormant marks)))
4624 (goto-char (point-min))
4625 (gnus-group-position-point))
4627 (defun gnus-group-listed-groups ()
4628 "Return a list of listed groups."
4630 (goto-char (point-min))
4631 (while (setq point (text-property-not-all (point) (point-max)
4634 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4638 (defun gnus-group-list-plus (&optional args)
4639 "List groups plus the current selection."
4641 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4642 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4644 (push last-command-event unread-command-events)
4645 (if (featurep 'xemacs)
4646 (push (make-event 'key-press '(key ?A)) unread-command-events)
4647 (push ?A unread-command-events))
4648 (let (gnus-pick-mode keys)
4649 (setq keys (if (featurep 'xemacs)
4650 (events-to-keys (read-key-sequence nil))
4651 (read-key-sequence nil)))
4652 (setq func (lookup-key (current-local-map) keys)))
4656 (call-interactively func))))
4658 (defun gnus-group-list-flush (&optional args)
4659 "Flush groups from the current selection."
4661 (let ((gnus-group-list-option 'flush))
4662 (gnus-group-list-plus args)))
4664 (defun gnus-group-list-limit (&optional args)
4665 "List groups limited within the current selection."
4667 (let ((gnus-group-list-option 'limit))
4668 (gnus-group-list-plus args)))
4670 (defun gnus-group-mark-article-read (group article)
4671 "Mark ARTICLE read."
4672 (let ((buffer (gnus-summary-buffer-name group))
4673 (mark gnus-read-mark)
4675 (if (get-buffer buffer)
4676 (with-current-buffer buffer
4677 (setq active gnus-newsgroup-active)
4678 (gnus-activate-group group)
4679 (when gnus-newsgroup-prepared
4680 (when (and gnus-newsgroup-auto-expire
4681 (memq mark gnus-auto-expirable-marks))
4682 (setq mark gnus-expirable-mark))
4683 (setq mark (gnus-request-update-mark
4684 group article mark))
4685 (gnus-mark-article-as-read article mark)
4686 (setq gnus-newsgroup-active (gnus-active group))
4688 (setq n (1+ (cdr active)))
4689 (while (<= n (cdr gnus-newsgroup-active))
4690 (unless (eq n article)
4691 (push n gnus-newsgroup-unselected))
4693 (setq gnus-newsgroup-unselected
4694 (nreverse gnus-newsgroup-unselected)))))
4695 (gnus-activate-group group)
4696 (gnus-group-make-articles-read group (list article))
4697 (when (gnus-group-auto-expirable-p group)
4698 (gnus-add-marked-articles
4699 group 'expire (list article))))))
4703 ;;; Group compaction. -- dvl
4706 (defun gnus-group-compact-group (group)
4707 "Compact the current group.
4708 Compaction means removing gaps between article numbers. Hence, this
4709 operation is only meaningful for back ends using one file per article
4712 Note: currently only implemented in nnml."
4713 (interactive (list (gnus-group-group-name)))
4715 (error "No group to compact"))
4716 (unless (gnus-check-backend-function 'request-compact-group group)
4717 (error "This back end does not support group compaction"))
4718 (let ((group-decoded (gnus-group-decoded-name group)))
4720 Compacting group %s... (this may take a long time)"
4723 (if (not (gnus-request-compact-group group))
4724 (gnus-error 3 "Couldn't compact group %s" group-decoded)
4725 (gnus-message 6 "Compacting group %s...done" group-decoded)
4727 ;; Invalidate the "original article" buffer which might be out of date.
4728 ;; #### NOTE: Yes, this might be a bit rude, but since compaction
4729 ;; #### will not happen very often, I think this is acceptable.
4730 (let ((original (get-buffer gnus-original-article-buffer)))
4731 (and original (gnus-kill-buffer original)))
4732 ;; Update the group line to reflect new information (art number etc).
4733 (gnus-group-update-group-line))))
4735 (provide 'gnus-group)
4737 ;;; gnus-group.el ends here