1 ;;; gnus-group.el --- group mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
32 (defvar tool-bar-map))
47 (let ((features (cons 'gnus-group features)))
49 (unless (boundp 'gnus-cache-active-hashtb)
50 (defvar gnus-cache-active-hashtb nil)))
52 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
53 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
55 (defcustom gnus-group-archive-directory
56 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
57 "*The address of the (ding) archives."
58 :group 'gnus-group-foreign
61 (defcustom gnus-group-recent-archive-directory
62 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
63 "*The address of the most recent (ding) articles."
64 :group 'gnus-group-foreign
67 (defcustom gnus-no-groups-message "No Gnus is good news"
68 "*Message displayed by Gnus when no groups are available."
72 (defcustom gnus-keep-same-level nil
73 "*Non-nil means that the next newsgroup after the current will be on the same level.
74 When you type, for instance, `n' after reading the last article in the
75 current newsgroup, you will go to the next newsgroup. If this variable
76 is nil, the next newsgroup will be the next from the group
78 If this variable is non-nil, Gnus will either put you in the
79 next newsgroup with the same level, or, if no such newsgroup is
80 available, the next newsgroup with the lowest possible level higher
81 than the current level.
82 If this variable is `best', Gnus will make the next newsgroup the one
84 :group 'gnus-group-levels
85 :type '(choice (const nil)
87 (sexp :tag "other" t)))
89 (defcustom gnus-group-goto-unread t
90 "*If non-nil, movement commands will go to the next unread and subscribed group."
91 :link '(custom-manual "(gnus)Group Maneuvering")
92 :group 'gnus-group-various
95 (defcustom gnus-goto-next-group-when-activating t
96 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
97 :link '(custom-manual "(gnus)Scanning New Messages")
98 :group 'gnus-group-various
101 (defcustom gnus-permanently-visible-groups nil
102 "*Regexp to match groups that should always be listed in the group buffer.
103 This means that they will still be listed even when there are no
104 unread articles in the groups.
106 If nil, no groups are permanently visible."
107 :group 'gnus-group-listing
108 :type '(choice regexp (const nil)))
110 (defcustom gnus-list-groups-with-ticked-articles t
111 "*If non-nil, list groups that have only ticked articles.
112 If nil, only list groups that have unread articles."
113 :group 'gnus-group-listing
116 (defcustom gnus-group-default-list-level gnus-level-subscribed
117 "*Default listing level.
118 Ignored if `gnus-group-use-permanent-levels' is non-nil."
119 :group 'gnus-group-listing
122 (defcustom gnus-group-list-inactive-groups t
123 "*If non-nil, inactive groups will be listed."
124 :group 'gnus-group-listing
125 :group 'gnus-group-levels
128 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
129 "*Function used for sorting the group buffer.
130 This function will be called with group info entries as the arguments
131 for the groups to be sorted. Pre-made functions include
132 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
133 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
134 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
135 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
137 This variable can also be a list of sorting functions. In that case,
138 the most significant sort function should be the last function in the
140 :group 'gnus-group-listing
141 :link '(custom-manual "(gnus)Sorting Groups")
142 :type '(repeat :value-to-internal (lambda (widget value)
143 (if (listp value) value (list value)))
144 :match (lambda (widget value)
146 (widget-editable-list-match widget value)))
147 (choice (function-item gnus-group-sort-by-alphabet)
148 (function-item gnus-group-sort-by-real-name)
149 (function-item gnus-group-sort-by-unread)
150 (function-item gnus-group-sort-by-level)
151 (function-item gnus-group-sort-by-score)
152 (function-item gnus-group-sort-by-method)
153 (function-item gnus-group-sort-by-server)
154 (function-item gnus-group-sort-by-rank)
155 (function :tag "other" nil))))
157 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%O\n"
158 "*Format of group lines.
159 It works along the same lines as a normal formatting string,
160 with some simple extensions.
162 %M Only marked articles (character, \"*\" or \" \")
163 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
164 %L Level of subscribedness (integer)
165 %N Number of unread articles (integer)
166 %I Number of dormant articles (integer)
167 %i Number of ticked and dormant (integer)
168 %T Number of ticked articles (integer)
169 %R Number of read articles (integer)
170 %U Number of unseen articles (integer)
171 %t Estimated total number of articles (integer)
172 %y Number of unread, unticked articles (integer)
173 %G Group name (string)
174 %g Qualified group name (string)
175 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
176 %C Group comment (string)
177 %D Group description (string)
178 %s Select method (string)
179 %o Moderated group (char, \"m\")
180 %p Process mark (char)
181 %B Whether a summary buffer for the group is open (char, \"*\")
182 %O Moderated group (string, \"(m)\" or \"\")
183 %P Topic indentation (string)
184 %m Whether there is new(ish) mail in the group (char, \"%\")
185 %n Select from where (string)
186 %z A string that look like `<%s:%n>' if a foreign select method is used
187 %d The date the group was last entered.
188 %E Icon as defined by `gnus-group-icon-list'.
189 %F The disk space used by the articles fetched by both the cache and agent.
190 %u User defined specifier. The next character in the format string should
191 be a letter. Gnus will call the function gnus-user-format-function-X,
192 where X is the letter following %u. The function will be passed a
193 single dummy parameter as argument. The function should return a
194 string, which will be inserted into the buffer just like information
195 from any other group specifier.
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 (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
432 (mm-coding-system-p 'utf-8))
435 "Alist of group regexp and the charset for group names.
438 ((\"\\.com\\.cn:\" . cn-gb-2312))"
440 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
442 (defcustom gnus-group-jump-to-group-prompt nil
443 "Default prompt for `gnus-group-jump-to-group'.
445 If non-nil, the value should be a string or an alist. If it is a string,
446 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
447 nnml:\" in the minibuffer prompt.
449 If it is an alist, it must consist of \(NUMBER . PROMPT\) pairs, for example:
450 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
451 used when no prefix argument is given to `gnus-group-jump-to-group'."
453 :group 'gnus-group-various
454 :type '(choice (string :tag "Prompt string")
455 (const :tag "Empty" nil)
456 (repeat (cons (integer :tag "Argument")
457 (string :tag "Prompt string")))))
459 (defvar gnus-group-listing-limit 1000
460 "*A limit of the number of groups when listing.
461 If the number of groups is larger than the limit, list them in a
464 ;;; Internal variables
466 (defvar gnus-group-is-exiting-p nil)
467 (defvar gnus-group-is-exiting-without-update-p nil)
468 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
469 "Function for sorting the group buffer.")
471 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
472 "Function for sorting the selected groups in the group buffer.")
474 (defvar gnus-group-indentation-function nil)
475 (defvar gnus-goto-missing-group-function nil)
476 (defvar gnus-group-update-group-function nil)
477 (defvar gnus-group-goto-next-group-function nil
478 "Function to override finding the next group after listing groups.")
480 (defvar gnus-group-edit-buffer nil)
482 (defvar gnus-group-line-format-alist
483 `((?M gnus-tmp-marked-mark ?c)
484 (?S gnus-tmp-subscribed ?c)
485 (?L gnus-tmp-level ?d)
486 (?N (cond ((eq number t) "*" )
490 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
491 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
493 (?R gnus-tmp-number-of-read ?s)
494 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
495 (?t gnus-tmp-number-total ?d)
496 (?y gnus-tmp-number-of-unread ?s)
497 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
498 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
499 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
500 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
501 (?g (if (boundp 'gnus-tmp-decoded-group)
502 gnus-tmp-decoded-group
505 (?G gnus-tmp-qualified-group ?s)
506 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
507 gnus-tmp-decoded-group
510 (?C gnus-tmp-comment ?s)
511 (?D gnus-tmp-newsgroup-description ?s)
512 (?o gnus-tmp-moderated ?c)
513 (?O gnus-tmp-moderated-string ?s)
514 (?p gnus-tmp-process-marked ?c)
515 (?s gnus-tmp-news-server ?s)
516 (?n ,(if (featurep 'xemacs)
517 '(symbol-name gnus-tmp-news-method)
518 'gnus-tmp-news-method)
520 (?P gnus-group-indentation ?s)
521 (?E gnus-tmp-group-icon ?s)
522 (?B gnus-tmp-summary-live ?c)
523 (?z gnus-tmp-news-method-string ?s)
524 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
525 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
526 (?u gnus-tmp-user-defined ?s)
527 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
530 (defvar gnus-group-mode-line-format-alist
531 `((?S gnus-tmp-news-server ?s)
532 (?M gnus-tmp-news-method ?s)
533 (?u gnus-tmp-user-defined ?s)
534 (?: gnus-tmp-colon ?s)))
536 (defvar gnus-topic-topology nil
537 "The complete topic hierarchy.")
539 (defvar gnus-topic-alist nil
540 "The complete topic-group alist.")
542 (defvar gnus-group-marked nil)
544 (defvar gnus-group-list-mode nil)
547 (defvar gnus-group-icon-cache nil)
549 (defvar gnus-group-listed-groups nil)
550 (defvar gnus-group-list-option nil)
556 (put 'gnus-group-mode 'mode-class 'special)
558 (gnus-define-keys gnus-group-mode-map
559 " " gnus-group-read-group
560 "=" gnus-group-select-group
561 "\r" gnus-group-select-group
562 "\M-\r" gnus-group-quick-select-group
563 "\M- " gnus-group-visible-select-group
564 [(meta control return)] gnus-group-select-group-ephemerally
565 "j" gnus-group-jump-to-group
566 "n" gnus-group-next-unread-group
567 "p" gnus-group-prev-unread-group
568 "\177" gnus-group-prev-unread-group
569 [delete] gnus-group-prev-unread-group
570 [backspace] gnus-group-prev-unread-group
571 "N" gnus-group-next-group
572 "P" gnus-group-prev-group
573 "\M-n" gnus-group-next-unread-group-same-level
574 "\M-p" gnus-group-prev-unread-group-same-level
575 "," gnus-group-best-unread-group
576 "." gnus-group-first-unread-group
577 "u" gnus-group-unsubscribe-current-group
578 "U" gnus-group-unsubscribe-group
579 "c" gnus-group-catchup-current
580 "C" gnus-group-catchup-current-all
581 "\M-c" gnus-group-clear-data
582 "l" gnus-group-list-groups
583 "L" gnus-group-list-all-groups
586 "g" gnus-group-get-new-news
587 "\M-g" gnus-group-get-new-news-this-group
588 "R" gnus-group-restart
589 "r" gnus-group-read-init-file
590 "B" gnus-group-browse-foreign-server
591 "b" gnus-group-check-bogus-groups
592 "F" gnus-group-find-new-groups
593 "\C-c\C-d" gnus-group-describe-group
594 "\M-d" gnus-group-describe-all-groups
595 "\C-c\C-a" gnus-group-apropos
596 "\C-c\M-\C-a" gnus-group-description-apropos
597 "a" gnus-group-post-news
598 "\ek" gnus-group-edit-local-kill
599 "\eK" gnus-group-edit-global-kill
600 "\C-k" gnus-group-kill-group
601 "\C-y" gnus-group-yank-group
602 "\C-w" gnus-group-kill-region
603 "\C-x\C-t" gnus-group-transpose-groups
604 "\C-c\C-l" gnus-group-list-killed
605 "\C-c\C-x" gnus-group-expire-articles
606 "\C-c\M-\C-x" gnus-group-expire-all-groups
608 "s" gnus-group-save-newsrc
609 "z" gnus-group-suspend
612 "?" gnus-group-describe-briefly
613 "\C-c\C-i" gnus-info-find-node
614 "\M-e" gnus-group-edit-group-method
615 "^" gnus-group-enter-server-mode
616 gnus-mouse-2 gnus-mouse-pick-group
617 [follow-link] mouse-face
618 "<" beginning-of-buffer
621 "\C-c\C-s" gnus-group-sort-groups
623 "\C-c\M-g" gnus-activate-all-groups
624 "\M-&" gnus-group-universal-argument
625 "#" gnus-group-mark-group
626 "\M-#" gnus-group-unmark-group)
628 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
629 "m" gnus-group-mark-group
630 "u" gnus-group-unmark-group
631 "w" gnus-group-mark-region
632 "b" gnus-group-mark-buffer
633 "r" gnus-group-mark-regexp
634 "U" gnus-group-unmark-all-groups)
636 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
637 "u" gnus-sieve-update
638 "g" gnus-sieve-generate)
640 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
641 "d" gnus-group-make-directory-group
642 "h" gnus-group-make-help-group
643 "u" gnus-group-make-useful-group
644 "a" gnus-group-make-archive-group
645 "k" gnus-group-make-kiboze-group
646 "l" gnus-group-nnimap-edit-acl
647 "m" gnus-group-make-group
648 "E" gnus-group-edit-group
649 "e" gnus-group-edit-group-method
650 "p" gnus-group-edit-group-parameters
651 "v" gnus-group-add-to-virtual
652 "V" gnus-group-make-empty-virtual
653 "D" gnus-group-enter-directory
654 "f" gnus-group-make-doc-group
655 "w" gnus-group-make-web-group
656 "M" gnus-group-read-ephemeral-group
657 "r" gnus-group-rename-group
658 "R" gnus-group-make-rss-group
659 "c" gnus-group-customize
660 "x" gnus-group-nnimap-expunge
661 "\177" gnus-group-delete-group
662 [delete] gnus-group-delete-group)
664 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
665 "b" gnus-group-brew-soup
666 "w" gnus-soup-save-areas
667 "s" gnus-soup-send-replies
668 "p" gnus-soup-pack-packet
669 "r" nnsoup-pack-replies)
671 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
672 "s" gnus-group-sort-groups
673 "a" gnus-group-sort-groups-by-alphabet
674 "u" gnus-group-sort-groups-by-unread
675 "l" gnus-group-sort-groups-by-level
676 "v" gnus-group-sort-groups-by-score
677 "r" gnus-group-sort-groups-by-rank
678 "m" gnus-group-sort-groups-by-method
679 "n" gnus-group-sort-groups-by-real-name)
681 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
682 "s" gnus-group-sort-selected-groups
683 "a" gnus-group-sort-selected-groups-by-alphabet
684 "u" gnus-group-sort-selected-groups-by-unread
685 "l" gnus-group-sort-selected-groups-by-level
686 "v" gnus-group-sort-selected-groups-by-score
687 "r" gnus-group-sort-selected-groups-by-rank
688 "m" gnus-group-sort-selected-groups-by-method
689 "n" gnus-group-sort-selected-groups-by-real-name)
691 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
692 "k" gnus-group-list-killed
693 "z" gnus-group-list-zombies
694 "s" gnus-group-list-groups
695 "u" gnus-group-list-all-groups
696 "A" gnus-group-list-active
697 "a" gnus-group-apropos
698 "d" gnus-group-description-apropos
699 "m" gnus-group-list-matching
700 "M" gnus-group-list-all-matching
701 "l" gnus-group-list-level
702 "c" gnus-group-list-cached
703 "?" gnus-group-list-dormant)
705 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
706 "k" gnus-group-list-limit
707 "z" gnus-group-list-limit
708 "s" gnus-group-list-limit
709 "u" gnus-group-list-limit
710 "A" gnus-group-list-limit
711 "m" gnus-group-list-limit
712 "M" gnus-group-list-limit
713 "l" gnus-group-list-limit
714 "c" gnus-group-list-limit
715 "?" gnus-group-list-limit)
717 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
718 "k" gnus-group-list-flush
719 "z" gnus-group-list-flush
720 "s" gnus-group-list-flush
721 "u" gnus-group-list-flush
722 "A" gnus-group-list-flush
723 "m" gnus-group-list-flush
724 "M" gnus-group-list-flush
725 "l" gnus-group-list-flush
726 "c" gnus-group-list-flush
727 "?" gnus-group-list-flush)
729 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
730 "k" gnus-group-list-plus
731 "z" gnus-group-list-plus
732 "s" gnus-group-list-plus
733 "u" gnus-group-list-plus
734 "A" gnus-group-list-plus
735 "m" gnus-group-list-plus
736 "M" gnus-group-list-plus
737 "l" gnus-group-list-plus
738 "c" gnus-group-list-plus
739 "?" gnus-group-list-plus)
741 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
742 "f" gnus-score-flush-cache
743 "e" gnus-score-edit-all-score)
745 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
746 "c" gnus-group-fetch-charter
747 "C" gnus-group-fetch-control
748 "d" gnus-group-describe-group
749 "f" gnus-group-fetch-faq
752 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
753 "l" gnus-group-set-current-level
754 "t" gnus-group-unsubscribe-current-group
755 "s" gnus-group-unsubscribe-group
756 "k" gnus-group-kill-group
757 "y" gnus-group-yank-group
758 "w" gnus-group-kill-region
759 "\C-k" gnus-group-kill-level
760 "z" gnus-group-kill-all-zombies)
762 (defun gnus-topic-mode-p ()
763 "Return non-nil in `gnus-topic-mode'."
764 (and (boundp 'gnus-topic-mode)
765 (symbol-value 'gnus-topic-mode)))
767 (defun gnus-group-make-menu-bar ()
768 (gnus-turn-off-edit-menu 'group)
769 (unless (boundp 'gnus-group-reading-menu)
772 gnus-group-reading-menu gnus-group-mode-map ""
774 ["Read" gnus-group-read-group
775 :included (not (gnus-topic-mode-p))
776 :active (gnus-group-group-name)]
777 ["Read " gnus-topic-read-group
778 :included (gnus-topic-mode-p)]
779 ["Select" gnus-group-select-group
780 :included (not (gnus-topic-mode-p))
781 :active (gnus-group-group-name)]
782 ["Select " gnus-topic-select-group
783 :included (gnus-topic-mode-p)]
784 ["See old articles" (gnus-group-select-group 'all)
785 :keys "C-u SPC" :active (gnus-group-group-name)]
786 ["Catch up" gnus-group-catchup-current
787 :included (not (gnus-topic-mode-p))
788 :active (gnus-group-group-name)
789 ,@(if (featurep 'xemacs) nil
790 '(:help "Mark unread articles in the current group as read"))]
791 ["Catch up " gnus-topic-catchup-articles
792 :included (gnus-topic-mode-p)
793 ,@(if (featurep 'xemacs) nil
794 '(:help "Mark unread articles in the current group or topic as read"))]
795 ["Catch up all articles" gnus-group-catchup-current-all
796 (gnus-group-group-name)]
797 ["Check for new articles" gnus-group-get-new-news-this-group
798 :included (not (gnus-topic-mode-p))
799 :active (gnus-group-group-name)
800 ,@(if (featurep 'xemacs) nil
801 '(:help "Check for new messages in current group"))]
802 ["Check for new articles " gnus-topic-get-new-news-this-topic
803 :included (gnus-topic-mode-p)
804 ,@(if (featurep 'xemacs) nil
805 '(:help "Check for new messages in current group or topic"))]
806 ["Toggle subscription" gnus-group-unsubscribe-current-group
807 (gnus-group-group-name)]
808 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
809 ,@(if (featurep 'xemacs) nil
810 '(:help "Kill (remove) current group"))]
811 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
812 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
813 ,@(if (featurep 'xemacs) nil
814 '(:help "Display description of the current group"))]
815 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
816 ["Fetch charter" gnus-group-fetch-charter
817 :active (gnus-group-group-name)
818 ,@(if (featurep 'xemacs) nil
819 '(:help "Display the charter of the current group"))]
820 ["Fetch control message" gnus-group-fetch-control
821 :active (gnus-group-group-name)
822 ,@(if (featurep 'xemacs) nil
823 '(:help "Display the archived control message for the current group"))]
824 ;; Actually one should check, if any of the marked groups gives t for
825 ;; (gnus-check-backend-function 'request-expire-articles ...)
826 ["Expire articles" gnus-group-expire-articles
827 :included (not (gnus-topic-mode-p))
828 :active (or (and (gnus-group-group-name)
829 (gnus-check-backend-function
830 'request-expire-articles
831 (gnus-group-group-name))) gnus-group-marked)]
832 ["Expire articles " gnus-topic-expire-articles
833 :included (gnus-topic-mode-p)]
834 ["Set group level..." gnus-group-set-current-level
835 (gnus-group-group-name)]
836 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
837 ["Customize" gnus-group-customize (gnus-group-group-name)]
839 ["Parameters" gnus-group-edit-group-parameters
840 :included (not (gnus-topic-mode-p))
841 :active (gnus-group-group-name)]
842 ["Parameters " gnus-topic-edit-parameters
843 :included (gnus-topic-mode-p)]
844 ["Select method" gnus-group-edit-group-method
845 (gnus-group-group-name)]
846 ["Info" gnus-group-edit-group (gnus-group-group-name)]
847 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
848 ["Global kill file" gnus-group-edit-global-kill t])))
851 gnus-group-group-menu gnus-group-mode-map ""
854 ["List unread subscribed groups" gnus-group-list-groups t]
855 ["List (un)subscribed groups" gnus-group-list-all-groups t]
856 ["List killed groups" gnus-group-list-killed gnus-killed-list]
857 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
858 ["List level..." gnus-group-list-level t]
859 ["Describe all groups" gnus-group-describe-all-groups t]
860 ["Group apropos..." gnus-group-apropos t]
861 ["Group and description apropos..." gnus-group-description-apropos t]
862 ["List groups matching..." gnus-group-list-matching t]
863 ["List all groups matching..." gnus-group-list-all-matching t]
864 ["List active file" gnus-group-list-active t]
865 ["List groups with cached" gnus-group-list-cached t]
866 ["List groups with dormant" gnus-group-list-dormant t])
868 ["Default sort" gnus-group-sort-groups t]
869 ["Sort by method" gnus-group-sort-groups-by-method t]
870 ["Sort by rank" gnus-group-sort-groups-by-rank t]
871 ["Sort by score" gnus-group-sort-groups-by-score t]
872 ["Sort by level" gnus-group-sort-groups-by-level t]
873 ["Sort by unread" gnus-group-sort-groups-by-unread t]
874 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
875 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
876 ("Sort process/prefixed"
877 ["Default sort" gnus-group-sort-selected-groups
878 (not (gnus-topic-mode-p))]
879 ["Sort by method" gnus-group-sort-selected-groups-by-method
880 (not (gnus-topic-mode-p))]
881 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
882 (not (gnus-topic-mode-p))]
883 ["Sort by score" gnus-group-sort-selected-groups-by-score
884 (not (gnus-topic-mode-p))]
885 ["Sort by level" gnus-group-sort-selected-groups-by-level
886 (not (gnus-topic-mode-p))]
887 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
888 (not (gnus-topic-mode-p))]
889 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
890 (not (gnus-topic-mode-p))]
891 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
892 (not (gnus-topic-mode-p))])
894 ["Mark group" gnus-group-mark-group
895 (and (gnus-group-group-name)
896 (not (memq (gnus-group-group-name) gnus-group-marked)))]
897 ["Unmark group" gnus-group-unmark-group
898 (and (gnus-group-group-name)
899 (memq (gnus-group-group-name) gnus-group-marked))]
900 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
901 ["Mark regexp..." gnus-group-mark-regexp t]
902 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
903 ["Mark buffer" gnus-group-mark-buffer t]
904 ["Execute command" gnus-group-universal-argument
905 (or gnus-group-marked (gnus-group-group-name))])
907 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
908 ["Kill all newsgroups in region" gnus-group-kill-region
909 :active (gnus-mark-active-p)]
910 ["Kill all zombie groups" gnus-group-kill-all-zombies
912 ["Kill all groups on level..." gnus-group-kill-level t])
914 ["Make a foreign group..." gnus-group-make-group t]
915 ["Add a directory group..." gnus-group-make-directory-group t]
916 ["Add the help group" gnus-group-make-help-group t]
917 ["Add the archive group" gnus-group-make-archive-group t]
918 ["Make a doc group..." gnus-group-make-doc-group t]
919 ["Make a web group..." gnus-group-make-web-group t]
920 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
921 ["Make a virtual group..." gnus-group-make-empty-virtual t]
922 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
923 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
924 ["Make an RSS group..." gnus-group-make-rss-group t]
925 ["Rename group..." gnus-group-rename-group
926 (gnus-check-backend-function
927 'request-rename-group (gnus-group-group-name))]
928 ["Delete group" gnus-group-delete-group
929 (gnus-check-backend-function
930 'request-delete-group (gnus-group-group-name))])
932 ["Next" gnus-group-next-group t]
933 ["Previous" gnus-group-prev-group t]
934 ["Next unread" gnus-group-next-unread-group t]
935 ["Previous unread" gnus-group-prev-unread-group t]
936 ["Next unread same level" gnus-group-next-unread-group-same-level t]
937 ["Previous unread same level"
938 gnus-group-prev-unread-group-same-level t]
939 ["Jump to group..." gnus-group-jump-to-group t]
940 ["First unread group" gnus-group-first-unread-group t]
941 ["Best unread group" gnus-group-best-unread-group t])
943 ["Generate" gnus-sieve-generate t]
944 ["Generate and update" gnus-sieve-update t])
945 ["Delete bogus groups" gnus-group-check-bogus-groups t]
946 ["Find new newsgroups" gnus-group-find-new-groups t]
947 ["Transpose" gnus-group-transpose-groups
948 (gnus-group-group-name)]
949 ["Read a directory as a group..." gnus-group-enter-directory t]))
952 gnus-group-misc-menu gnus-group-mode-map ""
955 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
956 ["Send replies" gnus-soup-send-replies
957 (fboundp 'gnus-soup-pack-packet)]
958 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
959 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
960 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
961 ["Send a mail" gnus-group-mail t]
962 ["Send a message (mail or news)" gnus-group-post-news t]
963 ["Create a local message" gnus-group-news t]
964 ["Check for new news" gnus-group-get-new-news
965 ,@(if (featurep 'xemacs) '(t)
966 '(:help "Get newly arrived articles"))
968 ["Send queued messages" gnus-delay-send-queue
969 ,@(if (featurep 'xemacs) '(t)
970 '(:help "Send all messages that are scheduled to be sent now"))
972 ["Activate all groups" gnus-activate-all-groups t]
973 ["Restart Gnus" gnus-group-restart t]
974 ["Read init file" gnus-group-read-init-file t]
975 ["Browse foreign server..." gnus-group-browse-foreign-server t]
976 ["Enter server buffer" gnus-group-enter-server-mode t]
977 ["Expire all expirable articles" gnus-group-expire-all-groups t]
978 ["Generate any kiboze groups" nnkiboze-generate-groups t]
979 ["Gnus version" gnus-version t]
980 ["Save .newsrc files" gnus-group-save-newsrc t]
981 ["Suspend Gnus" gnus-group-suspend t]
982 ["Clear dribble buffer" gnus-group-clear-dribble t]
983 ["Read manual" gnus-info-find-node t]
984 ["Flush score cache" gnus-score-flush-cache t]
985 ["Toggle topics" gnus-topic-mode t]
986 ["Send a bug report" gnus-bug t]
987 ["Exit from Gnus" gnus-group-exit
988 ,@(if (featurep 'xemacs) '(t)
989 '(:help "Quit reading news"))]
990 ["Exit without saving" gnus-group-quit t]))
992 (gnus-run-hooks 'gnus-group-menu-hook)))
994 (defvar gnus-group-toolbar-map nil)
996 ;; Emacs 21 tool bar. Should be no-op otherwise.
997 (defun gnus-group-make-tool-bar ()
999 (condition-case nil (require 'tool-bar) (error nil))
1000 (fboundp 'tool-bar-add-item-from-menu)
1001 (default-value 'tool-bar-mode)
1002 (not gnus-group-toolbar-map))
1003 (setq gnus-group-toolbar-map
1004 (let ((tool-bar-map (make-sparse-keymap))
1005 (load-path (mm-image-load-path)))
1006 (tool-bar-add-item-from-menu
1007 'gnus-group-get-new-news "get-news" gnus-group-mode-map)
1008 (tool-bar-add-item-from-menu
1009 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
1010 (tool-bar-add-item-from-menu
1011 'gnus-group-catchup-current "catchup" gnus-group-mode-map)
1012 (tool-bar-add-item-from-menu
1013 'gnus-group-describe-group "describe-group" gnus-group-mode-map)
1014 (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
1015 :help "Subscribe to the current group")
1016 (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
1018 :help "Unsubscribe from the current group")
1019 (tool-bar-add-item-from-menu
1020 'gnus-group-exit "exit-gnus" gnus-group-mode-map)
1022 (if gnus-group-toolbar-map
1023 (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
1025 (defun gnus-group-mode ()
1026 "Major mode for reading news.
1028 All normal editing commands are switched off.
1029 \\<gnus-group-mode-map>
1030 The group buffer lists (some of) the groups available. For instance,
1031 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1032 lists all zombie groups.
1034 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1035 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1037 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1039 The following commands are available:
1041 \\{gnus-group-mode-map}"
1043 (kill-all-local-variables)
1044 (when (gnus-visual-p 'group-menu 'menu)
1045 (gnus-group-make-menu-bar)
1046 (gnus-group-make-tool-bar))
1047 (gnus-simplify-mode-line)
1048 (setq major-mode 'gnus-group-mode)
1049 (setq mode-name "Group")
1050 (gnus-group-set-mode-line)
1051 (setq mode-line-process nil)
1052 (use-local-map gnus-group-mode-map)
1053 (buffer-disable-undo)
1054 (setq truncate-lines t)
1055 (setq buffer-read-only t
1056 show-trailing-whitespace nil)
1057 (gnus-set-default-directory)
1058 (gnus-update-format-specifications nil 'group 'group-mode)
1059 (gnus-update-group-mark-positions)
1064 (gnus-run-mode-hooks 'gnus-group-mode-hook))
1066 (defun gnus-update-group-mark-positions ()
1068 (let ((gnus-process-mark ?\200)
1069 (gnus-group-update-hook nil)
1070 (gnus-group-marked '("dummy.group"))
1071 (gnus-active-hashtb (make-vector 10 0))
1073 (gnus-set-active "dummy.group" '(0 . 0))
1074 (gnus-set-work-buffer)
1075 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1076 (goto-char (point-min))
1077 (setq gnus-group-mark-positions
1078 (list (cons 'process (and (search-forward
1079 (mm-string-as-multibyte "\200") nil t)
1080 (- (point) 2))))))))
1082 (defun gnus-mouse-pick-group (e)
1083 "Enter the group under the mouse pointer."
1086 (gnus-group-read-group nil))
1088 ;; Look at LEVEL and find out what the level is really supposed to be.
1089 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1090 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1091 (defun gnus-group-default-level (&optional level number-or-nil)
1093 (gnus-group-use-permanent-levels
1094 (or (setq gnus-group-use-permanent-levels
1095 (or level (if (numberp gnus-group-use-permanent-levels)
1096 gnus-group-use-permanent-levels
1097 (or gnus-group-default-list-level
1098 gnus-level-subscribed))))
1099 gnus-group-default-list-level gnus-level-subscribed))
1103 (or level gnus-group-default-list-level gnus-level-subscribed))))
1105 (defun gnus-group-setup-buffer ()
1106 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1107 (unless (eq major-mode 'gnus-group-mode)
1110 (gnus-carpal-setup-buffer 'group))))
1112 (defun gnus-group-name-charset (method group)
1114 (setq method (gnus-find-method-for-group group)))
1115 (let ((item (assoc method gnus-group-name-charset-method-alist))
1116 (alist gnus-group-name-charset-group-alist)
1120 (while (setq item (pop alist))
1121 (if (string-match (car item) group)
1123 result (cdr item))))
1126 (defun gnus-group-name-decode (string charset)
1127 ;; Fixme: Don't decode in unibyte mode.
1128 (if (and string charset (featurep 'mule))
1129 (mm-decode-coding-string string charset)
1132 (defun gnus-group-decoded-name (string)
1133 (let ((charset (gnus-group-name-charset nil string)))
1134 (gnus-group-name-decode string charset)))
1136 (defun gnus-group-list-groups (&optional level unread lowest)
1137 "List newsgroups with level LEVEL or lower that have unread articles.
1138 Default is all subscribed groups.
1139 If argument UNREAD is non-nil, groups with no unread articles are also
1142 Also see the `gnus-group-use-permanent-levels' variable."
1144 (list (if current-prefix-arg
1145 (prefix-numeric-value current-prefix-arg)
1147 (gnus-group-default-level nil t)
1148 gnus-group-default-list-level
1149 gnus-level-subscribed))))
1151 (setq level (car gnus-group-list-mode)
1152 unread (cdr gnus-group-list-mode)))
1153 (setq level (gnus-group-default-level level))
1154 (gnus-group-setup-buffer)
1155 (gnus-update-format-specifications nil 'group 'group-mode)
1156 (let ((case-fold-search nil)
1157 (props (text-properties-at (point-at-bol)))
1158 (empty (= (point-min) (point-max)))
1159 (group (gnus-group-group-name))
1161 (set-buffer gnus-group-buffer)
1162 (setq number (funcall gnus-group-prepare-function level unread lowest))
1163 (when (or (and (numberp number)
1165 (zerop (buffer-size)))
1166 ;; No groups in the buffer.
1167 (gnus-message 5 gnus-no-groups-message))
1168 ;; We have some groups displayed.
1169 (goto-char (point-max))
1170 (when (or (not gnus-group-goto-next-group-function)
1171 (not (funcall gnus-group-goto-next-group-function
1175 (goto-char (point-min)))
1177 ;; Go to the first group with unread articles.
1178 (gnus-group-search-forward t))
1180 ;; Find the right group to put point on. If the current group
1181 ;; has disappeared in the new listing, try to find the next
1182 ;; one. If no next one can be found, just leave point at the
1183 ;; first newsgroup in the buffer.
1184 (when (not (gnus-goto-char
1186 (point-min) (point-max)
1187 'gnus-group (gnus-intern-safe
1188 group gnus-active-hashtb))))
1189 (let ((newsrc (cdddr (gnus-group-entry group))))
1191 (not (gnus-goto-char
1193 (point-min) (point-max) 'gnus-group
1195 (caar newsrc) gnus-active-hashtb)))))
1196 (setq newsrc (cdr newsrc)))
1198 (goto-char (point-max))
1199 (forward-line -1)))))))
1200 ;; Adjust cursor point.
1201 (gnus-group-position-point)))
1203 (defun gnus-group-list-level (level &optional all)
1204 "List groups on LEVEL.
1205 If ALL (the prefix), also list groups that have no unread articles."
1206 (interactive "nList groups on level: \nP")
1207 (gnus-group-list-groups level all level))
1209 (defun gnus-group-prepare-logic (group test)
1210 (or (and gnus-group-listed-groups
1211 (null gnus-group-list-option)
1212 (member group gnus-group-listed-groups))
1214 ((null gnus-group-listed-groups) test)
1215 ((null gnus-group-list-option) test)
1216 (t (and (member group gnus-group-listed-groups)
1217 (if (eq gnus-group-list-option 'flush)
1221 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1222 "List all newsgroups with unread articles of level LEVEL or lower.
1223 If PREDICATE is a function, list groups that the function returns non-nil;
1224 if it is t, list groups that have no unread articles.
1225 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1226 If REGEXP is a function, list dead groups that the function returns non-nil;
1227 if it is a string, only list groups matching REGEXP."
1228 (set-buffer gnus-group-buffer)
1229 (let ((buffer-read-only nil)
1230 (newsrc (cdr gnus-newsrc-alist))
1231 (lowest (or lowest 1))
1232 (not-in-list (and gnus-group-listed-groups
1233 (copy-sequence gnus-group-listed-groups)))
1234 info clevel unread group params)
1236 (when (or (< lowest gnus-level-zombie)
1237 gnus-group-listed-groups)
1238 ;; List living groups.
1240 (setq info (car newsrc)
1241 group (gnus-info-group info)
1242 params (gnus-info-params info)
1244 unread (gnus-group-unread group))
1246 (setq not-in-list (delete group not-in-list)))
1247 (when (gnus-group-prepare-logic
1249 (and unread ; This group might be unchecked
1250 (or (not (stringp regexp))
1251 (string-match regexp group))
1252 (<= (setq clevel (gnus-info-level info)) level)
1255 ((functionp predicate)
1256 (funcall predicate info))
1257 (predicate t) ; We list all groups?
1260 (if (eq unread t) ; Unactivated?
1261 gnus-group-list-inactive-groups
1262 ; We list unactivated
1264 ; We list groups with unread articles
1265 (and gnus-list-groups-with-ticked-articles
1266 (cdr (assq 'tick (gnus-info-marks info))))
1267 ; And groups with tickeds
1268 ;; Check for permanent visibility.
1269 (and gnus-permanently-visible-groups
1270 (string-match gnus-permanently-visible-groups
1272 (memq 'visible params)
1273 (cdr (assq 'visible params)))))))
1274 (gnus-group-insert-group-line
1275 group (gnus-info-level info)
1276 (gnus-info-marks info) unread (gnus-info-method info)))))
1278 ;; List dead groups.
1279 (when (or gnus-group-listed-groups
1280 (and (>= level gnus-level-zombie)
1281 (<= lowest gnus-level-zombie)))
1282 (gnus-group-prepare-flat-list-dead
1283 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1284 gnus-level-zombie ?Z
1287 (dolist (group gnus-zombie-list)
1288 (setq not-in-list (delete group not-in-list))))
1289 (when (or gnus-group-listed-groups
1290 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1291 (gnus-group-prepare-flat-list-dead
1294 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1295 gnus-level-killed ?K regexp))
1297 (gnus-group-set-mode-line)
1298 (setq gnus-group-list-mode (cons level predicate))
1299 (gnus-run-hooks 'gnus-group-prepare-hook)
1302 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1303 ;; List zombies and killed lists somewhat faster, which was
1304 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1305 ;; this by ignoring the group format specification altogether.
1307 (if (> (length groups) gnus-group-listing-limit)
1309 (setq group (pop groups))
1310 (when (gnus-group-prepare-logic
1313 (and (stringp regexp) (string-match regexp group))
1314 (and (functionp regexp) (funcall regexp group))))
1315 (gnus-add-text-properties
1316 (point) (prog1 (1+ (point))
1317 (insert " " mark " *: "
1318 (gnus-group-decoded-name group)
1320 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1322 'gnus-level level))))
1324 (setq group (pop groups))
1325 (when (gnus-group-prepare-logic
1328 (and (stringp regexp) (string-match regexp group))
1329 (and (functionp regexp) (funcall regexp group))))
1330 (gnus-group-insert-group-line
1332 (let ((active (gnus-active group)))
1334 (if (zerop (cdr active))
1336 (- (1+ (cdr active)) (car active)))
1338 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1340 (defun gnus-group-update-group-line ()
1341 "Update the current line in the group buffer."
1342 (let* ((buffer-read-only nil)
1343 (group (gnus-group-group-name))
1344 (entry (and group (gnus-group-entry group)))
1345 gnus-group-indentation)
1348 (not (gnus-ephemeral-group-p group))
1350 (concat "(gnus-group-set-info '"
1351 (gnus-prin1-to-string (nth 2 entry))
1353 (setq gnus-group-indentation (gnus-group-group-indentation))
1355 (gnus-group-insert-group-line-info group)
1357 (gnus-group-position-point))))
1359 (defun gnus-group-insert-group-line-info (group)
1360 "Insert GROUP on the current line."
1361 (let ((entry (gnus-group-entry group))
1362 (gnus-group-indentation (gnus-group-group-indentation))
1366 ;; (Un)subscribed group.
1367 (setq info (nth 2 entry))
1368 (gnus-group-insert-group-line
1369 group (gnus-info-level info) (gnus-info-marks info)
1370 (or (car entry) t) (gnus-info-method info)))
1371 ;; This group is dead.
1372 (gnus-group-insert-group-line
1374 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1376 (if (setq active (gnus-active group))
1377 (if (zerop (cdr active))
1379 (- (1+ (cdr active)) (car active)))
1381 (gnus-method-simplify (gnus-find-method-for-group group))))))
1383 (defun gnus-number-of-unseen-articles-in-group (group)
1384 (let* ((info (nth 2 (gnus-group-entry group)))
1385 (marked (gnus-info-marks info))
1386 (seen (cdr (assq 'seen marked)))
1387 (active (gnus-active group)))
1390 (length (gnus-uncompress-range
1391 (gnus-range-difference
1392 (gnus-range-difference (list active) (gnus-info-read info))
1395 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1396 gnus-tmp-marked number
1398 "Insert a group line in the group buffer."
1399 (let* ((gnus-tmp-method
1400 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1401 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1403 (gnus-tmp-active (gnus-active gnus-tmp-group))
1404 (gnus-tmp-number-total
1406 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1408 (gnus-tmp-number-of-unread
1409 (if (numberp number) (int-to-string (max 0 number))
1411 (gnus-tmp-number-of-read
1412 (if (numberp number)
1413 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1415 (gnus-tmp-subscribed
1416 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1417 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1418 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1420 (gnus-tmp-qualified-group
1421 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1422 group-name-charset))
1424 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1426 (gnus-tmp-newsgroup-description
1427 (if gnus-description-hashtb
1428 (or (gnus-group-name-decode
1429 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1430 group-name-charset) "")
1433 (if (and gnus-moderated-hashtb
1434 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1436 (gnus-tmp-moderated-string
1437 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1438 (gnus-tmp-group-icon "==&&==")
1439 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1440 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1441 (gnus-tmp-news-method-string
1443 (format "(%s:%s)" (car gnus-tmp-method)
1444 (cadr gnus-tmp-method)) ""))
1445 (gnus-tmp-marked-mark
1446 (if (and (numberp number)
1448 (cdr (assq 'tick gnus-tmp-marked)))
1450 (gnus-tmp-summary-live
1451 (if (and (not gnus-group-is-exiting-p)
1452 (gnus-buffer-live-p (gnus-summary-buffer-name
1455 (gnus-tmp-process-marked
1456 (if (member gnus-tmp-group gnus-group-marked)
1457 gnus-process-mark ? ))
1458 (buffer-read-only nil)
1459 header gnus-tmp-header) ; passed as parameter to user-funcs.
1461 (gnus-add-text-properties
1465 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1466 gnus-tmp-group group-name-charset)))
1467 (eval gnus-group-line-format-spec)))
1468 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1469 gnus-unread ,(if (numberp number)
1470 (string-to-number gnus-tmp-number-of-unread)
1472 gnus-marked ,gnus-tmp-marked-mark
1473 gnus-indentation ,gnus-group-indentation
1474 gnus-level ,gnus-tmp-level))
1476 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1477 (gnus-run-hooks 'gnus-group-update-hook))
1479 ;; Allow XEmacs to remove front-sticky text properties.
1480 (gnus-group-remove-excess-properties)))
1482 (defun gnus-group-highlight-line ()
1483 "Highlight the current line according to `gnus-group-highlight'."
1484 (let* ((list gnus-group-highlight)
1486 (end (point-at-eol))
1487 ;; now find out where the line starts and leave point there.
1488 (beg (progn (beginning-of-line) (point)))
1489 (group (gnus-group-group-name))
1490 (entry (gnus-group-entry group))
1491 (unread (if (numberp (car entry)) (car entry) 0))
1492 (active (gnus-active group))
1493 (total (if active (1+ (- (cdr active) (car active))) 0))
1494 (info (nth 2 entry))
1495 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1496 (marked (gnus-info-marks info))
1497 (mailp (apply 'append
1500 (memq x (assoc (symbol-name
1501 (car (or method gnus-select-method)))
1502 gnus-valid-select-methods)))
1503 '(mail post-mail))))
1504 (level (or (gnus-info-level info) gnus-level-killed))
1505 (score (or (gnus-info-score info) 0))
1506 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1507 (group-age (gnus-group-timestamp-delta group))
1508 (inhibit-read-only t))
1509 ;; Eval the cars of the lists until we find a match.
1511 (not (eval (caar list))))
1512 (setq list (cdr list)))
1513 (let ((face (cdar list)))
1514 (unless (eq face (get-text-property beg 'face))
1515 (gnus-put-text-property-excluding-characters-with-faces
1517 (setq face (if (boundp face) (symbol-value face) face)))
1518 (gnus-extent-start-open beg)))
1521 (defun gnus-group-update-group (group &optional visible-only)
1522 "Update all lines where GROUP appear.
1523 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1525 ;; Can't use `save-excursion' here, so we do it manually.
1526 (let ((buf (current-buffer))
1528 (set-buffer gnus-group-buffer)
1529 (setq mark (point-marker))
1530 ;; The buffer may be narrowed.
1533 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1535 found buffer-read-only)
1536 ;; Enter the current status into the dribble buffer.
1537 (let ((entry (gnus-group-entry group)))
1539 (not (gnus-ephemeral-group-p group)))
1541 (concat "(gnus-group-set-info '"
1542 (gnus-prin1-to-string (nth 2 entry))
1544 ;; Find all group instances. If topics are in use, each group
1545 ;; may be listed in more than once.
1546 (while (setq loc (text-property-any
1547 loc (point-max) 'gnus-group ident))
1550 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1552 (gnus-group-insert-group-line-info group)
1555 (gnus-run-hooks 'gnus-group-update-group-hook)))
1556 (setq loc (1+ loc)))
1557 (unless (or found visible-only)
1558 ;; No such line in the buffer, find out where it's supposed to
1559 ;; go, and insert it there (or at the end of the buffer).
1560 (if gnus-goto-missing-group-function
1561 (funcall gnus-goto-missing-group-function group)
1562 (let ((entry (cddr (gnus-group-entry group))))
1563 (while (and entry (car entry)
1567 (point-min) (point-max)
1568 'gnus-group (gnus-intern-safe
1569 (caar entry) gnus-active-hashtb)))))
1570 (setq entry (cdr entry)))
1571 (or entry (goto-char (point-max)))))
1572 ;; Finally insert the line.
1573 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1574 (gnus-group-insert-group-line-info group)
1577 (gnus-run-hooks 'gnus-group-update-group-hook))))
1578 (when gnus-group-update-group-function
1579 (funcall gnus-group-update-group-function group))
1580 (gnus-group-set-mode-line)))
1582 (set-marker mark nil)
1585 (defun gnus-group-set-mode-line ()
1586 "Update the mode line in the group buffer."
1587 (when (memq 'group gnus-updated-mode-lines)
1588 ;; Yes, we want to keep this mode line updated.
1590 (set-buffer gnus-group-buffer)
1591 (let* ((gformat (or gnus-group-mode-line-format-spec
1592 (gnus-set-format 'group-mode)))
1593 (gnus-tmp-news-server (cadr gnus-select-method))
1594 (gnus-tmp-news-method (car gnus-select-method))
1595 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1597 gnus-tmp-header ;Dummy binding for user-defined formats
1598 ;; Get the resulting string.
1600 (and gnus-dribble-buffer
1601 (buffer-name gnus-dribble-buffer)
1602 (buffer-modified-p gnus-dribble-buffer)
1604 (set-buffer gnus-dribble-buffer)
1605 (not (zerop (buffer-size))))))
1606 (mode-string (eval gformat)))
1607 ;; Say whether the dribble buffer has been modified.
1608 (setq mode-line-modified
1609 (if modified (car gnus-mode-line-modified)
1610 (cdr gnus-mode-line-modified)))
1611 ;; If the line is too long, we chop it off.
1612 (when (> (length mode-string) max-len)
1613 (setq mode-string (substring mode-string 0 (- max-len 4))))
1615 (setq mode-line-buffer-identification
1616 (gnus-mode-line-buffer-identification
1617 (list mode-string)))
1618 (set-buffer-modified-p modified))))))
1620 (defun gnus-group-group-name ()
1621 "Get the name of the newsgroup on the current line."
1622 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1624 (symbol-name group))))
1626 (defun gnus-group-group-level ()
1627 "Get the level of the newsgroup on the current line."
1628 (get-text-property (point-at-bol) 'gnus-level))
1630 (defun gnus-group-group-indentation ()
1631 "Get the indentation of the newsgroup on the current line."
1632 (or (get-text-property (point-at-bol) 'gnus-indentation)
1633 (and gnus-group-indentation-function
1634 (funcall gnus-group-indentation-function))
1637 (defun gnus-group-group-unread ()
1638 "Get the number of unread articles of the newsgroup on the current line."
1639 (get-text-property (point-at-bol) 'gnus-unread))
1641 (defun gnus-group-new-mail (group)
1642 (if (nnmail-new-mail-p (gnus-group-real-name group))
1646 (defun gnus-group-level (group)
1647 "Return the estimated level of GROUP."
1648 (or (gnus-info-level (gnus-get-info group))
1649 (and (member group gnus-zombie-list) gnus-level-zombie)
1652 (defun gnus-group-search-forward (&optional backward all level first-too)
1653 "Find the next newsgroup with unread articles.
1654 If BACKWARD is non-nil, find the previous newsgroup instead.
1655 If ALL is non-nil, just find any newsgroup.
1656 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1658 If FIRST-TOO, the current line is also eligible as a target."
1659 (let ((way (if backward -1 1))
1660 (low gnus-level-killed)
1663 (if (and backward (progn (beginning-of-line)) (bobp))
1672 (get-text-property (point) 'gnus-group)
1676 (get-text-property (point) 'gnus-unread)))
1677 (and (numberp unread) (> unread 0)))
1678 (setq lev (get-text-property (point)
1680 (<= lev gnus-level-subscribed)))
1682 (and (setq lev (get-text-property (point)
1691 (zerop (forward-line way)))))
1693 (progn (gnus-group-position-point) t)
1694 (goto-char (or pos beg))
1697 (defun gnus-total-fetched-for (group)
1698 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1699 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1700 (size (+ size-in-cache size-in-agent))
1701 (suffix '("B" "K" "M" "G"))
1703 (cutoff (* 10 scale)))
1704 (while (> size cutoff)
1705 (setq size (/ size scale)
1706 suffix (cdr suffix)))
1707 (format "%5.1f%s" size (car suffix))))
1709 ;;; Gnus group mode commands
1713 (defun gnus-group-mark-line-p ()
1716 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1717 (eq (char-after) gnus-process-mark)))
1719 (defun gnus-group-mark-group (n &optional unmark no-advance)
1720 "Mark the current group."
1722 (let ((buffer-read-only nil)
1726 (when (setq group (gnus-group-group-name))
1727 ;; Go to the mark position.
1729 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1733 (setq gnus-group-marked (delete group gnus-group-marked))
1734 (insert-char ? 1 t))
1735 (setq gnus-group-marked
1736 (cons group (delete group gnus-group-marked)))
1737 (insert-char gnus-process-mark 1 t)))
1739 (gnus-group-next-group 1))
1741 (gnus-summary-position-point)
1744 (defun gnus-group-unmark-group (n)
1745 "Remove the mark from the current group."
1747 (gnus-group-mark-group n 'unmark)
1748 (gnus-group-position-point))
1750 (defun gnus-group-unmark-all-groups ()
1751 "Unmark all groups."
1754 (mapc 'gnus-group-remove-mark gnus-group-marked))
1755 (gnus-group-position-point))
1757 (defun gnus-group-mark-region (unmark beg end)
1758 "Mark all groups between point and mark.
1759 If UNMARK, remove the mark instead."
1760 (interactive "P\nr")
1761 (let ((num (count-lines beg end)))
1764 (- num (gnus-group-mark-group num unmark)))))
1766 (defun gnus-group-mark-buffer (&optional unmark)
1767 "Mark all groups in the buffer.
1768 If UNMARK, remove the mark instead."
1770 (gnus-group-mark-region unmark (point-min) (point-max)))
1772 (defun gnus-group-mark-regexp (regexp)
1773 "Mark all groups that match some regexp."
1774 (interactive "sMark (regexp): ")
1775 (let ((alist (cdr gnus-newsrc-alist))
1779 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1780 (gnus-group-jump-to-group group)
1781 (gnus-group-set-mark group)))))
1782 (gnus-group-position-point))
1784 (defun gnus-group-remove-mark (group &optional test-marked)
1785 "Remove the process mark from GROUP and move point there.
1786 Return nil if the group isn't displayed."
1787 (if (gnus-group-goto-group group nil test-marked)
1789 (gnus-group-mark-group 1 'unmark t)
1791 (setq gnus-group-marked
1792 (delete group gnus-group-marked))
1795 (defun gnus-group-set-mark (group)
1796 "Set the process mark on GROUP."
1797 (if (gnus-group-goto-group group)
1799 (gnus-group-mark-group 1 nil t))
1800 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1802 (defun gnus-group-universal-argument (arg &optional groups func)
1803 "Perform any command on all groups according to the process/prefix convention."
1805 (if (eq (setq func (or func
1808 (substitute-command-keys
1809 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1811 (gnus-error 1 "Undefined key")
1812 (gnus-group-iterate arg
1814 (command-execute func))))
1815 (gnus-group-position-point))
1817 (defun gnus-group-process-prefix (n)
1818 "Return a list of groups to work on.
1819 Take into consideration N (the prefix) and the list of marked groups."
1822 (setq n (prefix-numeric-value n))
1823 ;; There is a prefix, so we return a list of the N next
1825 (let ((way (if (< n 0) -1 1))
1830 (if (setq group (gnus-group-group-name))
1831 (push group groups))
1833 (gnus-group-next-group way)))
1835 ((and (gnus-region-active-p) (mark))
1836 ;; Work on the region between point and mark.
1837 (let ((max (max (point) (mark)))
1840 (goto-char (min (point) (mark)))
1843 (push (gnus-group-group-name) groups)
1844 (zerop (gnus-group-next-group 1))
1846 (nreverse groups))))
1848 ;; No prefix, but a list of marked articles.
1849 (reverse gnus-group-marked))
1851 ;; Neither marked articles or a prefix, so we return the
1853 (let ((group (gnus-group-group-name)))
1854 (and group (list group))))))
1856 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1857 ;;; imagine why I went through these contortions...
1859 (let ((function (make-symbol "gnus-group-iterate-function"))
1860 (window (make-symbol "gnus-group-iterate-window"))
1861 (groups (make-symbol "gnus-group-iterate-groups"))
1862 (group (make-symbol "gnus-group-iterate-group")))
1864 `(defun gnus-group-iterate (arg ,function)
1865 "Iterate FUNCTION over all process/prefixed groups.
1866 FUNCTION will be called with the group name as the parameter
1867 and with point over the group in question."
1868 (let ((,groups (gnus-group-process-prefix arg))
1869 (,window (selected-window))
1872 (setq ,group (car ,groups)
1873 ,groups (cdr ,groups))
1874 (select-window ,window)
1875 (gnus-group-remove-mark ,group)
1876 (save-selected-window
1878 (funcall ,function ,group)))))))))
1880 (put 'gnus-group-iterate 'lisp-indent-function 1)
1882 ;; Selecting groups.
1884 (defun gnus-group-read-group (&optional all no-article group select-articles)
1885 "Read news in this newsgroup.
1886 If the prefix argument ALL is non-nil, already read articles become
1887 readable. IF ALL is a number, fetch this number of articles. If the
1888 optional argument NO-ARTICLE is non-nil, no article will be
1889 auto-selected upon group entry. If GROUP is non-nil, fetch that
1892 (let ((no-display (eq all 0))
1893 (group (or group (gnus-group-group-name)))
1894 number active marked entry)
1898 (error "No group on current line"))
1899 (setq marked (gnus-info-marks
1900 (nth 2 (setq entry (gnus-group-entry group)))))
1901 ;; This group might be a dead group. In that case we have to get
1902 ;; the number of unread articles from `gnus-active-hashtb'.
1904 (cond ((numberp all) all)
1906 ((setq active (gnus-active group))
1907 (- (1+ (cdr active)) (car active)))))
1908 (gnus-summary-read-group
1909 group (or all (and (numberp number)
1910 (zerop (+ number (gnus-range-length
1911 (cdr (assq 'tick marked)))
1913 (cdr (assq 'dormant marked)))))))
1914 no-article nil no-display nil select-articles)))
1916 (defun gnus-group-select-group (&optional all)
1917 "Select this newsgroup.
1918 No article is selected automatically.
1919 If the group is opened, just switch the summary buffer.
1920 If ALL is non-nil, already read articles become readable.
1921 If ALL is a positive number, fetch this number of the latest
1922 articles in the group.
1923 If ALL is a negative number, fetch this number of the earliest
1924 articles in the group."
1926 (when (and (eobp) (not (gnus-group-group-name)))
1928 (gnus-group-read-group all t))
1930 (defun gnus-group-quick-select-group (&optional all)
1931 "Select the current group \"quickly\".
1932 This means that no highlighting or scoring will be performed.
1933 If ALL (the prefix argument) is 0, don't even generate the summary
1936 This might be useful if you want to toggle threading
1937 before entering the group."
1939 (require 'gnus-score)
1941 gnus-score-find-score-files-function
1942 gnus-home-score-file
1943 gnus-apply-kill-hook
1944 gnus-summary-expunge-below)
1945 (gnus-group-read-group all t)))
1947 (defun gnus-group-visible-select-group (&optional all)
1948 "Select the current group without hiding any articles."
1950 (let ((gnus-inhibit-limiting t))
1951 (gnus-group-read-group all t)))
1953 (defun gnus-group-select-group-ephemerally ()
1954 "Select the current group without doing any processing whatsoever.
1955 You will actually be entered into a group that's a copy of
1956 the current group; no changes you make while in this group will
1959 (require 'gnus-score)
1961 gnus-score-find-score-files-function gnus-apply-kill-hook
1962 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
1963 gnus-summary-mode-hook gnus-select-group-hook
1964 (group (gnus-group-group-name))
1965 (method (gnus-find-method-for-group group)))
1966 (gnus-group-read-ephemeral-group
1967 (gnus-group-prefixed-name group method) method)))
1970 (defun gnus-fetch-group (group &optional articles)
1971 "Start Gnus if necessary and enter GROUP.
1972 Returns whether the fetching was successful or not."
1973 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
1974 (unless (get-buffer gnus-group-buffer)
1976 (gnus-group-read-group articles nil group))
1979 (defun gnus-fetch-group-other-frame (group)
1980 "Pop up a frame and enter GROUP."
1982 (let ((window (get-buffer-window gnus-group-buffer)))
1984 (select-frame (window-frame window)))
1985 ((= (length (frame-list)) 1)
1986 (select-frame (make-frame)))
1989 (gnus-fetch-group group))
1991 (defvar gnus-ephemeral-group-server 0)
1993 (defcustom gnus-large-ephemeral-newsgroup 200
1994 "The number of articles which indicates a large ephemeral newsgroup.
1995 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
1997 If the number of articles in a newsgroup is greater than this value,
1998 confirmation is required for selecting the newsgroup. If it is nil, no
1999 confirmation is required."
2001 :group 'gnus-group-select
2002 :type '(choice (const :tag "No limit" nil)
2005 (defcustom gnus-fetch-old-ephemeral-headers nil
2006 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2009 :type '(choice (const :tag "off" nil)
2012 (sexp :menu-tag "other" t)))
2014 ;; Enter a group that is not in the group buffer. Non-nil is returned
2015 ;; if selection was successful.
2016 (defun gnus-group-read-ephemeral-group (group method &optional activate
2017 quit-config request-only
2021 "Read GROUP from METHOD as an ephemeral group.
2022 If ACTIVATE, request the group first.
2023 If QUIT-CONFIG, use that window configuration when exiting from the
2025 If REQUEST-ONLY, don't actually read the group; just request it.
2026 If SELECT-ARTICLES, only select those articles.
2027 If PARAMETERS, use those as the group parameters.
2028 If NUMBER, fetch this number of articles.
2030 Return the name of the group if selection was successful."
2033 ;; (gnus-read-group "Group name: ")
2035 "Group: " gnus-active-hashtb
2037 'gnus-group-history)
2038 (gnus-read-method "From method: ")))
2039 ;; Transform the select method into a unique server.
2040 (when (stringp method)
2041 (setq method (gnus-server-to-method method)))
2043 `(,(car method) ,(concat (cadr method) "-ephemeral")
2044 (,(intern (format "%s-address" (car method))) ,(cadr method))
2046 (let ((group (if (gnus-group-foreign-p group) group
2047 (gnus-group-prefixed-name (gnus-group-real-name group)
2052 ,gnus-level-default-subscribed nil nil ,method
2055 (cons 'quit-config quit-config)
2057 (cons gnus-summary-buffer
2058 gnus-current-window-configuration)))
2061 (push method gnus-ephemeral-servers)
2062 (set-buffer gnus-group-buffer)
2063 (unless (gnus-check-server method)
2064 (error "Unable to contact server: %s" (gnus-status-message method)))
2066 (gnus-activate-group group 'scan)
2067 (unless (gnus-request-group group)
2068 (error "Couldn't request group: %s"
2069 (nnheader-get-report (car method)))))
2073 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2074 (gnus-fetch-old-headers
2075 gnus-fetch-old-ephemeral-headers))
2076 (gnus-group-read-group (or number t) t group select-articles))
2080 (message "Quit reading the ephemeral group")
2083 (defun gnus-group-jump-to-group (group &optional prompt)
2084 "Jump to newsgroup GROUP.
2086 If PROMPT (the prefix) is a number, use the prompt specified in
2087 `gnus-group-jump-to-group-prompt'."
2089 (list (mm-string-make-unibyte
2091 "Group: " gnus-active-hashtb nil
2092 (gnus-read-active-file-p)
2093 (if current-prefix-arg
2094 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2095 (or (and (stringp gnus-group-jump-to-group-prompt)
2096 gnus-group-jump-to-group-prompt)
2097 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2098 (and (stringp p) p))))
2099 'gnus-group-history))))
2101 (when (equal group "")
2102 (error "Empty group name"))
2104 (unless (gnus-ephemeral-group-p group)
2105 ;; Either go to the line in the group buffer...
2106 (unless (gnus-group-goto-group group)
2107 ;; ... or insert the line.
2108 (gnus-group-update-group group)
2109 (gnus-group-goto-group group)))
2110 ;; Adjust cursor point.
2111 (gnus-group-position-point))
2113 (defun gnus-group-goto-group (group &optional far test-marked)
2114 "Goto to newsgroup GROUP.
2115 If FAR, it is likely that the group is not on the current line.
2116 If TEST-MARKED, the line must be marked."
2120 ;; It's quite likely that we are on the right line, so
2121 ;; we check the current line first.
2123 (eq (get-text-property (point) 'gnus-group)
2124 (gnus-intern-safe group gnus-active-hashtb))
2125 (or (not test-marked) (gnus-group-mark-line-p)))
2127 ;; Previous and next line are also likely, so we check them as well.
2131 (and (eq (get-text-property (point) 'gnus-group)
2132 (gnus-intern-safe group gnus-active-hashtb))
2133 (or (not test-marked) (gnus-group-mark-line-p)))))
2139 (and (eq (get-text-property (point) 'gnus-group)
2140 (gnus-intern-safe group gnus-active-hashtb))
2141 (or (not test-marked) (gnus-group-mark-line-p)))))
2145 (goto-char (point-min))
2147 (while (and (not found)
2152 (gnus-intern-safe group gnus-active-hashtb))))
2153 (if (gnus-group-mark-line-p)
2158 ;; Search through the entire buffer.
2161 (point-min) (point-max)
2162 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2164 (defun gnus-group-next-group (n &optional silent)
2165 "Go to next N'th newsgroup.
2166 If N is negative, search backward instead.
2167 Returns the difference between N and the number of skips actually
2170 (gnus-group-next-unread-group n t nil silent))
2172 (defun gnus-group-next-unread-group (n &optional all level silent)
2173 "Go to next N'th unread newsgroup.
2174 If N is negative, search backward instead.
2175 If ALL is non-nil, choose any newsgroup, unread or not.
2176 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2177 such group can be found, the next group with a level higher than
2179 Returns the difference between N and the number of skips actually
2182 (let ((backward (< n 0))
2185 (gnus-group-search-forward
2186 backward (or (not gnus-group-goto-unread) all) level))
2190 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2191 (if level " on this level or higher" "")))
2194 (defun gnus-group-prev-group (n)
2195 "Go to previous N'th newsgroup.
2196 Returns the difference between N and the number of skips actually
2199 (gnus-group-next-unread-group (- n) t))
2201 (defun gnus-group-prev-unread-group (n)
2202 "Go to previous N'th unread newsgroup.
2203 Returns the difference between N and the number of skips actually
2206 (gnus-group-next-unread-group (- n)))
2208 (defun gnus-group-next-unread-group-same-level (n)
2209 "Go to next N'th unread newsgroup on the same level.
2210 If N is negative, search backward instead.
2211 Returns the difference between N and the number of skips actually
2214 (gnus-group-next-unread-group n t (gnus-group-group-level))
2215 (gnus-group-position-point))
2217 (defun gnus-group-prev-unread-group-same-level (n)
2218 "Go to next N'th unread newsgroup on the same level.
2219 Returns the difference between N and the number of skips actually
2222 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2223 (gnus-group-position-point))
2225 (defun gnus-group-best-unread-group (&optional exclude-group)
2226 "Go to the group with the highest level.
2227 If EXCLUDE-GROUP, do not go to that group."
2229 (goto-char (point-min))
2233 (setq unread (get-text-property (point) 'gnus-unread))
2234 (when (and (numberp unread) (> unread 0))
2235 (when (and (get-text-property (point) 'gnus-level)
2236 (< (get-text-property (point) 'gnus-level) best)
2237 (or (not exclude-group)
2238 (not (equal exclude-group (gnus-group-group-name)))))
2239 (setq best (get-text-property (point) 'gnus-level))
2240 (setq best-point (point))))
2243 (goto-char best-point))
2244 (gnus-group-position-point)
2245 (and best-point (gnus-group-group-name))))
2247 (defun gnus-group-first-unread-group ()
2248 "Go to the first group with unread articles."
2251 (let ((opoint (point))
2253 (goto-char (point-min))
2254 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2255 (and (numberp unread) ; Not a topic.
2256 (not (zerop unread))) ; Has unread articles.
2257 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2260 nil)) ; Not success.
2261 (gnus-group-position-point)))
2263 (defun gnus-group-enter-server-mode ()
2264 "Jump to the server buffer."
2266 (gnus-enter-server-buffer))
2268 (defun gnus-group-make-group-simple (&optional group)
2269 "Add a new newsgroup.
2270 The user will be prompted for GROUP."
2272 (list (completing-read "Group: " gnus-active-hashtb
2273 nil nil nil 'gnus-group-history)))
2274 (gnus-group-make-group
2275 (gnus-group-real-name group)
2276 (gnus-group-server group)))
2278 (defun gnus-group-make-group (name &optional method address args)
2279 "Add a new newsgroup.
2280 The user will be prompted for a NAME, for a select METHOD, and an
2284 (gnus-read-group "Group name: ")
2285 (gnus-read-method "From method: ")))
2287 (when (stringp method)
2288 (setq method (or (gnus-server-to-method method) method)))
2289 (let* ((meth (gnus-method-simplify
2291 (not (gnus-server-equal method gnus-select-method)))
2292 (if address (list (intern method) address)
2294 (nname (if method (gnus-group-prefixed-name name meth) name))
2296 (when (gnus-group-entry nname)
2297 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2298 ;; Subscribe to the new group.
2299 (gnus-group-change-level
2300 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2301 gnus-level-default-subscribed gnus-level-killed
2302 (and (gnus-group-group-name)
2303 (gnus-group-entry (gnus-group-group-name)))
2306 (gnus-set-active nname (cons 1 0))
2307 (unless (gnus-ephemeral-group-p name)
2309 (concat "(gnus-group-set-info '"
2310 (gnus-prin1-to-string (cdr info)) ")")))
2312 (gnus-group-insert-group-line-info nname)
2314 (gnus-group-position-point)
2316 ;; Load the back end and try to make the back end create
2317 ;; the group as well.
2318 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2320 gnus-valid-select-methods)
2322 (gnus-check-server meth)
2323 (when (gnus-check-backend-function 'request-create-group nname)
2324 (unless (gnus-request-create-group nname nil args)
2325 (error "Could not create group on server: %s"
2326 (nnheader-get-report backend))))
2329 (defun gnus-group-delete-groups (&optional arg)
2330 "Delete the current group. Only meaningful with editable groups."
2332 (let ((n (length (gnus-group-process-prefix arg))))
2333 (when (gnus-yes-or-no-p
2335 "Delete this 1 group? "
2336 (format "Delete these %d groups? " n)))
2337 (gnus-group-iterate arg
2339 (gnus-group-delete-group group nil t))))))
2341 (defun gnus-group-delete-group (group &optional force no-prompt)
2342 "Delete the current group. Only meaningful with editable groups.
2343 If FORCE (the prefix) is non-nil, all the articles in the group will
2344 be deleted. This is \"deleted\" as in \"removed forever from the face
2345 of the Earth\". There is no undo. The user will be prompted before
2347 Note that you also have to specify FORCE if you want the group to
2348 be removed from the server, even when it's empty."
2350 (list (gnus-group-group-name)
2351 current-prefix-arg))
2353 (error "No group to delete"))
2354 (unless (gnus-check-backend-function 'request-delete-group group)
2355 (error "This back end does not support group deletion"))
2357 (let ((group-decoded (gnus-group-decoded-name group)))
2358 (if (and (not no-prompt)
2359 (not (gnus-yes-or-no-p
2361 "Do you really want to delete %s%s? "
2362 group-decoded (if force " and all its contents" "")))))
2364 (gnus-message 6 "Deleting group %s..." group-decoded)
2365 (if (not (gnus-request-delete-group group force))
2366 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2367 (gnus-message 6 "Deleting group %s...done" group-decoded)
2368 (gnus-group-goto-group group)
2369 (gnus-group-kill-group 1 t)
2370 (gnus-set-active group nil)
2372 (gnus-group-position-point)))
2374 (defun gnus-group-rename-group (group new-name)
2375 "Rename group from GROUP to NEW-NAME.
2376 When used interactively, GROUP is the group under point
2377 and NEW-NAME will be prompted for."
2380 (gnus-group-group-name)
2382 (unless (gnus-check-backend-function
2383 'request-rename-group (gnus-group-group-name))
2384 (error "This back end does not support renaming groups"))
2385 (gnus-read-group "Rename group to: "
2386 (gnus-group-real-name (gnus-group-group-name))))))
2388 (unless (gnus-check-backend-function 'request-rename-group group)
2389 (error "This back end does not support renaming groups"))
2391 (error "No group to rename"))
2392 (when (equal (gnus-group-real-name group) new-name)
2393 (error "Can't rename to the same name"))
2395 ;; We find the proper prefixed name.
2397 (if (gnus-group-native-p group)
2401 (gnus-group-prefixed-name
2402 (gnus-group-real-name new-name)
2403 (gnus-info-method (gnus-get-info group)))))
2405 (when (gnus-active new-name)
2406 (error "The group %s already exists" new-name))
2408 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2411 (gnus-group-goto-group group)
2412 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2413 (gnus-request-rename-group group new-name))))
2414 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2415 ;; We rename the group internally by killing it...
2416 (gnus-group-kill-group)
2417 ;; ... changing its name ...
2418 (setcar (cdar gnus-list-of-killed-groups) new-name)
2419 ;; ... and then yanking it. Magic!
2420 (gnus-group-yank-group)
2421 (gnus-set-active new-name (gnus-active group))
2422 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2424 (setq gnus-killed-list (delete group gnus-killed-list))
2425 (gnus-set-active group nil)
2426 (gnus-dribble-touch)
2427 (gnus-group-position-point)))
2429 (defun gnus-group-edit-group (group &optional part)
2430 "Edit the group on the current line."
2431 (interactive (list (gnus-group-group-name)))
2432 (let ((part (or part 'info))
2435 (error "No group on current line"))
2436 (unless (setq info (gnus-get-info group))
2437 (error "Killed group; can't be edited"))
2439 (gnus-close-group group))
2441 ;; Find the proper form to edit.
2442 (cond ((eq part 'method)
2443 (or (gnus-info-method info) "native"))
2445 (gnus-info-params info))
2447 ;; The proper documentation.
2449 "Editing the %s for `%s'."
2451 ((eq part 'method) "select method")
2452 ((eq part 'params) "group parameters")
2454 (gnus-group-decoded-name group))
2456 (gnus-group-edit-group-done ',part ,group form)))
2459 (gnus-create-info-command
2462 "(gnus)Select Methods")
2464 "(gnus)Group Parameters")
2466 "(gnus)Group Info"))))))
2468 (defun gnus-group-edit-group-method (group)
2469 "Edit the select method of GROUP."
2470 (interactive (list (gnus-group-group-name)))
2471 (gnus-group-edit-group group 'method))
2473 (defun gnus-group-edit-group-parameters (group)
2474 "Edit the group parameters of GROUP."
2475 (interactive (list (gnus-group-group-name)))
2476 (gnus-group-edit-group group 'params))
2478 (defun gnus-group-edit-group-done (part group form)
2480 (let* ((method (cond ((eq part 'info) (nth 4 form))
2481 ((eq part 'method) form)
2483 (info (cond ((eq part 'info) form)
2484 ((eq part 'method) (gnus-get-info group))
2487 (if (or (not method)
2489 gnus-select-method method))
2490 (gnus-group-real-name (car info))
2491 (gnus-group-prefixed-name
2492 (gnus-group-real-name (car info)) method))
2494 (when (and new-group
2495 (not (equal new-group group)))
2496 (when (gnus-group-goto-group group)
2497 (gnus-group-kill-group 1))
2498 (gnus-activate-group new-group))
2500 (if (not (and info new-group))
2501 (gnus-group-set-info form (or new-group group) part)
2502 (setq info (gnus-copy-sequence info))
2503 (setcar info new-group)
2504 (unless (gnus-server-equal method "native")
2505 (unless (nthcdr 3 info)
2506 (nconc info (list nil nil)))
2507 (unless (nthcdr 4 info)
2508 (nconc info (list nil)))
2509 (gnus-info-set-method info method))
2510 (gnus-group-set-info info))
2511 (gnus-group-update-group (or new-group group))
2512 (gnus-group-position-point)))
2514 (defun gnus-group-make-useful-group (group method)
2515 "Create one of the groups described in `gnus-useful-groups'."
2517 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2519 gnus-useful-groups)))
2520 (list (cadr entry) (caddr entry))))
2521 (setq method (gnus-copy-sequence method))
2523 (while (setq entry (memq (assq 'eval method) method))
2524 (setcar entry (eval (cadar entry)))))
2525 (gnus-group-make-group group method))
2527 (defun gnus-group-make-help-group (&optional noerror)
2528 "Create the Gnus documentation group.
2529 Optional argument NOERROR modifies the behavior of this function when the
2530 group already exists:
2531 - if not given, and error is signaled,
2532 - if t, stay silent,
2533 - if anything else, just print a message."
2535 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2536 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2537 (if (gnus-group-entry name)
2538 (cond ((eq noerror nil)
2539 (error "Documentation group already exists"))
2544 (gnus-message 1 "Documentation group already exists")))
2547 (gnus-message 1 "Couldn't find doc group")
2548 (gnus-group-make-group
2549 (gnus-group-real-name name)
2550 (list 'nndoc "gnus-help"
2551 (list 'nndoc-address file)
2552 (list 'nndoc-article-type 'mbox))))
2554 (gnus-group-position-point))
2556 (defun gnus-group-make-doc-group (file type)
2557 "Create a group that uses a single file as the source.
2559 If called with a prefix argument, ask for the file type."
2561 (list (read-file-name "File name: ")
2562 (and current-prefix-arg 'ask)))
2563 (when (eq type 'ask)
2568 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
2570 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2571 ((= char ?b) 'babyl)
2572 ((= char ?d) 'digest)
2573 ((= char ?f) 'forward)
2575 ((= char ?g) 'guess)
2576 (t (setq err (format "%c unknown. " char))
2579 (let* ((file (expand-file-name file))
2580 (name (gnus-generate-new-group-name
2581 (gnus-group-prefixed-name
2582 (file-name-nondirectory file) '(nndoc "")))))
2583 (gnus-group-make-group
2584 (gnus-group-real-name name)
2586 (list 'nndoc-address file)
2587 (list 'nndoc-article-type (or type 'guess))))))
2589 (defvar nnweb-type-definition)
2590 (defvar gnus-group-web-type-history nil)
2591 (defvar gnus-group-web-search-history nil)
2592 (defun gnus-group-make-web-group (&optional solid)
2593 "Create an ephemeral nnweb group.
2594 If SOLID (the prefix), create a solid group."
2598 (if solid (gnus-read-group "Group name: ")
2599 (message-unique-id)))
2600 (default-type (or (car gnus-group-web-type-history)
2601 (symbol-name (caar nnweb-type-definition))))
2605 (format "Search engine type (default %s): " default-type)
2606 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2607 nnweb-type-definition)
2608 nil t nil 'gnus-group-web-type-history)
2613 (cons (or (car gnus-group-web-search-history) "") 0)
2614 'gnus-group-web-search-history))
2616 `(nnweb ,group (nnweb-search ,search)
2617 (nnweb-type ,(intern type))
2618 (nnweb-ephemeral-p t))))
2621 (gnus-pull 'nnweb-ephemeral-p method)
2622 (gnus-group-make-group group method))
2623 (gnus-group-read-ephemeral-group
2625 (cons (current-buffer)
2626 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2629 (defvar nnrss-group-alist)
2630 (defun nnrss-discover-feed (arg))
2631 (defun nnrss-save-server-data (arg)))
2632 (defun gnus-group-make-rss-group (&optional url)
2633 "Given a URL, discover if there is an RSS feed.
2634 If there is, use Gnus to create an nnrss group"
2638 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2639 (let ((feedinfo (nnrss-discover-feed url)))
2641 (let ((title (gnus-newsgroup-savable-name
2642 (read-from-minibuffer "Title: "
2643 (gnus-newsgroup-savable-name
2644 (or (cdr (assoc 'title
2647 (desc (read-from-minibuffer "Description: "
2648 (cdr (assoc 'description
2650 (href (cdr (assoc 'href feedinfo)))
2651 (encodable (mm-coding-system-p 'utf-8)))
2653 ;; Unify non-ASCII text.
2654 (setq title (mm-decode-coding-string
2655 (mm-encode-coding-string title 'utf-8) 'utf-8)))
2656 (gnus-group-make-group (if encodable
2657 (mm-encode-coding-string title 'utf-8)
2660 (push (list title href desc) nnrss-group-alist)
2661 (nnrss-save-server-data nil))
2662 (error "No feeds found for %s" url))))
2664 (defvar nnwarchive-type-definition)
2665 (defvar gnus-group-warchive-type-history nil)
2666 (defvar gnus-group-warchive-login-history nil)
2667 (defvar gnus-group-warchive-address-history nil)
2669 (defun gnus-group-make-warchive-group ()
2670 "Create a nnwarchive group."
2672 (require 'nnwarchive)
2673 (let* ((group (gnus-read-group "Group name: "))
2674 (default-type (or (car gnus-group-warchive-type-history)
2675 (symbol-name (caar nnwarchive-type-definition))))
2679 (format "Warchive type (default %s): " default-type)
2680 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2681 nnwarchive-type-definition)
2682 nil t nil 'gnus-group-warchive-type-history)
2684 (address (read-string "Warchive address: "
2685 nil 'gnus-group-warchive-address-history))
2686 (default-login (or (car gnus-group-warchive-login-history)
2691 (format "Warchive login (default %s): " user-mail-address)
2692 default-login 'gnus-group-warchive-login-history)
2695 `(nnwarchive ,address
2696 (nnwarchive-type ,(intern type))
2697 (nnwarchive-login ,login))))
2698 (gnus-group-make-group group method)))
2700 (defun gnus-group-make-archive-group (&optional all)
2701 "Create the (ding) Gnus archive group of the most recent articles.
2702 Given a prefix, create a full group."
2704 (let ((group (gnus-group-prefixed-name
2705 (if all "ding.archives" "ding.recent") '(nndir ""))))
2706 (when (gnus-group-entry group)
2707 (error "Archive group already exists"))
2708 (gnus-group-make-group
2709 (gnus-group-real-name group)
2710 (list 'nndir (if all "hpc" "edu")
2711 (list 'nndir-directory
2712 (if all gnus-group-archive-directory
2713 gnus-group-recent-archive-directory))))
2714 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2716 (defun gnus-group-make-directory-group (dir)
2717 "Create an nndir group.
2718 The user will be prompted for a directory. The contents of this
2719 directory will be used as a newsgroup. The directory should contain
2720 mail messages or news articles in files that have numeric names."
2722 (list (read-file-name "Create group from directory: ")))
2723 (unless (file-exists-p dir)
2724 (error "No such directory"))
2725 (unless (file-directory-p dir)
2726 (error "Not a directory"))
2730 (while (or (not group) (gnus-group-entry group))
2732 (gnus-group-prefixed-name
2733 (expand-file-name ext dir)
2735 (setq ext (format "<%d>" (setq i (1+ i)))))
2736 (gnus-group-make-group
2737 (gnus-group-real-name group)
2738 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2740 (defvar nnkiboze-score-file)
2741 (defun gnus-group-make-kiboze-group (group address scores)
2742 "Create an nnkiboze group.
2743 The user will be prompted for a name, a regexp to match groups, and
2744 score file entries for articles to include in the group."
2747 (read-string "nnkiboze group name: ")
2748 (read-string "Source groups (regexp): ")
2749 (let ((headers (mapcar 'list
2750 '("subject" "from" "number" "date" "message-id"
2751 "references" "chars" "lines" "xref"
2752 "followup" "all" "body" "head")))
2753 scores header regexp regexps)
2754 (while (not (equal "" (setq header (completing-read
2755 "Match on header: " headers nil t))))
2757 (while (not (equal "" (setq regexp (read-string
2758 (format "Match on %s (regexp): "
2760 (push (list regexp nil nil 'r) regexps))
2761 (push (cons header regexps) scores))
2763 (gnus-group-make-group group "nnkiboze" address)
2764 (let* ((nnkiboze-current-group group)
2765 (score-file (car (nnkiboze-score-file "")))
2766 (score-dir (file-name-directory score-file)))
2767 (unless (file-exists-p score-dir)
2768 (make-directory score-dir))
2769 (with-temp-file score-file
2770 (let (emacs-lisp-mode-hook)
2771 (gnus-pp scores)))))
2773 (defun gnus-group-add-to-virtual (n vgroup)
2774 "Add the current group to a virtual group."
2776 (list current-prefix-arg
2777 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2779 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2780 (error "%s is not an nnvirtual group" vgroup))
2781 (gnus-close-group vgroup)
2782 (let* ((groups (gnus-group-process-prefix n))
2783 (method (gnus-info-method (gnus-get-info vgroup))))
2784 (setcar (cdr method)
2786 (nth 1 method) "\\|"
2789 (gnus-group-remove-mark s)
2790 (concat "\\(^" (regexp-quote s) "$\\)"))
2792 (gnus-group-position-point))
2794 (defun gnus-group-make-empty-virtual (group)
2795 "Create a new, fresh, empty virtual group."
2796 (interactive "sCreate new, empty virtual group: ")
2797 (let* ((method (list 'nnvirtual "^$"))
2798 (pgroup (gnus-group-prefixed-name group method)))
2799 ;; Check whether it exists already.
2800 (when (gnus-group-entry pgroup)
2801 (error "Group %s already exists" pgroup))
2802 ;; Subscribe the new group after the group on the current line.
2803 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2804 (gnus-group-update-group pgroup)
2806 (gnus-group-position-point)))
2808 (defun gnus-group-enter-directory (dir)
2809 "Enter an ephemeral nneething group."
2810 (interactive "DDirectory to read: ")
2811 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2812 (leaf (gnus-group-prefixed-name
2813 (file-name-nondirectory (directory-file-name dir))
2815 (name (gnus-generate-new-group-name leaf)))
2816 (unless (gnus-group-read-ephemeral-group
2818 (cons (current-buffer)
2819 (if (eq major-mode 'gnus-summary-mode)
2821 (error "Couldn't enter %s" dir))))
2824 (autoload 'nnimap-expunge "nnimap")
2825 (autoload 'nnimap-acl-get "nnimap")
2826 (autoload 'nnimap-acl-edit "nnimap"))
2828 (defun gnus-group-nnimap-expunge (group)
2829 "Expunge deleted articles in current nnimap GROUP."
2830 (interactive (list (gnus-group-group-name)))
2831 (let ((mailbox (gnus-group-real-name group)) method)
2833 (error "No group on current line"))
2834 (unless (gnus-get-info group)
2835 (error "Killed group; can't be edited"))
2836 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2837 (error "%s is not an nnimap group" group))
2838 (nnimap-expunge mailbox (cadr method))))
2840 (defun gnus-group-nnimap-edit-acl (group)
2841 "Edit the Access Control List of current nnimap GROUP."
2842 (interactive (list (gnus-group-group-name)))
2843 (let ((mailbox (gnus-group-real-name group)) method acl)
2845 (error "No group on current line"))
2846 (unless (gnus-get-info group)
2847 (error "Killed group; can't be edited"))
2848 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2849 (error "%s is not an nnimap group" group))
2850 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2851 (error "Server does not support ACL's"))
2852 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2854 An access control list is a list of (identifier . rights) elements.
2856 The identifier string specifies the corresponding user. The
2857 identifier \"anyone\" is reserved to refer to the universal identity.
2859 Rights is a string listing a (possibly empty) set of alphanumeric
2860 characters, each character listing a set of operations which is being
2861 controlled. Letters are reserved for ``standard'' rights, listed
2862 below. Digits are reserved for implementation or site defined rights.
2864 l - lookup (mailbox is visible to LIST/LSUB commands)
2865 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2866 SEARCH, COPY from mailbox)
2867 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2868 w - write (STORE flags other than \\SEEN and \\DELETED)
2869 i - insert (perform APPEND, COPY into mailbox)
2870 p - post (send mail to submission address for mailbox,
2871 not enforced by IMAP4 itself)
2872 c - create and delete mailbox (CREATE new sub-mailboxes in any
2873 implementation-defined hierarchy, RENAME or DELETE mailbox)
2874 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2875 a - administer (perform SETACL)" group)
2878 ,mailbox ',method ',acl form)))))
2880 ;; Group sorting commands
2881 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
2883 (defun gnus-group-sort-groups (func &optional reverse)
2884 "Sort the group buffer according to FUNC.
2885 When used interactively, the sorting function used will be
2886 determined by the `gnus-group-sort-function' variable.
2887 If REVERSE (the prefix), reverse the sorting order."
2888 (interactive (list gnus-group-sort-function current-prefix-arg))
2889 (funcall gnus-group-sort-alist-function
2890 (gnus-make-sort-function func) reverse)
2891 (gnus-group-unmark-all-groups)
2892 (gnus-group-list-groups)
2893 (gnus-dribble-touch))
2895 (defun gnus-group-sort-flat (func reverse)
2896 ;; We peel off the dummy group from the alist.
2898 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
2899 (pop gnus-newsrc-alist))
2901 (setq gnus-newsrc-alist
2902 (sort gnus-newsrc-alist func))
2904 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
2905 ;; Regenerate the hash table.
2906 (gnus-make-hashtable-from-newsrc-alist)))
2908 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
2909 "Sort the group buffer alphabetically by group name.
2910 If REVERSE, sort in reverse order."
2912 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
2914 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
2915 "Sort the group buffer alphabetically by real (unprefixed) group name.
2916 If REVERSE, sort in reverse order."
2918 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
2920 (defun gnus-group-sort-groups-by-unread (&optional reverse)
2921 "Sort the group buffer by number of unread articles.
2922 If REVERSE, sort in reverse order."
2924 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
2926 (defun gnus-group-sort-groups-by-level (&optional reverse)
2927 "Sort the group buffer by group level.
2928 If REVERSE, sort in reverse order."
2930 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
2932 (defun gnus-group-sort-groups-by-score (&optional reverse)
2933 "Sort the group buffer by group score.
2934 If REVERSE, sort in reverse order."
2936 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
2938 (defun gnus-group-sort-groups-by-rank (&optional reverse)
2939 "Sort the group buffer by group rank.
2940 If REVERSE, sort in reverse order."
2942 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
2944 (defun gnus-group-sort-groups-by-method (&optional reverse)
2945 "Sort the group buffer alphabetically by back end name.
2946 If REVERSE, sort in reverse order."
2948 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
2950 (defun gnus-group-sort-groups-by-server (&optional reverse)
2951 "Sort the group buffer alphabetically by server name.
2952 If REVERSE, sort in reverse order."
2954 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
2956 ;;; Selected group sorting.
2958 (defun gnus-group-sort-selected-groups (n func &optional reverse)
2959 "Sort the process/prefixed groups."
2960 (interactive (list current-prefix-arg gnus-group-sort-function))
2961 (let ((groups (gnus-group-process-prefix n)))
2962 (funcall gnus-group-sort-selected-function
2963 groups (gnus-make-sort-function func) reverse)
2964 (gnus-group-unmark-all-groups)
2965 (gnus-group-list-groups)
2966 (gnus-dribble-touch)))
2968 (defun gnus-group-sort-selected-flat (groups func reverse)
2969 (let (entries infos)
2970 ;; First find all the group entries for these groups.
2972 (push (nthcdr 2 (gnus-group-entry (pop groups)))
2974 ;; Then sort the infos.
2978 (lambda (entry) (car entry))
2979 (setq entries (nreverse entries)))
2982 (setq infos (nreverse infos)))
2983 ;; Go through all the infos and replace the old entries
2984 ;; with the new infos.
2986 (setcar (car entries) (pop infos))
2988 ;; Update the hashtable.
2989 (gnus-make-hashtable-from-newsrc-alist)))
2991 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
2992 "Sort the group buffer alphabetically by group name.
2993 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
2994 sort in reverse order."
2995 (interactive (gnus-interactive "P\ny"))
2996 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
2998 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
2999 "Sort the group buffer alphabetically by real group name.
3000 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3001 sort in reverse order."
3002 (interactive (gnus-interactive "P\ny"))
3003 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3005 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3006 "Sort the group buffer by number of unread articles.
3007 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3008 sort in reverse order."
3009 (interactive (gnus-interactive "P\ny"))
3010 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3012 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3013 "Sort the group buffer by group level.
3014 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3015 sort in reverse order."
3016 (interactive (gnus-interactive "P\ny"))
3017 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3019 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3020 "Sort the group buffer by group score.
3021 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3022 sort in reverse order."
3023 (interactive (gnus-interactive "P\ny"))
3024 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3026 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3027 "Sort the group buffer by group rank.
3028 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3029 sort in reverse order."
3030 (interactive (gnus-interactive "P\ny"))
3031 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3033 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3034 "Sort the group buffer alphabetically by back end 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-method reverse))
3040 ;;; Sorting predicates.
3042 (defun gnus-group-sort-by-alphabet (info1 info2)
3043 "Sort alphabetically."
3044 (string< (gnus-info-group info1) (gnus-info-group info2)))
3046 (defun gnus-group-sort-by-real-name (info1 info2)
3047 "Sort alphabetically on real (unprefixed) names."
3048 (string< (gnus-group-real-name (gnus-info-group info1))
3049 (gnus-group-real-name (gnus-info-group info2))))
3051 (defun gnus-group-sort-by-unread (info1 info2)
3052 "Sort by number of unread articles."
3053 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3054 (n2 (gnus-group-unread (gnus-info-group info1))))
3055 (< (or (and (numberp n1) n1) 0)
3056 (or (and (numberp n2) n2) 0))))
3058 (defun gnus-group-sort-by-level (info1 info2)
3060 (< (gnus-info-level info1) (gnus-info-level info2)))
3062 (defun gnus-group-sort-by-method (info1 info2)
3063 "Sort alphabetically by back end name."
3064 (string< (car (gnus-find-method-for-group
3065 (gnus-info-group info1) info1))
3066 (car (gnus-find-method-for-group
3067 (gnus-info-group info2) info2))))
3069 (defun gnus-group-sort-by-server (info1 info2)
3070 "Sort alphabetically by server name."
3071 (string< (gnus-method-to-full-server-name
3072 (gnus-find-method-for-group
3073 (gnus-info-group info1) info1))
3074 (gnus-method-to-full-server-name
3075 (gnus-find-method-for-group
3076 (gnus-info-group info2) info2))))
3078 (defun gnus-group-sort-by-score (info1 info2)
3079 "Sort by group score."
3080 (> (gnus-info-score info1) (gnus-info-score info2)))
3082 (defun gnus-group-sort-by-rank (info1 info2)
3083 "Sort by level and score."
3084 (let ((level1 (gnus-info-level info1))
3085 (level2 (gnus-info-level info2)))
3086 (or (< level1 level2)
3087 (and (= level1 level2)
3088 (> (gnus-info-score info1) (gnus-info-score info2))))))
3092 (defun gnus-group-clear-data (&optional arg)
3093 "Clear all marks and read ranges from the current group.
3094 Obeys the process/prefix convention."
3096 (gnus-group-iterate arg
3099 (gnus-info-clear-data (setq info (gnus-get-info group)))
3100 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3101 (when (gnus-group-goto-group group)
3102 (gnus-group-update-group-line))))))
3104 (defun gnus-group-clear-data-on-native-groups ()
3105 "Clear all marks and read ranges from all native groups."
3107 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3108 (let ((alist (cdr gnus-newsrc-alist))
3110 (while (setq info (pop alist))
3111 (when (gnus-group-native-p (gnus-info-group info))
3112 (gnus-info-clear-data info)))
3113 (gnus-get-unread-articles)
3114 (gnus-dribble-touch)
3115 (when (gnus-y-or-n-p
3116 "Move the cache away to avoid problems in the future? ")
3117 (call-interactively 'gnus-cache-move-cache)))))
3119 (defun gnus-info-clear-data (info)
3120 "Clear all marks and read ranges from INFO."
3121 (let ((group (gnus-info-group info))
3123 (dolist (el (gnus-info-marks info))
3124 (push `(,(cdr el) add (,(car el))) action))
3125 (push `(,(gnus-info-read info) add (read)) action)
3128 (gnus-request-set-mark ,group ',action)
3129 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3130 (gnus-info-set-read ',info ',(gnus-info-read info))
3131 (when (gnus-group-goto-group ,group)
3132 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3133 (gnus-group-update-group-line))))
3134 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3136 (gnus-request-set-mark group action)
3137 (gnus-info-set-read info nil)
3138 (when (gnus-info-marks info)
3139 (gnus-info-set-marks info nil))))
3141 ;; Group catching up.
3143 (defun gnus-group-catchup-current (&optional n all)
3144 "Mark all unread articles in the current newsgroup as read.
3145 If prefix argument N is numeric, the next N newsgroups will be
3146 caught up. If ALL is non-nil, marked articles will also be marked as
3147 read. Cross references (Xref: header) of articles are ignored.
3148 The number of newsgroups that this function was unable to catch
3151 (let ((groups (gnus-group-process-prefix n))
3154 (unless groups (error "No groups selected"))
3156 (or (not gnus-interactive-catchup) ;Without confirmation?
3161 "Do you really want to mark all articles in %s as read? "
3162 "Mark all unread articles in %s as read? ")
3163 (if (= (length groups) 1)
3164 (gnus-group-decoded-name (car groups))
3165 (format "these %d groups" (length groups)))))))
3167 (while (setq group (pop groups))
3168 (gnus-group-remove-mark group)
3169 ;; Virtual groups have to be given special treatment.
3170 (let ((method (gnus-find-method-for-group group)))
3171 (when (eq 'nnvirtual (car method))
3172 (nnvirtual-catchup-group
3173 (gnus-group-real-name group) (nth 1 method) all)))
3174 (if (>= (gnus-group-level group) gnus-level-zombie)
3175 (gnus-message 2 "Dead groups can't be caught up")
3177 (gnus-group-goto-group group)
3178 (gnus-group-catchup group all))
3179 (gnus-group-update-group-line)
3180 (setq ret (1+ ret)))))
3181 (gnus-group-next-unread-group 1)
3184 (defun gnus-group-catchup-current-all (&optional n)
3185 "Mark all articles in current newsgroup as read.
3186 Cross references (Xref: header) of articles are ignored."
3188 (gnus-group-catchup-current n 'all))
3190 (defun gnus-group-catchup (group &optional all)
3191 "Mark all articles in GROUP as read.
3192 If ALL is non-nil, all articles are marked as read.
3193 The return value is the number of articles that were marked as read,
3194 or nil if no action could be taken."
3195 (let* ((entry (gnus-group-entry group))
3197 (marks (gnus-info-marks (nth 2 entry)))
3198 (unread (gnus-sequence-of-unread-articles group)))
3199 ;; Remove entries for this group.
3200 (nnmail-purge-split-history (gnus-group-real-name group))
3201 ;; Do the updating only if the newsgroup isn't killed.
3202 (if (not (numberp (car entry)))
3203 (gnus-message 1 "Can't catch up %s; non-active group" group)
3204 (gnus-update-read-articles group nil)
3206 ;; Nix out the lists of marks and dormants.
3207 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3209 (list (cdr (assq 'dormant marks))
3211 (setq unread (gnus-range-add (gnus-range-add
3212 unread (cdr (assq 'dormant marks)))
3213 (cdr (assq 'tick marks))))
3214 (gnus-add-marked-articles group 'tick nil nil 'force)
3215 (gnus-add-marked-articles group 'dormant nil nil 'force))
3216 ;; Do auto-expirable marks if that's required.
3217 (when (gnus-group-auto-expirable-p group)
3218 (gnus-range-map (lambda (article)
3219 (gnus-add-marked-articles group 'expire (list article))
3220 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3222 (let ((gnus-newsgroup-name group))
3223 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3226 (defun gnus-group-expire-articles (&optional n)
3227 "Expire all expirable articles in the current newsgroup.
3228 Uses the process/prefix convention."
3230 (let ((groups (gnus-group-process-prefix n))
3233 (error "No groups to expire"))
3234 (while (setq group (pop groups))
3235 (gnus-group-remove-mark group)
3236 (gnus-group-expire-articles-1 group)
3237 (gnus-dribble-touch)
3238 (gnus-group-position-point))))
3240 (defun gnus-group-expire-articles-1 (group)
3241 (when (gnus-check-backend-function 'request-expire-articles group)
3242 (gnus-message 6 "Expiring articles in %s..."
3243 (gnus-group-decoded-name group))
3244 (let* ((info (gnus-get-info group))
3245 (expirable (if (gnus-group-total-expirable-p group)
3246 (cons nil (gnus-list-of-read-articles group))
3247 (assq 'expire (gnus-info-marks info))))
3248 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3249 (nnmail-expiry-target
3250 (or (gnus-group-find-parameter group 'expiry-target)
3251 nnmail-expiry-target)))
3253 (gnus-check-group group)
3256 (gnus-compress-sequence
3258 ;; We set the expiry variables to the group
3260 (let ((nnmail-expiry-wait-function nil)
3261 (nnmail-expiry-wait expiry-wait))
3262 (gnus-request-expire-articles
3263 (gnus-uncompress-sequence (cdr expirable)) group))
3264 ;; Just expire using the normal expiry values.
3265 (gnus-request-expire-articles
3266 (gnus-uncompress-sequence (cdr expirable)) group))))
3267 (gnus-close-group group))
3268 (gnus-message 6 "Expiring articles in %s...done"
3269 (gnus-group-decoded-name group))
3270 ;; Return the list of un-expired articles.
3273 (defun gnus-group-expire-all-groups ()
3274 "Expire all expirable articles in all newsgroups."
3277 (gnus-message 5 "Expiring...")
3278 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3279 (cdr gnus-newsrc-alist))))
3280 (gnus-group-expire-articles nil)))
3281 (gnus-group-position-point)
3282 (gnus-message 5 "Expiring...done"))
3284 (defun gnus-group-set-current-level (n level)
3285 "Set the level of the next N groups to LEVEL."
3290 (unless (gnus-group-process-prefix current-prefix-arg)
3291 (error "No group on the current line"))
3293 (let ((s (read-string
3294 (format "Level (default %s): "
3295 (or (gnus-group-group-level)
3296 gnus-level-default-subscribed)))))
3297 (if (string-match "^\\s-*$" s)
3298 (int-to-string (or (gnus-group-group-level)
3299 gnus-level-default-subscribed))
3301 (unless (and (>= level 1) (<= level gnus-level-killed))
3302 (error "Invalid level: %d" level))
3303 (dolist (group (gnus-group-process-prefix n))
3304 (gnus-group-remove-mark group)
3305 (gnus-message 6 "Changed level of %s from %d to %d"
3306 (gnus-group-decoded-name group)
3307 (or (gnus-group-group-level) gnus-level-killed)
3309 (gnus-group-change-level
3310 group level (or (gnus-group-group-level) gnus-level-killed))
3311 (gnus-group-update-group-line))
3312 (gnus-group-position-point))
3314 (defun gnus-group-unsubscribe (&optional n)
3315 "Unsubscribe the current group."
3317 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3319 (defun gnus-group-subscribe (&optional n)
3320 "Subscribe the current group."
3322 (gnus-group-unsubscribe-current-group n 'subscribe))
3324 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3325 "Toggle subscription of the current group.
3326 If given numerical prefix, toggle the N next groups."
3328 (dolist (group (gnus-group-process-prefix n))
3329 (gnus-group-remove-mark group)
3330 (gnus-group-unsubscribe-group
3333 ((eq do-sub 'unsubscribe)
3334 gnus-level-default-unsubscribed)
3335 ((eq do-sub 'subscribe)
3336 gnus-level-default-subscribed)
3337 ((<= (gnus-group-group-level) gnus-level-subscribed)
3338 gnus-level-default-unsubscribed)
3340 gnus-level-default-subscribed))
3342 (gnus-group-update-group-line))
3343 (gnus-group-next-group 1))
3345 (defun gnus-group-unsubscribe-group (group &optional level silent)
3346 "Toggle subscription to GROUP.
3347 Killed newsgroups are subscribed. If SILENT, don't try to update the
3350 (list (completing-read
3351 "Group: " gnus-active-hashtb nil
3352 (gnus-read-active-file-p)
3354 'gnus-group-history)))
3355 (let ((newsrc (gnus-group-entry group)))
3357 ((string-match "^[ \t]*$" group)
3358 (error "Empty group name"))
3360 ;; Toggle subscription flag.
3361 (gnus-group-change-level
3362 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3363 gnus-level-subscribed)
3364 (1+ gnus-level-subscribed)
3365 gnus-level-default-subscribed)))
3367 (gnus-group-update-group group)))
3368 ((and (stringp group)
3369 (or (not (gnus-read-active-file-p))
3370 (gnus-active group)))
3371 ;; Add new newsgroup.
3372 (gnus-group-change-level
3374 (if level level gnus-level-default-subscribed)
3375 (or (and (member group gnus-zombie-list)
3378 (when (gnus-group-group-name)
3379 (gnus-group-entry (gnus-group-group-name))))
3381 (gnus-group-update-group group)))
3382 (t (error "No such newsgroup: %s" group)))
3383 (gnus-group-position-point)))
3385 (defun gnus-group-transpose-groups (n)
3386 "Move the current newsgroup up N places.
3387 If given a negative prefix, move down instead. The difference between
3388 N and the number of steps taken is returned."
3390 (unless (gnus-group-group-name)
3391 (error "No group on current line"))
3392 (gnus-group-kill-group 1)
3394 (forward-line (- n))
3395 (gnus-group-yank-group)
3396 (gnus-group-position-point)))
3398 (defun gnus-group-kill-all-zombies (&optional dummy)
3399 "Kill all zombie newsgroups.
3400 The optional DUMMY should always be nil."
3401 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3403 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3404 (setq gnus-zombie-list nil)
3405 (gnus-dribble-touch)
3406 (gnus-group-list-groups)))
3408 (defun gnus-group-kill-region (begin end)
3409 "Kill newsgroups in current region (excluding current point).
3410 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3423 (beginning-of-line) ;Important when LINES < 1
3424 (gnus-group-kill-group lines)))
3426 (defun gnus-group-kill-group (&optional n discard)
3427 "Kill the next N groups.
3428 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3429 However, only groups that were alive can be yanked; already killed
3430 groups or zombie groups can't be yanked.
3431 The return value is the name of the group that was killed, or a list
3434 (let ((buffer-read-only nil)
3435 (groups (gnus-group-process-prefix n))
3436 group entry level out)
3437 (if (< (length groups) 10)
3438 ;; This is faster when there are few groups.
3440 (push (setq group (pop groups)) out)
3441 (gnus-group-remove-mark group)
3442 (setq level (gnus-group-group-level))
3444 (when (and (not discard)
3445 (setq entry (gnus-group-entry group)))
3448 (gnus-group-goto-group ,(gnus-group-group-name))
3449 (gnus-group-yank-group)))
3450 (push (cons (car entry) (nth 2 entry))
3451 gnus-list-of-killed-groups))
3452 (gnus-group-change-level
3453 (if entry entry group) gnus-level-killed (if entry nil level))
3454 (message "Killed group %s" (gnus-group-decoded-name group)))
3455 ;; If there are lots and lots of groups to be killed, we use
3456 ;; this thing instead.
3457 (dolist (group (nreverse groups))
3458 (gnus-group-remove-mark group)
3460 (push group gnus-killed-list)
3461 (setq gnus-newsrc-alist
3462 (delq (assoc group gnus-newsrc-alist)
3464 (when gnus-group-change-level-function
3465 (funcall gnus-group-change-level-function
3466 group gnus-level-killed 3))
3468 ((setq entry (gnus-group-entry group))
3469 (push (cons (car entry) (nth 2 entry))
3470 gnus-list-of-killed-groups)
3471 (setcdr (cdr entry) (cdddr entry)))
3472 ((member group gnus-zombie-list)
3473 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3474 ;; There may be more than one instance displayed.
3475 (while (gnus-group-goto-group group)
3476 (gnus-delete-line)))
3477 (gnus-make-hashtable-from-newsrc-alist))
3479 (gnus-group-position-point)
3480 (if (< (length out) 2) (car out) (nreverse out))))
3482 (defun gnus-group-yank-group (&optional arg)
3483 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3484 The numeric ARG specifies how many newsgroups are to be yanked. The
3485 name of the newsgroup yanked is returned, or (if several groups are
3486 yanked) a list of yanked groups is returned."
3488 (setq arg (or arg 1))
3489 (let (info group prev out)
3490 (while (>= (decf arg) 0)
3491 (when (not (setq info (pop gnus-list-of-killed-groups)))
3492 (error "No more newsgroups to yank"))
3493 (push (setq group (nth 1 info)) out)
3494 ;; Find which newsgroup to insert this one before - search
3495 ;; backward until something suitable is found. If there are no
3496 ;; other newsgroups in this buffer, just make this newsgroup the
3498 (setq prev (gnus-group-group-name))
3499 (gnus-group-change-level
3500 info (gnus-info-level (cdr info)) gnus-level-killed
3501 (and prev (gnus-group-entry prev))
3503 (gnus-group-insert-group-line-info group)
3505 `(when (gnus-group-goto-group ,group)
3506 (gnus-group-kill-group 1))))
3508 (gnus-group-position-point)
3509 (if (< (length out) 2) (car out) (nreverse out))))
3511 (defun gnus-group-kill-level (level)
3512 "Kill all groups that is on a certain LEVEL."
3513 (interactive "nKill all groups on level: ")
3515 ((= level gnus-level-zombie)
3516 (setq gnus-killed-list
3517 (nconc gnus-zombie-list gnus-killed-list))
3518 (setq gnus-zombie-list nil))
3519 ((and (< level gnus-level-zombie)
3521 (or gnus-expert-user
3524 "Do you really want to kill all groups on level %d? "
3526 (let* ((prev gnus-newsrc-alist)
3529 (if (= (gnus-info-level (car alist)) level)
3531 (push (gnus-info-group (car alist)) gnus-killed-list)
3532 (setcdr prev (cdr alist)))
3534 (setq alist (cdr alist)))
3535 (gnus-make-hashtable-from-newsrc-alist)
3536 (gnus-group-list-groups)))
3538 (error "Can't kill; invalid level: %d" level))))
3540 (defun gnus-group-list-all-groups (&optional arg)
3541 "List all newsgroups with level ARG or lower.
3542 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3543 unsubscribed groups."
3545 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3547 ;; Redefine this to list ALL killed groups if prefix arg used.
3548 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3549 (defun gnus-group-list-killed (&optional arg)
3550 "List all killed newsgroups in the group buffer.
3551 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3552 entail asking the server for the groups."
3554 ;; Find all possible killed newsgroups if arg.
3556 (gnus-get-killed-groups))
3557 (if (not gnus-killed-list)
3558 (gnus-message 6 "No killed groups")
3559 (let (gnus-group-list-mode)
3560 (funcall gnus-group-prepare-function
3561 gnus-level-killed t gnus-level-killed))
3562 (goto-char (point-min)))
3563 (gnus-group-position-point))
3565 (defun gnus-group-list-zombies ()
3566 "List all zombie newsgroups in the group buffer."
3568 (if (not gnus-zombie-list)
3569 (gnus-message 6 "No zombie groups")
3570 (let (gnus-group-list-mode)
3571 (funcall gnus-group-prepare-function
3572 gnus-level-zombie t gnus-level-zombie))
3573 (goto-char (point-min)))
3574 (gnus-group-position-point))
3576 (defun gnus-group-list-active ()
3577 "List all groups that are available from the server(s)."
3579 ;; First we make sure that we have really read the active file.
3580 (unless (gnus-read-active-file-p)
3581 (let ((gnus-read-active-file t)
3582 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3583 (gnus-read-active-file)))
3584 ;; Find all groups and sort them.
3592 (push (symbol-name sym) list)))
3596 (buffer-read-only nil)
3600 (setq group (pop groups))
3601 (gnus-add-text-properties
3602 (point) (prog1 (1+ (point))
3604 (gnus-group-decoded-name group)
3606 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3608 'gnus-level (inline (gnus-group-level group)))))
3609 (goto-char (point-min))))
3611 (defun gnus-activate-all-groups (level)
3612 "Activate absolutely all groups."
3613 (interactive (list gnus-level-unsubscribed))
3614 (let ((gnus-activate-level level)
3615 (gnus-activate-foreign-newsgroups level))
3616 (gnus-group-get-new-news)))
3618 (defun gnus-group-get-new-news (&optional arg)
3619 "Get newly arrived articles.
3620 If ARG is a number, it specifies which levels you are interested in
3621 re-scanning. If ARG is non-nil and not a number, this will force
3622 \"hard\" re-reading of the active files from all servers."
3625 (let ((gnus-inhibit-demon t)
3626 ;; Binding this variable will inhibit multiple fetchings
3627 ;; of the same mail source.
3628 (nnmail-fetched-sources (list t)))
3629 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3630 (gnus-run-hooks 'gnus-get-new-news-hook)
3632 ;; Read any slave files.
3634 (gnus-master-read-slave-newsrc))
3636 ;; We might read in new NoCeM messages here.
3637 (when (and gnus-use-nocem
3639 (gnus-nocem-scan-groups))
3640 ;; If ARG is not a number, then we read the active file.
3641 (when (and arg (not (numberp arg)))
3642 (let ((gnus-read-active-file t))
3643 (gnus-read-active-file))
3646 ;; If the user wants it, we scan for new groups.
3647 (when (eq gnus-check-new-newsgroups 'always)
3648 (gnus-find-new-newsgroups)))
3650 (setq arg (gnus-group-default-level arg t))
3651 (if (and gnus-read-active-file (not arg))
3653 (gnus-read-active-file)
3654 (gnus-get-unread-articles arg))
3655 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3656 (gnus-get-unread-articles arg)))
3657 (gnus-check-reasonable-setup)
3658 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3659 (gnus-group-list-groups (and (numberp arg)
3660 (max (car gnus-group-list-mode) arg)))))
3662 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3663 "Check for newly arrived news in the current group (and the N-1 next groups).
3664 The difference between N and the number of newsgroup checked is returned.
3665 If N is negative, this group and the N-1 previous groups will be checked.
3666 If DONT-SCAN is non-nil, scan non-activated groups as well."
3668 (let* ((groups (gnus-group-process-prefix n))
3669 (ret (if (numberp n) (- n (length groups)) 0))
3673 (gnus-inhibit-demon t)
3674 ;; Binding this variable will inhibit multiple fetchings
3675 ;; of the same mail source.
3676 (nnmail-fetched-sources (list t)))
3677 (gnus-run-hooks 'gnus-get-new-news-hook)
3678 (while (setq group (pop groups))
3679 (gnus-group-remove-mark group)
3680 ;; Bypass any previous denials from the server.
3681 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3682 (if (gnus-activate-group group (if dont-scan nil 'scan) nil method)
3683 (let ((info (gnus-get-info group))
3684 (active (gnus-active group)))
3686 (gnus-request-update-info info method))
3687 (gnus-get-unread-articles-in-group info active)
3688 (unless (gnus-virtual-group-p group)
3689 (gnus-close-group group))
3691 (gnus-agent-save-group-info
3692 method (gnus-group-real-name group) active))
3693 (gnus-group-update-group group))
3694 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3696 (gnus-error 3 "Server denied access")
3697 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3700 (when gnus-goto-next-group-when-activating
3701 (gnus-group-next-unread-group 1 t))
3702 (gnus-summary-position-point)
3705 (defun gnus-group-fetch-faq (group &optional faq-dir)
3706 "Fetch the FAQ for the current group.
3707 If given a prefix argument, prompt for the FAQ dir
3711 (gnus-group-group-name)
3712 (when current-prefix-arg
3714 "FAQ dir: " (and (listp gnus-group-faq-directory)
3716 gnus-group-faq-directory))))))
3718 (error "No group name given"))
3719 (let ((dirs (or faq-dir gnus-group-faq-directory))
3721 (unless (listp dirs)
3722 (setq dirs (list dirs)))
3723 (while (and (not found)
3724 (setq dir (pop dirs)))
3725 (let ((name (gnus-group-real-name group)))
3726 (setq file (expand-file-name name dir)))
3727 (if (not (file-exists-p file))
3728 (gnus-message 1 "No such file: %s" file)
3729 (let ((enable-local-variables nil))
3733 (defun gnus-group-fetch-charter (group)
3734 "Fetch the charter for the current group.
3735 If given a prefix argument, prompt for a group."
3737 (list (or (when current-prefix-arg
3738 (completing-read "Group: " gnus-active-hashtb))
3739 (gnus-group-group-name)
3740 gnus-newsgroup-name)))
3742 (error "No group name given"))
3744 (condition-case nil (require 'url-http) (error nil))
3745 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3747 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3748 (setq hierarchy (match-string 1 name))
3749 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3750 (if (fboundp 'url-http-file-exists-p)
3751 (url-http-file-exists-p (eval url))
3753 (browse-url (eval url))
3754 (setq url (concat "http://" hierarchy
3755 ".news-admin.org/charters/" name))
3756 (if (and (fboundp 'url-http-file-exists-p)
3757 (url-http-file-exists-p url))
3759 (gnus-group-fetch-control group))))))
3761 (defun gnus-group-fetch-control (group)
3762 "Fetch the archived control messages for the current group.
3763 If given a prefix argument, prompt for a group."
3765 (list (or (when current-prefix-arg
3766 (completing-read "Group: " gnus-active-hashtb))
3767 (gnus-group-group-name)
3768 gnus-newsgroup-name)))
3770 (error "No group name given"))
3771 (let ((name (gnus-group-real-name group))
3773 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3774 (setq hierarchy (match-string 1 name))
3775 (if gnus-group-fetch-control-use-browse-url
3776 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3777 hierarchy "/" name ".gz"))
3778 (let ((enable-local-variables nil))
3779 (gnus-group-read-ephemeral-group
3781 `(nndoc ,group (nndoc-address
3782 ,(find-file-noselect
3783 (concat "/ftp@ftp.isc.org:/usenet/control/"
3784 hierarchy "/" name ".gz")))
3785 (nndoc-article-type mbox)) t nil nil))))))
3787 (defun gnus-group-describe-group (force &optional group)
3788 "Display a description of the current newsgroup."
3789 (interactive (list current-prefix-arg (gnus-group-group-name)))
3790 (let* ((method (gnus-find-method-for-group group))
3791 (mname (gnus-group-prefixed-name "" method))
3794 gnus-description-hashtb)
3795 (gnus-sethash mname nil gnus-description-hashtb))
3797 (error "No group name given"))
3798 (when (or (and gnus-description-hashtb
3799 ;; We check whether this group's method has been
3800 ;; queried for a description file.
3801 (gnus-gethash mname gnus-description-hashtb))
3802 (setq desc (gnus-group-get-description group))
3803 (gnus-read-descriptions-file method))
3805 (or desc (gnus-gethash group gnus-description-hashtb)
3806 "No description available")))))
3808 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3809 (defun gnus-group-describe-all-groups (&optional force)
3810 "Pop up a buffer with descriptions of all newsgroups."
3813 (setq gnus-description-hashtb nil))
3814 (when (not (or gnus-description-hashtb
3815 (gnus-read-all-descriptions-files)))
3816 (error "Couldn't request descriptions file"))
3817 (let ((buffer-read-only nil)
3823 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3824 (insert (format " *: %-20s %s\n"
3825 (gnus-group-name-decode
3826 (symbol-name group) charset)
3827 (gnus-group-name-decode
3828 (symbol-value group) charset))))
3829 (gnus-add-text-properties
3830 b (1+ b) (list 'gnus-group group
3831 'gnus-unread t 'gnus-marked nil
3832 'gnus-level (1+ gnus-level-subscribed))))
3833 gnus-description-hashtb)
3834 (goto-char (point-min))
3835 (gnus-group-position-point)))
3837 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3838 (defun gnus-group-apropos (regexp &optional search-description)
3839 "List all newsgroups that have names that match a regexp."
3840 (interactive "sGnus apropos (regexp): ")
3842 (obuf (current-buffer))
3844 ;; Go through all newsgroups that are known to Gnus.
3847 (and (symbol-name group)
3848 (string-match regexp (symbol-name group))
3849 (symbol-value group)
3850 (push (symbol-name group) groups)))
3852 ;; Also go through all descriptions that are known to Gnus.
3853 (when search-description
3856 (and (string-match regexp (symbol-value group))
3857 (push (symbol-name group) groups)))
3858 gnus-description-hashtb))
3860 (gnus-message 3 "No groups matched \"%s\"." regexp)
3861 ;; Print out all the groups.
3863 (pop-to-buffer "*Gnus Help*")
3864 (buffer-disable-undo)
3866 (setq groups (sort groups 'string<))
3868 ;; Groups may be entered twice into the list of groups.
3869 (when (not (string= (car groups) prev))
3870 (setq prev (car groups))
3871 (let ((charset (gnus-group-name-charset nil prev)))
3872 (insert (gnus-group-name-decode prev charset) "\n")
3873 (when (and gnus-description-hashtb
3874 (setq des (gnus-gethash (car groups)
3875 gnus-description-hashtb)))
3876 (insert " " (gnus-group-name-decode des charset) "\n"))))
3877 (setq groups (cdr groups)))
3878 (goto-char (point-min))))
3879 (pop-to-buffer obuf)))
3881 (defun gnus-group-description-apropos (regexp)
3882 "List all newsgroups that have names or descriptions that match REGEXP."
3883 (interactive "sGnus description apropos (regexp): ")
3884 (when (not (or gnus-description-hashtb
3885 (gnus-read-all-descriptions-files)))
3886 (error "Couldn't request descriptions file"))
3887 (gnus-group-apropos regexp t))
3889 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3890 (defun gnus-group-list-matching (level regexp &optional all lowest)
3891 "List all groups with unread articles that match REGEXP.
3892 If the prefix LEVEL is non-nil, it should be a number that says which
3893 level to cut off listing groups.
3894 If ALL, also list groups with no unread articles.
3895 If LOWEST, don't list groups with level lower than LOWEST.
3897 This command may read the active file."
3898 (interactive "P\nsList newsgroups matching: ")
3899 ;; First make sure active file has been read.
3901 (> (prefix-numeric-value level) gnus-level-killed))
3902 (gnus-get-killed-groups))
3903 (funcall gnus-group-prepare-function
3904 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
3905 (goto-char (point-min))
3906 (gnus-group-position-point))
3908 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3909 "List all groups that match REGEXP.
3910 If the prefix LEVEL is non-nil, it should be a number that says which
3911 level to cut off listing groups.
3912 If LOWEST, don't list groups with level lower than LOWEST."
3913 (interactive "P\nsList newsgroups matching: ")
3915 (setq level (prefix-numeric-value level)))
3916 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
3918 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3919 (defun gnus-group-save-newsrc (&optional force)
3920 "Save the Gnus startup files.
3921 If FORCE, force saving whether it is necessary or not."
3923 (gnus-save-newsrc-file force))
3925 (defun gnus-group-restart (&optional arg)
3926 "Force Gnus to read the .newsrc file."
3928 (when (gnus-yes-or-no-p
3929 (format "Are you sure you want to restart Gnus? "))
3930 (gnus-save-newsrc-file)
3934 (defun gnus-group-read-init-file ()
3935 "Read the Gnus elisp init file."
3937 (gnus-read-init-file)
3938 (gnus-message 5 "Read %s" gnus-init-file))
3940 (defun gnus-group-check-bogus-groups (&optional silent)
3941 "Check bogus newsgroups.
3942 If given a prefix, don't ask for confirmation before removing a bogus
3945 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
3946 (gnus-group-list-groups))
3948 (defun gnus-group-find-new-groups (&optional arg)
3949 "Search for new groups and add them.
3950 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
3951 With 1 C-u, use the `ask-server' method to query the server for new
3953 With 2 C-u's, use most complete method possible to query the server
3954 for new groups, and subscribe the new groups as zombies."
3956 (gnus-find-new-newsgroups (or arg 1))
3957 (gnus-group-list-groups))
3959 (defun gnus-group-edit-global-kill (&optional article group)
3960 "Edit the global kill file.
3961 If GROUP, edit that local kill file instead."
3963 (setq gnus-current-kill-article article)
3964 (gnus-kill-file-edit-file group)
3967 (substitute-command-keys
3968 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
3969 (if group "local" "global")))))
3971 (defun gnus-group-edit-local-kill (article group)
3972 "Edit a local kill file."
3973 (interactive (list nil (gnus-group-group-name)))
3974 (gnus-group-edit-global-kill article group))
3976 (defun gnus-group-force-update ()
3977 "Update `.newsrc' file."
3979 (gnus-save-newsrc-file))
3981 (defvar gnus-backlog-articles)
3983 (defun gnus-group-suspend ()
3984 "Suspend the current Gnus session.
3985 In fact, cleanup buffers except for group mode buffer.
3986 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
3988 (gnus-run-hooks 'gnus-suspend-gnus-hook)
3989 (gnus-offer-save-summaries)
3990 ;; Kill Gnus buffers except for group mode buffer.
3991 (let ((group-buf (get-buffer gnus-group-buffer)))
3992 (mapcar (lambda (buf)
3993 (unless (or (member buf (list group-buf gnus-dribble-buffer))
3994 (with-current-buffer buf
3995 (eq major-mode 'message-mode)))
3996 (gnus-kill-buffer buf)))
3998 (setq gnus-backlog-articles nil)
3999 (gnus-kill-gnus-frames)
4001 (bury-buffer group-buf)
4002 (delete-windows-on group-buf t))))
4004 (defun gnus-group-clear-dribble ()
4005 "Clear all information from the dribble buffer."
4007 (gnus-dribble-clear)
4008 (gnus-message 7 "Cleared dribble buffer"))
4010 (defun gnus-group-exit ()
4011 "Quit reading news after updating .newsrc.eld and .newsrc.
4012 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4015 (or noninteractive ;For gnus-batch-kill
4016 (not gnus-interactive-exit) ;Without confirmation
4018 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4019 (gnus-run-hooks 'gnus-exit-gnus-hook)
4020 ;; Offer to save data from non-quitted summary buffers.
4021 (gnus-offer-save-summaries)
4022 ;; Save the newsrc file(s).
4023 (gnus-save-newsrc-file)
4025 (gnus-close-backends)
4026 ;; Reset everything.
4028 ;; Allow the user to do things after cleaning up.
4029 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4031 (defun gnus-group-quit ()
4032 "Quit reading news without updating .newsrc.eld or .newsrc.
4033 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4035 (when (or noninteractive ;For gnus-batch-kill
4036 (zerop (buffer-size))
4037 (not (gnus-server-opened gnus-select-method))
4039 (not gnus-current-startup-file)
4041 (format "Quit reading news without saving %s? "
4042 (file-name-nondirectory gnus-current-startup-file))))
4043 (gnus-run-hooks 'gnus-exit-gnus-hook)
4044 (gnus-configure-windows 'group t)
4045 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4046 (not (zerop (save-excursion
4047 (set-buffer gnus-dribble-buffer)
4050 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4052 (gnus-close-backends)
4054 (gnus-kill-buffer gnus-group-buffer)
4055 ;; Allow the user to do things after cleaning up.
4056 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4058 (defun gnus-group-describe-briefly ()
4059 "Give a one line description of the group mode commands."
4061 (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")))
4063 (defun gnus-group-browse-foreign-server (method)
4064 "Browse a foreign news server.
4065 If called interactively, this function will ask for a select method
4066 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4067 If not, METHOD should be a list where the first element is the method
4068 and the second element is the address."
4070 (list (let ((how (completing-read
4072 (append gnus-valid-select-methods gnus-server-alist)
4073 nil t (cons "nntp" 0) 'gnus-method-history)))
4074 ;; We either got a back end name or a virtual server name.
4075 ;; If the first, we also need an address.
4076 (if (assoc how gnus-valid-select-methods)
4078 ;; Suggested by mapjph@bath.ac.uk.
4081 (mapcar 'list gnus-secondary-servers)))
4082 ;; We got a server name.
4084 (gnus-browse-foreign-server method))
4086 (defun gnus-group-set-info (info &optional method-only-group part)
4087 (when (or info part)
4088 (let* ((entry (gnus-group-entry
4089 (or method-only-group (gnus-info-group info))))
4091 (info (if method-only-group (nth 2 entry) info))
4093 (when method-only-group
4095 (error "Trying to change non-existent group %s" method-only-group))
4096 ;; We have received parts of the actual group info - either the
4097 ;; select method or the group parameters. We first check
4098 ;; whether we have to extend the info, and if so, do that.
4099 (let ((len (length info))
4100 (total (if (eq part 'method) 5 6)))
4102 (setcdr (nthcdr (1- len) info)
4103 (make-list (- total len) nil)))
4104 ;; Then we enter the new info.
4105 (setcar (nthcdr (1- total) info) part-info)))
4107 ;; This is a new group, so we just create it.
4109 (set-buffer gnus-group-buffer)
4110 (setq method (gnus-info-method info))
4111 (when (gnus-server-equal method "native")
4114 (set-buffer gnus-group-buffer)
4116 ;; It's a foreign group...
4117 (gnus-group-make-group
4118 (gnus-group-real-name (gnus-info-group info))
4119 (if (stringp method) method
4120 (prin1-to-string (car method)))
4122 (nth 1 (gnus-info-method info))))
4123 ;; It's a native group.
4124 (gnus-group-make-group (gnus-info-group info))))
4125 (gnus-message 6 "Note: New group created")
4127 (gnus-group-entry (gnus-group-prefixed-name
4128 (gnus-group-real-name (gnus-info-group info))
4129 (or (gnus-info-method info) gnus-select-method))))))
4130 ;; Whether it was a new group or not, we now have the entry, so we
4131 ;; can do the update.
4134 (setcar (nthcdr 2 entry) info)
4135 (when (and (not (eq (car entry) t))
4136 (gnus-active (gnus-info-group info)))
4137 (setcar entry (length
4138 (gnus-list-of-unread-articles (car info))))))
4139 (error "No such group: %s" (gnus-info-group info))))))
4141 (defun gnus-group-set-method-info (group select-method)
4142 (gnus-group-set-info select-method group 'method))
4144 (defun gnus-group-set-params-info (group params)
4145 (gnus-group-set-info params group 'params))
4147 (defun gnus-add-marked-articles (group type articles &optional info force)
4148 ;; Add ARTICLES of TYPE to the info of GROUP.
4149 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4150 ;; add, but replace marked articles of TYPE with ARTICLES.
4151 (let ((info (or info (gnus-get-info group)))
4154 (and (not (setq marked (nthcdr 3 info)))
4156 (setcdr (nthcdr 2 info)
4157 (list (list (cons type (gnus-compress-sequence
4159 (and (not (setq m (assq type (car marked))))
4162 (cons (cons type (gnus-compress-sequence articles t) )
4166 (setcar (nthcdr 3 info)
4167 (gnus-delete-alist type (car marked)))
4168 (setcdr m (gnus-compress-sequence articles t)))
4169 (setcdr m (gnus-compress-sequence
4170 (sort (nconc (gnus-uncompress-range (cdr m))
4171 (copy-sequence articles)) '<) t))))))
4173 (defun gnus-add-mark (group mark article)
4174 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4175 (let ((buffer (gnus-summary-buffer-name group)))
4176 (if (gnus-buffer-live-p buffer)
4178 (set-buffer (get-buffer buffer))
4179 (gnus-summary-add-mark article mark))
4180 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4184 ;;; Group timestamps
4187 (defun gnus-group-set-timestamp ()
4188 "Change the timestamp of the current group to the current time.
4189 This function can be used in hooks like `gnus-select-group-hook'
4190 or `gnus-group-catchup-group-hook'."
4191 (when gnus-newsgroup-name
4192 (let ((time (current-time)))
4193 (setcdr (cdr time) nil)
4194 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4196 (defsubst gnus-group-timestamp (group)
4197 "Return the timestamp for GROUP."
4198 (gnus-group-get-parameter group 'timestamp t))
4200 (defun gnus-group-timestamp-delta (group)
4201 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4202 (let* ((time (or (gnus-group-timestamp group)
4204 (delta (subtract-time (current-time) time)))
4205 (+ (* (nth 0 delta) 65536.0)
4208 (defun gnus-group-timestamp-string (group)
4209 "Return a string of the timestamp for GROUP."
4210 (let ((time (gnus-group-timestamp group)))
4213 (gnus-time-iso8601 time))))
4215 (defun gnus-group-list-cached (level &optional lowest)
4216 "List all groups with cached articles.
4217 If the prefix LEVEL is non-nil, it should be a number that says which
4218 level to cut off listing groups.
4219 If LOWEST, don't list groups with level lower than LOWEST.
4221 This command may read the active file."
4224 (setq level (prefix-numeric-value level)))
4225 (when (or (not level) (>= level gnus-level-zombie))
4227 (funcall gnus-group-prepare-function
4228 (or level gnus-level-subscribed)
4230 (let ((marks (gnus-info-marks info)))
4231 (assq 'cache marks)))
4234 (or (gnus-gethash group
4235 gnus-cache-active-hashtb)
4236 ;; Cache active file might use "."
4239 (mapconcat 'identity
4240 (split-string group ":")
4242 gnus-cache-active-hashtb))))
4243 (goto-char (point-min))
4244 (gnus-group-position-point))
4246 (defun gnus-group-list-dormant (level &optional lowest)
4247 "List all groups with dormant articles.
4248 If the prefix LEVEL is non-nil, it should be a number that says which
4249 level to cut off listing groups.
4250 If LOWEST, don't list groups with level lower than LOWEST.
4252 This command may read the active file."
4255 (setq level (prefix-numeric-value level)))
4256 (when (or (not level) (>= level gnus-level-zombie))
4258 (funcall gnus-group-prepare-function
4259 (or level gnus-level-subscribed)
4261 (let ((marks (gnus-info-marks info)))
4262 (assq 'dormant marks)))
4265 (goto-char (point-min))
4266 (gnus-group-position-point))
4268 (defun gnus-group-listed-groups ()
4269 "Return a list of listed groups."
4271 (goto-char (point-min))
4272 (while (setq point (text-property-not-all (point) (point-max)
4275 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4279 (defun gnus-group-list-plus (&optional args)
4280 "List groups plus the current selection."
4282 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4283 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4285 (push last-command-event unread-command-events)
4286 (if (featurep 'xemacs)
4287 (push (make-event 'key-press '(key ?A)) unread-command-events)
4288 (push ?A unread-command-events))
4289 (let (gnus-pick-mode keys)
4290 (setq keys (if (featurep 'xemacs)
4291 (events-to-keys (read-key-sequence nil))
4292 (read-key-sequence nil)))
4293 (setq func (lookup-key (current-local-map) keys)))
4297 (call-interactively func))))
4299 (defun gnus-group-list-flush (&optional args)
4300 "Flush groups from the current selection."
4302 (let ((gnus-group-list-option 'flush))
4303 (gnus-group-list-plus args)))
4305 (defun gnus-group-list-limit (&optional args)
4306 "List groups limited within the current selection."
4308 (let ((gnus-group-list-option 'limit))
4309 (gnus-group-list-plus args)))
4311 (defun gnus-group-mark-article-read (group article)
4312 "Mark ARTICLE read."
4313 (let ((buffer (gnus-summary-buffer-name group))
4314 (mark gnus-read-mark)
4316 (if (get-buffer buffer)
4317 (with-current-buffer buffer
4318 (setq active gnus-newsgroup-active)
4319 (gnus-activate-group group)
4320 (when gnus-newsgroup-prepared
4321 (when (and gnus-newsgroup-auto-expire
4322 (memq mark gnus-auto-expirable-marks))
4323 (setq mark gnus-expirable-mark))
4324 (setq mark (gnus-request-update-mark
4325 group article mark))
4326 (gnus-mark-article-as-read article mark)
4327 (setq gnus-newsgroup-active (gnus-active group))
4329 (setq n (1+ (cdr active)))
4330 (while (<= n (cdr gnus-newsgroup-active))
4331 (unless (eq n article)
4332 (push n gnus-newsgroup-unselected))
4334 (setq gnus-newsgroup-unselected
4335 (nreverse gnus-newsgroup-unselected)))))
4336 (gnus-activate-group group)
4337 (gnus-group-make-articles-read group (list article))
4338 (when (gnus-group-auto-expirable-p group)
4339 (gnus-add-marked-articles
4340 group 'expire (list article))))))
4342 (provide 'gnus-group)
4344 ;;; arch-tag: 2eb5440f-0bca-4091-814c-e37817536af6
4345 ;;; gnus-group.el ends here