1 ;;; gnus-group.el --- group mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (let ((features (cons 'gnus-group features)))
48 (unless (boundp 'gnus-cache-active-hashtb)
49 (defvar gnus-cache-active-hashtb nil)))
51 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
52 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
54 (defcustom gnus-group-archive-directory
55 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
56 "*The address of the (ding) archives."
57 :group 'gnus-group-foreign
60 (defcustom gnus-group-recent-archive-directory
61 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
62 "*The address of the most recent (ding) articles."
63 :group 'gnus-group-foreign
66 (defcustom gnus-no-groups-message "No Gnus is good news"
67 "*Message displayed by Gnus when no groups are available."
71 (defcustom gnus-keep-same-level nil
72 "*Non-nil means that the next newsgroup after the current will be on the same level.
73 When you type, for instance, `n' after reading the last article in the
74 current newsgroup, you will go to the next newsgroup. If this variable
75 is nil, the next newsgroup will be the next from the group
77 If this variable is non-nil, Gnus will either put you in the
78 next newsgroup with the same level, or, if no such newsgroup is
79 available, the next newsgroup with the lowest possible level higher
80 than the current level.
81 If this variable is `best', Gnus will make the next newsgroup the one
83 :group 'gnus-group-levels
84 :type '(choice (const nil)
86 (sexp :tag "other" t)))
88 (defcustom gnus-group-goto-unread t
89 "*If non-nil, movement commands will go to the next unread and subscribed group."
90 :link '(custom-manual "(gnus)Group Maneuvering")
91 :group 'gnus-group-various
94 (defcustom gnus-goto-next-group-when-activating t
95 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
96 :link '(custom-manual "(gnus)Scanning New Messages")
97 :group 'gnus-group-various
100 (defcustom gnus-permanently-visible-groups nil
101 "*Regexp to match groups that should always be listed in the group buffer.
102 This means that they will still be listed even when there are no
103 unread articles in the groups.
105 If nil, no groups are permanently visible."
106 :group 'gnus-group-listing
107 :type '(choice regexp (const nil)))
109 (defcustom gnus-list-groups-with-ticked-articles t
110 "*If non-nil, list groups that have only ticked articles.
111 If nil, only list groups that have unread articles."
112 :group 'gnus-group-listing
115 (defcustom gnus-group-default-list-level gnus-level-subscribed
116 "*Default listing level.
117 Ignored if `gnus-group-use-permanent-levels' is non-nil."
118 :group 'gnus-group-listing
121 (defcustom gnus-group-list-inactive-groups t
122 "*If non-nil, inactive groups will be listed."
123 :group 'gnus-group-listing
124 :group 'gnus-group-levels
127 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
128 "*Function used for sorting the group buffer.
129 This function will be called with group info entries as the arguments
130 for the groups to be sorted. Pre-made functions include
131 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
132 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
133 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
134 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
136 This variable can also be a list of sorting functions. In that case,
137 the most significant sort function should be the last function in the
139 :group 'gnus-group-listing
140 :link '(custom-manual "(gnus)Sorting Groups")
141 :type '(repeat :value-to-internal (lambda (widget value)
142 (if (listp value) value (list value)))
143 :match (lambda (widget value)
145 (widget-editable-list-match widget value)))
146 (choice (function-item gnus-group-sort-by-alphabet)
147 (function-item gnus-group-sort-by-real-name)
148 (function-item gnus-group-sort-by-unread)
149 (function-item gnus-group-sort-by-level)
150 (function-item gnus-group-sort-by-score)
151 (function-item gnus-group-sort-by-method)
152 (function-item gnus-group-sort-by-server)
153 (function-item gnus-group-sort-by-rank)
154 (function :tag "other" nil))))
156 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
157 "*Format of group lines.
158 It works along the same lines as a normal formatting string,
159 with some simple extensions.
161 %M Only marked articles (character, \"*\" or \" \")
162 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
163 %L Level of subscribedness (integer)
164 %N Number of unread articles (integer)
165 %I Number of dormant articles (integer)
166 %i Number of ticked and dormant (integer)
167 %T Number of ticked articles (integer)
168 %R Number of read articles (integer)
169 %U Number of unseen articles (integer)
170 %t Estimated total number of articles (integer)
171 %y Number of unread, unticked articles (integer)
172 %G Group name (string)
173 %g Qualified group name (string)
174 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
175 %C Group comment (string)
176 %D Group description (string)
177 %s Select method (string)
178 %o Moderated group (char, \"m\")
179 %p Process mark (char)
180 %B Whether a summary buffer for the group is open (char, \"*\")
181 %O Moderated group (string, \"(m)\" or \"\")
182 %P Topic indentation (string)
183 %m Whether there is new(ish) mail in the group (char, \"%\")
184 %w Number of new(ish) mails in the group (integer)
185 %n Select from where (string)
186 %z A string that look like `<%s:%n>' if a foreign select method is used
187 %d The date the group was last entered.
188 %E Icon as defined by `gnus-group-icon-list'.
189 %F The disk space used by the articles fetched by both the cache and agent.
190 %u User defined specifier. The next character in the format string should
191 be a letter. Gnus will call the function gnus-user-format-function-X,
192 where X is the letter following %u. The function will be passed a
193 single dummy parameter as argument. The function should return a
194 string, which will be inserted into the buffer just like information
195 from any other group specifier.
197 Note that this format specification is not always respected. For
198 reasons of efficiency, when listing killed groups, this specification
199 is ignored altogether. If the spec is changed considerably, your
200 output may end up looking strange when listing both alive and killed
203 If you use %o or %O, reading the active file will be slower and quite
204 a bit of extra memory will be used. %D and %F will also worsen
205 performance. Also note that if you change the format specification to
206 include any of these specs, you must probably re-start Gnus to see
209 General format specifiers can also be used.
210 See Info node `(gnus)Formatting Variables'."
211 :link '(custom-manual "(gnus)Formatting Variables")
212 :group 'gnus-group-visual
215 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
216 "*The format specification for the group mode line.
217 It works along the same lines as a normal formatting string,
218 with some simple extensions:
220 %S The native news server.
221 %M The native select method.
222 %: \":\" if %S isn't \"\"."
223 :group 'gnus-group-visual
226 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
227 (when (featurep 'xemacs)
228 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
229 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
231 (defcustom gnus-group-menu-hook nil
232 "Hook run after the creation of the group mode menu."
233 :group 'gnus-group-various
236 (defcustom gnus-group-catchup-group-hook nil
237 "Hook run when catching up a group from the group buffer."
238 :group 'gnus-group-various
239 :link '(custom-manual "(gnus)Group Data")
242 (defcustom gnus-group-update-group-hook nil
243 "Hook called when updating group lines."
244 :group 'gnus-group-visual
247 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
248 "*A function that is called to generate the group buffer.
249 The function is called with three arguments: The first is a number;
250 all group with a level less or equal to that number should be listed,
251 if the second is non-nil, empty groups should also be displayed. If
252 the third is non-nil, it is a number. No groups with a level lower
253 than this number should be displayed.
255 The only current function implemented is `gnus-group-prepare-flat'."
256 :group 'gnus-group-listing
259 (defcustom gnus-group-prepare-hook nil
260 "Hook called after the group buffer has been generated.
261 If you want to modify the group buffer, you can use this hook."
262 :group 'gnus-group-listing
265 (defcustom gnus-suspend-gnus-hook nil
266 "Hook called when suspending (not exiting) Gnus."
270 (defcustom gnus-exit-gnus-hook nil
271 "Hook called when exiting Gnus."
275 (defcustom gnus-after-exiting-gnus-hook nil
276 "Hook called after exiting Gnus."
280 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
281 "Hook called when a group line is changed.
282 The hook will not be called if `gnus-visual' is nil.
284 The default function `gnus-group-highlight-line' will
285 highlight the line according to the `gnus-group-highlight'
287 :group 'gnus-group-visual
290 (defcustom gnus-useful-groups
291 '(("(ding) mailing list mirrored at sunsite.auc.dk"
293 (nntp "sunsite.auc.dk"
294 (nntp-address "sunsite.auc.dk")))
297 (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/"))
301 (nndoc-article-type mbox)
302 (eval `(nndoc-address
303 ,(let ((file (nnheader-find-etc-directory
306 (error "Couldn't find doc group"))
308 "*Alist of useful group-server pairs."
309 :group 'gnus-group-listing
310 :type '(repeat (list (string :tag "Description")
312 (sexp :tag "Method"))))
314 (defcustom gnus-group-highlight
316 ((and mailp (= unread 0) (eq level 1)) .
317 gnus-group-mail-1-empty)
318 ((and mailp (eq level 1)) .
320 ((and mailp (= unread 0) (eq level 2)) .
321 gnus-group-mail-2-empty)
322 ((and mailp (eq level 2)) .
324 ((and mailp (= unread 0) (eq level 3)) .
325 gnus-group-mail-3-empty)
326 ((and mailp (eq level 3)) .
328 ((and mailp (= unread 0)) .
329 gnus-group-mail-low-empty)
333 ((and (= unread 0) (eq level 1)) .
334 gnus-group-news-1-empty)
335 ((and (eq level 1)) .
337 ((and (= unread 0) (eq level 2)) .
338 gnus-group-news-2-empty)
339 ((and (eq level 2)) .
341 ((and (= unread 0) (eq level 3)) .
342 gnus-group-news-3-empty)
343 ((and (eq level 3)) .
345 ((and (= unread 0) (eq level 4)) .
346 gnus-group-news-4-empty)
347 ((and (eq level 4)) .
349 ((and (= unread 0) (eq level 5)) .
350 gnus-group-news-5-empty)
351 ((and (eq level 5)) .
353 ((and (= unread 0) (eq level 6)) .
354 gnus-group-news-6-empty)
355 ((and (eq level 6)) .
357 ((and (= unread 0)) .
358 gnus-group-news-low-empty)
360 gnus-group-news-low))
361 "*Controls the highlighting of group buffer lines.
363 Below is a list of `Form'/`Face' pairs. When deciding how a a
364 particular group line should be displayed, each form is
365 evaluated. The content of the face field after the first true form is
366 used. You can change how those group lines are displayed by
367 editing the face field.
369 It is also possible to change and add form fields, but currently that
370 requires an understanding of Lisp expressions. Hopefully this will
371 change in a future release. For now, you can use the following
372 variables in the Lisp expression:
374 group: The name of the group.
375 unread: The number of unread articles in the group.
376 method: The select method used.
377 mailp: Whether it's a mail group or not.
378 level: The level of the group.
379 score: The score of the group.
380 ticked: The number of ticked articles."
381 :group 'gnus-group-visual
382 :type '(repeat (cons (sexp :tag "Form") face)))
384 (defcustom gnus-new-mail-mark ?%
385 "Mark used for groups with new mail."
386 :group 'gnus-group-visual
389 (defgroup gnus-group-icons nil
390 "Add Icons to your group buffer. "
391 :group 'gnus-group-visual)
393 (defcustom gnus-group-icon-list
395 "*Controls the insertion of icons into group buffer lines.
397 Below is a list of `Form'/`File' pairs. When deciding how a
398 particular group line should be displayed, each form is evaluated.
399 The icon from the file field after the first true form is used. You
400 can change how those group lines are displayed by editing the file
401 field. The File will either be found in the
402 `gnus-group-glyph-directory' or by designating absolute name of the
405 It is also possible to change and add form fields, but currently that
406 requires an understanding of Lisp expressions. Hopefully this will
407 change in a future release. For now, you can use the following
408 variables in the Lisp expression:
410 group: The name of the group.
411 unread: The number of unread articles in the group.
412 method: The select method used.
413 mailp: Whether it's a mail group or not.
414 newsp: Whether it's a news group or not
415 level: The level of the group.
416 score: The score of the group.
417 ticked: The number of ticked articles."
418 :group 'gnus-group-icons
419 :type '(repeat (cons (sexp :tag "Form") file)))
421 (defcustom gnus-group-name-charset-method-alist nil
422 "Alist of method and the charset for group names.
425 (((nntp \"news.com.cn\") . cn-gb-2312))"
428 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
430 (defcustom gnus-group-name-charset-group-alist
431 (if (mm-coding-system-p 'utf-8)
432 '(("[^\000-\177]" . utf-8))
434 "Alist of group regexp and the charset for group names.
437 ((\"\\.com\\.cn:\" . cn-gb-2312))"
439 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
441 (defcustom gnus-group-jump-to-group-prompt nil
442 "Default prompt for `gnus-group-jump-to-group'.
444 If non-nil, the value should be a string or an alist. If it is a string,
445 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
446 nnml:\" in the minibuffer prompt.
448 If it is an alist, it must consist of \(NUMBER . PROMPT\) pairs, for example:
449 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
450 used when no prefix argument is given to `gnus-group-jump-to-group'."
452 :group 'gnus-group-various
453 :type '(choice (string :tag "Prompt string")
454 (const :tag "Empty" nil)
455 (repeat (cons (integer :tag "Argument")
456 (string :tag "Prompt string")))))
458 (defvar gnus-group-listing-limit 1000
459 "*A limit of the number of groups when listing.
460 If the number of groups is larger than the limit, list them in a
463 ;;; Internal variables
465 (defvar gnus-group-is-exiting-p nil)
466 (defvar gnus-group-is-exiting-without-update-p nil)
467 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
468 "Function for sorting the group buffer.")
470 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
471 "Function for sorting the selected groups in the group buffer.")
473 (defvar gnus-group-indentation-function nil)
474 (defvar gnus-goto-missing-group-function nil)
475 (defvar gnus-group-update-group-function nil)
476 (defvar gnus-group-goto-next-group-function nil
477 "Function to override finding the next group after listing groups.")
479 (defvar gnus-group-edit-buffer nil)
481 (defvar gnus-group-line-format-alist
482 `((?M gnus-tmp-marked-mark ?c)
483 (?S gnus-tmp-subscribed ?c)
484 (?L gnus-tmp-level ?d)
485 (?N (cond ((eq number t) "*" )
489 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
490 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
492 (?R gnus-tmp-number-of-read ?s)
493 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
494 (?t gnus-tmp-number-total ?d)
495 (?y gnus-tmp-number-of-unread ?s)
496 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
497 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
498 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
499 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
500 (?g (if (boundp 'gnus-tmp-decoded-group)
501 gnus-tmp-decoded-group
504 (?G gnus-tmp-qualified-group ?s)
505 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
506 gnus-tmp-decoded-group
509 (?C gnus-tmp-comment ?s)
510 (?D gnus-tmp-newsgroup-description ?s)
511 (?o gnus-tmp-moderated ?c)
512 (?O gnus-tmp-moderated-string ?s)
513 (?p gnus-tmp-process-marked ?c)
514 (?s gnus-tmp-news-server ?s)
515 (?n ,(if (featurep 'xemacs)
516 '(symbol-name gnus-tmp-news-method)
517 'gnus-tmp-news-method)
519 (?P gnus-group-indentation ?s)
520 (?E gnus-tmp-group-icon ?s)
521 (?B gnus-tmp-summary-live ?c)
522 (?z gnus-tmp-news-method-string ?s)
523 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
524 (?w (if (gnus-news-group-p gnus-tmp-group)
528 (nnmail-new-mail-numbers (gnus-group-real-name gnus-tmp-group))
531 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
532 (?u gnus-tmp-user-defined ?s)
533 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
536 (defvar gnus-group-mode-line-format-alist
537 `((?S gnus-tmp-news-server ?s)
538 (?M gnus-tmp-news-method ?s)
539 (?u gnus-tmp-user-defined ?s)
540 (?: gnus-tmp-colon ?s)))
542 (defvar gnus-topic-topology nil
543 "The complete topic hierarchy.")
545 (defvar gnus-topic-alist nil
546 "The complete topic-group alist.")
548 (defvar gnus-group-marked nil)
550 (defvar gnus-group-list-mode nil)
553 (defvar gnus-group-icon-cache nil)
555 (defvar gnus-group-listed-groups nil)
556 (defvar gnus-group-list-option nil)
562 (put 'gnus-group-mode 'mode-class 'special)
564 (gnus-define-keys gnus-group-mode-map
565 " " gnus-group-read-group
566 "=" gnus-group-select-group
567 "\r" gnus-group-select-group
568 "\M-\r" gnus-group-quick-select-group
569 "\M- " gnus-group-visible-select-group
570 [(meta control return)] gnus-group-select-group-ephemerally
571 "j" gnus-group-jump-to-group
572 "n" gnus-group-next-unread-group
573 "p" gnus-group-prev-unread-group
574 "\177" gnus-group-prev-unread-group
575 [delete] gnus-group-prev-unread-group
576 [backspace] gnus-group-prev-unread-group
577 "N" gnus-group-next-group
578 "P" gnus-group-prev-group
579 "\M-n" gnus-group-next-unread-group-same-level
580 "\M-p" gnus-group-prev-unread-group-same-level
581 "," gnus-group-best-unread-group
582 "." gnus-group-first-unread-group
583 "u" gnus-group-unsubscribe-current-group
584 "U" gnus-group-unsubscribe-group
585 "c" gnus-group-catchup-current
586 "C" gnus-group-catchup-current-all
587 "\M-c" gnus-group-clear-data
588 "l" gnus-group-list-groups
589 "L" gnus-group-list-all-groups
592 "g" gnus-group-get-new-news
593 "\M-g" gnus-group-get-new-news-this-group
594 "R" gnus-group-restart
595 "r" gnus-group-read-init-file
596 "B" gnus-group-browse-foreign-server
597 "b" gnus-group-check-bogus-groups
598 "F" gnus-group-find-new-groups
599 "\C-c\C-d" gnus-group-describe-group
600 "\M-d" gnus-group-describe-all-groups
601 "\C-c\C-a" gnus-group-apropos
602 "\C-c\M-\C-a" gnus-group-description-apropos
603 "a" gnus-group-post-news
604 "\ek" gnus-group-edit-local-kill
605 "\eK" gnus-group-edit-global-kill
606 "\C-k" gnus-group-kill-group
607 "\C-y" gnus-group-yank-group
608 "\C-w" gnus-group-kill-region
609 "\C-x\C-t" gnus-group-transpose-groups
610 "\C-c\C-l" gnus-group-list-killed
611 "\C-c\C-x" gnus-group-expire-articles
612 "\C-c\M-\C-x" gnus-group-expire-all-groups
614 "s" gnus-group-save-newsrc
615 "z" gnus-group-suspend
618 "?" gnus-group-describe-briefly
619 "\C-c\C-i" gnus-info-find-node
620 "\M-e" gnus-group-edit-group-method
621 "^" gnus-group-enter-server-mode
622 gnus-mouse-2 gnus-mouse-pick-group
623 [follow-link] mouse-face
624 "<" beginning-of-buffer
627 "\C-c\C-n" gnus-namazu-search
628 "\C-c\C-s" gnus-group-sort-groups
630 "\C-c\M-g" gnus-activate-all-groups
631 "\M-&" gnus-group-universal-argument
632 "#" gnus-group-mark-group
633 "\M-#" gnus-group-unmark-group)
635 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
636 "m" gnus-group-mark-group
637 "u" gnus-group-unmark-group
638 "w" gnus-group-mark-region
639 "b" gnus-group-mark-buffer
640 "r" gnus-group-mark-regexp
641 "U" gnus-group-unmark-all-groups)
643 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
644 "u" gnus-sieve-update
645 "g" gnus-sieve-generate)
647 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
648 "d" gnus-group-make-directory-group
649 "h" gnus-group-make-help-group
650 "u" gnus-group-make-useful-group
651 "a" gnus-group-make-archive-group
652 "k" gnus-group-make-kiboze-group
653 "l" gnus-group-nnimap-edit-acl
654 "m" gnus-group-make-group
655 "n" gnus-group-make-shimbun-group
656 "E" gnus-group-edit-group
657 "e" gnus-group-edit-group-method
658 "p" gnus-group-edit-group-parameters
659 "v" gnus-group-add-to-virtual
660 "V" gnus-group-make-empty-virtual
661 "D" gnus-group-enter-directory
662 "f" gnus-group-make-doc-group
663 "G" gnus-group-make-nnir-group
664 "w" gnus-group-make-web-group
665 "M" gnus-group-read-ephemeral-group
666 "r" gnus-group-rename-group
667 "R" gnus-group-make-rss-group
668 "c" gnus-group-customize
669 "x" gnus-group-nnimap-expunge
670 "\177" gnus-group-delete-group
671 [delete] gnus-group-delete-group)
673 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
674 "b" gnus-group-brew-soup
675 "w" gnus-soup-save-areas
676 "s" gnus-soup-send-replies
677 "p" gnus-soup-pack-packet
678 "r" nnsoup-pack-replies)
680 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
681 "s" gnus-group-sort-groups
682 "a" gnus-group-sort-groups-by-alphabet
683 "u" gnus-group-sort-groups-by-unread
684 "l" gnus-group-sort-groups-by-level
685 "v" gnus-group-sort-groups-by-score
686 "r" gnus-group-sort-groups-by-rank
687 "m" gnus-group-sort-groups-by-method
688 "n" gnus-group-sort-groups-by-real-name)
690 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
691 "s" gnus-group-sort-selected-groups
692 "a" gnus-group-sort-selected-groups-by-alphabet
693 "u" gnus-group-sort-selected-groups-by-unread
694 "l" gnus-group-sort-selected-groups-by-level
695 "v" gnus-group-sort-selected-groups-by-score
696 "r" gnus-group-sort-selected-groups-by-rank
697 "m" gnus-group-sort-selected-groups-by-method
698 "n" gnus-group-sort-selected-groups-by-real-name)
700 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
701 "k" gnus-group-list-killed
702 "z" gnus-group-list-zombies
703 "s" gnus-group-list-groups
704 "u" gnus-group-list-all-groups
705 "A" gnus-group-list-active
706 "a" gnus-group-apropos
707 "d" gnus-group-description-apropos
708 "m" gnus-group-list-matching
709 "M" gnus-group-list-all-matching
710 "l" gnus-group-list-level
711 "c" gnus-group-list-cached
712 "?" gnus-group-list-dormant)
714 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
715 "k" gnus-group-list-limit
716 "z" gnus-group-list-limit
717 "s" gnus-group-list-limit
718 "u" gnus-group-list-limit
719 "A" gnus-group-list-limit
720 "m" gnus-group-list-limit
721 "M" gnus-group-list-limit
722 "l" gnus-group-list-limit
723 "c" gnus-group-list-limit
724 "?" gnus-group-list-limit)
726 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
727 "k" gnus-group-list-flush
728 "z" gnus-group-list-flush
729 "s" gnus-group-list-flush
730 "u" gnus-group-list-flush
731 "A" gnus-group-list-flush
732 "m" gnus-group-list-flush
733 "M" gnus-group-list-flush
734 "l" gnus-group-list-flush
735 "c" gnus-group-list-flush
736 "?" gnus-group-list-flush)
738 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
739 "k" gnus-group-list-plus
740 "z" gnus-group-list-plus
741 "s" gnus-group-list-plus
742 "u" gnus-group-list-plus
743 "A" gnus-group-list-plus
744 "m" gnus-group-list-plus
745 "M" gnus-group-list-plus
746 "l" gnus-group-list-plus
747 "c" gnus-group-list-plus
748 "?" gnus-group-list-plus)
750 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
751 "f" gnus-score-flush-cache
752 "e" gnus-score-edit-all-score)
754 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
755 "c" gnus-group-fetch-charter
756 "C" gnus-group-fetch-control
757 "d" gnus-group-describe-group
758 "f" gnus-group-fetch-faq
761 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
762 "l" gnus-group-set-current-level
763 "t" gnus-group-unsubscribe-current-group
764 "s" gnus-group-unsubscribe-group
765 "k" gnus-group-kill-group
766 "y" gnus-group-yank-group
767 "w" gnus-group-kill-region
768 "\C-k" gnus-group-kill-level
769 "z" gnus-group-kill-all-zombies)
771 (defun gnus-topic-mode-p ()
772 "Return non-nil in `gnus-topic-mode'."
773 (and (boundp 'gnus-topic-mode)
774 (symbol-value 'gnus-topic-mode)))
776 (defun gnus-group-make-menu-bar ()
777 (gnus-turn-off-edit-menu 'group)
778 (unless (boundp 'gnus-group-reading-menu)
781 gnus-group-reading-menu gnus-group-mode-map ""
783 ["Read" gnus-group-read-group
784 :included (not (gnus-topic-mode-p))
785 :active (gnus-group-group-name)]
786 ["Read " gnus-topic-read-group
787 :included (gnus-topic-mode-p)]
788 ["Select" gnus-group-select-group
789 :included (not (gnus-topic-mode-p))
790 :active (gnus-group-group-name)]
791 ["Select " gnus-topic-select-group
792 :included (gnus-topic-mode-p)]
793 ["See old articles" (gnus-group-select-group 'all)
794 :keys "C-u SPC" :active (gnus-group-group-name)]
795 ["Catch up" gnus-group-catchup-current
796 :included (not (gnus-topic-mode-p))
797 :active (gnus-group-group-name)
798 ,@(if (featurep 'xemacs) nil
799 '(:help "Mark unread articles in the current group as read"))]
800 ["Catch up " gnus-topic-catchup-articles
801 :included (gnus-topic-mode-p)
802 ,@(if (featurep 'xemacs) nil
803 '(:help "Mark unread articles in the current group or topic as read"))]
804 ["Catch up all articles" gnus-group-catchup-current-all
805 (gnus-group-group-name)]
806 ["Check for new articles" gnus-group-get-new-news-this-group
807 :included (not (gnus-topic-mode-p))
808 :active (gnus-group-group-name)
809 ,@(if (featurep 'xemacs) nil
810 '(:help "Check for new messages in current group"))]
811 ["Check for new articles " gnus-topic-get-new-news-this-topic
812 :included (gnus-topic-mode-p)
813 ,@(if (featurep 'xemacs) nil
814 '(:help "Check for new messages in current group or topic"))]
815 ["Toggle subscription" gnus-group-unsubscribe-current-group
816 (gnus-group-group-name)]
817 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
818 ,@(if (featurep 'xemacs) nil
819 '(:help "Kill (remove) current group"))]
820 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
821 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
822 ,@(if (featurep 'xemacs) nil
823 '(:help "Display description of the current group"))]
824 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
825 ["Fetch charter" gnus-group-fetch-charter
826 :active (gnus-group-group-name)
827 ,@(if (featurep 'xemacs) nil
828 '(:help "Display the charter of the current group"))]
829 ["Fetch control message" gnus-group-fetch-control
830 :active (gnus-group-group-name)
831 ,@(if (featurep 'xemacs) nil
832 '(:help "Display the archived control message for the current group"))]
833 ;; Actually one should check, if any of the marked groups gives t for
834 ;; (gnus-check-backend-function 'request-expire-articles ...)
835 ["Expire articles" gnus-group-expire-articles
836 :included (not (gnus-topic-mode-p))
837 :active (or (and (gnus-group-group-name)
838 (gnus-check-backend-function
839 'request-expire-articles
840 (gnus-group-group-name))) gnus-group-marked)]
841 ["Expire articles " gnus-topic-expire-articles
842 :included (gnus-topic-mode-p)]
843 ["Set group level..." gnus-group-set-current-level
844 (gnus-group-group-name)]
845 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
846 ["Customize" gnus-group-customize (gnus-group-group-name)]
848 ["Parameters" gnus-group-edit-group-parameters
849 :included (not (gnus-topic-mode-p))
850 :active (gnus-group-group-name)]
851 ["Parameters " gnus-topic-edit-parameters
852 :included (gnus-topic-mode-p)]
853 ["Select method" gnus-group-edit-group-method
854 (gnus-group-group-name)]
855 ["Info" gnus-group-edit-group (gnus-group-group-name)]
856 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
857 ["Global kill file" gnus-group-edit-global-kill t])))
860 gnus-group-group-menu gnus-group-mode-map ""
863 ["List unread subscribed groups" gnus-group-list-groups t]
864 ["List (un)subscribed groups" gnus-group-list-all-groups t]
865 ["List killed groups" gnus-group-list-killed gnus-killed-list]
866 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
867 ["List level..." gnus-group-list-level t]
868 ["Describe all groups" gnus-group-describe-all-groups t]
869 ["Group apropos..." gnus-group-apropos t]
870 ["Group and description apropos..." gnus-group-description-apropos t]
871 ["List groups matching..." gnus-group-list-matching t]
872 ["List all groups matching..." gnus-group-list-all-matching t]
873 ["List active file" gnus-group-list-active t]
874 ["List groups with cached" gnus-group-list-cached t]
875 ["List groups with dormant" gnus-group-list-dormant t])
877 ["Default sort" gnus-group-sort-groups t]
878 ["Sort by method" gnus-group-sort-groups-by-method t]
879 ["Sort by rank" gnus-group-sort-groups-by-rank t]
880 ["Sort by score" gnus-group-sort-groups-by-score t]
881 ["Sort by level" gnus-group-sort-groups-by-level t]
882 ["Sort by unread" gnus-group-sort-groups-by-unread t]
883 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
884 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
885 ("Sort process/prefixed"
886 ["Default sort" gnus-group-sort-selected-groups
887 (not (gnus-topic-mode-p))]
888 ["Sort by method" gnus-group-sort-selected-groups-by-method
889 (not (gnus-topic-mode-p))]
890 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
891 (not (gnus-topic-mode-p))]
892 ["Sort by score" gnus-group-sort-selected-groups-by-score
893 (not (gnus-topic-mode-p))]
894 ["Sort by level" gnus-group-sort-selected-groups-by-level
895 (not (gnus-topic-mode-p))]
896 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
897 (not (gnus-topic-mode-p))]
898 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
899 (not (gnus-topic-mode-p))]
900 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
901 (not (gnus-topic-mode-p))])
903 ["Mark group" gnus-group-mark-group
904 (and (gnus-group-group-name)
905 (not (memq (gnus-group-group-name) gnus-group-marked)))]
906 ["Unmark group" gnus-group-unmark-group
907 (and (gnus-group-group-name)
908 (memq (gnus-group-group-name) gnus-group-marked))]
909 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
910 ["Mark regexp..." gnus-group-mark-regexp t]
911 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
912 ["Mark buffer" gnus-group-mark-buffer t]
913 ["Execute command" gnus-group-universal-argument
914 (or gnus-group-marked (gnus-group-group-name))])
916 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
917 ["Kill all newsgroups in region" gnus-group-kill-region
918 :active (gnus-mark-active-p)]
919 ["Kill all zombie groups" gnus-group-kill-all-zombies
921 ["Kill all groups on level..." gnus-group-kill-level t])
923 ["Make a foreign group..." gnus-group-make-group t]
924 ["Make a shimbun group..." gnus-group-make-shimbun-group t]
925 ["Add a directory group..." gnus-group-make-directory-group t]
926 ["Add the help group" gnus-group-make-help-group t]
927 ["Add the archive group" gnus-group-make-archive-group t]
928 ["Make a doc group..." gnus-group-make-doc-group t]
929 ["Make a web group..." gnus-group-make-web-group t]
930 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
931 ["Make a virtual group..." gnus-group-make-empty-virtual t]
932 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
933 ["Make an RSS group..." gnus-group-make-rss-group t]
934 ["Rename group..." gnus-group-rename-group
935 (gnus-check-backend-function
936 'request-rename-group (gnus-group-group-name))]
937 ["Delete group" gnus-group-delete-group
938 (gnus-check-backend-function
939 'request-delete-group (gnus-group-group-name))])
941 ["Next" gnus-group-next-group t]
942 ["Previous" gnus-group-prev-group t]
943 ["Next unread" gnus-group-next-unread-group t]
944 ["Previous unread" gnus-group-prev-unread-group t]
945 ["Next unread same level" gnus-group-next-unread-group-same-level t]
946 ["Previous unread same level"
947 gnus-group-prev-unread-group-same-level t]
948 ["Jump to group..." gnus-group-jump-to-group t]
949 ["First unread group" gnus-group-first-unread-group t]
950 ["Best unread group" gnus-group-best-unread-group t])
952 ["Generate" gnus-sieve-generate t]
953 ["Generate and update" gnus-sieve-update t])
954 ["Delete bogus groups" gnus-group-check-bogus-groups t]
955 ["Find new newsgroups" gnus-group-find-new-groups t]
956 ["Transpose" gnus-group-transpose-groups
957 (gnus-group-group-name)]
958 ["Read a directory as a group..." gnus-group-enter-directory t]))
961 gnus-group-misc-menu gnus-group-mode-map ""
964 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
965 ["Send replies" gnus-soup-send-replies
966 (fboundp 'gnus-soup-pack-packet)]
967 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
968 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
969 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
970 ["Send a mail" gnus-group-mail t]
971 ["Send a message (mail or news)" gnus-group-post-news t]
972 ["Create a local message" gnus-group-news t]
973 ["Check for new news" gnus-group-get-new-news
974 ,@(if (featurep 'xemacs) '(t)
975 '(:help "Get newly arrived articles"))
977 ["Send queued messages" gnus-delay-send-queue
978 ,@(if (featurep 'xemacs) '(t)
979 '(:help "Send all messages that are scheduled to be sent now"))
981 ["Activate all groups" gnus-activate-all-groups t]
982 ["Restart Gnus" gnus-group-restart t]
983 ["Read init file" gnus-group-read-init-file t]
984 ["Browse foreign server..." gnus-group-browse-foreign-server t]
985 ["Enter server buffer" gnus-group-enter-server-mode t]
986 ["Expire all expirable articles" gnus-group-expire-all-groups t]
987 ["Generate any kiboze groups" nnkiboze-generate-groups t]
988 ["Gnus version" gnus-version t]
989 ["Save .newsrc files" gnus-group-save-newsrc t]
990 ["Suspend Gnus" gnus-group-suspend t]
991 ["Clear dribble buffer" gnus-group-clear-dribble t]
992 ["Read manual" gnus-info-find-node t]
993 ["Flush score cache" gnus-score-flush-cache t]
994 ["Toggle topics" gnus-topic-mode t]
995 ["Send a bug report" gnus-bug t]
996 ["Exit from Gnus" gnus-group-exit
997 ,@(if (featurep 'xemacs) '(t)
998 '(:help "Quit reading news"))]
999 ["Exit without saving" gnus-group-quit t]))
1001 (gnus-run-hooks 'gnus-group-menu-hook)))
1003 (defvar gnus-group-toolbar-map nil)
1005 ;; Emacs 21 tool bar. Should be no-op otherwise.
1006 (defun gnus-group-make-tool-bar ()
1008 (condition-case nil (require 'tool-bar) (error nil))
1009 (fboundp 'tool-bar-add-item-from-menu)
1010 (default-value 'tool-bar-mode)
1011 (not gnus-group-toolbar-map))
1012 (setq gnus-group-toolbar-map
1013 (let ((tool-bar-map (make-sparse-keymap))
1014 (load-path (mm-image-load-path)))
1015 (tool-bar-add-item-from-menu
1016 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
1017 (tool-bar-add-item-from-menu
1018 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
1019 (tool-bar-add-item-from-menu
1020 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
1021 (tool-bar-add-item-from-menu
1022 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
1023 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
1024 :help "Subscribe to the current group")
1025 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
1027 :help "Unsubscribe from the current group")
1028 (tool-bar-add-item-from-menu
1029 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
1031 (if gnus-group-toolbar-map
1032 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
1034 (defun gnus-group-mode ()
1035 "Major mode for reading news.
1037 All normal editing commands are switched off.
1038 \\<gnus-group-mode-map>
1039 The group buffer lists (some of) the groups available. For instance,
1040 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1041 lists all zombie groups.
1043 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1044 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1046 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1048 The following commands are available:
1050 \\{gnus-group-mode-map}"
1052 (kill-all-local-variables)
1053 (when (gnus-visual-p 'group-menu 'menu)
1054 (gnus-group-make-menu-bar)
1055 (gnus-group-make-tool-bar))
1056 (gnus-simplify-mode-line)
1057 (setq major-mode 'gnus-group-mode)
1058 (setq mode-name "Group")
1059 (gnus-group-set-mode-line)
1060 (setq mode-line-process nil)
1061 (use-local-map gnus-group-mode-map)
1062 (buffer-disable-undo)
1063 (setq truncate-lines t)
1064 (setq buffer-read-only t
1065 show-trailing-whitespace nil)
1066 (gnus-set-default-directory)
1067 (gnus-update-format-specifications nil 'group 'group-mode)
1068 (gnus-update-group-mark-positions)
1073 (gnus-run-mode-hooks 'gnus-group-mode-hook))
1075 (defun gnus-update-group-mark-positions ()
1077 (let ((gnus-process-mark ?\200)
1078 (gnus-group-update-hook nil)
1079 (gnus-group-marked '("dummy.group"))
1080 (gnus-active-hashtb (make-vector 10 0))
1082 (gnus-set-active "dummy.group" '(0 . 0))
1083 (gnus-set-work-buffer)
1084 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1085 (goto-char (point-min))
1086 (setq gnus-group-mark-positions
1087 (list (cons 'process (and (search-forward
1088 (string-as-multibyte "\200") nil t)
1089 (- (point) 2))))))))
1091 (defun gnus-mouse-pick-group (e)
1092 "Enter the group under the mouse pointer."
1095 (gnus-group-read-group nil))
1097 ;; Look at LEVEL and find out what the level is really supposed to be.
1098 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1099 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1100 (defun gnus-group-default-level (&optional level number-or-nil)
1102 (gnus-group-use-permanent-levels
1103 (or (setq gnus-group-use-permanent-levels
1104 (or level (if (numberp gnus-group-use-permanent-levels)
1105 gnus-group-use-permanent-levels
1106 (or gnus-group-default-list-level
1107 gnus-level-subscribed))))
1108 gnus-group-default-list-level gnus-level-subscribed))
1112 (or level gnus-group-default-list-level gnus-level-subscribed))))
1114 (defun gnus-group-setup-buffer ()
1115 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1116 (unless (eq major-mode 'gnus-group-mode)
1119 (gnus-carpal-setup-buffer 'group))))
1121 (defun gnus-group-name-charset (method group)
1123 (setq method (gnus-find-method-for-group group)))
1124 (let ((item (assoc method gnus-group-name-charset-method-alist))
1125 (alist gnus-group-name-charset-group-alist)
1129 (while (setq item (pop alist))
1130 (if (string-match (car item) group)
1132 result (cdr item))))
1135 (defun gnus-group-name-decode (string charset)
1136 ;; Fixme: Don't decode in unibyte mode.
1137 (if (and string charset (featurep 'mule))
1138 (decode-coding-string string charset)
1141 (defun gnus-group-decoded-name (string)
1142 (let ((charset (gnus-group-name-charset nil string)))
1143 (gnus-group-name-decode string charset)))
1145 (defun gnus-group-name-encode (string charset)
1146 (if (and string charset (featurep 'mule))
1147 (encode-coding-string string charset)
1150 (defun gnus-group-encoded-name (string)
1151 (let ((charset (gnus-group-name-charset nil string)))
1152 (gnus-group-name-encode string charset)))
1154 (defun gnus-group-completing-read-group-name
1155 (prompt table &optional predicate require-match initial-contents history)
1159 (push (list (gnus-group-decoded-name (symbol-name group))) table))
1163 (dolist (entry (prog1
1166 (push (list (gnus-group-decoded-name (car entry))) table)))
1167 (gnus-group-encoded-name
1169 prompt table predicate
1174 (defun gnus-group-list-groups (&optional level unread lowest)
1175 "List newsgroups with level LEVEL or lower that have unread articles.
1176 Default is all subscribed groups.
1177 If argument UNREAD is non-nil, groups with no unread articles are also
1180 Also see the `gnus-group-use-permanent-levels' variable."
1182 (list (if current-prefix-arg
1183 (prefix-numeric-value current-prefix-arg)
1185 (gnus-group-default-level nil t)
1186 gnus-group-default-list-level
1187 gnus-level-subscribed))))
1189 (setq level (car gnus-group-list-mode)
1190 unread (cdr gnus-group-list-mode)))
1191 (setq level (gnus-group-default-level level))
1192 (gnus-group-setup-buffer)
1193 (gnus-update-format-specifications nil 'group 'group-mode)
1194 (let ((case-fold-search nil)
1195 (props (text-properties-at (point-at-bol)))
1196 (empty (= (point-min) (point-max)))
1197 (group (gnus-group-group-name))
1199 (set-buffer gnus-group-buffer)
1200 (setq number (funcall gnus-group-prepare-function level unread lowest))
1201 (when (or (and (numberp number)
1203 (zerop (buffer-size)))
1204 ;; No groups in the buffer.
1205 (gnus-message 5 gnus-no-groups-message))
1206 ;; We have some groups displayed.
1207 (goto-char (point-max))
1208 (when (or (not gnus-group-goto-next-group-function)
1209 (not (funcall gnus-group-goto-next-group-function
1213 (goto-char (point-min)))
1215 ;; Go to the first group with unread articles.
1216 (gnus-group-search-forward t))
1218 ;; Find the right group to put point on. If the current group
1219 ;; has disappeared in the new listing, try to find the next
1220 ;; one. If no next one can be found, just leave point at the
1221 ;; first newsgroup in the buffer.
1222 (when (not (gnus-goto-char
1224 (point-min) (point-max)
1225 'gnus-group (gnus-intern-safe
1226 group gnus-active-hashtb))))
1227 (let ((newsrc (cdddr (gnus-group-entry group))))
1229 (not (gnus-goto-char
1231 (point-min) (point-max) 'gnus-group
1233 (caar newsrc) gnus-active-hashtb)))))
1234 (setq newsrc (cdr newsrc)))
1236 (goto-char (point-max))
1237 (forward-line -1)))))))
1238 ;; Adjust cursor point.
1239 (gnus-group-position-point)))
1241 (defun gnus-group-list-level (level &optional all)
1242 "List groups on LEVEL.
1243 If ALL (the prefix), also list groups that have no unread articles."
1244 (interactive "nList groups on level: \nP")
1245 (gnus-group-list-groups level all level))
1247 (defun gnus-group-prepare-logic (group test)
1248 (or (and gnus-group-listed-groups
1249 (null gnus-group-list-option)
1250 (member group gnus-group-listed-groups))
1252 ((null gnus-group-listed-groups) test)
1253 ((null gnus-group-list-option) test)
1254 (t (and (member group gnus-group-listed-groups)
1255 (if (eq gnus-group-list-option 'flush)
1259 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1260 "List all newsgroups with unread articles of level LEVEL or lower.
1261 If PREDICATE is a function, list groups that the function returns non-nil;
1262 if it is t, list groups that have no unread articles.
1263 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1264 If REGEXP is a function, list dead groups that the function returns non-nil;
1265 if it is a string, only list groups matching REGEXP."
1266 (set-buffer gnus-group-buffer)
1267 (let ((buffer-read-only nil)
1268 (newsrc (cdr gnus-newsrc-alist))
1269 (lowest (or lowest 1))
1270 (not-in-list (and gnus-group-listed-groups
1271 (copy-sequence gnus-group-listed-groups)))
1272 info clevel unread group params)
1274 (when (or (< lowest gnus-level-zombie)
1275 gnus-group-listed-groups)
1276 ;; List living groups.
1278 (setq info (car newsrc)
1279 group (gnus-info-group info)
1280 params (gnus-info-params info)
1282 unread (gnus-group-unread group))
1284 (setq not-in-list (delete group not-in-list)))
1285 (when (gnus-group-prepare-logic
1287 (and unread ; This group might be unchecked
1288 (or (not (stringp regexp))
1289 (string-match regexp group))
1290 (<= (setq clevel (gnus-info-level info)) level)
1293 ((functionp predicate)
1294 (funcall predicate info))
1295 (predicate t) ; We list all groups?
1298 (if (eq unread t) ; Unactivated?
1299 gnus-group-list-inactive-groups
1300 ; We list unactivated
1302 ; We list groups with unread articles
1303 (and gnus-list-groups-with-ticked-articles
1304 (cdr (assq 'tick (gnus-info-marks info))))
1305 ; And groups with tickeds
1306 ;; Check for permanent visibility.
1307 (and gnus-permanently-visible-groups
1308 (string-match gnus-permanently-visible-groups
1310 (memq 'visible params)
1311 (cdr (assq 'visible params)))))))
1312 (gnus-group-insert-group-line
1313 group (gnus-info-level info)
1314 (gnus-info-marks info) unread (gnus-info-method info)))))
1316 ;; List dead groups.
1317 (when (or gnus-group-listed-groups
1318 (and (>= level gnus-level-zombie)
1319 (<= lowest gnus-level-zombie)))
1320 (gnus-group-prepare-flat-list-dead
1321 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1322 gnus-level-zombie ?Z
1325 (dolist (group gnus-zombie-list)
1326 (setq not-in-list (delete group not-in-list))))
1327 (when (or gnus-group-listed-groups
1328 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1329 (gnus-group-prepare-flat-list-dead
1332 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1333 gnus-level-killed ?K regexp))
1335 (gnus-group-set-mode-line)
1336 (setq gnus-group-list-mode (cons level predicate))
1337 (gnus-run-hooks 'gnus-group-prepare-hook)
1340 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1341 ;; List zombies and killed lists somewhat faster, which was
1342 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1343 ;; this by ignoring the group format specification altogether.
1345 (if (> (length groups) gnus-group-listing-limit)
1347 (setq group (pop groups))
1348 (when (gnus-group-prepare-logic
1351 (and (stringp regexp) (string-match regexp group))
1352 (and (functionp regexp) (funcall regexp group))))
1353 (gnus-add-text-properties
1354 (point) (prog1 (1+ (point))
1355 (insert " " mark " *: "
1356 (gnus-group-decoded-name group)
1358 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1360 'gnus-level level))))
1362 (setq group (pop groups))
1363 (when (gnus-group-prepare-logic
1366 (and (stringp regexp) (string-match regexp group))
1367 (and (functionp regexp) (funcall regexp group))))
1368 (gnus-group-insert-group-line
1370 (let ((active (gnus-active group)))
1372 (if (zerop (cdr active))
1374 (- (1+ (cdr active)) (car active)))
1376 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1378 (defun gnus-group-update-group-line ()
1379 "Update the current line in the group buffer."
1380 (let* ((buffer-read-only nil)
1381 (group (gnus-group-group-name))
1382 (entry (and group (gnus-group-entry group)))
1383 gnus-group-indentation)
1386 (not (gnus-ephemeral-group-p group))
1388 (concat "(gnus-group-set-info '"
1389 (gnus-prin1-to-string (nth 2 entry))
1391 (setq gnus-group-indentation (gnus-group-group-indentation))
1393 (gnus-group-insert-group-line-info group)
1395 (gnus-group-position-point))))
1397 (defun gnus-group-insert-group-line-info (group)
1398 "Insert GROUP on the current line."
1399 (let ((entry (gnus-group-entry group))
1400 (gnus-group-indentation (gnus-group-group-indentation))
1404 ;; (Un)subscribed group.
1405 (setq info (nth 2 entry))
1406 (gnus-group-insert-group-line
1407 group (gnus-info-level info) (gnus-info-marks info)
1408 (or (car entry) t) (gnus-info-method info)))
1409 ;; This group is dead.
1410 (gnus-group-insert-group-line
1412 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1414 (if (setq active (gnus-active group))
1415 (if (zerop (cdr active))
1417 (- (1+ (cdr active)) (car active)))
1419 (gnus-method-simplify (gnus-find-method-for-group group))))))
1421 (defun gnus-number-of-unseen-articles-in-group (group)
1422 (let* ((info (nth 2 (gnus-group-entry group)))
1423 (marked (gnus-info-marks info))
1424 (seen (cdr (assq 'seen marked)))
1425 (active (gnus-active group)))
1428 (length (gnus-uncompress-range
1429 (gnus-range-difference
1430 (gnus-range-difference (list active) (gnus-info-read info))
1433 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1434 gnus-tmp-marked number
1436 "Insert a group line in the group buffer."
1437 (let* ((gnus-tmp-method
1438 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1439 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1441 (gnus-tmp-active (gnus-active gnus-tmp-group))
1442 (gnus-tmp-number-total
1444 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1446 (gnus-tmp-number-of-unread
1447 (if (numberp number) (int-to-string (max 0 number))
1449 (gnus-tmp-number-of-read
1450 (if (numberp number)
1451 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1453 (gnus-tmp-subscribed
1454 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1455 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1456 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1458 (gnus-tmp-qualified-group
1459 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1460 group-name-charset))
1462 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1464 (gnus-tmp-newsgroup-description
1465 (if gnus-description-hashtb
1466 (or (gnus-group-name-decode
1467 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1468 group-name-charset) "")
1471 (if (and gnus-moderated-hashtb
1472 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1474 (gnus-tmp-moderated-string
1475 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1476 (gnus-tmp-group-icon "==&&==")
1477 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1478 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1479 (gnus-tmp-news-method-string
1481 (format "(%s:%s)" (car gnus-tmp-method)
1482 (cadr gnus-tmp-method)) ""))
1483 (gnus-tmp-marked-mark
1484 (if (and (numberp number)
1486 (cdr (assq 'tick gnus-tmp-marked)))
1488 (gnus-tmp-summary-live
1489 (if (and (not gnus-group-is-exiting-p)
1490 (gnus-buffer-live-p (gnus-summary-buffer-name
1493 (gnus-tmp-process-marked
1494 (if (member gnus-tmp-group gnus-group-marked)
1495 gnus-process-mark ? ))
1496 (buffer-read-only nil)
1497 header gnus-tmp-header) ; passed as parameter to user-funcs.
1499 (gnus-add-text-properties
1503 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1504 gnus-tmp-group group-name-charset)))
1505 (eval gnus-group-line-format-spec)))
1506 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1507 gnus-unread ,(if (numberp number)
1508 (string-to-number gnus-tmp-number-of-unread)
1510 gnus-marked ,gnus-tmp-marked-mark
1511 gnus-indentation ,gnus-group-indentation
1512 gnus-level ,gnus-tmp-level))
1514 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1515 (gnus-run-hooks 'gnus-group-update-hook))
1517 ;; Allow XEmacs to remove front-sticky text properties.
1518 (gnus-group-remove-excess-properties)))
1520 (defun gnus-group-highlight-line ()
1521 "Highlight the current line according to `gnus-group-highlight'."
1522 (let* ((list gnus-group-highlight)
1524 (end (point-at-eol))
1525 ;; now find out where the line starts and leave point there.
1526 (beg (progn (beginning-of-line) (point)))
1527 (group (gnus-group-group-name))
1528 (entry (gnus-group-entry group))
1529 (unread (if (numberp (car entry)) (car entry) 0))
1530 (active (gnus-active group))
1531 (total (if active (1+ (- (cdr active) (car active))) 0))
1532 (info (nth 2 entry))
1533 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1534 (marked (gnus-info-marks info))
1535 (mailp (apply 'append
1538 (memq x (assoc (symbol-name
1539 (car (or method gnus-select-method)))
1540 gnus-valid-select-methods)))
1541 '(mail post-mail))))
1542 (level (or (gnus-info-level info) gnus-level-killed))
1543 (score (or (gnus-info-score info) 0))
1544 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1545 (group-age (gnus-group-timestamp-delta group))
1546 (inhibit-read-only t))
1547 ;; Eval the cars of the lists until we find a match.
1549 (not (eval (caar list))))
1550 (setq list (cdr list)))
1551 (let ((face (cdar list)))
1552 (unless (eq face (get-text-property beg 'face))
1553 (gnus-put-text-property-excluding-characters-with-faces
1555 (setq face (if (boundp face) (symbol-value face) face)))
1556 (gnus-extent-start-open beg)))
1559 (defun gnus-group-update-group (group &optional visible-only)
1560 "Update all lines where GROUP appear.
1561 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1563 ;; Can't use `save-excursion' here, so we do it manually.
1564 (let ((buf (current-buffer))
1566 (set-buffer gnus-group-buffer)
1567 (setq mark (point-marker))
1568 ;; The buffer may be narrowed.
1571 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1573 found buffer-read-only)
1574 ;; Enter the current status into the dribble buffer.
1575 (let ((entry (gnus-group-entry group)))
1577 (not (gnus-ephemeral-group-p group)))
1579 (concat "(gnus-group-set-info '"
1580 (gnus-prin1-to-string (nth 2 entry))
1582 ;; Find all group instances. If topics are in use, each group
1583 ;; may be listed in more than once.
1584 (while (setq loc (text-property-any
1585 loc (point-max) 'gnus-group ident))
1588 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1590 (gnus-group-insert-group-line-info group)
1593 (gnus-run-hooks 'gnus-group-update-group-hook)))
1594 (setq loc (1+ loc)))
1595 (unless (or found visible-only)
1596 ;; No such line in the buffer, find out where it's supposed to
1597 ;; go, and insert it there (or at the end of the buffer).
1598 (if gnus-goto-missing-group-function
1599 (funcall gnus-goto-missing-group-function group)
1600 (let ((entry (cddr (gnus-group-entry group))))
1601 (while (and entry (car entry)
1605 (point-min) (point-max)
1606 'gnus-group (gnus-intern-safe
1607 (caar entry) gnus-active-hashtb)))))
1608 (setq entry (cdr entry)))
1609 (or entry (goto-char (point-max)))))
1610 ;; Finally insert the line.
1611 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1612 (gnus-group-insert-group-line-info group)
1615 (gnus-run-hooks 'gnus-group-update-group-hook))))
1616 (when gnus-group-update-group-function
1617 (funcall gnus-group-update-group-function group))
1618 (gnus-group-set-mode-line)))
1620 (set-marker mark nil)
1623 (defun gnus-group-set-mode-line ()
1624 "Update the mode line in the group buffer."
1625 (when (memq 'group gnus-updated-mode-lines)
1626 ;; Yes, we want to keep this mode line updated.
1628 (set-buffer gnus-group-buffer)
1629 (let* ((gformat (or gnus-group-mode-line-format-spec
1630 (gnus-set-format 'group-mode)))
1631 (gnus-tmp-news-server (cadr gnus-select-method))
1632 (gnus-tmp-news-method (car gnus-select-method))
1633 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1635 gnus-tmp-header ;Dummy binding for user-defined formats
1636 ;; Get the resulting string.
1638 (and gnus-dribble-buffer
1639 (buffer-name gnus-dribble-buffer)
1640 (buffer-modified-p gnus-dribble-buffer)
1642 (set-buffer gnus-dribble-buffer)
1643 (not (zerop (buffer-size))))))
1644 (mode-string (eval gformat)))
1645 ;; Say whether the dribble buffer has been modified.
1646 (setq mode-line-modified
1647 (if modified (car gnus-mode-line-modified)
1648 (cdr gnus-mode-line-modified)))
1649 ;; If the line is too long, we chop it off.
1650 (when (> (length mode-string) max-len)
1651 (setq mode-string (substring mode-string 0 (- max-len 4))))
1653 (setq mode-line-buffer-identification
1654 (gnus-mode-line-buffer-identification
1655 (list mode-string)))
1656 (set-buffer-modified-p modified))))))
1658 (defun gnus-group-group-name ()
1659 "Get the name of the newsgroup on the current line."
1660 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1662 (symbol-name group))))
1664 (defun gnus-group-group-level ()
1665 "Get the level of the newsgroup on the current line."
1666 (get-text-property (point-at-bol) 'gnus-level))
1668 (defun gnus-group-group-indentation ()
1669 "Get the indentation of the newsgroup on the current line."
1670 (or (get-text-property (point-at-bol) 'gnus-indentation)
1671 (and gnus-group-indentation-function
1672 (funcall gnus-group-indentation-function))
1675 (defun gnus-group-group-unread ()
1676 "Get the number of unread articles of the newsgroup on the current line."
1677 (get-text-property (point-at-bol) 'gnus-unread))
1679 (defun gnus-group-new-mail (group)
1680 (if (nnmail-new-mail-p (gnus-group-real-name group))
1684 (defun gnus-group-level (group)
1685 "Return the estimated level of GROUP."
1686 (or (gnus-info-level (gnus-get-info group))
1687 (and (member group gnus-zombie-list) gnus-level-zombie)
1690 (defun gnus-group-search-forward (&optional backward all level first-too)
1691 "Find the next newsgroup with unread articles.
1692 If BACKWARD is non-nil, find the previous newsgroup instead.
1693 If ALL is non-nil, just find any newsgroup.
1694 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1696 If FIRST-TOO, the current line is also eligible as a target."
1697 (let ((way (if backward -1 1))
1698 (low gnus-level-killed)
1701 (if (and backward (progn (beginning-of-line)) (bobp))
1710 (get-text-property (point) 'gnus-group)
1714 (get-text-property (point) 'gnus-unread)))
1715 (and (numberp unread) (> unread 0)))
1716 (setq lev (get-text-property (point)
1718 (<= lev gnus-level-subscribed)))
1720 (and (setq lev (get-text-property (point)
1729 (zerop (forward-line way)))))
1731 (progn (gnus-group-position-point) t)
1732 (goto-char (or pos beg))
1735 (defun gnus-total-fetched-for (group)
1736 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1737 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1738 (size (+ size-in-cache size-in-agent))
1739 (suffix '("B" "K" "M" "G"))
1741 (cutoff (* 10 scale)))
1742 (while (> size cutoff)
1743 (setq size (/ size scale)
1744 suffix (cdr suffix)))
1745 (format "%5.1f%s" size (car suffix))))
1747 ;;; Gnus group mode commands
1751 (defun gnus-group-mark-line-p ()
1754 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1755 (eq (char-after) gnus-process-mark)))
1757 (defun gnus-group-mark-group (n &optional unmark no-advance)
1758 "Mark the current group."
1760 (let ((buffer-read-only nil)
1764 (when (setq group (gnus-group-group-name))
1765 ;; Go to the mark position.
1767 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1771 (setq gnus-group-marked (delete group gnus-group-marked))
1772 (insert-char ? 1 t))
1773 (setq gnus-group-marked
1774 (cons group (delete group gnus-group-marked)))
1775 (insert-char gnus-process-mark 1 t)))
1777 (gnus-group-next-group 1))
1779 (gnus-summary-position-point)
1782 (defun gnus-group-unmark-group (n)
1783 "Remove the mark from the current group."
1785 (gnus-group-mark-group n 'unmark)
1786 (gnus-group-position-point))
1788 (defun gnus-group-unmark-all-groups ()
1789 "Unmark all groups."
1792 (mapc 'gnus-group-remove-mark gnus-group-marked))
1793 (gnus-group-position-point))
1795 (defun gnus-group-mark-region (unmark beg end)
1796 "Mark all groups between point and mark.
1797 If UNMARK, remove the mark instead."
1798 (interactive "P\nr")
1799 (let ((num (count-lines beg end)))
1802 (- num (gnus-group-mark-group num unmark)))))
1804 (defun gnus-group-mark-buffer (&optional unmark)
1805 "Mark all groups in the buffer.
1806 If UNMARK, remove the mark instead."
1808 (gnus-group-mark-region unmark (point-min) (point-max)))
1810 (defun gnus-group-mark-regexp (regexp)
1811 "Mark all groups that match some regexp."
1812 (interactive "sMark (regexp): ")
1813 (let ((alist (cdr gnus-newsrc-alist))
1817 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1818 (gnus-group-jump-to-group group)
1819 (gnus-group-set-mark group)))))
1820 (gnus-group-position-point))
1822 (defun gnus-group-remove-mark (group &optional test-marked)
1823 "Remove the process mark from GROUP and move point there.
1824 Return nil if the group isn't displayed."
1825 (if (gnus-group-goto-group group nil test-marked)
1827 (gnus-group-mark-group 1 'unmark t)
1829 (setq gnus-group-marked
1830 (delete group gnus-group-marked))
1833 (defun gnus-group-set-mark (group)
1834 "Set the process mark on GROUP."
1835 (if (gnus-group-goto-group group)
1837 (gnus-group-mark-group 1 nil t))
1838 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1840 (defun gnus-group-universal-argument (arg &optional groups func)
1841 "Perform any command on all groups according to the process/prefix convention."
1843 (if (eq (setq func (or func
1846 (substitute-command-keys
1847 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1849 (gnus-error 1 "Undefined key")
1850 (gnus-group-iterate arg
1852 (command-execute func))))
1853 (gnus-group-position-point))
1855 (defun gnus-group-process-prefix (n)
1856 "Return a list of groups to work on.
1857 Take into consideration N (the prefix) and the list of marked groups."
1860 (setq n (prefix-numeric-value n))
1861 ;; There is a prefix, so we return a list of the N next
1863 (let ((way (if (< n 0) -1 1))
1868 (if (setq group (gnus-group-group-name))
1869 (push group groups))
1871 (gnus-group-next-group way)))
1873 ((and (gnus-region-active-p) (mark))
1874 ;; Work on the region between point and mark.
1875 (let ((max (max (point) (mark)))
1878 (goto-char (min (point) (mark)))
1881 (push (gnus-group-group-name) groups)
1882 (zerop (gnus-group-next-group 1))
1884 (nreverse groups))))
1886 ;; No prefix, but a list of marked articles.
1887 (reverse gnus-group-marked))
1889 ;; Neither marked articles or a prefix, so we return the
1891 (let ((group (gnus-group-group-name)))
1892 (and group (list group))))))
1894 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1895 ;;; imagine why I went through these contortions...
1897 (let ((function (make-symbol "gnus-group-iterate-function"))
1898 (window (make-symbol "gnus-group-iterate-window"))
1899 (groups (make-symbol "gnus-group-iterate-groups"))
1900 (group (make-symbol "gnus-group-iterate-group")))
1902 `(defun gnus-group-iterate (arg ,function)
1903 "Iterate FUNCTION over all process/prefixed groups.
1904 FUNCTION will be called with the group name as the parameter
1905 and with point over the group in question."
1906 (let ((,groups (gnus-group-process-prefix arg))
1907 (,window (selected-window))
1910 (setq ,group (car ,groups)
1911 ,groups (cdr ,groups))
1912 (select-window ,window)
1913 (gnus-group-remove-mark ,group)
1914 (save-selected-window
1916 (funcall ,function ,group)))))))))
1918 (put 'gnus-group-iterate 'lisp-indent-function 1)
1920 ;; Selecting groups.
1922 (defun gnus-group-read-group (&optional all no-article group select-articles)
1923 "Read news in this newsgroup.
1924 If the prefix argument ALL is non-nil, already read articles become
1925 readable. IF ALL is a number, fetch this number of articles. If the
1926 optional argument NO-ARTICLE is non-nil, no article will be
1927 auto-selected upon group entry. If GROUP is non-nil, fetch that
1930 (let ((no-display (eq all 0))
1931 (group (or group (gnus-group-group-name)))
1932 number active marked entry)
1936 (error "No group on current line"))
1937 (setq marked (gnus-info-marks
1938 (nth 2 (setq entry (gnus-group-entry group)))))
1939 ;; This group might be a dead group. In that case we have to get
1940 ;; the number of unread articles from `gnus-active-hashtb'.
1942 (cond ((numberp all) all)
1944 ((setq active (gnus-active group))
1945 (- (1+ (cdr active)) (car active)))))
1946 (gnus-summary-read-group
1947 group (or all (and (numberp number)
1948 (zerop (+ number (gnus-range-length
1949 (cdr (assq 'tick marked)))
1951 (cdr (assq 'dormant marked)))))))
1952 no-article nil no-display nil select-articles)))
1954 (defun gnus-group-select-group (&optional all)
1955 "Select this newsgroup.
1956 No article is selected automatically.
1957 If the group is opened, just switch the summary buffer.
1958 If ALL is non-nil, already read articles become readable.
1959 If ALL is a positive number, fetch this number of the latest
1960 articles in the group.
1961 If ALL is a negative number, fetch this number of the earliest
1962 articles in the group."
1964 (when (and (eobp) (not (gnus-group-group-name)))
1966 (gnus-group-read-group all t))
1968 (defun gnus-group-quick-select-group (&optional all)
1969 "Select the current group \"quickly\".
1970 This means that no highlighting or scoring will be performed.
1971 If ALL (the prefix argument) is 0, don't even generate the summary
1974 This might be useful if you want to toggle threading
1975 before entering the group."
1977 (require 'gnus-score)
1979 gnus-score-find-score-files-function
1980 gnus-home-score-file
1981 gnus-apply-kill-hook
1982 gnus-summary-expunge-below)
1983 (gnus-group-read-group all t)))
1985 (defun gnus-group-visible-select-group (&optional all)
1986 "Select the current group without hiding any articles."
1988 (let ((gnus-inhibit-limiting t))
1989 (gnus-group-read-group all t)))
1991 (defun gnus-group-select-group-ephemerally ()
1992 "Select the current group without doing any processing whatsoever.
1993 You will actually be entered into a group that's a copy of
1994 the current group; no changes you make while in this group will
1997 (require 'gnus-score)
1999 gnus-score-find-score-files-function gnus-apply-kill-hook
2000 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2001 gnus-summary-mode-hook gnus-select-group-hook
2002 (group (gnus-group-group-name))
2003 (method (gnus-find-method-for-group group)))
2004 (gnus-group-read-ephemeral-group
2005 (gnus-group-prefixed-name group method) method)))
2008 (defun gnus-fetch-group (group &optional articles)
2009 "Start Gnus if necessary and enter GROUP.
2010 Returns whether the fetching was successful or not."
2011 (interactive (list (gnus-group-completing-read-group-name
2012 "Group name: " gnus-active-hashtb)))
2013 (unless (get-buffer gnus-group-buffer)
2015 (gnus-group-read-group articles nil group))
2018 (defun gnus-fetch-group-other-frame (group)
2019 "Pop up a frame and enter GROUP."
2021 (let ((window (get-buffer-window gnus-group-buffer)))
2023 (select-frame (window-frame window)))
2024 ((= (length (frame-list)) 1)
2025 (select-frame (make-frame)))
2028 (gnus-fetch-group group))
2030 (defvar gnus-ephemeral-group-server 0)
2032 (defcustom gnus-large-ephemeral-newsgroup 200
2033 "The number of articles which indicates a large ephemeral newsgroup.
2034 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2036 If the number of articles in a newsgroup is greater than this value,
2037 confirmation is required for selecting the newsgroup. If it is nil, no
2038 confirmation is required."
2040 :group 'gnus-group-select
2041 :type '(choice (const :tag "No limit" nil)
2044 (defcustom gnus-fetch-old-ephemeral-headers nil
2045 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2048 :type '(choice (const :tag "off" nil)
2051 (sexp :menu-tag "other" t)))
2053 ;; Enter a group that is not in the group buffer. Non-nil is returned
2054 ;; if selection was successful.
2055 (defun gnus-group-read-ephemeral-group (group method &optional activate
2056 quit-config request-only
2060 "Read GROUP from METHOD as an ephemeral group.
2061 If ACTIVATE, request the group first.
2062 If QUIT-CONFIG, use that window configuration when exiting from the
2064 If REQUEST-ONLY, don't actually read the group; just request it.
2065 If SELECT-ARTICLES, only select those articles.
2066 If PARAMETERS, use those as the group parameters.
2067 If NUMBER, fetch this number of articles.
2069 Return the name of the group if selection was successful."
2072 ;; (gnus-read-group "Group name: ")
2074 "Group: " gnus-active-hashtb
2076 'gnus-group-history)
2077 (gnus-read-method "From method: ")))
2078 ;; Transform the select method into a unique server.
2079 (when (stringp method)
2080 (setq method (gnus-server-to-method method)))
2082 `(,(car method) ,(concat (cadr method) "-ephemeral")
2083 (,(intern (format "%s-address" (car method))) ,(cadr method))
2085 (let ((group (if (gnus-group-foreign-p group) group
2086 (gnus-group-prefixed-name (gnus-group-real-name group)
2091 ,gnus-level-default-subscribed nil nil ,method
2094 (cons 'quit-config quit-config)
2096 (cons gnus-summary-buffer
2097 gnus-current-window-configuration)))
2100 (push method gnus-ephemeral-servers)
2101 (set-buffer gnus-group-buffer)
2102 (unless (gnus-check-server method)
2103 (error "Unable to contact server: %s" (gnus-status-message method)))
2105 (gnus-activate-group group 'scan)
2106 (unless (gnus-request-group group)
2107 (error "Couldn't request group: %s"
2108 (nnheader-get-report (car method)))))
2112 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2113 (gnus-fetch-old-headers
2114 gnus-fetch-old-ephemeral-headers))
2115 (gnus-group-read-group (or number t) t group select-articles))
2119 (message "Quit reading the ephemeral group")
2122 (defun gnus-group-jump-to-group (group &optional prompt)
2123 "Jump to newsgroup GROUP.
2125 If PROMPT (the prefix) is a number, use the prompt specified in
2126 `gnus-group-jump-to-group-prompt'."
2128 (list (mm-string-make-unibyte
2130 "Group: " gnus-active-hashtb nil
2131 (gnus-read-active-file-p)
2132 (if current-prefix-arg
2133 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2134 (or (and (stringp gnus-group-jump-to-group-prompt)
2135 gnus-group-jump-to-group-prompt)
2136 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2137 (and (stringp p) p))))
2138 'gnus-group-history))))
2140 (when (equal group "")
2141 (error "Empty group name"))
2143 (unless (gnus-ephemeral-group-p group)
2144 ;; Either go to the line in the group buffer...
2145 (unless (gnus-group-goto-group group)
2146 ;; ... or insert the line.
2147 (gnus-group-update-group group)
2148 (gnus-group-goto-group group)))
2149 ;; Adjust cursor point.
2150 (gnus-group-position-point))
2152 (defun gnus-group-goto-group (group &optional far test-marked)
2153 "Goto to newsgroup GROUP.
2154 If FAR, it is likely that the group is not on the current line.
2155 If TEST-MARKED, the line must be marked."
2159 ;; It's quite likely that we are on the right line, so
2160 ;; we check the current line first.
2162 (eq (get-text-property (point) 'gnus-group)
2163 (gnus-intern-safe group gnus-active-hashtb))
2164 (or (not test-marked) (gnus-group-mark-line-p)))
2166 ;; Previous and next line are also likely, so we check them as well.
2170 (and (eq (get-text-property (point) 'gnus-group)
2171 (gnus-intern-safe group gnus-active-hashtb))
2172 (or (not test-marked) (gnus-group-mark-line-p)))))
2178 (and (eq (get-text-property (point) 'gnus-group)
2179 (gnus-intern-safe group gnus-active-hashtb))
2180 (or (not test-marked) (gnus-group-mark-line-p)))))
2184 (goto-char (point-min))
2186 (while (and (not found)
2191 (gnus-intern-safe group gnus-active-hashtb))))
2192 (if (gnus-group-mark-line-p)
2197 ;; Search through the entire buffer.
2200 (point-min) (point-max)
2201 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2203 (defun gnus-group-next-group (n &optional silent)
2204 "Go to next N'th newsgroup.
2205 If N is negative, search backward instead.
2206 Returns the difference between N and the number of skips actually
2209 (gnus-group-next-unread-group n t nil silent))
2211 (defun gnus-group-next-unread-group (n &optional all level silent)
2212 "Go to next N'th unread newsgroup.
2213 If N is negative, search backward instead.
2214 If ALL is non-nil, choose any newsgroup, unread or not.
2215 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2216 such group can be found, the next group with a level higher than
2218 Returns the difference between N and the number of skips actually
2221 (let ((backward (< n 0))
2224 (gnus-group-search-forward
2225 backward (or (not gnus-group-goto-unread) all) level))
2229 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2230 (if level " on this level or higher" "")))
2233 (defun gnus-group-prev-group (n)
2234 "Go to previous N'th newsgroup.
2235 Returns the difference between N and the number of skips actually
2238 (gnus-group-next-unread-group (- n) t))
2240 (defun gnus-group-prev-unread-group (n)
2241 "Go to previous N'th unread newsgroup.
2242 Returns the difference between N and the number of skips actually
2245 (gnus-group-next-unread-group (- n)))
2247 (defun gnus-group-next-unread-group-same-level (n)
2248 "Go to next N'th unread newsgroup on the same level.
2249 If N is negative, search backward instead.
2250 Returns the difference between N and the number of skips actually
2253 (gnus-group-next-unread-group n t (gnus-group-group-level))
2254 (gnus-group-position-point))
2256 (defun gnus-group-prev-unread-group-same-level (n)
2257 "Go to next N'th unread newsgroup on the same level.
2258 Returns the difference between N and the number of skips actually
2261 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2262 (gnus-group-position-point))
2264 (defun gnus-group-best-unread-group (&optional exclude-group)
2265 "Go to the group with the highest level.
2266 If EXCLUDE-GROUP, do not go to that group."
2268 (goto-char (point-min))
2272 (setq unread (get-text-property (point) 'gnus-unread))
2273 (when (and (numberp unread) (> unread 0))
2274 (when (and (get-text-property (point) 'gnus-level)
2275 (< (get-text-property (point) 'gnus-level) best)
2276 (or (not exclude-group)
2277 (not (equal exclude-group (gnus-group-group-name)))))
2278 (setq best (get-text-property (point) 'gnus-level))
2279 (setq best-point (point))))
2282 (goto-char best-point))
2283 (gnus-group-position-point)
2284 (and best-point (gnus-group-group-name))))
2286 (defun gnus-group-first-unread-group ()
2287 "Go to the first group with unread articles."
2290 (let ((opoint (point))
2292 (goto-char (point-min))
2293 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2294 (and (numberp unread) ; Not a topic.
2295 (not (zerop unread))) ; Has unread articles.
2296 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2299 nil)) ; Not success.
2300 (gnus-group-position-point)))
2302 (defun gnus-group-enter-server-mode ()
2303 "Jump to the server buffer."
2305 (gnus-enter-server-buffer))
2307 (defun gnus-group-make-group-simple (&optional group)
2308 "Add a new newsgroup.
2309 The user will be prompted for GROUP."
2311 (list (completing-read "Group: " gnus-active-hashtb
2312 nil nil nil 'gnus-group-history)))
2313 (gnus-group-make-group
2314 (gnus-group-real-name group)
2315 (gnus-group-server group)))
2317 (defun gnus-group-make-group (name &optional method address args)
2318 "Add a new newsgroup.
2319 The user will be prompted for a NAME, for a select METHOD, and an
2323 (gnus-read-group "Group name: ")
2324 (gnus-read-method "From method: ")))
2326 (when (stringp method)
2327 (setq method (or (gnus-server-to-method method) method)))
2328 (let* ((meth (gnus-method-simplify
2330 (not (gnus-server-equal method gnus-select-method)))
2331 (if address (list (intern method) address)
2333 (nname (if method (gnus-group-prefixed-name name meth) name))
2335 (when (gnus-group-entry nname)
2336 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2337 ;; Subscribe to the new group.
2338 (gnus-group-change-level
2339 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2340 gnus-level-default-subscribed gnus-level-killed
2341 (and (gnus-group-group-name)
2342 (gnus-group-entry (gnus-group-group-name)))
2345 (gnus-set-active nname (cons 1 0))
2346 (unless (gnus-ephemeral-group-p name)
2348 (concat "(gnus-group-set-info '"
2349 (gnus-prin1-to-string (cdr info)) ")")))
2351 (gnus-group-insert-group-line-info nname)
2353 (gnus-group-position-point)
2355 ;; Load the back end and try to make the back end create
2356 ;; the group as well.
2357 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2359 gnus-valid-select-methods)
2361 (gnus-check-server meth)
2362 (when (gnus-check-backend-function 'request-create-group nname)
2363 (unless (gnus-request-create-group nname nil args)
2364 (error "Could not create group on server: %s"
2365 (nnheader-get-report backend))))
2368 (defun gnus-group-delete-groups (&optional arg)
2369 "Delete the current group. Only meaningful with editable groups."
2371 (let ((n (length (gnus-group-process-prefix arg))))
2372 (when (gnus-yes-or-no-p
2374 "Delete this 1 group? "
2375 (format "Delete these %d groups? " n)))
2376 (gnus-group-iterate arg
2378 (gnus-group-delete-group group nil t))))))
2380 (defun gnus-group-delete-group (group &optional force no-prompt)
2381 "Delete the current group. Only meaningful with editable groups.
2382 If FORCE (the prefix) is non-nil, all the articles in the group will
2383 be deleted. This is \"deleted\" as in \"removed forever from the face
2384 of the Earth\". There is no undo. The user will be prompted before
2386 Note that you also have to specify FORCE if you want the group to
2387 be removed from the server, even when it's empty."
2389 (list (gnus-group-group-name)
2390 current-prefix-arg))
2392 (error "No group to delete"))
2393 (unless (gnus-check-backend-function 'request-delete-group group)
2394 (error "This back end does not support group deletion"))
2396 (let ((group-decoded (gnus-group-decoded-name group)))
2397 (if (and (not no-prompt)
2398 (not (gnus-yes-or-no-p
2400 "Do you really want to delete %s%s? "
2401 group-decoded (if force " and all its contents" "")))))
2403 (gnus-message 6 "Deleting group %s..." group-decoded)
2404 (if (not (gnus-request-delete-group group force))
2405 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2406 (gnus-message 6 "Deleting group %s...done" group-decoded)
2407 (gnus-group-goto-group group)
2408 (gnus-group-kill-group 1 t)
2409 (gnus-set-active group nil)
2411 (gnus-group-position-point)))
2413 (defun gnus-group-rename-group (group new-name)
2414 "Rename group from GROUP to NEW-NAME.
2415 When used interactively, GROUP is the group under point
2416 and NEW-NAME will be prompted for."
2419 (gnus-group-group-name)
2421 (unless (gnus-check-backend-function
2422 'request-rename-group (gnus-group-group-name))
2423 (error "This back end does not support renaming groups"))
2424 (gnus-read-group "Rename group to: "
2425 (gnus-group-real-name (gnus-group-group-name))))))
2427 (unless (gnus-check-backend-function 'request-rename-group group)
2428 (error "This back end does not support renaming groups"))
2430 (error "No group to rename"))
2431 (when (equal (gnus-group-real-name group) new-name)
2432 (error "Can't rename to the same name"))
2434 ;; We find the proper prefixed name.
2436 (if (gnus-group-native-p group)
2440 (gnus-group-prefixed-name
2441 (gnus-group-real-name new-name)
2442 (gnus-info-method (gnus-get-info group)))))
2444 (when (gnus-active new-name)
2445 (error "The group %s already exists" new-name))
2447 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2450 (gnus-group-goto-group group)
2451 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2452 (gnus-request-rename-group group new-name))))
2453 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2454 ;; We rename the group internally by killing it...
2455 (gnus-group-kill-group)
2456 ;; ... changing its name ...
2457 (setcar (cdar gnus-list-of-killed-groups) new-name)
2458 ;; ... and then yanking it. Magic!
2459 (gnus-group-yank-group)
2460 (gnus-set-active new-name (gnus-active group))
2461 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2463 (setq gnus-killed-list (delete group gnus-killed-list))
2464 (gnus-set-active group nil)
2465 (gnus-dribble-touch)
2466 (gnus-group-position-point)))
2468 (defun gnus-group-edit-group (group &optional part)
2469 "Edit the group on the current line."
2470 (interactive (list (gnus-group-group-name)))
2471 (let ((part (or part 'info))
2474 (error "No group on current line"))
2475 (unless (setq info (gnus-get-info group))
2476 (error "Killed group; can't be edited"))
2478 (gnus-close-group group))
2480 ;; Find the proper form to edit.
2481 (cond ((eq part 'method)
2482 (or (gnus-info-method info) "native"))
2484 (gnus-info-params info))
2486 ;; The proper documentation.
2488 "Editing the %s for `%s'."
2490 ((eq part 'method) "select method")
2491 ((eq part 'params) "group parameters")
2493 (gnus-group-decoded-name group))
2495 (gnus-group-edit-group-done ',part ,group form)))
2498 (gnus-create-info-command
2500 (or gnus-info-filename
2501 (get-language-info current-language-environment 'gnus-info)
2503 (cond ((eq part 'method)
2510 (defun gnus-group-edit-group-method (group)
2511 "Edit the select method of GROUP."
2512 (interactive (list (gnus-group-group-name)))
2513 (gnus-group-edit-group group 'method))
2515 (defun gnus-group-edit-group-parameters (group)
2516 "Edit the group parameters of GROUP."
2517 (interactive (list (gnus-group-group-name)))
2518 (gnus-group-edit-group group 'params))
2520 (defun gnus-group-edit-group-done (part group form)
2522 (let* ((method (cond ((eq part 'info) (nth 4 form))
2523 ((eq part 'method) form)
2525 (info (cond ((eq part 'info) form)
2526 ((eq part 'method) (gnus-get-info group))
2529 (if (or (not method)
2531 gnus-select-method method))
2532 (gnus-group-real-name (car info))
2533 (gnus-group-prefixed-name
2534 (gnus-group-real-name (car info)) method))
2536 (when (and new-group
2537 (not (equal new-group group)))
2538 (when (gnus-group-goto-group group)
2539 (gnus-group-kill-group 1))
2540 (gnus-activate-group new-group))
2542 (if (not (and info new-group))
2543 (gnus-group-set-info form (or new-group group) part)
2544 (setq info (gnus-copy-sequence info))
2545 (setcar info new-group)
2546 (unless (gnus-server-equal method "native")
2547 (unless (nthcdr 3 info)
2548 (nconc info (list nil nil)))
2549 (unless (nthcdr 4 info)
2550 (nconc info (list nil)))
2551 (gnus-info-set-method info method))
2552 (gnus-group-set-info info))
2553 (gnus-group-update-group (or new-group group))
2554 (gnus-group-position-point)))
2556 (defun gnus-group-make-useful-group (group method)
2557 "Create one of the groups described in `gnus-useful-groups'."
2559 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2561 gnus-useful-groups)))
2562 (list (cadr entry) (caddr entry))))
2563 (setq method (gnus-copy-sequence method))
2565 (while (setq entry (memq (assq 'eval method) method))
2566 (setcar entry (eval (cadar entry)))))
2567 (gnus-group-make-group group method))
2569 (defun gnus-group-make-help-group (&optional noerror)
2570 "Create the Gnus documentation group.
2571 Optional argument NOERROR modifies the behavior of this function when the
2572 group already exists:
2573 - if not given, and error is signaled,
2574 - if t, stay silent,
2575 - if anything else, just print a message."
2577 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2578 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2579 (if (gnus-group-entry name)
2580 (cond ((eq noerror nil)
2581 (error "Documentation group already exists"))
2586 (gnus-message 1 "Documentation group already exists")))
2589 (gnus-message 1 "Couldn't find doc group")
2590 (gnus-group-make-group
2591 (gnus-group-real-name name)
2592 (list 'nndoc "gnus-help"
2593 (list 'nndoc-address file)
2594 (list 'nndoc-article-type 'mbox))))
2596 (gnus-group-position-point))
2598 (defun gnus-group-make-doc-group (file type)
2599 "Create a group that uses a single file as the source.
2601 If called with a prefix argument, ask for the file type."
2603 (list (read-file-name "File name: ")
2604 (and current-prefix-arg 'ask)))
2605 (when (eq type 'ask)
2610 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
2612 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2613 ((= char ?b) 'babyl)
2614 ((= char ?d) 'digest)
2615 ((= char ?f) 'forward)
2617 ((= char ?g) 'guess)
2618 (t (setq err (format "%c unknown. " char))
2621 (let* ((file (expand-file-name file))
2622 (name (gnus-generate-new-group-name
2623 (gnus-group-prefixed-name
2624 (file-name-nondirectory file) '(nndoc "")))))
2625 (gnus-group-make-group
2626 (gnus-group-real-name name)
2628 (list 'nndoc-address file)
2629 (list 'nndoc-article-type (or type 'guess))))))
2631 (defvar nnweb-type-definition)
2632 (defvar gnus-group-web-type-history nil)
2633 (defvar gnus-group-web-search-history nil)
2634 (defun gnus-group-make-web-group (&optional solid)
2635 "Create an ephemeral nnweb group.
2636 If SOLID (the prefix), create a solid group."
2640 (if solid (gnus-read-group "Group name: ")
2641 (message-unique-id)))
2642 (default-type (or (car gnus-group-web-type-history)
2643 (symbol-name (caar nnweb-type-definition))))
2647 (format "Search engine type (default %s): " default-type)
2648 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2649 nnweb-type-definition)
2650 nil t nil 'gnus-group-web-type-history)
2655 (cons (or (car gnus-group-web-search-history) "") 0)
2656 'gnus-group-web-search-history))
2658 `(nnweb ,group (nnweb-search ,search)
2659 (nnweb-type ,(intern type))
2660 (nnweb-ephemeral-p t))))
2663 (gnus-pull 'nnweb-ephemeral-p method)
2664 (gnus-group-make-group group method))
2665 (gnus-group-read-ephemeral-group
2667 (cons (current-buffer)
2668 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2671 (defvar nnrss-group-alist)
2672 (defun nnrss-discover-feed (arg))
2673 (defun nnrss-save-server-data (arg)))
2674 (defun gnus-group-make-rss-group (&optional url)
2675 "Given a URL, discover if there is an RSS feed.
2676 If there is, use Gnus to create an nnrss group"
2680 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2681 (let ((feedinfo (nnrss-discover-feed url)))
2683 (let ((title (gnus-newsgroup-savable-name
2684 (read-from-minibuffer "Title: "
2685 (gnus-newsgroup-savable-name
2686 (or (cdr (assoc 'title
2689 (desc (read-from-minibuffer "Description: "
2690 (cdr (assoc 'description
2692 (href (cdr (assoc 'href feedinfo)))
2693 (encodable (mm-coding-system-p 'utf-8)))
2695 ;; Unify non-ASCII text.
2696 (setq title (mm-decode-coding-string
2697 (mm-encode-coding-string title 'utf-8) 'utf-8)))
2698 (gnus-group-make-group (if encodable
2699 (mm-encode-coding-string title 'utf-8)
2702 (push (list title href desc) nnrss-group-alist)
2703 (nnrss-save-server-data nil))
2704 (error "No feeds found for %s" url))))
2706 (defvar nnwarchive-type-definition)
2707 (defvar gnus-group-warchive-type-history nil)
2708 (defvar gnus-group-warchive-login-history nil)
2709 (defvar gnus-group-warchive-address-history nil)
2711 (defun gnus-group-make-warchive-group ()
2712 "Create a nnwarchive group."
2714 (require 'nnwarchive)
2715 (let* ((group (gnus-read-group "Group name: "))
2716 (default-type (or (car gnus-group-warchive-type-history)
2717 (symbol-name (caar nnwarchive-type-definition))))
2721 (format "Warchive type (default %s): " default-type)
2722 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2723 nnwarchive-type-definition)
2724 nil t nil 'gnus-group-warchive-type-history)
2726 (address (read-string "Warchive address: "
2727 nil 'gnus-group-warchive-address-history))
2728 (default-login (or (car gnus-group-warchive-login-history)
2733 (format "Warchive login (default %s): " user-mail-address)
2734 default-login 'gnus-group-warchive-login-history)
2737 `(nnwarchive ,address
2738 (nnwarchive-type ,(intern type))
2739 (nnwarchive-login ,login))))
2740 (gnus-group-make-group group method)))
2742 (defun gnus-group-make-archive-group (&optional all)
2743 "Create the (ding) Gnus archive group of the most recent articles.
2744 Given a prefix, create a full group."
2746 (let ((group (gnus-group-prefixed-name
2747 (if all "ding.archives" "ding.recent") '(nndir ""))))
2748 (when (gnus-group-entry group)
2749 (error "Archive group already exists"))
2750 (gnus-group-make-group
2751 (gnus-group-real-name group)
2752 (list 'nndir (if all "hpc" "edu")
2753 (list 'nndir-directory
2754 (if all gnus-group-archive-directory
2755 gnus-group-recent-archive-directory))))
2756 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2758 (defun gnus-group-make-directory-group (dir)
2759 "Create an nndir group.
2760 The user will be prompted for a directory. The contents of this
2761 directory will be used as a newsgroup. The directory should contain
2762 mail messages or news articles in files that have numeric names."
2764 (list (read-file-name "Create group from directory: ")))
2765 (unless (file-exists-p dir)
2766 (error "No such directory"))
2767 (unless (file-directory-p dir)
2768 (error "Not a directory"))
2772 (while (or (not group) (gnus-group-entry group))
2774 (gnus-group-prefixed-name
2775 (expand-file-name ext dir)
2777 (setq ext (format "<%d>" (setq i (1+ i)))))
2778 (gnus-group-make-group
2779 (gnus-group-real-name group)
2780 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2782 (defvar nnkiboze-score-file)
2783 (defun gnus-group-make-kiboze-group (group address scores)
2784 "Create an nnkiboze group.
2785 The user will be prompted for a name, a regexp to match groups, and
2786 score file entries for articles to include in the group."
2789 (read-string "nnkiboze group name: ")
2790 (read-string "Source groups (regexp): ")
2791 (let ((headers (mapcar 'list
2792 '("subject" "from" "number" "date" "message-id"
2793 "references" "chars" "lines" "xref"
2794 "followup" "all" "body" "head")))
2795 scores header regexp regexps)
2796 (while (not (equal "" (setq header (completing-read
2797 "Match on header: " headers nil t))))
2799 (while (not (equal "" (setq regexp (read-string
2800 (format "Match on %s (regexp): "
2802 (push (list regexp nil nil 'r) regexps))
2803 (push (cons header regexps) scores))
2805 (gnus-group-make-group group "nnkiboze" address)
2806 (let* ((nnkiboze-current-group group)
2807 (score-file (car (nnkiboze-score-file "")))
2808 (score-dir (file-name-directory score-file)))
2809 (unless (file-exists-p score-dir)
2810 (make-directory score-dir))
2811 (with-temp-file score-file
2812 (let (emacs-lisp-mode-hook)
2813 (gnus-pp scores)))))
2815 (defun gnus-group-add-to-virtual (n vgroup)
2816 "Add the current group to a virtual group."
2818 (list current-prefix-arg
2819 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2821 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2822 (error "%s is not an nnvirtual group" vgroup))
2823 (gnus-close-group vgroup)
2824 (let* ((groups (gnus-group-process-prefix n))
2825 (method (gnus-info-method (gnus-get-info vgroup))))
2826 (setcar (cdr method)
2828 (nth 1 method) "\\|"
2831 (gnus-group-remove-mark s)
2832 (concat "\\(^" (regexp-quote s) "$\\)"))
2834 (gnus-group-position-point))
2836 (defun gnus-group-make-empty-virtual (group)
2837 "Create a new, fresh, empty virtual group."
2838 (interactive "sCreate new, empty virtual group: ")
2839 (let* ((method (list 'nnvirtual "^$"))
2840 (pgroup (gnus-group-prefixed-name group method)))
2841 ;; Check whether it exists already.
2842 (when (gnus-group-entry pgroup)
2843 (error "Group %s already exists" pgroup))
2844 ;; Subscribe the new group after the group on the current line.
2845 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2846 (gnus-group-update-group pgroup)
2848 (gnus-group-position-point)))
2850 (defun gnus-group-enter-directory (dir)
2851 "Enter an ephemeral nneething group."
2852 (interactive "DDirectory to read: ")
2853 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2854 (leaf (gnus-group-prefixed-name
2855 (file-name-nondirectory (directory-file-name dir))
2857 (name (gnus-generate-new-group-name leaf)))
2858 (unless (gnus-group-read-ephemeral-group
2860 (cons (current-buffer)
2861 (if (eq major-mode 'gnus-summary-mode)
2863 (error "Couldn't enter %s" dir))))
2866 (autoload 'nnimap-expunge "nnimap")
2867 (autoload 'nnimap-acl-get "nnimap")
2868 (autoload 'nnimap-acl-edit "nnimap"))
2870 (defun gnus-group-nnimap-expunge (group)
2871 "Expunge deleted articles in current nnimap GROUP."
2872 (interactive (list (gnus-group-group-name)))
2873 (let ((mailbox (gnus-group-real-name group)) method)
2875 (error "No group on current line"))
2876 (unless (gnus-get-info group)
2877 (error "Killed group; can't be edited"))
2878 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2879 (error "%s is not an nnimap group" group))
2880 (nnimap-expunge mailbox (cadr method))))
2882 (defun gnus-group-nnimap-edit-acl (group)
2883 "Edit the Access Control List of current nnimap GROUP."
2884 (interactive (list (gnus-group-group-name)))
2885 (let ((mailbox (gnus-group-real-name group)) method acl)
2887 (error "No group on current line"))
2888 (unless (gnus-get-info group)
2889 (error "Killed group; can't be edited"))
2890 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2891 (error "%s is not an nnimap group" group))
2892 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2893 (error "Server does not support ACL's"))
2894 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2896 An access control list is a list of (identifier . rights) elements.
2898 The identifier string specifies the corresponding user. The
2899 identifier \"anyone\" is reserved to refer to the universal identity.
2901 Rights is a string listing a (possibly empty) set of alphanumeric
2902 characters, each character listing a set of operations which is being
2903 controlled. Letters are reserved for ``standard'' rights, listed
2904 below. Digits are reserved for implementation or site defined rights.
2906 l - lookup (mailbox is visible to LIST/LSUB commands)
2907 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2908 SEARCH, COPY from mailbox)
2909 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2910 w - write (STORE flags other than \\SEEN and \\DELETED)
2911 i - insert (perform APPEND, COPY into mailbox)
2912 p - post (send mail to submission address for mailbox,
2913 not enforced by IMAP4 itself)
2914 c - create and delete mailbox (CREATE new sub-mailboxes in any
2915 implementation-defined hierarchy, RENAME or DELETE mailbox)
2916 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2917 a - administer (perform SETACL)" group)
2920 ,mailbox ',method ',acl form)))))
2922 ;; Group sorting commands
2923 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2925 (defun gnus-group-sort-groups (func &optional reverse)
2926 "Sort the group buffer according to FUNC.
2927 When used interactively, the sorting function used will be
2928 determined by the `gnus-group-sort-function' variable.
2929 If REVERSE (the prefix), reverse the sorting order."
2930 (interactive (list gnus-group-sort-function current-prefix-arg))
2931 (funcall gnus-group-sort-alist-function
2932 (gnus-make-sort-function func) reverse)
2933 (gnus-group-unmark-all-groups)
2934 (gnus-group-list-groups)
2935 (gnus-dribble-touch))
2937 (defun gnus-group-sort-flat (func reverse)
2938 ;; We peel off the dummy group from the alist.
2940 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2941 (pop gnus-newsrc-alist))
2943 (setq gnus-newsrc-alist
2944 (sort gnus-newsrc-alist func))
2946 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2947 ;; Regenerate the hash table.
2948 (gnus-make-hashtable-from-newsrc-alist)))
2950 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2951 "Sort the group buffer alphabetically by group name.
2952 If REVERSE, sort in reverse order."
2954 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2956 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2957 "Sort the group buffer alphabetically by real (unprefixed) group name.
2958 If REVERSE, sort in reverse order."
2960 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2962 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2963 "Sort the group buffer by number of unread articles.
2964 If REVERSE, sort in reverse order."
2966 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2968 (defun gnus-group-sort-groups-by-level (&optional reverse)
2969 "Sort the group buffer by group level.
2970 If REVERSE, sort in reverse order."
2972 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2974 (defun gnus-group-sort-groups-by-score (&optional reverse)
2975 "Sort the group buffer by group score.
2976 If REVERSE, sort in reverse order."
2978 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2980 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2981 "Sort the group buffer by group rank.
2982 If REVERSE, sort in reverse order."
2984 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2986 (defun gnus-group-sort-groups-by-method (&optional reverse)
2987 "Sort the group buffer alphabetically by back end name.
2988 If REVERSE, sort in reverse order."
2990 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2992 (defun gnus-group-sort-groups-by-server (&optional reverse)
2993 "Sort the group buffer alphabetically by server name.
2994 If REVERSE, sort in reverse order."
2996 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2998 ;;; Selected group sorting.
3000 (defun gnus-group-sort-selected-groups (n func &optional reverse)
3001 "Sort the process/prefixed groups."
3002 (interactive (list current-prefix-arg gnus-group-sort-function))
3003 (let ((groups (gnus-group-process-prefix n)))
3004 (funcall gnus-group-sort-selected-function
3005 groups (gnus-make-sort-function func) reverse)
3006 (gnus-group-unmark-all-groups)
3007 (gnus-group-list-groups)
3008 (gnus-dribble-touch)))
3010 (defun gnus-group-sort-selected-flat (groups func reverse)
3011 (let (entries infos)
3012 ;; First find all the group entries for these groups.
3014 (push (nthcdr 2 (gnus-group-entry (pop groups)))
3016 ;; Then sort the infos.
3020 (lambda (entry) (car entry))
3021 (setq entries (nreverse entries)))
3024 (setq infos (nreverse infos)))
3025 ;; Go through all the infos and replace the old entries
3026 ;; with the new infos.
3028 (setcar (car entries) (pop infos))
3030 ;; Update the hashtable.
3031 (gnus-make-hashtable-from-newsrc-alist)))
3033 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3034 "Sort the group buffer alphabetically by group name.
3035 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3036 sort in reverse order."
3037 (interactive (gnus-interactive "P\ny"))
3038 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3040 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3041 "Sort the group buffer alphabetically by real group name.
3042 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3043 sort in reverse order."
3044 (interactive (gnus-interactive "P\ny"))
3045 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3047 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3048 "Sort the group buffer by number of unread articles.
3049 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3050 sort in reverse order."
3051 (interactive (gnus-interactive "P\ny"))
3052 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3054 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3055 "Sort the group buffer by group level.
3056 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3057 sort in reverse order."
3058 (interactive (gnus-interactive "P\ny"))
3059 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3061 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3062 "Sort the group buffer by group score.
3063 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3064 sort in reverse order."
3065 (interactive (gnus-interactive "P\ny"))
3066 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3068 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3069 "Sort the group buffer by group rank.
3070 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3071 sort in reverse order."
3072 (interactive (gnus-interactive "P\ny"))
3073 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3075 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3076 "Sort the group buffer alphabetically by back end name.
3077 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3078 sort in reverse order."
3079 (interactive (gnus-interactive "P\ny"))
3080 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3082 ;;; Sorting predicates.
3084 (defun gnus-group-sort-by-alphabet (info1 info2)
3085 "Sort alphabetically."
3086 (string< (gnus-info-group info1) (gnus-info-group info2)))
3088 (defun gnus-group-sort-by-real-name (info1 info2)
3089 "Sort alphabetically on real (unprefixed) names."
3090 (string< (gnus-group-real-name (gnus-info-group info1))
3091 (gnus-group-real-name (gnus-info-group info2))))
3093 (defun gnus-group-sort-by-unread (info1 info2)
3094 "Sort by number of unread articles."
3095 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3096 (n2 (gnus-group-unread (gnus-info-group info1))))
3097 (< (or (and (numberp n1) n1) 0)
3098 (or (and (numberp n2) n2) 0))))
3100 (defun gnus-group-sort-by-level (info1 info2)
3102 (< (gnus-info-level info1) (gnus-info-level info2)))
3104 (defun gnus-group-sort-by-method (info1 info2)
3105 "Sort alphabetically by back end name."
3106 (string< (car (gnus-find-method-for-group
3107 (gnus-info-group info1) info1))
3108 (car (gnus-find-method-for-group
3109 (gnus-info-group info2) info2))))
3111 (defun gnus-group-sort-by-server (info1 info2)
3112 "Sort alphabetically by server name."
3113 (string< (gnus-method-to-full-server-name
3114 (gnus-find-method-for-group
3115 (gnus-info-group info1) info1))
3116 (gnus-method-to-full-server-name
3117 (gnus-find-method-for-group
3118 (gnus-info-group info2) info2))))
3120 (defun gnus-group-sort-by-score (info1 info2)
3121 "Sort by group score."
3122 (> (gnus-info-score info1) (gnus-info-score info2)))
3124 (defun gnus-group-sort-by-rank (info1 info2)
3125 "Sort by level and score."
3126 (let ((level1 (gnus-info-level info1))
3127 (level2 (gnus-info-level info2)))
3128 (or (< level1 level2)
3129 (and (= level1 level2)
3130 (> (gnus-info-score info1) (gnus-info-score info2))))))
3134 (defun gnus-group-clear-data (&optional arg)
3135 "Clear all marks and read ranges from the current group.
3136 Obeys the process/prefix convention."
3138 (gnus-group-iterate arg
3141 (gnus-info-clear-data (setq info (gnus-get-info group)))
3142 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3143 (when (gnus-group-goto-group group)
3144 (gnus-group-update-group-line))))))
3146 (defun gnus-group-clear-data-on-native-groups ()
3147 "Clear all marks and read ranges from all native groups."
3149 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3150 (let ((alist (cdr gnus-newsrc-alist))
3152 (while (setq info (pop alist))
3153 (when (gnus-group-native-p (gnus-info-group info))
3154 (gnus-info-clear-data info)))
3155 (gnus-get-unread-articles)
3156 (gnus-dribble-touch)
3157 (when (gnus-y-or-n-p
3158 "Move the cache away to avoid problems in the future? ")
3159 (call-interactively 'gnus-cache-move-cache)))))
3161 (defun gnus-info-clear-data (info)
3162 "Clear all marks and read ranges from INFO."
3163 (let ((group (gnus-info-group info))
3165 (dolist (el (gnus-info-marks info))
3166 (push `(,(cdr el) add (,(car el))) action))
3167 (push `(,(gnus-info-read info) add (read)) action)
3170 (gnus-request-set-mark ,group ',action)
3171 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3172 (gnus-info-set-read ',info ',(gnus-info-read info))
3173 (when (gnus-group-goto-group ,group)
3174 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3175 (gnus-group-update-group-line))))
3176 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3178 (gnus-request-set-mark group action)
3179 (gnus-info-set-read info nil)
3180 (when (gnus-info-marks info)
3181 (gnus-info-set-marks info nil))))
3183 ;; Group catching up.
3185 (defun gnus-group-catchup-current (&optional n all)
3186 "Mark all unread articles in the current newsgroup as read.
3187 If prefix argument N is numeric, the next N newsgroups will be
3188 caught up. If ALL is non-nil, marked articles will also be marked as
3189 read. Cross references (Xref: header) of articles are ignored.
3190 The number of newsgroups that this function was unable to catch
3193 (let ((groups (gnus-group-process-prefix n))
3196 (unless groups (error "No groups selected"))
3198 (or (not gnus-interactive-catchup) ;Without confirmation?
3203 "Do you really want to mark all articles in %s as read? "
3204 "Mark all unread articles in %s as read? ")
3205 (if (= (length groups) 1)
3206 (gnus-group-decoded-name (car groups))
3207 (format "these %d groups" (length groups)))))))
3209 (while (setq group (pop groups))
3210 (gnus-group-remove-mark group)
3211 ;; Virtual groups have to be given special treatment.
3212 (let ((method (gnus-find-method-for-group group)))
3213 (when (eq 'nnvirtual (car method))
3214 (nnvirtual-catchup-group
3215 (gnus-group-real-name group) (nth 1 method) all)))
3216 (if (>= (gnus-group-level group) gnus-level-zombie)
3217 (gnus-message 2 "Dead groups can't be caught up")
3219 (gnus-group-goto-group group)
3220 (gnus-group-catchup group all))
3221 (gnus-group-update-group-line)
3222 (setq ret (1+ ret)))))
3223 (gnus-group-next-unread-group 1)
3226 (defun gnus-group-catchup-current-all (&optional n)
3227 "Mark all articles in current newsgroup as read.
3228 Cross references (Xref: header) of articles are ignored."
3230 (gnus-group-catchup-current n 'all))
3232 (defun gnus-group-catchup (group &optional all)
3233 "Mark all articles in GROUP as read.
3234 If ALL is non-nil, all articles are marked as read.
3235 The return value is the number of articles that were marked as read,
3236 or nil if no action could be taken."
3237 (let* ((entry (gnus-group-entry group))
3239 (marks (gnus-info-marks (nth 2 entry)))
3240 (unread (gnus-sequence-of-unread-articles group)))
3241 ;; Remove entries for this group.
3242 (nnmail-purge-split-history (gnus-group-real-name group))
3243 ;; Do the updating only if the newsgroup isn't killed.
3244 (if (not (numberp (car entry)))
3245 (gnus-message 1 "Can't catch up %s; non-active group" group)
3246 (gnus-update-read-articles group nil)
3248 ;; Nix out the lists of marks and dormants.
3249 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3251 (list (cdr (assq 'dormant marks))
3253 (setq unread (gnus-range-add (gnus-range-add
3254 unread (cdr (assq 'dormant marks)))
3255 (cdr (assq 'tick marks))))
3256 (gnus-add-marked-articles group 'tick nil nil 'force)
3257 (gnus-add-marked-articles group 'dormant nil nil 'force))
3258 ;; Do auto-expirable marks if that's required.
3259 (when (gnus-group-auto-expirable-p group)
3260 (gnus-range-map (lambda (article)
3261 (gnus-add-marked-articles group 'expire (list article))
3262 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3264 (let ((gnus-newsgroup-name group))
3265 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3268 (defun gnus-group-expire-articles (&optional n)
3269 "Expire all expirable articles in the current newsgroup.
3270 Uses the process/prefix convention."
3272 (let ((groups (gnus-group-process-prefix n))
3275 (error "No groups to expire"))
3276 (while (setq group (pop groups))
3277 (gnus-group-remove-mark group)
3278 (gnus-group-expire-articles-1 group)
3279 (gnus-dribble-touch)
3280 (gnus-group-position-point))))
3282 (defun gnus-group-expire-articles-1 (group)
3283 (when (gnus-check-backend-function 'request-expire-articles group)
3284 (gnus-message 6 "Expiring articles in %s..."
3285 (gnus-group-decoded-name group))
3286 (let* ((info (gnus-get-info group))
3287 (expirable (if (gnus-group-total-expirable-p group)
3288 (cons nil (gnus-list-of-read-articles group))
3289 (assq 'expire (gnus-info-marks info))))
3290 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3291 (nnmail-expiry-target
3292 (or (gnus-group-find-parameter group 'expiry-target)
3293 nnmail-expiry-target)))
3295 (gnus-check-group group)
3298 (gnus-compress-sequence
3300 ;; We set the expiry variables to the group
3302 (let ((nnmail-expiry-wait-function nil)
3303 (nnmail-expiry-wait expiry-wait))
3304 (gnus-request-expire-articles
3305 (gnus-uncompress-sequence (cdr expirable)) group))
3306 ;; Just expire using the normal expiry values.
3307 (gnus-request-expire-articles
3308 (gnus-uncompress-sequence (cdr expirable)) group))))
3309 (gnus-close-group group))
3310 (gnus-message 6 "Expiring articles in %s...done"
3311 (gnus-group-decoded-name group))
3312 ;; Return the list of un-expired articles.
3315 (defun gnus-group-expire-all-groups ()
3316 "Expire all expirable articles in all newsgroups."
3319 (gnus-message 5 "Expiring...")
3320 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3321 (cdr gnus-newsrc-alist))))
3322 (gnus-group-expire-articles nil)))
3323 (gnus-group-position-point)
3324 (gnus-message 5 "Expiring...done"))
3326 (defun gnus-group-set-current-level (n level)
3327 "Set the level of the next N groups to LEVEL."
3332 (unless (gnus-group-process-prefix current-prefix-arg)
3333 (error "No group on the current line"))
3335 (let ((s (read-string
3336 (format "Level (default %s): "
3337 (or (gnus-group-group-level)
3338 gnus-level-default-subscribed)))))
3339 (if (string-match "^\\s-*$" s)
3340 (int-to-string (or (gnus-group-group-level)
3341 gnus-level-default-subscribed))
3343 (unless (and (>= level 1) (<= level gnus-level-killed))
3344 (error "Invalid level: %d" level))
3345 (dolist (group (gnus-group-process-prefix n))
3346 (gnus-group-remove-mark group)
3347 (gnus-message 6 "Changed level of %s from %d to %d"
3348 (gnus-group-decoded-name group)
3349 (or (gnus-group-group-level) gnus-level-killed)
3351 (gnus-group-change-level
3352 group level (or (gnus-group-group-level) gnus-level-killed))
3353 (gnus-group-update-group-line))
3354 (gnus-group-position-point))
3356 (defun gnus-group-unsubscribe (&optional n)
3357 "Unsubscribe the current group."
3359 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3361 (defun gnus-group-subscribe (&optional n)
3362 "Subscribe the current group."
3364 (gnus-group-unsubscribe-current-group n 'subscribe))
3366 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3367 "Toggle subscription of the current group.
3368 If given numerical prefix, toggle the N next groups."
3370 (dolist (group (gnus-group-process-prefix n))
3371 (gnus-group-remove-mark group)
3372 (gnus-group-unsubscribe-group
3375 ((eq do-sub 'unsubscribe)
3376 gnus-level-default-unsubscribed)
3377 ((eq do-sub 'subscribe)
3378 gnus-level-default-subscribed)
3379 ((<= (gnus-group-group-level) gnus-level-subscribed)
3380 gnus-level-default-unsubscribed)
3382 gnus-level-default-subscribed))
3384 (gnus-group-update-group-line))
3385 (gnus-group-next-group 1))
3387 (defun gnus-group-unsubscribe-group (group &optional level silent)
3388 "Toggle subscription to GROUP.
3389 Killed newsgroups are subscribed. If SILENT, don't try to update the
3392 (list (gnus-group-completing-read-group-name
3393 "Group: " gnus-active-hashtb nil
3394 (gnus-read-active-file-p)
3396 'gnus-group-history)))
3397 (let ((newsrc (gnus-group-entry group)))
3399 ((string-match "^[ \t]*$" group)
3400 (error "Empty group name"))
3402 ;; Toggle subscription flag.
3403 (gnus-group-change-level
3404 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3405 gnus-level-subscribed)
3406 (1+ gnus-level-subscribed)
3407 gnus-level-default-subscribed)))
3409 (gnus-group-update-group group)))
3410 ((and (stringp group)
3411 (or (not (gnus-read-active-file-p))
3412 (gnus-active group)))
3413 ;; Add new newsgroup.
3414 (gnus-group-change-level
3416 (if level level gnus-level-default-subscribed)
3417 (or (and (member group gnus-zombie-list)
3420 (when (gnus-group-group-name)
3421 (gnus-group-entry (gnus-group-group-name))))
3423 (gnus-group-update-group group)))
3424 (t (error "No such newsgroup: %s" group)))
3425 (gnus-group-position-point)))
3427 (defun gnus-group-transpose-groups (n)
3428 "Move the current newsgroup up N places.
3429 If given a negative prefix, move down instead. The difference between
3430 N and the number of steps taken is returned."
3432 (unless (gnus-group-group-name)
3433 (error "No group on current line"))
3434 (gnus-group-kill-group 1)
3436 (forward-line (- n))
3437 (gnus-group-yank-group)
3438 (gnus-group-position-point)))
3440 (defun gnus-group-kill-all-zombies (&optional dummy)
3441 "Kill all zombie newsgroups.
3442 The optional DUMMY should always be nil."
3443 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3445 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3446 (setq gnus-zombie-list nil)
3447 (gnus-dribble-touch)
3448 (gnus-group-list-groups)))
3450 (defun gnus-group-kill-region (begin end)
3451 "Kill newsgroups in current region (excluding current point).
3452 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3465 (beginning-of-line) ;Important when LINES < 1
3466 (gnus-group-kill-group lines)))
3468 (defun gnus-group-kill-group (&optional n discard)
3469 "Kill the next N groups.
3470 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3471 However, only groups that were alive can be yanked; already killed
3472 groups or zombie groups can't be yanked.
3473 The return value is the name of the group that was killed, or a list
3476 (let ((buffer-read-only nil)
3477 (groups (gnus-group-process-prefix n))
3478 group entry level out)
3479 (if (< (length groups) 10)
3480 ;; This is faster when there are few groups.
3482 (push (setq group (pop groups)) out)
3483 (gnus-group-remove-mark group)
3484 (setq level (gnus-group-group-level))
3486 (when (and (not discard)
3487 (setq entry (gnus-group-entry group)))
3490 (gnus-group-goto-group ,(gnus-group-group-name))
3491 (gnus-group-yank-group)))
3492 (push (cons (car entry) (nth 2 entry))
3493 gnus-list-of-killed-groups))
3494 (gnus-group-change-level
3495 (if entry entry group) gnus-level-killed (if entry nil level))
3496 (message "Killed group %s" (gnus-group-decoded-name group)))
3497 ;; If there are lots and lots of groups to be killed, we use
3498 ;; this thing instead.
3499 (dolist (group (nreverse groups))
3500 (gnus-group-remove-mark group)
3502 (push group gnus-killed-list)
3503 (setq gnus-newsrc-alist
3504 (delq (assoc group gnus-newsrc-alist)
3506 (when gnus-group-change-level-function
3507 (funcall gnus-group-change-level-function
3508 group gnus-level-killed 3))
3510 ((setq entry (gnus-group-entry group))
3511 (push (cons (car entry) (nth 2 entry))
3512 gnus-list-of-killed-groups)
3513 (setcdr (cdr entry) (cdddr entry)))
3514 ((member group gnus-zombie-list)
3515 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3516 ;; There may be more than one instance displayed.
3517 (while (gnus-group-goto-group group)
3518 (gnus-delete-line)))
3519 (gnus-make-hashtable-from-newsrc-alist))
3521 (gnus-group-position-point)
3522 (if (< (length out) 2) (car out) (nreverse out))))
3524 (defun gnus-group-yank-group (&optional arg)
3525 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3526 The numeric ARG specifies how many newsgroups are to be yanked. The
3527 name of the newsgroup yanked is returned, or (if several groups are
3528 yanked) a list of yanked groups is returned."
3530 (setq arg (or arg 1))
3531 (let (info group prev out)
3532 (while (>= (decf arg) 0)
3533 (when (not (setq info (pop gnus-list-of-killed-groups)))
3534 (error "No more newsgroups to yank"))
3535 (push (setq group (nth 1 info)) out)
3536 ;; Find which newsgroup to insert this one before - search
3537 ;; backward until something suitable is found. If there are no
3538 ;; other newsgroups in this buffer, just make this newsgroup the
3540 (setq prev (gnus-group-group-name))
3541 (gnus-group-change-level
3542 info (gnus-info-level (cdr info)) gnus-level-killed
3543 (and prev (gnus-group-entry prev))
3545 (gnus-group-insert-group-line-info group)
3547 `(when (gnus-group-goto-group ,group)
3548 (gnus-group-kill-group 1))))
3550 (gnus-group-position-point)
3551 (if (< (length out) 2) (car out) (nreverse out))))
3553 (defun gnus-group-kill-level (level)
3554 "Kill all groups that is on a certain LEVEL."
3555 (interactive "nKill all groups on level: ")
3557 ((= level gnus-level-zombie)
3558 (setq gnus-killed-list
3559 (nconc gnus-zombie-list gnus-killed-list))
3560 (setq gnus-zombie-list nil))
3561 ((and (< level gnus-level-zombie)
3563 (or gnus-expert-user
3566 "Do you really want to kill all groups on level %d? "
3568 (let* ((prev gnus-newsrc-alist)
3571 (if (= (gnus-info-level (car alist)) level)
3573 (push (gnus-info-group (car alist)) gnus-killed-list)
3574 (setcdr prev (cdr alist)))
3576 (setq alist (cdr alist)))
3577 (gnus-make-hashtable-from-newsrc-alist)
3578 (gnus-group-list-groups)))
3580 (error "Can't kill; invalid level: %d" level))))
3582 (defun gnus-group-list-all-groups (&optional arg)
3583 "List all newsgroups with level ARG or lower.
3584 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3585 unsubscribed groups."
3587 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3589 ;; Redefine this to list ALL killed groups if prefix arg used.
3590 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3591 (defun gnus-group-list-killed (&optional arg)
3592 "List all killed newsgroups in the group buffer.
3593 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3594 entail asking the server for the groups."
3596 ;; Find all possible killed newsgroups if arg.
3598 (gnus-get-killed-groups))
3599 (if (not gnus-killed-list)
3600 (gnus-message 6 "No killed groups")
3601 (let (gnus-group-list-mode)
3602 (funcall gnus-group-prepare-function
3603 gnus-level-killed t gnus-level-killed))
3604 (goto-char (point-min)))
3605 (gnus-group-position-point))
3607 (defun gnus-group-list-zombies ()
3608 "List all zombie newsgroups in the group buffer."
3610 (if (not gnus-zombie-list)
3611 (gnus-message 6 "No zombie groups")
3612 (let (gnus-group-list-mode)
3613 (funcall gnus-group-prepare-function
3614 gnus-level-zombie t gnus-level-zombie))
3615 (goto-char (point-min)))
3616 (gnus-group-position-point))
3618 (defun gnus-group-list-active ()
3619 "List all groups that are available from the server(s)."
3621 ;; First we make sure that we have really read the active file.
3622 (unless (gnus-read-active-file-p)
3623 (let ((gnus-read-active-file t)
3624 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3625 (gnus-read-active-file)))
3626 ;; Find all groups and sort them.
3634 (push (symbol-name sym) list)))
3638 (buffer-read-only nil)
3642 (setq group (pop groups))
3643 (gnus-add-text-properties
3644 (point) (prog1 (1+ (point))
3646 (gnus-group-decoded-name group)
3648 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3650 'gnus-level (inline (gnus-group-level group)))))
3651 (goto-char (point-min))))
3653 (defun gnus-activate-all-groups (level)
3654 "Activate absolutely all groups."
3655 (interactive (list gnus-level-unsubscribed))
3656 (let ((gnus-activate-level level)
3657 (gnus-activate-foreign-newsgroups level))
3658 (gnus-group-get-new-news)))
3660 (defun gnus-group-get-new-news (&optional arg)
3661 "Get newly arrived articles.
3662 If ARG is a number, it specifies which levels you are interested in
3663 re-scanning. If ARG is non-nil and not a number, this will force
3664 \"hard\" re-reading of the active files from all servers."
3667 (let ((gnus-inhibit-demon t)
3668 ;; Binding this variable will inhibit multiple fetchings
3669 ;; of the same mail source.
3670 (nnmail-fetched-sources (list t)))
3671 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3672 (gnus-run-hooks 'gnus-get-new-news-hook)
3674 ;; Read any slave files.
3676 (gnus-master-read-slave-newsrc))
3678 ;; We might read in new NoCeM messages here.
3679 (when (and gnus-use-nocem
3681 (gnus-nocem-scan-groups))
3682 ;; If ARG is not a number, then we read the active file.
3683 (when (and arg (not (numberp arg)))
3684 (let ((gnus-read-active-file t))
3685 (gnus-read-active-file))
3688 ;; If the user wants it, we scan for new groups.
3689 (when (eq gnus-check-new-newsgroups 'always)
3690 (gnus-find-new-newsgroups)))
3692 (setq arg (gnus-group-default-level arg t))
3693 (if (and gnus-read-active-file (not arg))
3695 (gnus-read-active-file)
3696 (gnus-get-unread-articles arg))
3697 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3698 (gnus-get-unread-articles arg)))
3699 (gnus-check-reasonable-setup)
3700 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3701 (gnus-group-list-groups (and (numberp arg)
3702 (max (car gnus-group-list-mode) arg))))
3704 (when (and gnus-agent (not (interactive-p)))
3705 (gnus-agent-toggle-plugged gnus-plugged)))
3707 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3708 "Check for newly arrived news in the current group (and the N-1 next groups).
3709 The difference between N and the number of newsgroup checked is returned.
3710 If N is negative, this group and the N-1 previous groups will be checked.
3711 If DONT-SCAN is non-nil, scan non-activated groups as well."
3713 (let* ((groups (gnus-group-process-prefix n))
3714 (ret (if (numberp n) (- n (length groups)) 0))
3718 (gnus-inhibit-demon t)
3719 ;; Binding this variable will inhibit multiple fetchings
3720 ;; of the same mail source.
3721 (nnmail-fetched-sources (list t)))
3722 (gnus-run-hooks 'gnus-get-new-news-hook)
3723 (while (setq group (pop groups))
3724 (gnus-group-remove-mark group)
3725 ;; Bypass any previous denials from the server.
3726 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3727 (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
3728 (let ((info (gnus-get-info group))
3729 (active (gnus-active group)))
3731 (gnus-request-update-info info method))
3732 (gnus-get-unread-articles-in-group info active)
3733 (unless (gnus-virtual-group-p group)
3734 (gnus-close-group group))
3736 (gnus-agent-save-group-info
3737 method (gnus-group-real-name group) active))
3738 (gnus-group-update-group group))
3739 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3741 (gnus-error 3 "Server denied access")
3742 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3745 (when gnus-goto-next-group-when-activating
3746 (gnus-group-next-unread-group 1 t))
3747 (gnus-summary-position-point)
3750 (defun gnus-group-fetch-faq (group &optional faq-dir)
3751 "Fetch the FAQ for the current group.
3752 If given a prefix argument, prompt for the FAQ dir
3756 (gnus-group-group-name)
3757 (when current-prefix-arg
3759 "FAQ dir: " (and (listp gnus-group-faq-directory)
3761 gnus-group-faq-directory))))))
3763 (error "No group name given"))
3764 (let ((dirs (or faq-dir gnus-group-faq-directory))
3766 (unless (listp dirs)
3767 (setq dirs (list dirs)))
3768 (while (and (not found)
3769 (setq dir (pop dirs)))
3770 (let ((name (gnus-group-real-name group)))
3771 (setq file (expand-file-name name dir)))
3772 (if (not (file-exists-p file))
3773 (gnus-message 1 "No such file: %s" file)
3774 (let ((enable-local-variables nil))
3778 (defun gnus-group-fetch-charter (group)
3779 "Fetch the charter for the current group.
3780 If given a prefix argument, prompt for a group."
3782 (list (or (when current-prefix-arg
3783 (completing-read "Group: " gnus-active-hashtb))
3784 (gnus-group-group-name)
3785 gnus-newsgroup-name)))
3787 (error "No group name given"))
3789 (condition-case nil (require 'url-http) (error nil))
3790 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3792 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3793 (setq hierarchy (match-string 1 name))
3794 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3795 (if (fboundp 'url-http-file-exists-p)
3796 (url-http-file-exists-p (eval url))
3798 (browse-url (eval url))
3799 (setq url (concat "http://" hierarchy
3800 ".news-admin.org/charters/" name))
3801 (if (and (fboundp 'url-http-file-exists-p)
3802 (url-http-file-exists-p url))
3804 (gnus-group-fetch-control group))))))
3806 (defun gnus-group-fetch-control (group)
3807 "Fetch the archived control messages for the current group.
3808 If given a prefix argument, prompt for a group."
3810 (list (or (when current-prefix-arg
3811 (completing-read "Group: " gnus-active-hashtb))
3812 (gnus-group-group-name)
3813 gnus-newsgroup-name)))
3815 (error "No group name given"))
3816 (let ((name (gnus-group-real-name group))
3818 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3819 (setq hierarchy (match-string 1 name))
3820 (if gnus-group-fetch-control-use-browse-url
3821 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3822 hierarchy "/" name ".gz"))
3823 (let ((enable-local-variables nil))
3824 (gnus-group-read-ephemeral-group
3826 `(nndoc ,group (nndoc-address
3827 ,(find-file-noselect
3828 (concat "/ftp@ftp.isc.org:/usenet/control/"
3829 hierarchy "/" name ".gz")))
3830 (nndoc-article-type mbox)) t nil nil))))))
3832 (defun gnus-group-describe-group (force &optional group)
3833 "Display a description of the current newsgroup."
3834 (interactive (list current-prefix-arg (gnus-group-group-name)))
3835 (let* ((method (gnus-find-method-for-group group))
3836 (mname (gnus-group-prefixed-name "" method))
3839 gnus-description-hashtb)
3840 (gnus-sethash mname nil gnus-description-hashtb))
3842 (error "No group name given"))
3843 (when (or (and gnus-description-hashtb
3844 ;; We check whether this group's method has been
3845 ;; queried for a description file.
3846 (gnus-gethash mname gnus-description-hashtb))
3847 (setq desc (gnus-group-get-description group))
3848 (gnus-read-descriptions-file method))
3850 (or desc (gnus-gethash group gnus-description-hashtb)
3851 "No description available")))))
3853 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3854 (defun gnus-group-describe-all-groups (&optional force)
3855 "Pop up a buffer with descriptions of all newsgroups."
3858 (setq gnus-description-hashtb nil))
3859 (when (not (or gnus-description-hashtb
3860 (gnus-read-all-descriptions-files)))
3861 (error "Couldn't request descriptions file"))
3862 (let ((buffer-read-only nil)
3868 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3869 (insert (format " *: %-20s %s\n"
3870 (gnus-group-name-decode
3871 (symbol-name group) charset)
3872 (gnus-group-name-decode
3873 (symbol-value group) charset))))
3874 (gnus-add-text-properties
3875 b (1+ b) (list 'gnus-group group
3876 'gnus-unread t 'gnus-marked nil
3877 'gnus-level (1+ gnus-level-subscribed))))
3878 gnus-description-hashtb)
3879 (goto-char (point-min))
3880 (gnus-group-position-point)))
3882 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3883 (defun gnus-group-apropos (regexp &optional search-description)
3884 "List all newsgroups that have names that match a regexp."
3885 (interactive "sGnus apropos (regexp): ")
3887 (obuf (current-buffer))
3889 ;; Go through all newsgroups that are known to Gnus.
3892 (and (symbol-name group)
3893 (string-match regexp (symbol-name group))
3894 (symbol-value group)
3895 (push (symbol-name group) groups)))
3897 ;; Also go through all descriptions that are known to Gnus.
3898 (when search-description
3901 (and (string-match regexp (symbol-value group))
3902 (push (symbol-name group) groups)))
3903 gnus-description-hashtb))
3905 (gnus-message 3 "No groups matched \"%s\"." regexp)
3906 ;; Print out all the groups.
3908 (pop-to-buffer "*Gnus Help*")
3909 (buffer-disable-undo)
3911 (setq groups (sort groups 'string<))
3913 ;; Groups may be entered twice into the list of groups.
3914 (when (not (string= (car groups) prev))
3915 (setq prev (car groups))
3916 (let ((charset (gnus-group-name-charset nil prev)))
3917 (insert (gnus-group-name-decode prev charset) "\n")
3918 (when (and gnus-description-hashtb
3919 (setq des (gnus-gethash (car groups)
3920 gnus-description-hashtb)))
3921 (insert " " (gnus-group-name-decode des charset) "\n"))))
3922 (setq groups (cdr groups)))
3923 (goto-char (point-min))))
3924 (pop-to-buffer obuf)))
3926 (defun gnus-group-description-apropos (regexp)
3927 "List all newsgroups that have names or descriptions that match REGEXP."
3928 (interactive "sGnus description apropos (regexp): ")
3929 (when (not (or gnus-description-hashtb
3930 (gnus-read-all-descriptions-files)))
3931 (error "Couldn't request descriptions file"))
3932 (gnus-group-apropos regexp t))
3934 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3935 (defun gnus-group-list-matching (level regexp &optional all lowest)
3936 "List all groups with unread articles that match REGEXP.
3937 If the prefix LEVEL is non-nil, it should be a number that says which
3938 level to cut off listing groups.
3939 If ALL, also list groups with no unread articles.
3940 If LOWEST, don't list groups with level lower than LOWEST.
3942 This command may read the active file."
3943 (interactive "P\nsList newsgroups matching: ")
3944 ;; First make sure active file has been read.
3946 (> (prefix-numeric-value level) gnus-level-killed))
3947 (gnus-get-killed-groups))
3948 (funcall gnus-group-prepare-function
3949 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3950 (goto-char (point-min))
3951 (gnus-group-position-point))
3953 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3954 "List all groups that match REGEXP.
3955 If the prefix LEVEL is non-nil, it should be a number that says which
3956 level to cut off listing groups.
3957 If LOWEST, don't list groups with level lower than LOWEST."
3958 (interactive "P\nsList newsgroups matching: ")
3960 (setq level (prefix-numeric-value level)))
3961 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3963 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3964 (defun gnus-group-save-newsrc (&optional force)
3965 "Save the Gnus startup files.
3966 If FORCE, force saving whether it is necessary or not."
3968 (gnus-save-newsrc-file force))
3970 (defun gnus-group-restart (&optional arg)
3971 "Force Gnus to read the .newsrc file."
3973 (when (gnus-yes-or-no-p
3974 (format "Are you sure you want to restart Gnus? "))
3975 (gnus-save-newsrc-file)
3979 (defun gnus-group-read-init-file ()
3980 "Read the Gnus elisp init file."
3982 (gnus-read-init-file)
3983 (gnus-message 5 "Read %s" gnus-init-file))
3985 (defun gnus-group-check-bogus-groups (&optional silent)
3986 "Check bogus newsgroups.
3987 If given a prefix, don't ask for confirmation before removing a bogus
3990 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3991 (gnus-group-list-groups))
3993 (defun gnus-group-find-new-groups (&optional arg)
3994 "Search for new groups and add them.
3995 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3996 With 1 C-u, use the `ask-server' method to query the server for new
3998 With 2 C-u's, use most complete method possible to query the server
3999 for new groups, and subscribe the new groups as zombies."
4001 (gnus-find-new-newsgroups (or arg 1))
4002 (gnus-group-list-groups))
4004 (defun gnus-group-edit-global-kill (&optional article group)
4005 "Edit the global kill file.
4006 If GROUP, edit that local kill file instead."
4008 (setq gnus-current-kill-article article)
4009 (gnus-kill-file-edit-file group)
4012 (substitute-command-keys
4013 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
4014 (if group "local" "global")))))
4016 (defun gnus-group-edit-local-kill (article group)
4017 "Edit a local kill file."
4018 (interactive (list nil (gnus-group-group-name)))
4019 (gnus-group-edit-global-kill article group))
4021 (defun gnus-group-force-update ()
4022 "Update `.newsrc' file."
4024 (gnus-save-newsrc-file))
4026 (defvar gnus-backlog-articles)
4028 (defun gnus-group-suspend ()
4029 "Suspend the current Gnus session.
4030 In fact, cleanup buffers except for group mode buffer.
4031 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4033 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4034 (gnus-offer-save-summaries)
4035 ;; Kill Gnus buffers except for group mode buffer.
4036 (let ((group-buf (get-buffer gnus-group-buffer)))
4037 (mapcar (lambda (buf)
4038 (unless (or (member buf (list group-buf gnus-dribble-buffer))
4039 (with-current-buffer buf
4040 (eq major-mode 'message-mode)))
4041 (gnus-kill-buffer buf)))
4043 (setq gnus-backlog-articles nil)
4044 (gnus-kill-gnus-frames)
4046 (bury-buffer group-buf)
4047 (delete-windows-on group-buf t))))
4049 (defun gnus-group-clear-dribble ()
4050 "Clear all information from the dribble buffer."
4052 (gnus-dribble-clear)
4053 (gnus-message 7 "Cleared dribble buffer"))
4055 (defun gnus-group-exit ()
4056 "Quit reading news after updating .newsrc.eld and .newsrc.
4057 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4060 (or noninteractive ;For gnus-batch-kill
4061 (not gnus-interactive-exit) ;Without confirmation
4063 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4064 (gnus-run-hooks 'gnus-exit-gnus-hook)
4065 ;; Offer to save data from non-quitted summary buffers.
4066 (gnus-offer-save-summaries)
4067 ;; Save the newsrc file(s).
4068 (gnus-save-newsrc-file)
4070 (gnus-close-backends)
4071 ;; Reset everything.
4073 ;; Allow the user to do things after cleaning up.
4074 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4076 (defun gnus-group-quit ()
4077 "Quit reading news without updating .newsrc.eld or .newsrc.
4078 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4080 (when (or noninteractive ;For gnus-batch-kill
4081 (zerop (buffer-size))
4082 (not (gnus-server-opened gnus-select-method))
4084 (not gnus-current-startup-file)
4086 (format "Quit reading news without saving %s? "
4087 (file-name-nondirectory gnus-current-startup-file))))
4088 (gnus-run-hooks 'gnus-exit-gnus-hook)
4089 (gnus-configure-windows 'group t)
4090 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4091 (not (zerop (save-excursion
4092 (set-buffer gnus-dribble-buffer)
4095 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4097 (gnus-close-backends)
4099 (gnus-kill-buffer gnus-group-buffer)
4100 ;; Allow the user to do things after cleaning up.
4101 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4103 (defun gnus-group-describe-briefly ()
4104 "Give a one line description of the group mode commands."
4106 (gnus-message 7 (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-read-group]:Select \\[gnus-group-next-unread-group]:Forward \\[gnus-group-prev-unread-group]:Backward \\[gnus-group-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-group-describe-briefly]:This help")))
4108 (defun gnus-group-browse-foreign-server (method)
4109 "Browse a foreign news server.
4110 If called interactively, this function will ask for a select method
4111 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4112 If not, METHOD should be a list where the first element is the method
4113 and the second element is the address."
4115 (list (let ((how (completing-read
4117 (append gnus-valid-select-methods gnus-server-alist)
4118 nil t (cons "nntp" 0) 'gnus-method-history)))
4119 ;; We either got a back end name or a virtual server name.
4120 ;; If the first, we also need an address.
4121 (if (assoc how gnus-valid-select-methods)
4123 ;; Suggested by mapjph@bath.ac.uk.
4126 (mapcar 'list gnus-secondary-servers)))
4127 ;; We got a server name.
4129 (gnus-browse-foreign-server method))
4131 (defun gnus-group-set-info (info &optional method-only-group part)
4132 (when (or info part)
4133 (let* ((entry (gnus-group-entry
4134 (or method-only-group (gnus-info-group info))))
4136 (info (if method-only-group (nth 2 entry) info))
4138 (when method-only-group
4140 (error "Trying to change non-existent group %s" method-only-group))
4141 ;; We have received parts of the actual group info - either the
4142 ;; select method or the group parameters. We first check
4143 ;; whether we have to extend the info, and if so, do that.
4144 (let ((len (length info))
4145 (total (if (eq part 'method) 5 6)))
4147 (setcdr (nthcdr (1- len) info)
4148 (make-list (- total len) nil)))
4149 ;; Then we enter the new info.
4150 (setcar (nthcdr (1- total) info) part-info)))
4152 ;; This is a new group, so we just create it.
4154 (set-buffer gnus-group-buffer)
4155 (setq method (gnus-info-method info))
4156 (when (gnus-server-equal method "native")
4159 (set-buffer gnus-group-buffer)
4161 ;; It's a foreign group...
4162 (gnus-group-make-group
4163 (gnus-group-real-name (gnus-info-group info))
4164 (if (stringp method) method
4165 (prin1-to-string (car method)))
4167 (nth 1 (gnus-info-method info))))
4168 ;; It's a native group.
4169 (gnus-group-make-group (gnus-info-group info))))
4170 (gnus-message 6 "Note: New group created")
4172 (gnus-group-entry (gnus-group-prefixed-name
4173 (gnus-group-real-name (gnus-info-group info))
4174 (or (gnus-info-method info) gnus-select-method))))))
4175 ;; Whether it was a new group or not, we now have the entry, so we
4176 ;; can do the update.
4179 (setcar (nthcdr 2 entry) info)
4180 (when (and (not (eq (car entry) t))
4181 (gnus-active (gnus-info-group info)))
4182 (setcar entry (length
4183 (gnus-list-of-unread-articles (car info))))))
4184 (error "No such group: %s" (gnus-info-group info))))))
4186 (defun gnus-group-set-method-info (group select-method)
4187 (gnus-group-set-info select-method group 'method))
4189 (defun gnus-group-set-params-info (group params)
4190 (gnus-group-set-info params group 'params))
4192 (defun gnus-add-marked-articles (group type articles &optional info force)
4193 ;; Add ARTICLES of TYPE to the info of GROUP.
4194 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4195 ;; add, but replace marked articles of TYPE with ARTICLES.
4196 (let ((info (or info (gnus-get-info group)))
4199 (and (not (setq marked (nthcdr 3 info)))
4201 (setcdr (nthcdr 2 info)
4202 (list (list (cons type (gnus-compress-sequence
4204 (and (not (setq m (assq type (car marked))))
4207 (cons (cons type (gnus-compress-sequence articles t) )
4211 (setcar (nthcdr 3 info)
4212 (gnus-delete-alist type (car marked)))
4213 (setcdr m (gnus-compress-sequence articles t)))
4214 (setcdr m (gnus-compress-sequence
4215 (sort (nconc (gnus-uncompress-range (cdr m))
4216 (copy-sequence articles)) '<) t))))))
4218 (defun gnus-add-mark (group mark article)
4219 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4220 (let ((buffer (gnus-summary-buffer-name group)))
4221 (if (gnus-buffer-live-p buffer)
4223 (set-buffer (get-buffer buffer))
4224 (gnus-summary-add-mark article mark))
4225 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4229 ;;; Group timestamps
4232 (defun gnus-group-set-timestamp ()
4233 "Change the timestamp of the current group to the current time.
4234 This function can be used in hooks like `gnus-select-group-hook'
4235 or `gnus-group-catchup-group-hook'."
4236 (when gnus-newsgroup-name
4237 (let ((time (current-time)))
4238 (setcdr (cdr time) nil)
4239 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4241 (defsubst gnus-group-timestamp (group)
4242 "Return the timestamp for GROUP."
4243 (gnus-group-get-parameter group 'timestamp t))
4245 (defun gnus-group-timestamp-delta (group)
4246 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4247 (let* ((time (or (gnus-group-timestamp group)
4249 (delta (subtract-time (current-time) time)))
4250 (+ (* (nth 0 delta) 65536.0)
4253 (defun gnus-group-timestamp-string (group)
4254 "Return a string of the timestamp for GROUP."
4255 (let ((time (gnus-group-timestamp group)))
4258 (gnus-time-iso8601 time))))
4260 (defun gnus-group-list-cached (level &optional lowest)
4261 "List all groups with cached articles.
4262 If the prefix LEVEL is non-nil, it should be a number that says which
4263 level to cut off listing groups.
4264 If LOWEST, don't list groups with level lower than LOWEST.
4266 This command may read the active file."
4269 (setq level (prefix-numeric-value level)))
4270 (when (or (not level) (>= level gnus-level-zombie))
4272 (funcall gnus-group-prepare-function
4273 (or level gnus-level-subscribed)
4275 (let ((marks (gnus-info-marks info)))
4276 (assq 'cache marks)))
4279 (or (gnus-gethash group
4280 gnus-cache-active-hashtb)
4281 ;; Cache active file might use "."
4284 (mapconcat 'identity
4285 (split-string group ":")
4287 gnus-cache-active-hashtb))))
4288 (goto-char (point-min))
4289 (gnus-group-position-point))
4291 (defun gnus-group-list-dormant (level &optional lowest)
4292 "List all groups with dormant articles.
4293 If the prefix LEVEL is non-nil, it should be a number that says which
4294 level to cut off listing groups.
4295 If LOWEST, don't list groups with level lower than LOWEST.
4297 This command may read the active file."
4300 (setq level (prefix-numeric-value level)))
4301 (when (or (not level) (>= level gnus-level-zombie))
4303 (funcall gnus-group-prepare-function
4304 (or level gnus-level-subscribed)
4306 (let ((marks (gnus-info-marks info)))
4307 (assq 'dormant marks)))
4310 (goto-char (point-min))
4311 (gnus-group-position-point))
4313 (defun gnus-group-listed-groups ()
4314 "Return a list of listed groups."
4316 (goto-char (point-min))
4317 (while (setq point (text-property-not-all (point) (point-max)
4320 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4324 (defun gnus-group-list-plus (&optional args)
4325 "List groups plus the current selection."
4327 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4328 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4330 (push last-command-event unread-command-events)
4331 (if (featurep 'xemacs)
4332 (push (make-event 'key-press '(key ?A)) unread-command-events)
4333 (push ?A unread-command-events))
4334 (let (gnus-pick-mode keys)
4335 (setq keys (if (featurep 'xemacs)
4336 (events-to-keys (read-key-sequence nil))
4337 (read-key-sequence nil)))
4338 (setq func (lookup-key (current-local-map) keys)))
4342 (call-interactively func))))
4344 (defun gnus-group-list-flush (&optional args)
4345 "Flush groups from the current selection."
4347 (let ((gnus-group-list-option 'flush))
4348 (gnus-group-list-plus args)))
4350 (defun gnus-group-list-limit (&optional args)
4351 "List groups limited within the current selection."
4353 (let ((gnus-group-list-option 'limit))
4354 (gnus-group-list-plus args)))
4356 (defun gnus-group-mark-article-read (group article)
4357 "Mark ARTICLE read."
4358 (let ((buffer (gnus-summary-buffer-name group))
4359 (mark gnus-read-mark)
4361 (if (get-buffer buffer)
4362 (with-current-buffer buffer
4363 (setq active gnus-newsgroup-active)
4364 (gnus-activate-group group)
4365 (when gnus-newsgroup-prepared
4366 (when (and gnus-newsgroup-auto-expire
4367 (memq mark gnus-auto-expirable-marks))
4368 (setq mark gnus-expirable-mark))
4369 (setq mark (gnus-request-update-mark
4370 group article mark))
4371 (gnus-mark-article-as-read article mark)
4372 (setq gnus-newsgroup-active (gnus-active group))
4374 (setq n (1+ (cdr active)))
4375 (while (<= n (cdr gnus-newsgroup-active))
4376 (unless (eq n article)
4377 (push n gnus-newsgroup-unselected))
4379 (setq gnus-newsgroup-unselected
4380 (nreverse gnus-newsgroup-unselected)))))
4381 (gnus-activate-group group)
4382 (gnus-group-make-articles-read group (list article))
4383 (when (gnus-group-auto-expirable-p group)
4384 (gnus-add-marked-articles
4385 group 'expire (list article))))))
4387 (provide 'gnus-group)
4389 ;;; gnus-group.el ends here