1 ;;; gnus-group.el --- group mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, 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-mode))
48 (let ((features (cons 'gnus-group features)))
50 (defvar gnus-cache-active-hashtb))
52 (defcustom gnus-group-archive-directory
53 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
54 "*The address of the (ding) archives."
55 :group 'gnus-group-foreign
58 (defcustom gnus-group-recent-archive-directory
59 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
60 "*The address of the most recent (ding) articles."
61 :group 'gnus-group-foreign
64 (defcustom gnus-no-groups-message "No gnus is bad news"
65 "*Message displayed by Gnus when no groups are available."
69 (defcustom gnus-keep-same-level nil
70 "*Non-nil means that the next newsgroup after the current will be on the same level.
71 When you type, for instance, `n' after reading the last article in the
72 current newsgroup, you will go to the next newsgroup. If this variable
73 is nil, the next newsgroup will be the next from the group
75 If this variable is non-nil, Gnus will either put you in the
76 next newsgroup with the same level, or, if no such newsgroup is
77 available, the next newsgroup with the lowest possible level higher
78 than the current level.
79 If this variable is `best', Gnus will make the next newsgroup the one
81 :group 'gnus-group-levels
82 :type '(choice (const nil)
84 (sexp :tag "other" t)))
86 (defcustom gnus-group-goto-unread t
87 "*If non-nil, movement commands will go to the next unread and subscribed group."
88 :link '(custom-manual "(gnus)Group Maneuvering")
89 :group 'gnus-group-various
92 (defcustom gnus-goto-next-group-when-activating t
93 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
94 :link '(custom-manual "(gnus)Scanning New Messages")
95 :group 'gnus-group-various
98 (defcustom gnus-permanently-visible-groups nil
99 "*Regexp to match groups that should always be listed in the group buffer.
100 This means that they will still be listed even when there are no
101 unread articles in the groups.
103 If nil, no groups are permanently visible."
104 :group 'gnus-group-listing
105 :type '(choice regexp (const nil)))
107 (defcustom gnus-list-groups-with-ticked-articles t
108 "*If non-nil, list groups that have only ticked articles.
109 If nil, only list groups that have unread articles."
110 :group 'gnus-group-listing
113 (defcustom gnus-group-default-list-level gnus-level-subscribed
114 "*Default listing level.
115 Ignored if `gnus-group-use-permanent-levels' is non-nil."
116 :group 'gnus-group-listing
119 (defcustom gnus-group-list-inactive-groups t
120 "*If non-nil, inactive groups will be listed."
121 :group 'gnus-group-listing
122 :group 'gnus-group-levels
125 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
126 "*Function used for sorting the group buffer.
127 This function will be called with group info entries as the arguments
128 for the groups to be sorted. Pre-made functions include
129 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
130 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
131 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
132 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
134 This variable can also be a list of sorting functions. In that case,
135 the most significant sort function should be the last function in the
137 :group 'gnus-group-listing
138 :link '(custom-manual "(gnus)Sorting Groups")
139 :type '(repeat :value-to-internal (lambda (widget value)
140 (if (listp value) value (list value)))
141 :match (lambda (widget value)
143 (widget-editable-list-match widget value)))
144 (choice (function-item gnus-group-sort-by-alphabet)
145 (function-item gnus-group-sort-by-real-name)
146 (function-item gnus-group-sort-by-unread)
147 (function-item gnus-group-sort-by-level)
148 (function-item gnus-group-sort-by-score)
149 (function-item gnus-group-sort-by-method)
150 (function-item gnus-group-sort-by-server)
151 (function-item gnus-group-sort-by-rank)
152 (function :tag "other" nil))))
154 (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y:%B%(%g%)%l %O\n"
155 "*Format of group lines.
156 It works along the same lines as a normal formatting string,
157 with some simple extensions.
159 %M Only marked articles (character, \"*\" or \" \")
160 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
161 %L Level of subscribedness (integer)
162 %N Number of unread articles (integer)
163 %I Number of dormant articles (integer)
164 %i Number of ticked and dormant (integer)
165 %T Number of ticked articles (integer)
166 %R Number of read articles (integer)
167 %U Number of unseen articles (integer)
168 %t Estimated total number of articles (integer)
169 %y Number of unread, unticked articles (integer)
170 %G Group name (string)
171 %g Qualified group name (string)
172 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
173 %C Group comment (string)
174 %D Group description (string)
175 %s Select method (string)
176 %o Moderated group (char, \"m\")
177 %p Process mark (char)
178 %B Whether a summary buffer for the group is open (char, \"*\")
179 %O Moderated group (string, \"(m)\" or \"\")
180 %P Topic indentation (string)
181 %m Whether there is new(ish) mail in the group (char, \"%\")
182 %l Whether there are GroupLens predictions for this group (string)
183 %n Select from where (string)
184 %z A string that look like `<%s:%n>' if a foreign select method is used
185 %d The date the group was last entered.
186 %E Icon as defined by `gnus-group-icon-list'.
187 %u User defined specifier. The next character in the format string should
188 be a letter. Gnus will call the function gnus-user-format-function-X,
189 where X is the letter following %u. The function will be passed a
190 single dummy parameter as argument. The function should return a
191 string, which will be inserted into the buffer just like information
192 from any other group specifier.
194 Note that this format specification is not always respected. For
195 reasons of efficiency, when listing killed groups, this specification
196 is ignored altogether. If the spec is changed considerably, your
197 output may end up looking strange when listing both alive and killed
200 If you use %o or %O, reading the active file will be slower and quite
201 a bit of extra memory will be used. %D will also worsen performance.
202 Also note that if you change the format specification to include any
203 of these specs, you must probably re-start Gnus to see them go into
206 General format specifiers can also be used.
207 See Info node `(gnus)Formatting Variables'."
208 :link '(custom-manual "(gnus)Formatting Variables")
209 :group 'gnus-group-visual
212 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}"
213 "*The format specification for the group mode line.
214 It works along the same lines as a normal formatting string,
215 with some simple extensions:
217 %S The native news server.
218 %M The native select method.
219 %: \":\" if %S isn't \"\"."
220 :group 'gnus-group-visual
223 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
224 (when (featurep 'xemacs)
225 (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
226 (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar))
228 (defcustom gnus-group-menu-hook nil
229 "Hook run after the creation of the group mode menu."
230 :group 'gnus-group-various
233 (defcustom gnus-group-catchup-group-hook nil
234 "Hook run when catching up a group from the group buffer."
235 :group 'gnus-group-various
236 :link '(custom-manual "(gnus)Group Data")
239 (defcustom gnus-group-update-group-hook nil
240 "Hook called when updating group lines."
241 :group 'gnus-group-visual
244 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
245 "*A function that is called to generate the group buffer.
246 The function is called with three arguments: The first is a number;
247 all group with a level less or equal to that number should be listed,
248 if the second is non-nil, empty groups should also be displayed. If
249 the third is non-nil, it is a number. No groups with a level lower
250 than this number should be displayed.
252 The only current function implemented is `gnus-group-prepare-flat'."
253 :group 'gnus-group-listing
256 (defcustom gnus-group-prepare-hook nil
257 "Hook called after the group buffer has been generated.
258 If you want to modify the group buffer, you can use this hook."
259 :group 'gnus-group-listing
262 (defcustom gnus-suspend-gnus-hook nil
263 "Hook called when suspending (not exiting) Gnus."
267 (defcustom gnus-exit-gnus-hook nil
268 "Hook called when exiting Gnus."
272 (defcustom gnus-after-exiting-gnus-hook nil
273 "Hook called after exiting Gnus."
277 (defcustom gnus-group-update-hook '(gnus-group-highlight-line)
278 "Hook called when a group line is changed.
279 The hook will not be called if `gnus-visual' is nil.
281 The default function `gnus-group-highlight-line' will
282 highlight the line according to the `gnus-group-highlight'
284 :group 'gnus-group-visual
287 (defcustom gnus-useful-groups
288 '(("(ding) mailing list mirrored at gmane.org"
289 "gmane.emacs.gnus.general"
291 (nntp-address "news.gmane.org")))
294 (nntp "news.gnus.org"
295 (nntp-address "news.gnus.org")))
296 ("Local Gnus help group"
299 (nndoc-article-type mbox)
300 (eval `(nndoc-address
301 ,(let ((file (nnheader-find-etc-directory
304 (error "Couldn't find doc group"))
306 "*Alist of useful group-server pairs."
307 :group 'gnus-group-listing
308 :type '(repeat (list (string :tag "Description")
310 (sexp :tag "Method"))))
312 (defcustom gnus-group-highlight
314 ((and mailp (= unread 0) (eq level 1)) .
315 gnus-group-mail-1-empty)
316 ((and mailp (eq level 1)) .
318 ((and mailp (= unread 0) (eq level 2)) .
319 gnus-group-mail-2-empty)
320 ((and mailp (eq level 2)) .
322 ((and mailp (= unread 0) (eq level 3)) .
323 gnus-group-mail-3-empty)
324 ((and mailp (eq level 3)) .
326 ((and mailp (= unread 0)) .
327 gnus-group-mail-low-empty)
331 ((and (= unread 0) (eq level 1)) .
332 gnus-group-news-1-empty)
333 ((and (eq level 1)) .
335 ((and (= unread 0) (eq level 2)) .
336 gnus-group-news-2-empty)
337 ((and (eq level 2)) .
339 ((and (= unread 0) (eq level 3)) .
340 gnus-group-news-3-empty)
341 ((and (eq level 3)) .
343 ((and (= unread 0) (eq level 4)) .
344 gnus-group-news-4-empty)
345 ((and (eq level 4)) .
347 ((and (= unread 0) (eq level 5)) .
348 gnus-group-news-5-empty)
349 ((and (eq level 5)) .
351 ((and (= unread 0) (eq level 6)) .
352 gnus-group-news-6-empty)
353 ((and (eq level 6)) .
355 ((and (= unread 0)) .
356 gnus-group-news-low-empty)
358 gnus-group-news-low))
359 "*Controls the highlighting of group buffer lines.
361 Below is a list of `Form'/`Face' pairs. When deciding how a a
362 particular group line should be displayed, each form is
363 evaluated. The content of the face field after the first true form is
364 used. You can change how those group lines are displayed by
365 editing the face field.
367 It is also possible to change and add form fields, but currently that
368 requires an understanding of Lisp expressions. Hopefully this will
369 change in a future release. For now, you can use the following
370 variables in the Lisp expression:
372 group: The name of the group.
373 unread: The number of unread articles in the group.
374 method: The select method used.
375 mailp: Whether it's a mail group or not.
376 level: The level of the group.
377 score: The score of the group.
378 ticked: The number of ticked articles."
379 :group 'gnus-group-visual
380 :type '(repeat (cons (sexp :tag "Form") face)))
381 (put 'gnus-group-highlight 'risky-local-variable t)
383 (defcustom gnus-new-mail-mark ?%
384 "Mark used for groups with new mail."
385 :group 'gnus-group-visual
388 (defgroup gnus-group-icons nil
389 "Add Icons to your group buffer."
390 :group 'gnus-group-visual)
392 (defcustom gnus-group-icon-list
394 "*Controls the insertion of icons into group buffer lines.
396 Below is a list of `Form'/`File' pairs. When deciding how a
397 particular group line should be displayed, each form is evaluated.
398 The icon from the file field after the first true form is used. You
399 can change how those group lines are displayed by editing the file
400 field. The File will either be found in the
401 `gnus-group-glyph-directory' or by designating absolute name of the
404 It is also possible to change and add form fields, but currently that
405 requires an understanding of Lisp expressions. Hopefully this will
406 change in a future release. For now, you can use the following
407 variables in the Lisp expression:
409 group: The name of the group.
410 unread: The number of unread articles in the group.
411 method: The select method used.
412 mailp: Whether it's a mail group or not.
413 newsp: Whether it's a news group or not
414 level: The level of the group.
415 score: The score of the group.
416 ticked: The number of ticked articles."
417 :group 'gnus-group-icons
418 :type '(repeat (cons (sexp :tag "Form") file)))
419 (put 'gnus-group-icon-list 'risky-local-variable t)
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'.
444 If non-nil, the value should be a string, e.g. \"nnml:\",
445 in which case `gnus-group-jump-to-group' offers \"Group: nnml:\"
446 in the minibuffer prompt."
448 :group 'gnus-group-various
449 :type '(choice (string :tag "Prompt string")
450 (const :tag "Empty" nil)))
452 (defvar gnus-group-listing-limit 1000
453 "*A limit of the number of groups when listing.
454 If the number of groups is larger than the limit, list them in a
457 ;;; Internal variables
459 (defvar gnus-group-is-exiting-p nil)
460 (defvar gnus-group-is-exiting-without-update-p nil)
461 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
462 "Function for sorting the group buffer.")
464 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
465 "Function for sorting the selected groups in the group buffer.")
467 (defvar gnus-group-indentation-function nil)
468 (defvar gnus-goto-missing-group-function nil)
469 (defvar gnus-group-update-group-function nil)
470 (defvar gnus-group-goto-next-group-function nil
471 "Function to override finding the next group after listing groups.")
473 (defvar gnus-group-edit-buffer nil)
475 (defvar gnus-group-line-format-alist
476 `((?M gnus-tmp-marked-mark ?c)
477 (?S gnus-tmp-subscribed ?c)
478 (?L gnus-tmp-level ?d)
479 (?N (cond ((eq number t) "*" )
483 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
484 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
486 (?R gnus-tmp-number-of-read ?s)
487 (?U (gnus-number-of-unseen-articles-in-group gnus-tmp-group) ?d)
488 (?t gnus-tmp-number-total ?d)
489 (?y gnus-tmp-number-of-unread ?s)
490 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
491 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
492 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
493 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
494 (?g (if (boundp 'gnus-tmp-decoded-group)
495 gnus-tmp-decoded-group
498 (?G gnus-tmp-qualified-group ?s)
499 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
500 gnus-tmp-decoded-group
503 (?C gnus-tmp-comment ?s)
504 (?D gnus-tmp-newsgroup-description ?s)
505 (?o gnus-tmp-moderated ?c)
506 (?O gnus-tmp-moderated-string ?s)
507 (?p gnus-tmp-process-marked ?c)
508 (?s gnus-tmp-news-server ?s)
509 (?n ,(if (featurep 'xemacs)
510 '(symbol-name gnus-tmp-news-method)
511 'gnus-tmp-news-method)
513 (?P gnus-group-indentation ?s)
514 (?E gnus-tmp-group-icon ?s)
515 (?B gnus-tmp-summary-live ?c)
516 (?l gnus-tmp-grouplens ?s)
517 (?z gnus-tmp-news-method-string ?s)
518 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
519 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
520 (?u gnus-tmp-user-defined ?s)))
522 (defvar gnus-group-mode-line-format-alist
523 `((?S gnus-tmp-news-server ?s)
524 (?M gnus-tmp-news-method ?s)
525 (?u gnus-tmp-user-defined ?s)
526 (?: gnus-tmp-colon ?s)))
528 (defvar gnus-topic-topology nil
529 "The complete topic hierarchy.")
531 (defvar gnus-topic-alist nil
532 "The complete topic-group alist.")
534 (defvar gnus-group-marked nil)
536 (defvar gnus-group-list-mode nil)
539 (defvar gnus-group-icon-cache nil)
541 (defvar gnus-group-listed-groups nil)
542 (defvar gnus-group-list-option nil)
548 (put 'gnus-group-mode 'mode-class 'special)
550 (gnus-define-keys gnus-group-mode-map
551 " " gnus-group-read-group
552 "=" gnus-group-select-group
553 "\r" gnus-group-select-group
554 "\M-\r" gnus-group-quick-select-group
555 "\M- " gnus-group-visible-select-group
556 [(meta control return)] gnus-group-select-group-ephemerally
557 "j" gnus-group-jump-to-group
558 "n" gnus-group-next-unread-group
559 "p" gnus-group-prev-unread-group
560 "\177" gnus-group-prev-unread-group
561 [delete] gnus-group-prev-unread-group
562 [backspace] gnus-group-prev-unread-group
563 "N" gnus-group-next-group
564 "P" gnus-group-prev-group
565 "\M-n" gnus-group-next-unread-group-same-level
566 "\M-p" gnus-group-prev-unread-group-same-level
567 "," gnus-group-best-unread-group
568 "." gnus-group-first-unread-group
569 "u" gnus-group-unsubscribe-current-group
570 "U" gnus-group-unsubscribe-group
571 "c" gnus-group-catchup-current
572 "C" gnus-group-catchup-current-all
573 "\M-c" gnus-group-clear-data
574 "l" gnus-group-list-groups
575 "L" gnus-group-list-all-groups
578 "g" gnus-group-get-new-news
579 "\M-g" gnus-group-get-new-news-this-group
580 "R" gnus-group-restart
581 "r" gnus-group-read-init-file
582 "B" gnus-group-browse-foreign-server
583 "b" gnus-group-check-bogus-groups
584 "F" gnus-group-find-new-groups
585 "\C-c\C-d" gnus-group-describe-group
586 "\M-d" gnus-group-describe-all-groups
587 "\C-c\C-a" gnus-group-apropos
588 "\C-c\M-\C-a" gnus-group-description-apropos
589 "a" gnus-group-post-news
590 "\ek" gnus-group-edit-local-kill
591 "\eK" gnus-group-edit-global-kill
592 "\C-k" gnus-group-kill-group
593 "\C-y" gnus-group-yank-group
594 "\C-w" gnus-group-kill-region
595 "\C-x\C-t" gnus-group-transpose-groups
596 "\C-c\C-l" gnus-group-list-killed
597 "\C-c\C-x" gnus-group-expire-articles
598 "\C-c\M-\C-x" gnus-group-expire-all-groups
600 "s" gnus-group-save-newsrc
601 "z" gnus-group-suspend
604 "?" gnus-group-describe-briefly
605 "\C-c\C-i" gnus-info-find-node
606 "\M-e" gnus-group-edit-group-method
607 "^" gnus-group-enter-server-mode
608 gnus-mouse-2 gnus-mouse-pick-group
609 [follow-link] mouse-face
610 "<" beginning-of-buffer
613 "\C-c\C-s" gnus-group-sort-groups
615 "\C-c\M-g" gnus-activate-all-groups
616 "\M-&" gnus-group-universal-argument
617 "#" gnus-group-mark-group
618 "\M-#" gnus-group-unmark-group)
620 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
621 "m" gnus-group-mark-group
622 "u" gnus-group-unmark-group
623 "w" gnus-group-mark-region
624 "b" gnus-group-mark-buffer
625 "r" gnus-group-mark-regexp
626 "U" gnus-group-unmark-all-groups)
628 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
629 "u" gnus-sieve-update
630 "g" gnus-sieve-generate)
632 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
633 "d" gnus-group-make-directory-group
634 "h" gnus-group-make-help-group
635 "u" gnus-group-make-useful-group
636 "a" gnus-group-make-archive-group
637 "k" gnus-group-make-kiboze-group
638 "l" gnus-group-nnimap-edit-acl
639 "m" gnus-group-make-group
640 "E" gnus-group-edit-group
641 "e" gnus-group-edit-group-method
642 "p" gnus-group-edit-group-parameters
643 "v" gnus-group-add-to-virtual
644 "V" gnus-group-make-empty-virtual
645 "D" gnus-group-enter-directory
646 "f" gnus-group-make-doc-group
647 "w" gnus-group-make-web-group
648 "M" gnus-group-read-ephemeral-group
649 "r" gnus-group-rename-group
650 "R" gnus-group-make-rss-group
651 "c" gnus-group-customize
652 "x" gnus-group-nnimap-expunge
653 "\177" gnus-group-delete-group
654 [delete] gnus-group-delete-group)
656 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
657 "b" gnus-group-brew-soup
658 "w" gnus-soup-save-areas
659 "s" gnus-soup-send-replies
660 "p" gnus-soup-pack-packet
661 "r" nnsoup-pack-replies)
663 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
664 "s" gnus-group-sort-groups
665 "a" gnus-group-sort-groups-by-alphabet
666 "u" gnus-group-sort-groups-by-unread
667 "l" gnus-group-sort-groups-by-level
668 "v" gnus-group-sort-groups-by-score
669 "r" gnus-group-sort-groups-by-rank
670 "m" gnus-group-sort-groups-by-method
671 "n" gnus-group-sort-groups-by-real-name)
673 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
674 "s" gnus-group-sort-selected-groups
675 "a" gnus-group-sort-selected-groups-by-alphabet
676 "u" gnus-group-sort-selected-groups-by-unread
677 "l" gnus-group-sort-selected-groups-by-level
678 "v" gnus-group-sort-selected-groups-by-score
679 "r" gnus-group-sort-selected-groups-by-rank
680 "m" gnus-group-sort-selected-groups-by-method
681 "n" gnus-group-sort-selected-groups-by-real-name)
683 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
684 "k" gnus-group-list-killed
685 "z" gnus-group-list-zombies
686 "s" gnus-group-list-groups
687 "u" gnus-group-list-all-groups
688 "A" gnus-group-list-active
689 "a" gnus-group-apropos
690 "d" gnus-group-description-apropos
691 "m" gnus-group-list-matching
692 "M" gnus-group-list-all-matching
693 "l" gnus-group-list-level
694 "c" gnus-group-list-cached
695 "?" gnus-group-list-dormant)
697 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
698 "k" gnus-group-list-limit
699 "z" gnus-group-list-limit
700 "s" gnus-group-list-limit
701 "u" gnus-group-list-limit
702 "A" gnus-group-list-limit
703 "m" gnus-group-list-limit
704 "M" gnus-group-list-limit
705 "l" gnus-group-list-limit
706 "c" gnus-group-list-limit
707 "?" gnus-group-list-limit)
709 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
710 "k" gnus-group-list-flush
711 "z" gnus-group-list-flush
712 "s" gnus-group-list-flush
713 "u" gnus-group-list-flush
714 "A" gnus-group-list-flush
715 "m" gnus-group-list-flush
716 "M" gnus-group-list-flush
717 "l" gnus-group-list-flush
718 "c" gnus-group-list-flush
719 "?" gnus-group-list-flush)
721 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
722 "k" gnus-group-list-plus
723 "z" gnus-group-list-plus
724 "s" gnus-group-list-plus
725 "u" gnus-group-list-plus
726 "A" gnus-group-list-plus
727 "m" gnus-group-list-plus
728 "M" gnus-group-list-plus
729 "l" gnus-group-list-plus
730 "c" gnus-group-list-plus
731 "?" gnus-group-list-plus)
733 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
734 "f" gnus-score-flush-cache)
736 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
737 "c" gnus-group-fetch-charter
738 "C" gnus-group-fetch-control
739 "d" gnus-group-describe-group
740 "f" gnus-group-fetch-faq
743 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
744 "l" gnus-group-set-current-level
745 "t" gnus-group-unsubscribe-current-group
746 "s" gnus-group-unsubscribe-group
747 "k" gnus-group-kill-group
748 "y" gnus-group-yank-group
749 "w" gnus-group-kill-region
750 "\C-k" gnus-group-kill-level
751 "z" gnus-group-kill-all-zombies)
753 (defun gnus-topic-mode-p ()
754 "Return non-nil in `gnus-topic-mode'."
755 (and (boundp 'gnus-topic-mode)
756 (symbol-value 'gnus-topic-mode)))
758 (defun gnus-group-make-menu-bar ()
759 (gnus-turn-off-edit-menu 'group)
760 (unless (boundp 'gnus-group-reading-menu)
763 gnus-group-reading-menu gnus-group-mode-map ""
765 ["Read" gnus-group-read-group
766 :included (not (gnus-topic-mode-p))
767 :active (gnus-group-group-name)]
768 ["Read " gnus-topic-read-group
769 :included (gnus-topic-mode-p)]
770 ["Select" gnus-group-select-group
771 :included (not (gnus-topic-mode-p))
772 :active (gnus-group-group-name)]
773 ["Select " gnus-topic-select-group
774 :included (gnus-topic-mode-p)]
775 ["See old articles" (gnus-group-select-group 'all)
776 :keys "C-u SPC" :active (gnus-group-group-name)]
777 ["Catch up" gnus-group-catchup-current
778 :included (not (gnus-topic-mode-p))
779 :active (gnus-group-group-name)
780 ,@(if (featurep 'xemacs) nil
781 '(:help "Mark unread articles in the current group as read"))]
782 ["Catch up " gnus-topic-catchup-articles
783 :included (gnus-topic-mode-p)
784 ,@(if (featurep 'xemacs) nil
785 '(:help "Mark unread articles in the current group or topic as read"))]
786 ["Catch up all articles" gnus-group-catchup-current-all
787 (gnus-group-group-name)]
788 ["Check for new articles" gnus-group-get-new-news-this-group
789 :included (not (gnus-topic-mode-p))
790 :active (gnus-group-group-name)
791 ,@(if (featurep 'xemacs) nil
792 '(:help "Check for new messages in current group"))]
793 ["Check for new articles " gnus-topic-get-new-news-this-topic
794 :included (gnus-topic-mode-p)
795 ,@(if (featurep 'xemacs) nil
796 '(:help "Check for new messages in current group or topic"))]
797 ["Toggle subscription" gnus-group-unsubscribe-current-group
798 (gnus-group-group-name)]
799 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
800 ,@(if (featurep 'xemacs) nil
801 '(:help "Kill (remove) current group"))]
802 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
803 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
804 ,@(if (featurep 'xemacs) nil
805 '(:help "Display description of the current group"))]
806 ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
807 ["Fetch charter" gnus-group-fetch-charter
808 :active (gnus-group-group-name)
809 ,@(if (featurep 'xemacs) nil
810 '(:help "Display the charter of the current group"))]
811 ["Fetch control message" gnus-group-fetch-control
812 :active (gnus-group-group-name)
813 ,@(if (featurep 'xemacs) nil
814 '(:help "Display the archived control message for the current group"))]
815 ;; Actually one should check, if any of the marked groups gives t for
816 ;; (gnus-check-backend-function 'request-expire-articles ...)
817 ["Expire articles" gnus-group-expire-articles
818 :included (not (gnus-topic-mode-p))
819 :active (or (and (gnus-group-group-name)
820 (gnus-check-backend-function
821 'request-expire-articles
822 (gnus-group-group-name))) gnus-group-marked)]
823 ["Expire articles " gnus-topic-expire-articles
824 :included (gnus-topic-mode-p)]
825 ["Set group level..." gnus-group-set-current-level
826 (gnus-group-group-name)]
827 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
828 ["Customize" gnus-group-customize (gnus-group-group-name)]
830 ["Parameters" gnus-group-edit-group-parameters
831 :included (not (gnus-topic-mode-p))
832 :active (gnus-group-group-name)]
833 ["Parameters " gnus-topic-edit-parameters
834 :included (gnus-topic-mode-p)]
835 ["Select method" gnus-group-edit-group-method
836 (gnus-group-group-name)]
837 ["Info" gnus-group-edit-group (gnus-group-group-name)]
838 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
839 ["Global kill file" gnus-group-edit-global-kill t])))
842 gnus-group-group-menu gnus-group-mode-map ""
845 ["List unread subscribed groups" gnus-group-list-groups t]
846 ["List (un)subscribed groups" gnus-group-list-all-groups t]
847 ["List killed groups" gnus-group-list-killed gnus-killed-list]
848 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
849 ["List level..." gnus-group-list-level t]
850 ["Describe all groups" gnus-group-describe-all-groups t]
851 ["Group apropos..." gnus-group-apropos t]
852 ["Group and description apropos..." gnus-group-description-apropos t]
853 ["List groups matching..." gnus-group-list-matching t]
854 ["List all groups matching..." gnus-group-list-all-matching t]
855 ["List active file" gnus-group-list-active t]
856 ["List groups with cached" gnus-group-list-cached t]
857 ["List groups with dormant" gnus-group-list-dormant t])
859 ["Default sort" gnus-group-sort-groups t]
860 ["Sort by method" gnus-group-sort-groups-by-method t]
861 ["Sort by rank" gnus-group-sort-groups-by-rank t]
862 ["Sort by score" gnus-group-sort-groups-by-score t]
863 ["Sort by level" gnus-group-sort-groups-by-level t]
864 ["Sort by unread" gnus-group-sort-groups-by-unread t]
865 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
866 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
867 ("Sort process/prefixed"
868 ["Default sort" gnus-group-sort-selected-groups
869 (not (gnus-topic-mode-p))]
870 ["Sort by method" gnus-group-sort-selected-groups-by-method
871 (not (gnus-topic-mode-p))]
872 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
873 (not (gnus-topic-mode-p))]
874 ["Sort by score" gnus-group-sort-selected-groups-by-score
875 (not (gnus-topic-mode-p))]
876 ["Sort by level" gnus-group-sort-selected-groups-by-level
877 (not (gnus-topic-mode-p))]
878 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
879 (not (gnus-topic-mode-p))]
880 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
881 (not (gnus-topic-mode-p))]
882 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
883 (not (gnus-topic-mode-p))])
885 ["Mark group" gnus-group-mark-group
886 (and (gnus-group-group-name)
887 (not (memq (gnus-group-group-name) gnus-group-marked)))]
888 ["Unmark group" gnus-group-unmark-group
889 (and (gnus-group-group-name)
890 (memq (gnus-group-group-name) gnus-group-marked))]
891 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
892 ["Mark regexp..." gnus-group-mark-regexp t]
893 ["Mark region" gnus-group-mark-region :active (gnus-mark-active-p)]
894 ["Mark buffer" gnus-group-mark-buffer t]
895 ["Execute command" gnus-group-universal-argument
896 (or gnus-group-marked (gnus-group-group-name))])
898 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
899 ["Kill all newsgroups in region" gnus-group-kill-region
900 :active (gnus-mark-active-p)]
901 ["Kill all zombie groups" gnus-group-kill-all-zombies
903 ["Kill all groups on level..." gnus-group-kill-level t])
905 ["Make a foreign group..." gnus-group-make-group t]
906 ["Add a directory group..." gnus-group-make-directory-group t]
907 ["Add the help group" gnus-group-make-help-group t]
908 ["Add the archive group" gnus-group-make-archive-group t]
909 ["Make a doc group..." gnus-group-make-doc-group t]
910 ["Make a web group..." gnus-group-make-web-group t]
911 ["Make a kiboze group..." gnus-group-make-kiboze-group t]
912 ["Make a virtual group..." gnus-group-make-empty-virtual t]
913 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
914 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
915 ["Make an RSS group..." gnus-group-make-rss-group t]
916 ["Rename group..." gnus-group-rename-group
917 (gnus-check-backend-function
918 'request-rename-group (gnus-group-group-name))]
919 ["Delete group" gnus-group-delete-group
920 (gnus-check-backend-function
921 'request-delete-group (gnus-group-group-name))])
923 ["Next" gnus-group-next-group t]
924 ["Previous" gnus-group-prev-group t]
925 ["Next unread" gnus-group-next-unread-group t]
926 ["Previous unread" gnus-group-prev-unread-group t]
927 ["Next unread same level" gnus-group-next-unread-group-same-level t]
928 ["Previous unread same level"
929 gnus-group-prev-unread-group-same-level t]
930 ["Jump to group..." gnus-group-jump-to-group t]
931 ["First unread group" gnus-group-first-unread-group t]
932 ["Best unread group" gnus-group-best-unread-group t])
934 ["Generate" gnus-sieve-generate t]
935 ["Generate and update" gnus-sieve-update t])
936 ["Delete bogus groups" gnus-group-check-bogus-groups t]
937 ["Find new newsgroups" gnus-group-find-new-groups t]
938 ["Transpose" gnus-group-transpose-groups
939 (gnus-group-group-name)]
940 ["Read a directory as a group..." gnus-group-enter-directory t]))
943 gnus-group-misc-menu gnus-group-mode-map ""
946 ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
947 ["Send replies" gnus-soup-send-replies
948 (fboundp 'gnus-soup-pack-packet)]
949 ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
950 ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
951 ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)])
952 ["Send a mail" gnus-group-mail t]
953 ["Send a message (mail or news)" gnus-group-post-news t]
954 ["Create a local message" gnus-group-news t]
955 ["Check for new news" gnus-group-get-new-news
956 ,@(if (featurep 'xemacs) '(t)
957 '(:help "Get newly arrived articles"))
959 ["Send queued messages" gnus-delay-send-queue
960 ,@(if (featurep 'xemacs) '(t)
961 '(:help "Send all messages that are scheduled to be sent now"))
963 ["Activate all groups" gnus-activate-all-groups t]
964 ["Restart Gnus" gnus-group-restart t]
965 ["Read init file" gnus-group-read-init-file t]
966 ["Browse foreign server..." gnus-group-browse-foreign-server t]
967 ["Enter server buffer" gnus-group-enter-server-mode t]
968 ["Expire all expirable articles" gnus-group-expire-all-groups t]
969 ["Generate any kiboze groups" nnkiboze-generate-groups t]
970 ["Gnus version" gnus-version t]
971 ["Save .newsrc files" gnus-group-save-newsrc t]
972 ["Suspend Gnus" gnus-group-suspend t]
973 ["Clear dribble buffer" gnus-group-clear-dribble t]
974 ["Read manual" gnus-info-find-node t]
975 ["Flush score cache" gnus-score-flush-cache t]
976 ["Toggle topics" gnus-topic-mode t]
977 ["Send a bug report" gnus-bug t]
978 ["Exit from Gnus" gnus-group-exit
979 ,@(if (featurep 'xemacs) '(t)
980 '(:help "Quit reading news"))]
981 ["Exit without saving" gnus-group-quit t]))
983 (gnus-run-hooks 'gnus-group-menu-hook)))
986 (defvar gnus-group-tool-bar-map nil)
988 (defun gnus-group-tool-bar-update (&optional symbol value)
989 "Update group buffer toolbar.
990 Setter function for custom variables."
992 (set-default symbol value))
993 ;; (setq-default gnus-group-tool-bar-map nil)
994 ;; (use-local-map gnus-group-mode-map)
996 (with-current-buffer gnus-group-buffer
997 (gnus-group-make-tool-bar t))))
999 (defcustom gnus-group-tool-bar (if (eq gmm-tool-bar-style 'gnome)
1000 'gnus-group-tool-bar-gnome
1001 'gnus-group-tool-bar-retro)
1002 "Specifies the Gnus group tool bar.
1004 It can be either a list or a symbol refering to a list. See
1005 `gmm-tool-bar-from-list' for the format of the list. The
1006 default key map is `gnus-group-mode-map'.
1008 Pre-defined symbols include `gnus-group-tool-bar-gnome' and
1009 `gnus-group-tool-bar-retro'."
1010 :type '(choice (const :tag "GNOME style" gnus-group-tool-bar-gnome)
1011 (const :tag "Retro look" gnus-group-tool-bar-retro)
1012 (repeat :tag "User defined list" gmm-tool-bar-item)
1014 :version "22.1" ;; Gnus 5.10.9
1015 :initialize 'custom-initialize-default
1016 :set 'gnus-group-tool-bar-update
1019 (defcustom gnus-group-tool-bar-gnome
1020 '((gnus-group-post-news "mail/compose")
1021 ;; Some useful agent icons? I don't use the agent so agent users should
1022 ;; suggest useful commands:
1023 (gnus-agent-toggle-plugged "disconnect" t
1024 :help "Gnus is currently unplugged. Click to work online."
1025 :visible (and gnus-agent (not gnus-plugged)))
1026 (gnus-agent-toggle-plugged "connect" t
1027 :help "Gnus is currently plugged. Click to work offline."
1028 :visible (and gnus-agent gnus-plugged))
1029 ;; FIXME: gnus-agent-toggle-plugged (in gnus-agent-group-make-menu-bar)
1030 ;; should have a better help text.
1031 (gnus-group-send-queue "mail/outbox" t
1032 :visible (and gnus-agent gnus-plugged)
1033 :help "Send articles from the queue group")
1034 (gnus-group-get-new-news "mail/inbox" nil
1035 :visible (or (not gnus-agent)
1037 ;; FIXME: gnus-*-read-group should have a better help text.
1038 (gnus-topic-read-group "open" nil
1039 :visible (and (boundp 'gnus-topic-mode)
1041 (gnus-group-read-group "open" nil
1042 :visible (not (and (boundp 'gnus-topic-mode)
1044 ;; (gnus-group-find-new-groups "???" nil)
1045 (gnus-group-save-newsrc "save")
1046 (gnus-group-describe-group "describe")
1047 (gnus-group-unsubscribe-current-group "gnus/toggle-subscription")
1048 (gnus-group-prev-unread-group "left-arrow")
1049 (gnus-group-next-unread-group "right-arrow")
1050 (gnus-group-exit "exit")
1051 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
1052 (gnus-info-find-node "help"))
1053 "List of functions for the group tool bar (GNOME style).
1055 See `gmm-tool-bar-from-list' for the format of the list."
1056 :type '(repeat gmm-tool-bar-item)
1057 :version "22.1" ;; Gnus 5.10.9
1058 :initialize 'custom-initialize-default
1059 :set 'gnus-group-tool-bar-update
1062 (defcustom gnus-group-tool-bar-retro
1063 '((gnus-group-get-new-news "gnus/get-news")
1064 (gnus-group-get-new-news-this-group "gnus/gnntg")
1065 (gnus-group-catchup-current "gnus/catchup")
1066 (gnus-group-describe-group "gnus/describe-group")
1067 (gnus-group-subscribe "gnus/subscribe" t
1068 :help "Subscribe to the current group")
1069 (gnus-group-unsubscribe "gnus/unsubscribe" t
1070 :help "Unsubscribe from the current group")
1071 (gnus-group-exit "gnus/exit-gnus" gnus-group-mode-map))
1072 "List of functions for the group tool bar (retro look).
1074 See `gmm-tool-bar-from-list' for the format of the list."
1075 :type '(repeat gmm-tool-bar-item)
1076 :version "22.1" ;; Gnus 5.10.9
1077 :initialize 'custom-initialize-default
1078 :set 'gnus-group-tool-bar-update
1081 (defcustom gnus-group-tool-bar-zap-list t
1082 "List of icon items from the global tool bar.
1083 These items are not displayed in the Gnus group mode tool bar.
1085 See `gmm-tool-bar-from-list' for the format of the list."
1086 :type 'gmm-tool-bar-zap-list
1087 :version "22.1" ;; Gnus 5.10.9
1088 :initialize 'custom-initialize-default
1089 :set 'gnus-group-tool-bar-update
1092 (defvar image-load-path)
1094 (defun gnus-group-make-tool-bar (&optional force)
1095 "Make a group mode tool bar from `gnus-group-tool-bar'.
1096 When FORCE, rebuild the tool bar."
1097 (when (and (not (featurep 'xemacs))
1098 (boundp 'tool-bar-mode)
1100 ;; The Gnus 5.10.6 code checked (default-value 'tool-bar-mode).
1102 (or (not gnus-group-tool-bar-map) force))
1104 (gmm-image-load-path-for-library "gnus"
1105 "gnus/toggle-subscription.xpm"
1107 (image-load-path (cons (car load-path)
1108 (when (boundp 'image-load-path)
1110 (map (gmm-tool-bar-from-list gnus-group-tool-bar
1111 gnus-group-tool-bar-zap-list
1112 'gnus-group-mode-map)))
1114 (set (make-local-variable 'tool-bar-map) map))))
1115 gnus-group-tool-bar-map)
1117 (defun gnus-group-mode ()
1118 "Major mode for reading news.
1120 All normal editing commands are switched off.
1121 \\<gnus-group-mode-map>
1122 The group buffer lists (some of) the groups available. For instance,
1123 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1124 lists all zombie groups.
1126 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1127 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1129 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1131 The following commands are available:
1133 \\{gnus-group-mode-map}"
1135 (kill-all-local-variables)
1136 (when (gnus-visual-p 'group-menu 'menu)
1137 (gnus-group-make-menu-bar)
1138 (gnus-group-make-tool-bar))
1139 (gnus-simplify-mode-line)
1140 (setq major-mode 'gnus-group-mode)
1141 (setq mode-name "Group")
1142 (gnus-group-set-mode-line)
1143 (setq mode-line-process nil)
1144 (use-local-map gnus-group-mode-map)
1145 (buffer-disable-undo)
1146 (setq truncate-lines t)
1147 (setq buffer-read-only t)
1148 (gnus-set-default-directory)
1149 (gnus-update-format-specifications nil 'group 'group-mode)
1150 (gnus-update-group-mark-positions)
1155 (gnus-run-mode-hooks 'gnus-group-mode-hook))
1157 (defun gnus-update-group-mark-positions ()
1159 (let ((gnus-process-mark ?\200)
1160 (gnus-group-update-hook nil)
1161 (gnus-group-marked '("dummy.group"))
1162 (gnus-active-hashtb (make-vector 10 0))
1164 (gnus-set-active "dummy.group" '(0 . 0))
1165 (gnus-set-work-buffer)
1166 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1167 (goto-char (point-min))
1168 (setq gnus-group-mark-positions
1169 (list (cons 'process (and (search-forward
1170 (mm-string-as-multibyte "\200") nil t)
1171 (- (point) 2))))))))
1173 (defun gnus-mouse-pick-group (e)
1174 "Enter the group under the mouse pointer."
1177 (gnus-group-read-group nil))
1179 ;; Look at LEVEL and find out what the level is really supposed to be.
1180 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1181 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1182 (defun gnus-group-default-level (&optional level number-or-nil)
1184 (gnus-group-use-permanent-levels
1185 (or (setq gnus-group-use-permanent-levels
1186 (or level (if (numberp gnus-group-use-permanent-levels)
1187 gnus-group-use-permanent-levels
1188 (or gnus-group-default-list-level
1189 gnus-level-subscribed))))
1190 gnus-group-default-list-level gnus-level-subscribed))
1194 (or level gnus-group-default-list-level gnus-level-subscribed))))
1196 (defun gnus-group-setup-buffer ()
1197 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1198 (unless (eq major-mode 'gnus-group-mode)
1201 (gnus-carpal-setup-buffer 'group))))
1203 (defun gnus-group-name-charset (method group)
1205 (setq method (gnus-find-method-for-group group)))
1206 (let ((item (assoc method gnus-group-name-charset-method-alist))
1207 (alist gnus-group-name-charset-group-alist)
1211 (while (setq item (pop alist))
1212 (if (string-match (car item) group)
1214 result (cdr item))))
1217 (defun gnus-group-name-decode (string charset)
1218 ;; Fixme: Don't decode in unibyte mode.
1219 (if (and string charset (featurep 'mule))
1220 (mm-decode-coding-string string charset)
1223 (defun gnus-group-decoded-name (string)
1224 (let ((charset (gnus-group-name-charset nil string)))
1225 (gnus-group-name-decode string charset)))
1227 (defun gnus-group-list-groups (&optional level unread lowest)
1228 "List newsgroups with level LEVEL or lower that have unread articles.
1229 Default is all subscribed groups.
1230 If argument UNREAD is non-nil, groups with no unread articles are also
1233 Also see the `gnus-group-use-permanent-levels' variable."
1235 (list (if current-prefix-arg
1236 (prefix-numeric-value current-prefix-arg)
1238 (gnus-group-default-level nil t)
1239 gnus-group-default-list-level
1240 gnus-level-subscribed))))
1242 (setq level (car gnus-group-list-mode)
1243 unread (cdr gnus-group-list-mode)))
1244 (setq level (gnus-group-default-level level))
1245 (gnus-group-setup-buffer)
1246 (gnus-update-format-specifications nil 'group 'group-mode)
1247 (let ((case-fold-search nil)
1248 (props (text-properties-at (gnus-point-at-bol)))
1249 (empty (= (point-min) (point-max)))
1250 (group (gnus-group-group-name))
1252 (set-buffer gnus-group-buffer)
1253 (setq number (funcall gnus-group-prepare-function level unread lowest))
1254 (when (or (and (numberp number)
1256 (zerop (buffer-size)))
1257 ;; No groups in the buffer.
1258 (gnus-message 5 gnus-no-groups-message))
1259 ;; We have some groups displayed.
1260 (goto-char (point-max))
1261 (when (or (not gnus-group-goto-next-group-function)
1262 (not (funcall gnus-group-goto-next-group-function
1266 (goto-char (point-min)))
1268 ;; Go to the first group with unread articles.
1269 (gnus-group-search-forward t))
1271 ;; Find the right group to put point on. If the current group
1272 ;; has disappeared in the new listing, try to find the next
1273 ;; one. If no next one can be found, just leave point at the
1274 ;; first newsgroup in the buffer.
1275 (when (not (gnus-goto-char
1277 (point-min) (point-max)
1278 'gnus-group (gnus-intern-safe
1279 group gnus-active-hashtb))))
1280 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
1282 (not (gnus-goto-char
1284 (point-min) (point-max) 'gnus-group
1286 (caar newsrc) gnus-active-hashtb)))))
1287 (setq newsrc (cdr newsrc)))
1289 (goto-char (point-max))
1290 (forward-line -1)))))))
1291 ;; Adjust cursor point.
1292 (gnus-group-position-point)))
1294 (defun gnus-group-list-level (level &optional all)
1295 "List groups on LEVEL.
1296 If ALL (the prefix), also list groups that have no unread articles."
1297 (interactive "nList groups on level: \nP")
1298 (gnus-group-list-groups level all level))
1300 (defun gnus-group-prepare-logic (group test)
1301 (or (and gnus-group-listed-groups
1302 (null gnus-group-list-option)
1303 (member group gnus-group-listed-groups))
1305 ((null gnus-group-listed-groups) test)
1306 ((null gnus-group-list-option) test)
1307 (t (and (member group gnus-group-listed-groups)
1308 (if (eq gnus-group-list-option 'flush)
1312 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1313 "List all newsgroups with unread articles of level LEVEL or lower.
1314 If PREDICATE is a function, list groups that the function returns non-nil;
1315 if it is t, list groups that have no unread articles.
1316 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1317 If REGEXP is a function, list dead groups that the function returns non-nil;
1318 if it is a string, only list groups matching REGEXP."
1319 (set-buffer gnus-group-buffer)
1320 (let ((buffer-read-only nil)
1321 (newsrc (cdr gnus-newsrc-alist))
1322 (lowest (or lowest 1))
1323 (not-in-list (and gnus-group-listed-groups
1324 (copy-sequence gnus-group-listed-groups)))
1325 info clevel unread group params)
1327 (when (or (< lowest gnus-level-zombie)
1328 gnus-group-listed-groups)
1329 ;; List living groups.
1331 (setq info (car newsrc)
1332 group (gnus-info-group info)
1333 params (gnus-info-params info)
1335 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
1337 (setq not-in-list (delete group not-in-list)))
1338 (when (gnus-group-prepare-logic
1340 (and unread ; This group might be unchecked
1341 (or (not (stringp regexp))
1342 (string-match regexp group))
1343 (<= (setq clevel (gnus-info-level info)) level)
1346 ((functionp predicate)
1347 (funcall predicate info))
1348 (predicate t) ; We list all groups?
1351 (if (eq unread t) ; Unactivated?
1352 gnus-group-list-inactive-groups
1353 ; We list unactivated
1355 ; We list groups with unread articles
1356 (and gnus-list-groups-with-ticked-articles
1357 (cdr (assq 'tick (gnus-info-marks info))))
1358 ; And groups with tickeds
1359 ;; Check for permanent visibility.
1360 (and gnus-permanently-visible-groups
1361 (string-match gnus-permanently-visible-groups
1363 (memq 'visible params)
1364 (cdr (assq 'visible params)))))))
1365 (gnus-group-insert-group-line
1366 group (gnus-info-level info)
1367 (gnus-info-marks info) unread (gnus-info-method info)))))
1369 ;; List dead groups.
1370 (when (or gnus-group-listed-groups
1371 (and (>= level gnus-level-zombie)
1372 (<= lowest gnus-level-zombie)))
1373 (gnus-group-prepare-flat-list-dead
1374 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1375 gnus-level-zombie ?Z
1378 (dolist (group gnus-zombie-list)
1379 (setq not-in-list (delete group not-in-list))))
1380 (when (or gnus-group-listed-groups
1381 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1382 (gnus-group-prepare-flat-list-dead
1385 (setq gnus-killed-list (sort gnus-killed-list 'string<)))
1386 gnus-level-killed ?K regexp))
1388 (gnus-group-set-mode-line)
1389 (setq gnus-group-list-mode (cons level predicate))
1390 (gnus-run-hooks 'gnus-group-prepare-hook)
1393 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1394 ;; List zombies and killed lists somewhat faster, which was
1395 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1396 ;; this by ignoring the group format specification altogether.
1398 (if (> (length groups) gnus-group-listing-limit)
1400 (setq group (pop groups))
1401 (when (gnus-group-prepare-logic
1404 (and (stringp regexp) (string-match regexp group))
1405 (and (functionp regexp) (funcall regexp group))))
1406 (gnus-add-text-properties
1407 (point) (prog1 (1+ (point))
1408 (insert " " mark " *: "
1409 (gnus-group-decoded-name group)
1411 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1413 'gnus-level level))))
1415 (setq group (pop groups))
1416 (when (gnus-group-prepare-logic
1419 (and (stringp regexp) (string-match regexp group))
1420 (and (functionp regexp) (funcall regexp group))))
1421 (gnus-group-insert-group-line
1423 (let ((active (gnus-active group)))
1425 (if (zerop (cdr active))
1427 (- (1+ (cdr active)) (car active)))
1429 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1431 (defun gnus-group-update-group-line ()
1432 "Update the current line in the group buffer."
1433 (let* ((buffer-read-only nil)
1434 (group (gnus-group-group-name))
1435 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
1436 gnus-group-indentation)
1439 (not (gnus-ephemeral-group-p group))
1441 (concat "(gnus-group-set-info '"
1442 (gnus-prin1-to-string (nth 2 entry))
1444 (setq gnus-group-indentation (gnus-group-group-indentation))
1446 (gnus-group-insert-group-line-info group)
1448 (gnus-group-position-point))))
1450 (defun gnus-group-insert-group-line-info (group)
1451 "Insert GROUP on the current line."
1452 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
1453 (gnus-group-indentation (gnus-group-group-indentation))
1457 ;; (Un)subscribed group.
1458 (setq info (nth 2 entry))
1459 (gnus-group-insert-group-line
1460 group (gnus-info-level info) (gnus-info-marks info)
1461 (or (car entry) t) (gnus-info-method info)))
1462 ;; This group is dead.
1463 (gnus-group-insert-group-line
1465 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1467 (if (setq active (gnus-active group))
1468 (if (zerop (cdr active))
1470 (- (1+ (cdr active)) (car active)))
1472 (gnus-method-simplify (gnus-find-method-for-group group))))))
1474 (defun gnus-number-of-unseen-articles-in-group (group)
1475 (let* ((info (nth 2 (gnus-group-entry group)))
1476 (marked (gnus-info-marks info))
1477 (seen (cdr (assq 'seen marked)))
1478 (active (gnus-active group)))
1481 (length (gnus-uncompress-range
1482 (gnus-range-difference
1483 (gnus-range-difference (list active) (gnus-info-read info))
1486 ;; Moving through the Group buffer (in topic mode) e.g. with C-n doesn't
1487 ;; update the state (enabled/disabled) of the icon `gnus-group-describe-group'
1488 ;; automatically. After `C-l' the state is correct. See the following report
1490 ;; <http://thread.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de>:
1491 ;; From: Reiner Steib
1492 ;; Subject: tool bar icons not updated according to :active condition
1493 ;; Newsgroups: gmane.emacs.devel
1494 ;; Date: Mon, 23 Jan 2006 19:59:13 +0100
1495 ;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
1497 (defcustom gnus-group-update-tool-bar
1498 (and (not (featurep 'xemacs))
1499 (boundp 'tool-bar-mode)
1501 ;; Using `redraw-frame' (see `gnus-tool-bar-update') in Emacs 21 might
1502 ;; be confusing, so maybe we shouldn't call it by default.
1503 (fboundp 'force-window-update))
1504 "Force updating the group buffer tool bar."
1507 :initialize 'custom-initialize-default
1508 :set (lambda (symbol value)
1509 (set-default symbol value)
1510 (when (gnus-alive-p)
1511 (with-current-buffer gnus-group-buffer
1512 ;; FIXME: Is there a better way to redraw the group buffer?
1513 (gnus-group-get-new-news 0))))
1516 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1517 gnus-tmp-marked number
1519 "Insert a group line in the group buffer."
1520 (let* ((gnus-tmp-method
1521 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1522 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1524 (gnus-tmp-active (gnus-active gnus-tmp-group))
1525 (gnus-tmp-number-total
1527 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1529 (gnus-tmp-number-of-unread
1530 (if (numberp number) (int-to-string (max 0 number))
1532 (gnus-tmp-number-of-read
1533 (if (numberp number)
1534 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1536 (gnus-tmp-subscribed
1537 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1538 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1539 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1541 (gnus-tmp-qualified-group
1542 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1543 group-name-charset))
1545 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1547 (gnus-tmp-newsgroup-description
1548 (if gnus-description-hashtb
1549 (or (gnus-group-name-decode
1550 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1551 group-name-charset) "")
1554 (if (and gnus-moderated-hashtb
1555 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1557 (gnus-tmp-moderated-string
1558 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1559 (gnus-tmp-group-icon "==&&==")
1560 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1561 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1562 (gnus-tmp-news-method-string
1564 (format "(%s:%s)" (car gnus-tmp-method)
1565 (cadr gnus-tmp-method)) ""))
1566 (gnus-tmp-marked-mark
1567 (if (and (numberp number)
1569 (cdr (assq 'tick gnus-tmp-marked)))
1571 (gnus-tmp-summary-live
1572 (if (and (not gnus-group-is-exiting-p)
1573 (gnus-buffer-live-p (gnus-summary-buffer-name
1576 (gnus-tmp-process-marked
1577 (if (member gnus-tmp-group gnus-group-marked)
1578 gnus-process-mark ? ))
1580 (or (and gnus-use-grouplens
1581 (bbb-grouplens-group-p gnus-tmp-group))
1583 (buffer-read-only nil)
1585 header gnus-tmp-header) ; passed as parameter to user-funcs.
1588 (gnus-add-text-properties
1592 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1593 gnus-tmp-group group-name-charset)))
1594 (eval gnus-group-line-format-spec)))
1595 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1596 gnus-unread ,(if (numberp number)
1597 (string-to-number gnus-tmp-number-of-unread)
1599 gnus-marked ,gnus-tmp-marked-mark
1600 gnus-indentation ,gnus-group-indentation
1601 gnus-level ,gnus-tmp-level))
1603 (when gnus-group-update-tool-bar
1604 (gnus-put-text-property beg end 'point-entered
1605 'gnus-tool-bar-update)
1606 (gnus-put-text-property beg end 'point-left
1607 'gnus-tool-bar-update))
1609 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1610 (gnus-run-hooks 'gnus-group-update-hook))
1612 ;; Allow XEmacs to remove front-sticky text properties.
1613 (gnus-group-remove-excess-properties)))
1615 (defun gnus-group-highlight-line ()
1616 "Highlight the current line according to `gnus-group-highlight'."
1617 (let* ((list gnus-group-highlight)
1619 (end (gnus-point-at-eol))
1620 ;; now find out where the line starts and leave point there.
1621 (beg (progn (beginning-of-line) (point)))
1622 (group (gnus-group-group-name))
1623 (entry (gnus-group-entry group))
1624 (unread (if (numberp (car entry)) (car entry) 0))
1625 (active (gnus-active group))
1626 (total (if active (1+ (- (cdr active) (car active))) 0))
1627 (info (nth 2 entry))
1628 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1629 (marked (gnus-info-marks info))
1630 (mailp (apply 'append
1633 (memq x (assoc (symbol-name
1634 (car (or method gnus-select-method)))
1635 gnus-valid-select-methods)))
1636 '(mail post-mail))))
1637 (level (or (gnus-info-level info) gnus-level-killed))
1638 (score (or (gnus-info-score info) 0))
1639 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1640 (group-age (gnus-group-timestamp-delta group))
1641 (inhibit-read-only t))
1642 ;; Eval the cars of the lists until we find a match.
1644 (not (eval (caar list))))
1645 (setq list (cdr list)))
1646 (let ((face (cdar list)))
1647 (unless (eq face (get-text-property beg 'face))
1648 (gnus-put-text-property-excluding-characters-with-faces
1650 (setq face (if (boundp face) (symbol-value face) face)))
1651 (gnus-extent-start-open beg)))
1654 (defun gnus-group-update-group (group &optional visible-only)
1655 "Update all lines where GROUP appear.
1656 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1658 ;; Can't use `save-excursion' here, so we do it manually.
1659 (let ((buf (current-buffer))
1661 (set-buffer gnus-group-buffer)
1662 (setq mark (point-marker))
1663 ;; The buffer may be narrowed.
1666 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1668 found buffer-read-only)
1669 ;; Enter the current status into the dribble buffer.
1670 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
1672 (not (gnus-ephemeral-group-p group)))
1674 (concat "(gnus-group-set-info '"
1675 (gnus-prin1-to-string (nth 2 entry))
1677 ;; Find all group instances. If topics are in use, each group
1678 ;; may be listed in more than once.
1679 (while (setq loc (text-property-any
1680 loc (point-max) 'gnus-group ident))
1683 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1685 (gnus-group-insert-group-line-info group)
1688 (gnus-run-hooks 'gnus-group-update-group-hook)))
1689 (setq loc (1+ loc)))
1690 (unless (or found visible-only)
1691 ;; No such line in the buffer, find out where it's supposed to
1692 ;; go, and insert it there (or at the end of the buffer).
1693 (if gnus-goto-missing-group-function
1694 (funcall gnus-goto-missing-group-function group)
1695 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
1696 (while (and entry (car entry)
1700 (point-min) (point-max)
1701 'gnus-group (gnus-intern-safe
1702 (caar entry) gnus-active-hashtb)))))
1703 (setq entry (cdr entry)))
1704 (or entry (goto-char (point-max)))))
1705 ;; Finally insert the line.
1706 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1707 (gnus-group-insert-group-line-info group)
1710 (gnus-run-hooks 'gnus-group-update-group-hook))))
1711 (when gnus-group-update-group-function
1712 (funcall gnus-group-update-group-function group))
1713 (gnus-group-set-mode-line)))
1715 (set-marker mark nil)
1718 (defun gnus-group-set-mode-line ()
1719 "Update the mode line in the group buffer."
1720 (when (memq 'group gnus-updated-mode-lines)
1721 ;; Yes, we want to keep this mode line updated.
1723 (set-buffer gnus-group-buffer)
1724 (let* ((gformat (or gnus-group-mode-line-format-spec
1725 (gnus-set-format 'group-mode)))
1726 (gnus-tmp-news-server (cadr gnus-select-method))
1727 (gnus-tmp-news-method (car gnus-select-method))
1728 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1730 gnus-tmp-header ;Dummy binding for user-defined formats
1731 ;; Get the resulting string.
1733 (and gnus-dribble-buffer
1734 (buffer-name gnus-dribble-buffer)
1735 (buffer-modified-p gnus-dribble-buffer)
1737 (set-buffer gnus-dribble-buffer)
1738 (not (zerop (buffer-size))))))
1739 (mode-string (eval gformat)))
1740 ;; Say whether the dribble buffer has been modified.
1741 (setq mode-line-modified
1742 (if modified (car gnus-mode-line-modified)
1743 (cdr gnus-mode-line-modified)))
1744 ;; If the line is too long, we chop it off.
1745 (when (> (length mode-string) max-len)
1746 (setq mode-string (substring mode-string 0 (- max-len 4))))
1748 (setq mode-line-buffer-identification
1749 (gnus-mode-line-buffer-identification
1750 (list mode-string)))
1751 (set-buffer-modified-p modified))))))
1753 (defun gnus-group-group-name ()
1754 "Get the name of the newsgroup on the current line."
1755 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
1757 (symbol-name group))))
1759 (defun gnus-group-group-level ()
1760 "Get the level of the newsgroup on the current line."
1761 (get-text-property (gnus-point-at-bol) 'gnus-level))
1763 (defun gnus-group-group-indentation ()
1764 "Get the indentation of the newsgroup on the current line."
1765 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
1766 (and gnus-group-indentation-function
1767 (funcall gnus-group-indentation-function))
1770 (defun gnus-group-group-unread ()
1771 "Get the number of unread articles of the newsgroup on the current line."
1772 (get-text-property (gnus-point-at-bol) 'gnus-unread))
1774 (defun gnus-group-new-mail (group)
1775 (if (nnmail-new-mail-p (gnus-group-real-name group))
1779 (defun gnus-group-level (group)
1780 "Return the estimated level of GROUP."
1781 (or (gnus-info-level (gnus-get-info group))
1782 (and (member group gnus-zombie-list) gnus-level-zombie)
1785 (defun gnus-group-search-forward (&optional backward all level first-too)
1786 "Find the next newsgroup with unread articles.
1787 If BACKWARD is non-nil, find the previous newsgroup instead.
1788 If ALL is non-nil, just find any newsgroup.
1789 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1791 If FIRST-TOO, the current line is also eligible as a target."
1792 (let ((way (if backward -1 1))
1793 (low gnus-level-killed)
1796 (if (and backward (progn (beginning-of-line)) (bobp))
1805 (get-text-property (point) 'gnus-group)
1809 (get-text-property (point) 'gnus-unread)))
1810 (and (numberp unread) (> unread 0)))
1811 (setq lev (get-text-property (point)
1813 (<= lev gnus-level-subscribed)))
1815 (and (setq lev (get-text-property (point)
1824 (zerop (forward-line way)))))
1826 (progn (gnus-group-position-point) t)
1827 (goto-char (or pos beg))
1830 ;;; Gnus group mode commands
1834 (defun gnus-group-mark-line-p ()
1837 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1838 (eq (char-after) gnus-process-mark)))
1840 (defun gnus-group-mark-group (n &optional unmark no-advance)
1841 "Mark the current group."
1843 (let ((buffer-read-only nil)
1847 (when (setq group (gnus-group-group-name))
1848 ;; Go to the mark position.
1850 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1851 (subst-char-in-region
1852 (point) (1+ (point)) (char-after)
1855 (setq gnus-group-marked (delete group gnus-group-marked))
1857 (setq gnus-group-marked
1858 (cons group (delete group gnus-group-marked)))
1859 gnus-process-mark)))
1861 (gnus-group-next-group 1))
1863 (gnus-summary-position-point)
1866 (defun gnus-group-unmark-group (n)
1867 "Remove the mark from the current group."
1869 (gnus-group-mark-group n 'unmark)
1870 (gnus-group-position-point))
1872 (defun gnus-group-unmark-all-groups ()
1873 "Unmark all groups."
1875 (let ((groups gnus-group-marked))
1878 (gnus-group-remove-mark (pop groups)))))
1879 (gnus-group-position-point))
1881 (defun gnus-group-mark-region (unmark beg end)
1882 "Mark all groups between point and mark.
1883 If UNMARK, remove the mark instead."
1884 (interactive "P\nr")
1885 (let ((num (count-lines beg end)))
1888 (- num (gnus-group-mark-group num unmark)))))
1890 (defun gnus-group-mark-buffer (&optional unmark)
1891 "Mark all groups in the buffer.
1892 If UNMARK, remove the mark instead."
1894 (gnus-group-mark-region unmark (point-min) (point-max)))
1896 (defun gnus-group-mark-regexp (regexp)
1897 "Mark all groups that match some regexp."
1898 (interactive "sMark (regexp): ")
1899 (let ((alist (cdr gnus-newsrc-alist))
1903 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1904 (gnus-group-jump-to-group group)
1905 (gnus-group-set-mark group)))))
1906 (gnus-group-position-point))
1908 (defun gnus-group-remove-mark (group &optional test-marked)
1909 "Remove the process mark from GROUP and move point there.
1910 Return nil if the group isn't displayed."
1911 (if (gnus-group-goto-group group nil test-marked)
1913 (gnus-group-mark-group 1 'unmark t)
1915 (setq gnus-group-marked
1916 (delete group gnus-group-marked))
1919 (defun gnus-group-set-mark (group)
1920 "Set the process mark on GROUP."
1921 (if (gnus-group-goto-group group)
1923 (gnus-group-mark-group 1 nil t))
1924 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1926 (defun gnus-group-universal-argument (arg &optional groups func)
1927 "Perform any command on all groups according to the process/prefix convention."
1929 (if (eq (setq func (or func
1932 (substitute-command-keys
1933 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1935 (gnus-error 1 "Undefined key")
1936 (gnus-group-iterate arg
1938 (command-execute func))))
1939 (gnus-group-position-point))
1941 (defun gnus-group-process-prefix (n)
1942 "Return a list of groups to work on.
1943 Take into consideration N (the prefix) and the list of marked groups."
1946 (setq n (prefix-numeric-value n))
1947 ;; There is a prefix, so we return a list of the N next
1949 (let ((way (if (< n 0) -1 1))
1954 (if (setq group (gnus-group-group-name))
1955 (push group groups))
1957 (gnus-group-next-group way)))
1959 ((and (gnus-region-active-p) (mark))
1960 ;; Work on the region between point and mark.
1961 (let ((max (max (point) (mark)))
1964 (goto-char (min (point) (mark)))
1967 (push (gnus-group-group-name) groups)
1968 (zerop (gnus-group-next-group 1))
1970 (nreverse groups))))
1972 ;; No prefix, but a list of marked articles.
1973 (reverse gnus-group-marked))
1975 ;; Neither marked articles or a prefix, so we return the
1977 (let ((group (gnus-group-group-name)))
1978 (and group (list group))))))
1980 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
1981 ;;; imagine why I went through these contortions...
1983 (let ((function (make-symbol "gnus-group-iterate-function"))
1984 (window (make-symbol "gnus-group-iterate-window"))
1985 (groups (make-symbol "gnus-group-iterate-groups"))
1986 (group (make-symbol "gnus-group-iterate-group")))
1988 `(defun gnus-group-iterate (arg ,function)
1989 "Iterate FUNCTION over all process/prefixed groups.
1990 FUNCTION will be called with the group name as the parameter
1991 and with point over the group in question."
1992 (let ((,groups (gnus-group-process-prefix arg))
1993 (,window (selected-window))
1996 (setq ,group (car ,groups)
1997 ,groups (cdr ,groups))
1998 (select-window ,window)
1999 (gnus-group-remove-mark ,group)
2000 (save-selected-window
2002 (funcall ,function ,group)))))))))
2004 (put 'gnus-group-iterate 'lisp-indent-function 1)
2006 ;; Selecting groups.
2008 (defun gnus-group-read-group (&optional all no-article group select-articles)
2009 "Read news in this newsgroup.
2010 If the prefix argument ALL is non-nil, already read articles become
2013 If ALL is a positive number, fetch this number of the latest
2014 articles in the group. If ALL is a negative number, fetch this
2015 number of the earliest articles in the group.
2017 If the optional argument NO-ARTICLE is non-nil, no article will
2018 be auto-selected upon group entry. If GROUP is non-nil, fetch
2021 (let ((no-display (eq all 0))
2022 (group (or group (gnus-group-group-name)))
2023 number active marked entry)
2027 (error "No group on current line"))
2028 (setq marked (gnus-info-marks
2029 (nth 2 (setq entry (gnus-gethash
2030 group gnus-newsrc-hashtb)))))
2031 ;; This group might be a dead group. In that case we have to get
2032 ;; the number of unread articles from `gnus-active-hashtb'.
2034 (cond ((numberp all) all)
2036 ((setq active (gnus-active group))
2037 (- (1+ (cdr active)) (car active)))))
2038 (gnus-summary-read-group
2039 group (or all (and (numberp number)
2040 (zerop (+ number (gnus-range-length
2041 (cdr (assq 'tick marked)))
2043 (cdr (assq 'dormant marked)))))))
2044 no-article nil no-display nil select-articles)))
2046 (defun gnus-group-select-group (&optional all)
2047 "Select this newsgroup.
2048 No article is selected automatically.
2049 If the group is opened, just switch the summary buffer.
2050 If ALL is non-nil, already read articles become readable.
2051 If ALL is a positive number, fetch this number of the latest
2052 articles in the group.
2053 If ALL is a negative number, fetch this number of the earliest
2054 articles in the group."
2056 (when (and (eobp) (not (gnus-group-group-name)))
2058 (gnus-group-read-group all t))
2060 (defun gnus-group-quick-select-group (&optional all)
2061 "Select the current group \"quickly\".
2062 This means that no highlighting or scoring will be performed.
2063 If ALL (the prefix argument) is 0, don't even generate the summary
2066 This might be useful if you want to toggle threading
2067 before entering the group."
2069 (require 'gnus-score)
2071 gnus-score-find-score-files-function
2072 gnus-home-score-file
2073 gnus-apply-kill-hook
2074 gnus-summary-expunge-below)
2075 (gnus-group-read-group all t)))
2077 (defun gnus-group-visible-select-group (&optional all)
2078 "Select the current group without hiding any articles."
2080 (let ((gnus-inhibit-limiting t))
2081 (gnus-group-read-group all t)))
2083 (defun gnus-group-select-group-ephemerally ()
2084 "Select the current group without doing any processing whatsoever.
2085 You will actually be entered into a group that's a copy of
2086 the current group; no changes you make while in this group will
2089 (require 'gnus-score)
2091 gnus-score-find-score-files-function gnus-apply-kill-hook
2092 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2093 gnus-summary-mode-hook gnus-select-group-hook
2094 (group (gnus-group-group-name))
2095 (method (gnus-find-method-for-group group)))
2096 (gnus-group-read-ephemeral-group
2097 (gnus-group-prefixed-name group method) method)))
2100 (defun gnus-fetch-group (group &optional articles)
2101 "Start Gnus if necessary and enter GROUP.
2102 Returns whether the fetching was successful or not."
2103 (interactive (list (completing-read "Group name: " gnus-active-hashtb)))
2104 (unless (get-buffer gnus-group-buffer)
2106 (gnus-group-read-group articles nil group))
2109 (defun gnus-fetch-group-other-frame (group)
2110 "Pop up a frame and enter GROUP."
2112 (let ((window (get-buffer-window gnus-group-buffer)))
2114 (select-frame (window-frame window)))
2115 ((= (length (frame-list)) 1)
2116 (select-frame (make-frame)))
2119 (gnus-fetch-group group))
2121 (defvar gnus-ephemeral-group-server 0)
2123 (defcustom gnus-large-ephemeral-newsgroup 200
2124 "The number of articles which indicates a large ephemeral newsgroup.
2125 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2127 If the number of articles in a newsgroup is greater than this value,
2128 confirmation is required for selecting the newsgroup. If it is nil, no
2129 confirmation is required."
2131 :group 'gnus-group-select
2132 :type '(choice (const :tag "No limit" nil)
2135 (defcustom gnus-fetch-old-ephemeral-headers nil
2136 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2139 :type '(choice (const :tag "off" nil)
2142 (sexp :menu-tag "other" t)))
2144 ;; Enter a group that is not in the group buffer. Non-nil is returned
2145 ;; if selection was successful.
2146 (defun gnus-group-read-ephemeral-group (group method &optional activate
2147 quit-config request-only
2151 "Read GROUP from METHOD as an ephemeral group.
2152 If ACTIVATE, request the group first.
2153 If QUIT-CONFIG, use that window configuration when exiting from the
2155 If REQUEST-ONLY, don't actually read the group; just request it.
2156 If SELECT-ARTICLES, only select those articles.
2157 If PARAMETERS, use those as the group parameters.
2158 If NUMBER, fetch this number of articles.
2160 Return the name of the group if selection was successful."
2163 ;; (gnus-read-group "Group name: ")
2165 "Group: " gnus-active-hashtb
2167 'gnus-group-history)
2168 (gnus-read-method "From method: ")))
2169 ;; Transform the select method into a unique server.
2170 (when (stringp method)
2171 (setq method (gnus-server-to-method method)))
2173 `(,(car method) ,(concat (cadr method) "-ephemeral")
2174 (,(intern (format "%s-address" (car method))) ,(cadr method))
2176 (let ((group (if (gnus-group-foreign-p group) group
2177 (gnus-group-prefixed-name (gnus-group-real-name group)
2182 ,gnus-level-default-subscribed nil nil ,method
2185 (cons 'quit-config quit-config)
2187 (cons gnus-summary-buffer
2188 gnus-current-window-configuration)))
2191 (push method gnus-ephemeral-servers)
2192 (set-buffer gnus-group-buffer)
2193 (unless (gnus-check-server method)
2194 (error "Unable to contact server: %s" (gnus-status-message method)))
2196 (gnus-activate-group group 'scan)
2197 (unless (gnus-request-group group)
2198 (error "Couldn't request group: %s"
2199 (nnheader-get-report (car method)))))
2203 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2204 (gnus-fetch-old-headers
2205 gnus-fetch-old-ephemeral-headers))
2206 (gnus-group-read-group (or number t) t group select-articles))
2210 (message "Quit reading the ephemeral group")
2213 (defun gnus-group-jump-to-group (group)
2214 "Jump to newsgroup GROUP."
2216 (list (mm-string-make-unibyte
2218 "Group: " gnus-active-hashtb nil
2219 (gnus-read-active-file-p)
2220 gnus-group-jump-to-group-prompt
2221 'gnus-group-history))))
2223 (when (equal group "")
2224 (error "Empty group name"))
2226 (unless (gnus-ephemeral-group-p group)
2227 ;; Either go to the line in the group buffer...
2228 (unless (gnus-group-goto-group group)
2229 ;; ... or insert the line.
2230 (gnus-group-update-group group)
2231 (gnus-group-goto-group group)))
2232 ;; Adjust cursor point.
2233 (gnus-group-position-point))
2235 (defun gnus-group-goto-group (group &optional far test-marked)
2236 "Goto to newsgroup GROUP.
2237 If FAR, it is likely that the group is not on the current line.
2238 If TEST-MARKED, the line must be marked."
2242 ;; It's quite likely that we are on the right line, so
2243 ;; we check the current line first.
2245 (eq (get-text-property (point) 'gnus-group)
2246 (gnus-intern-safe group gnus-active-hashtb))
2247 (or (not test-marked) (gnus-group-mark-line-p)))
2249 ;; Previous and next line are also likely, so we check them as well.
2253 (and (eq (get-text-property (point) 'gnus-group)
2254 (gnus-intern-safe group gnus-active-hashtb))
2255 (or (not test-marked) (gnus-group-mark-line-p)))))
2261 (and (eq (get-text-property (point) 'gnus-group)
2262 (gnus-intern-safe group gnus-active-hashtb))
2263 (or (not test-marked) (gnus-group-mark-line-p)))))
2267 (goto-char (point-min))
2269 (while (and (not found)
2274 (gnus-intern-safe group gnus-active-hashtb))))
2275 (if (gnus-group-mark-line-p)
2280 ;; Search through the entire buffer.
2283 (point-min) (point-max)
2284 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2286 (defun gnus-group-next-group (n &optional silent)
2287 "Go to next N'th newsgroup.
2288 If N is negative, search backward instead.
2289 Returns the difference between N and the number of skips actually
2292 (gnus-group-next-unread-group n t nil silent))
2294 (defun gnus-group-next-unread-group (n &optional all level silent)
2295 "Go to next N'th unread newsgroup.
2296 If N is negative, search backward instead.
2297 If ALL is non-nil, choose any newsgroup, unread or not.
2298 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2299 such group can be found, the next group with a level higher than
2301 Returns the difference between N and the number of skips actually
2304 (let ((backward (< n 0))
2307 (gnus-group-search-forward
2308 backward (or (not gnus-group-goto-unread) all) level))
2312 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2313 (if level " on this level or higher" "")))
2316 (defun gnus-group-prev-group (n)
2317 "Go to previous N'th newsgroup.
2318 Returns the difference between N and the number of skips actually
2321 (gnus-group-next-unread-group (- n) t))
2323 (defun gnus-group-prev-unread-group (n)
2324 "Go to previous N'th unread newsgroup.
2325 Returns the difference between N and the number of skips actually
2328 (gnus-group-next-unread-group (- n)))
2330 (defun gnus-group-next-unread-group-same-level (n)
2331 "Go to next N'th unread newsgroup on the same level.
2332 If N is negative, search backward instead.
2333 Returns the difference between N and the number of skips actually
2336 (gnus-group-next-unread-group n t (gnus-group-group-level))
2337 (gnus-group-position-point))
2339 (defun gnus-group-prev-unread-group-same-level (n)
2340 "Go to next N'th unread newsgroup on the same level.
2341 Returns the difference between N and the number of skips actually
2344 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2345 (gnus-group-position-point))
2347 (defun gnus-group-best-unread-group (&optional exclude-group)
2348 "Go to the group with the highest level.
2349 If EXCLUDE-GROUP, do not go to that group."
2351 (goto-char (point-min))
2355 (setq unread (get-text-property (point) 'gnus-unread))
2356 (when (and (numberp unread) (> unread 0))
2357 (when (and (get-text-property (point) 'gnus-level)
2358 (< (get-text-property (point) 'gnus-level) best)
2359 (or (not exclude-group)
2360 (not (equal exclude-group (gnus-group-group-name)))))
2361 (setq best (get-text-property (point) 'gnus-level))
2362 (setq best-point (point))))
2365 (goto-char best-point))
2366 (gnus-group-position-point)
2367 (and best-point (gnus-group-group-name))))
2369 (defun gnus-group-first-unread-group ()
2370 "Go to the first group with unread articles."
2373 (let ((opoint (point))
2375 (goto-char (point-min))
2376 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2377 (and (numberp unread) ; Not a topic.
2378 (not (zerop unread))) ; Has unread articles.
2379 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2382 nil)) ; Not success.
2383 (gnus-group-position-point)))
2385 (defun gnus-group-enter-server-mode ()
2386 "Jump to the server buffer."
2388 (gnus-enter-server-buffer))
2390 (defun gnus-group-make-group (name &optional method address args)
2391 "Add a new newsgroup.
2392 The user will be prompted for a NAME, for a select METHOD, and an
2396 (gnus-read-group "Group name: ")
2397 (gnus-read-method "From method: ")))
2399 (when (stringp method)
2400 (setq method (or (gnus-server-to-method method) method)))
2401 (let* ((meth (gnus-method-simplify
2403 (not (gnus-server-equal method gnus-select-method)))
2404 (if address (list (intern method) address)
2406 (nname (if method (gnus-group-prefixed-name name meth) name))
2408 (when (gnus-gethash nname gnus-newsrc-hashtb)
2409 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2410 ;; Subscribe to the new group.
2411 (gnus-group-change-level
2412 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2413 gnus-level-default-subscribed gnus-level-killed
2414 (and (gnus-group-group-name)
2415 (gnus-gethash (gnus-group-group-name)
2416 gnus-newsrc-hashtb))
2419 (gnus-set-active nname (cons 1 0))
2420 (unless (gnus-ephemeral-group-p name)
2422 (concat "(gnus-group-set-info '"
2423 (gnus-prin1-to-string (cdr info)) ")")))
2425 (gnus-group-insert-group-line-info nname)
2427 (gnus-group-position-point)
2429 ;; Load the back end and try to make the back end create
2430 ;; the group as well.
2431 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2433 gnus-valid-select-methods)
2435 (gnus-check-server meth)
2436 (when (gnus-check-backend-function 'request-create-group nname)
2437 (unless (gnus-request-create-group nname nil args)
2438 (error "Could not create group on server: %s"
2439 (nnheader-get-report backend))))
2442 (defun gnus-group-delete-groups (&optional arg)
2443 "Delete the current group. Only meaningful with editable groups."
2445 (let ((n (length (gnus-group-process-prefix arg))))
2446 (when (gnus-yes-or-no-p
2448 "Delete this 1 group? "
2449 (format "Delete these %d groups? " n)))
2450 (gnus-group-iterate arg
2452 (gnus-group-delete-group group nil t))))))
2454 (defun gnus-group-delete-group (group &optional force no-prompt)
2455 "Delete the current group. Only meaningful with editable groups.
2456 If FORCE (the prefix) is non-nil, all the articles in the group will
2457 be deleted. This is \"deleted\" as in \"removed forever from the face
2458 of the Earth\". There is no undo. The user will be prompted before
2460 Note that you also have to specify FORCE if you want the group to
2461 be removed from the server, even when it's empty."
2463 (list (gnus-group-group-name)
2464 current-prefix-arg))
2466 (error "No group to delete"))
2467 (unless (gnus-check-backend-function 'request-delete-group group)
2468 (error "This back end does not support group deletion"))
2470 (let ((group-decoded (gnus-group-decoded-name group)))
2471 (if (and (not no-prompt)
2472 (not (gnus-yes-or-no-p
2474 "Do you really want to delete %s%s? "
2475 group-decoded (if force " and all its contents" "")))))
2477 (gnus-message 6 "Deleting group %s..." group-decoded)
2478 (if (not (gnus-request-delete-group group force))
2479 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2480 (gnus-message 6 "Deleting group %s...done" group-decoded)
2481 (gnus-group-goto-group group)
2482 (gnus-group-kill-group 1 t)
2483 (gnus-sethash group nil gnus-active-hashtb)
2485 (gnus-group-position-point)))
2487 (defun gnus-group-rename-group (group new-name)
2488 "Rename group from GROUP to NEW-NAME.
2489 When used interactively, GROUP is the group under point
2490 and NEW-NAME will be prompted for."
2493 (gnus-group-group-name)
2495 (unless (gnus-check-backend-function
2496 'request-rename-group (gnus-group-group-name))
2497 (error "This back end does not support renaming groups"))
2498 (gnus-read-group "Rename group to: "
2499 (gnus-group-real-name (gnus-group-group-name))))))
2501 (unless (gnus-check-backend-function 'request-rename-group group)
2502 (error "This back end does not support renaming groups"))
2504 (error "No group to rename"))
2505 (when (equal (gnus-group-real-name group) new-name)
2506 (error "Can't rename to the same name"))
2508 ;; We find the proper prefixed name.
2510 (if (gnus-group-native-p group)
2514 (gnus-group-prefixed-name
2515 (gnus-group-real-name new-name)
2516 (gnus-info-method (gnus-get-info group)))))
2518 (when (gnus-active new-name)
2519 (error "The group %s already exists" new-name))
2521 (gnus-message 6 "Renaming group %s to %s..." group new-name)
2524 (gnus-group-goto-group group)
2525 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2526 (gnus-request-rename-group group new-name))))
2527 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
2528 ;; We rename the group internally by killing it...
2529 (gnus-group-kill-group)
2530 ;; ... changing its name ...
2531 (setcar (cdar gnus-list-of-killed-groups) new-name)
2532 ;; ... and then yanking it. Magic!
2533 (gnus-group-yank-group)
2534 (gnus-set-active new-name (gnus-active group))
2535 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
2537 (setq gnus-killed-list (delete group gnus-killed-list))
2538 (gnus-set-active group nil)
2539 (gnus-dribble-touch)
2540 (gnus-group-position-point)))
2542 (defun gnus-group-edit-group (group &optional part)
2543 "Edit the group on the current line."
2544 (interactive (list (gnus-group-group-name)))
2545 (let ((part (or part 'info))
2548 (error "No group on current line"))
2549 (unless (setq info (gnus-get-info group))
2550 (error "Killed group; can't be edited"))
2552 (gnus-close-group group))
2554 ;; Find the proper form to edit.
2555 (cond ((eq part 'method)
2556 (or (gnus-info-method info) "native"))
2558 (gnus-info-params info))
2560 ;; The proper documentation.
2562 "Editing the %s for `%s'."
2564 ((eq part 'method) "select method")
2565 ((eq part 'params) "group parameters")
2567 (gnus-group-decoded-name group))
2569 (gnus-group-edit-group-done ',part ,group form)))
2572 (gnus-create-info-command
2575 "(gnus)Select Methods")
2577 "(gnus)Group Parameters")
2579 "(gnus)Group Info"))))))
2581 (defun gnus-group-edit-group-method (group)
2582 "Edit the select method of GROUP."
2583 (interactive (list (gnus-group-group-name)))
2584 (gnus-group-edit-group group 'method))
2586 (defun gnus-group-edit-group-parameters (group)
2587 "Edit the group parameters of GROUP."
2588 (interactive (list (gnus-group-group-name)))
2589 (gnus-group-edit-group group 'params))
2591 (defun gnus-group-edit-group-done (part group form)
2593 (let* ((method (cond ((eq part 'info) (nth 4 form))
2594 ((eq part 'method) form)
2596 (info (cond ((eq part 'info) form)
2597 ((eq part 'method) (gnus-get-info group))
2600 (if (or (not method)
2602 gnus-select-method method))
2603 (gnus-group-real-name (car info))
2604 (gnus-group-prefixed-name
2605 (gnus-group-real-name (car info)) method))
2607 (when (and new-group
2608 (not (equal new-group group)))
2609 (when (gnus-group-goto-group group)
2610 (gnus-group-kill-group 1))
2611 (gnus-activate-group new-group))
2613 (if (not (and info new-group))
2614 (gnus-group-set-info form (or new-group group) part)
2615 (setq info (gnus-copy-sequence info))
2616 (setcar info new-group)
2617 (unless (gnus-server-equal method "native")
2618 (unless (nthcdr 3 info)
2619 (nconc info (list nil nil)))
2620 (unless (nthcdr 4 info)
2621 (nconc info (list nil)))
2622 (gnus-info-set-method info method))
2623 (gnus-group-set-info info))
2624 (gnus-group-update-group (or new-group group))
2625 (gnus-group-position-point)))
2627 (defun gnus-group-make-useful-group (group method)
2628 "Create one of the groups described in `gnus-useful-groups'."
2630 (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups
2632 gnus-useful-groups)))
2633 (list (cadr entry) (caddr entry))))
2634 (setq method (gnus-copy-sequence method))
2636 (while (setq entry (memq (assq 'eval method) method))
2637 (setcar entry (eval (cadar entry)))))
2638 (gnus-group-make-group group method))
2640 (defun gnus-group-make-help-group (&optional noerror)
2641 "Create the Gnus documentation group.
2642 Optional argument NOERROR modifies the behavior of this function when the
2643 group already exists:
2644 - if not given, and error is signaled,
2645 - if t, stay silent,
2646 - if anything else, just print a message."
2648 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
2649 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
2650 (if (gnus-gethash name gnus-newsrc-hashtb)
2651 (cond ((eq noerror nil)
2652 (error "Documentation group already exists"))
2657 (gnus-message 1 "Documentation group already exists")))
2660 (gnus-message 1 "Couldn't find doc group")
2661 (gnus-group-make-group
2662 (gnus-group-real-name name)
2663 (list 'nndoc "gnus-help"
2664 (list 'nndoc-address file)
2665 (list 'nndoc-article-type 'mbox))))
2667 (gnus-group-position-point))
2669 (defun gnus-group-make-doc-group (file type)
2670 "Create a group that uses a single file as the source.
2672 If called with a prefix argument, ask for the file type."
2674 (list (read-file-name "File name: ")
2675 (and current-prefix-arg 'ask)))
2676 (when (eq type 'ask)
2681 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
2683 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
2684 ((= char ?b) 'babyl)
2685 ((= char ?d) 'digest)
2686 ((= char ?f) 'forward)
2688 ((= char ?g) 'guess)
2689 (t (setq err (format "%c unknown. " char))
2692 (setq file (expand-file-name file))
2693 (let ((name (gnus-generate-new-group-name
2694 (gnus-group-prefixed-name
2695 (file-name-nondirectory file) '(nndoc ""))))
2696 (encodable (mm-coding-system-p 'utf-8)))
2697 (gnus-group-make-group
2699 (mm-encode-coding-string (gnus-group-real-name name) 'utf-8)
2700 (gnus-group-real-name name))
2701 (list 'nndoc (if encodable
2702 (mm-encode-coding-string file 'utf-8)
2704 (list 'nndoc-address file)
2705 (list 'nndoc-article-type (or type 'guess))))))
2707 (defvar nnweb-type-definition)
2708 (defvar gnus-group-web-type-history nil)
2709 (defvar gnus-group-web-search-history nil)
2710 (defun gnus-group-make-web-group (&optional solid)
2711 "Create an ephemeral nnweb group.
2712 If SOLID (the prefix), create a solid group."
2716 (if solid (gnus-read-group "Group name: ")
2717 (message-unique-id)))
2718 (default-type (or (car gnus-group-web-type-history)
2719 (symbol-name (caar nnweb-type-definition))))
2723 (format "Search engine type (default %s): " default-type)
2724 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2725 nnweb-type-definition)
2726 nil t nil 'gnus-group-web-type-history)
2731 (cons (or (car gnus-group-web-search-history) "") 0)
2732 'gnus-group-web-search-history))
2734 `(nnweb ,group (nnweb-search ,search)
2735 (nnweb-type ,(intern type))
2736 (nnweb-ephemeral-p t))))
2739 (gnus-pull 'nnweb-ephemeral-p method)
2740 (gnus-group-make-group group method))
2741 (gnus-group-read-ephemeral-group
2743 (cons (current-buffer)
2744 (if (eq major-mode 'gnus-summary-mode) 'summary 'group))))))
2747 (defvar nnrss-group-alist)
2748 (defun nnrss-discover-feed (arg))
2749 (defun nnrss-save-server-data (arg)))
2750 (defun gnus-group-make-rss-group (&optional url)
2751 "Given a URL, discover if there is an RSS feed.
2752 If there is, use Gnus to create an nnrss group"
2756 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
2757 (let ((feedinfo (nnrss-discover-feed url)))
2759 (let ((title (gnus-newsgroup-savable-name
2760 (read-from-minibuffer "Title: "
2761 (gnus-newsgroup-savable-name
2762 (or (cdr (assoc 'title
2765 (desc (read-from-minibuffer "Description: "
2766 (cdr (assoc 'description
2768 (href (cdr (assoc 'href feedinfo)))
2769 (encodable (mm-coding-system-p 'utf-8)))
2771 ;; Unify non-ASCII text.
2772 (setq title (mm-decode-coding-string
2773 (mm-encode-coding-string title 'utf-8) 'utf-8)))
2774 (gnus-group-make-group (if encodable
2775 (mm-encode-coding-string title 'utf-8)
2778 (push (list title href desc) nnrss-group-alist)
2779 (nnrss-save-server-data nil))
2780 (error "No feeds found for %s" url))))
2782 (defvar nnwarchive-type-definition)
2783 (defvar gnus-group-warchive-type-history nil)
2784 (defvar gnus-group-warchive-login-history nil)
2785 (defvar gnus-group-warchive-address-history nil)
2787 (defun gnus-group-make-warchive-group ()
2788 "Create a nnwarchive group."
2790 (require 'nnwarchive)
2791 (let* ((group (gnus-read-group "Group name: "))
2792 (default-type (or (car gnus-group-warchive-type-history)
2793 (symbol-name (caar nnwarchive-type-definition))))
2797 (format "Warchive type (default %s): " default-type)
2798 (mapcar (lambda (elem) (list (symbol-name (car elem))))
2799 nnwarchive-type-definition)
2800 nil t nil 'gnus-group-warchive-type-history)
2802 (address (read-string "Warchive address: "
2803 nil 'gnus-group-warchive-address-history))
2804 (default-login (or (car gnus-group-warchive-login-history)
2809 (format "Warchive login (default %s): " user-mail-address)
2810 default-login 'gnus-group-warchive-login-history)
2813 `(nnwarchive ,address
2814 (nnwarchive-type ,(intern type))
2815 (nnwarchive-login ,login))))
2816 (gnus-group-make-group group method)))
2818 (defun gnus-group-make-archive-group (&optional all)
2819 "Create the (ding) Gnus archive group of the most recent articles.
2820 Given a prefix, create a full group."
2822 (let ((group (gnus-group-prefixed-name
2823 (if all "ding.archives" "ding.recent") '(nndir ""))))
2824 (when (gnus-gethash group gnus-newsrc-hashtb)
2825 (error "Archive group already exists"))
2826 (gnus-group-make-group
2827 (gnus-group-real-name group)
2828 (list 'nndir (if all "hpc" "edu")
2829 (list 'nndir-directory
2830 (if all gnus-group-archive-directory
2831 gnus-group-recent-archive-directory))))
2832 (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org"))))
2834 (defun gnus-group-make-directory-group (dir)
2835 "Create an nndir group.
2836 The user will be prompted for a directory. The contents of this
2837 directory will be used as a newsgroup. The directory should contain
2838 mail messages or news articles in files that have numeric names."
2840 (list (read-file-name "Create group from directory: ")))
2841 (unless (file-exists-p dir)
2842 (error "No such directory"))
2843 (unless (file-directory-p dir)
2844 (error "Not a directory"))
2848 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
2850 (gnus-group-prefixed-name
2851 (expand-file-name ext dir)
2853 (setq ext (format "<%d>" (setq i (1+ i)))))
2854 (gnus-group-make-group
2855 (gnus-group-real-name group)
2856 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
2858 (defvar nnkiboze-score-file)
2859 (defun gnus-group-make-kiboze-group (group address scores)
2860 "Create an nnkiboze group.
2861 The user will be prompted for a name, a regexp to match groups, and
2862 score file entries for articles to include in the group."
2865 (read-string "nnkiboze group name: ")
2866 (read-string "Source groups (regexp): ")
2867 (let ((headers (mapcar (lambda (group) (list group))
2868 '("subject" "from" "number" "date" "message-id"
2869 "references" "chars" "lines" "xref"
2870 "followup" "all" "body" "head")))
2871 scores header regexp regexps)
2872 (while (not (equal "" (setq header (completing-read
2873 "Match on header: " headers nil t))))
2875 (while (not (equal "" (setq regexp (read-string
2876 (format "Match on %s (regexp): "
2878 (push (list regexp nil nil 'r) regexps))
2879 (push (cons header regexps) scores))
2881 (gnus-group-make-group group "nnkiboze" address)
2882 (let* ((nnkiboze-current-group group)
2883 (score-file (car (nnkiboze-score-file "")))
2884 (score-dir (file-name-directory score-file)))
2885 (unless (file-exists-p score-dir)
2886 (make-directory score-dir))
2887 (with-temp-file score-file
2888 (let (emacs-lisp-mode-hook)
2889 (gnus-pp scores)))))
2891 (defun gnus-group-add-to-virtual (n vgroup)
2892 "Add the current group to a virtual group."
2894 (list current-prefix-arg
2895 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
2897 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
2898 (error "%s is not an nnvirtual group" vgroup))
2899 (gnus-close-group vgroup)
2900 (let* ((groups (gnus-group-process-prefix n))
2901 (method (gnus-info-method (gnus-get-info vgroup))))
2902 (setcar (cdr method)
2904 (nth 1 method) "\\|"
2907 (gnus-group-remove-mark s)
2908 (concat "\\(^" (regexp-quote s) "$\\)"))
2910 (gnus-group-position-point))
2912 (defun gnus-group-make-empty-virtual (group)
2913 "Create a new, fresh, empty virtual group."
2914 (interactive "sCreate new, empty virtual group: ")
2915 (let* ((method (list 'nnvirtual "^$"))
2916 (pgroup (gnus-group-prefixed-name group method)))
2917 ;; Check whether it exists already.
2918 (when (gnus-gethash pgroup gnus-newsrc-hashtb)
2919 (error "Group %s already exists" pgroup))
2920 ;; Subscribe the new group after the group on the current line.
2921 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
2922 (gnus-group-update-group pgroup)
2924 (gnus-group-position-point)))
2926 (defun gnus-group-enter-directory (dir)
2927 "Enter an ephemeral nneething group."
2928 (interactive "DDirectory to read: ")
2929 (let* ((method (list 'nneething dir '(nneething-read-only t)))
2930 (leaf (gnus-group-prefixed-name
2931 (file-name-nondirectory (directory-file-name dir))
2933 (name (gnus-generate-new-group-name leaf)))
2934 (unless (gnus-group-read-ephemeral-group
2936 (cons (current-buffer)
2937 (if (eq major-mode 'gnus-summary-mode)
2939 (error "Couldn't enter %s" dir))))
2942 (autoload 'nnimap-expunge "nnimap")
2943 (autoload 'nnimap-acl-get "nnimap")
2944 (autoload 'nnimap-acl-edit "nnimap"))
2946 (defun gnus-group-nnimap-expunge (group)
2947 "Expunge deleted articles in current nnimap GROUP."
2948 (interactive (list (gnus-group-group-name)))
2949 (let ((mailbox (gnus-group-real-name group)) method)
2951 (error "No group on current line"))
2952 (unless (gnus-get-info group)
2953 (error "Killed group; can't be edited"))
2954 (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group))))
2955 (error "%s is not an nnimap group" group))
2956 (nnimap-expunge mailbox (cadr method))))
2958 (defun gnus-group-nnimap-edit-acl (group)
2959 "Edit the Access Control List of current nnimap GROUP."
2960 (interactive (list (gnus-group-group-name)))
2961 (let ((mailbox (gnus-group-real-name group)) method acl)
2963 (error "No group on current line"))
2964 (unless (gnus-get-info group)
2965 (error "Killed group; can't be edited"))
2966 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
2967 (error "%s is not an nnimap group" group))
2968 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
2969 (error "Server does not support ACL's"))
2970 (gnus-edit-form acl (format "Editing the access control list for `%s'.
2972 An access control list is a list of (identifier . rights) elements.
2974 The identifier string specifies the corresponding user. The
2975 identifier \"anyone\" is reserved to refer to the universal identity.
2977 Rights is a string listing a (possibly empty) set of alphanumeric
2978 characters, each character listing a set of operations which is being
2979 controlled. Letters are reserved for ``standard'' rights, listed
2980 below. Digits are reserved for implementation or site defined rights.
2982 l - lookup (mailbox is visible to LIST/LSUB commands)
2983 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
2984 SEARCH, COPY from mailbox)
2985 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
2986 w - write (STORE flags other than \\SEEN and \\DELETED)
2987 i - insert (perform APPEND, COPY into mailbox)
2988 p - post (send mail to submission address for mailbox,
2989 not enforced by IMAP4 itself)
2990 c - create and delete mailbox (CREATE new sub-mailboxes in any
2991 implementation-defined hierarchy, RENAME or DELETE mailbox)
2992 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
2993 a - administer (perform SETACL)" group)
2996 ,mailbox ',method ',acl form)))))
2998 ;; Group sorting commands
2999 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3001 (defun gnus-group-sort-groups (func &optional reverse)
3002 "Sort the group buffer according to FUNC.
3003 When used interactively, the sorting function used will be
3004 determined by the `gnus-group-sort-function' variable.
3005 If REVERSE (the prefix), reverse the sorting order."
3006 (interactive (list gnus-group-sort-function current-prefix-arg))
3007 (funcall gnus-group-sort-alist-function
3008 (gnus-make-sort-function func) reverse)
3009 (gnus-group-unmark-all-groups)
3010 (gnus-group-list-groups)
3011 (gnus-dribble-touch))
3013 (defun gnus-group-sort-flat (func reverse)
3014 ;; We peel off the dummy group from the alist.
3016 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
3017 (pop gnus-newsrc-alist))
3019 (setq gnus-newsrc-alist
3020 (sort gnus-newsrc-alist func))
3022 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
3023 ;; Regenerate the hash table.
3024 (gnus-make-hashtable-from-newsrc-alist)))
3026 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
3027 "Sort the group buffer alphabetically by group name.
3028 If REVERSE, sort in reverse order."
3030 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
3032 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
3033 "Sort the group buffer alphabetically by real (unprefixed) group name.
3034 If REVERSE, sort in reverse order."
3036 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
3038 (defun gnus-group-sort-groups-by-unread (&optional reverse)
3039 "Sort the group buffer by number of unread articles.
3040 If REVERSE, sort in reverse order."
3042 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
3044 (defun gnus-group-sort-groups-by-level (&optional reverse)
3045 "Sort the group buffer by group level.
3046 If REVERSE, sort in reverse order."
3048 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
3050 (defun gnus-group-sort-groups-by-score (&optional reverse)
3051 "Sort the group buffer by group score.
3052 If REVERSE, sort in reverse order."
3054 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
3056 (defun gnus-group-sort-groups-by-rank (&optional reverse)
3057 "Sort the group buffer by group rank.
3058 If REVERSE, sort in reverse order."
3060 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
3062 (defun gnus-group-sort-groups-by-method (&optional reverse)
3063 "Sort the group buffer alphabetically by back end name.
3064 If REVERSE, sort in reverse order."
3066 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
3068 (defun gnus-group-sort-groups-by-server (&optional reverse)
3069 "Sort the group buffer alphabetically by server name.
3070 If REVERSE, sort in reverse order."
3072 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
3074 ;;; Selected group sorting.
3076 (defun gnus-group-sort-selected-groups (n func &optional reverse)
3077 "Sort the process/prefixed groups."
3078 (interactive (list current-prefix-arg gnus-group-sort-function))
3079 (let ((groups (gnus-group-process-prefix n)))
3080 (funcall gnus-group-sort-selected-function
3081 groups (gnus-make-sort-function func) reverse)
3082 (gnus-group-unmark-all-groups)
3083 (gnus-group-list-groups)
3084 (gnus-dribble-touch)))
3086 (defun gnus-group-sort-selected-flat (groups func reverse)
3087 (let (entries infos)
3088 ;; First find all the group entries for these groups.
3090 (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb))
3092 ;; Then sort the infos.
3096 (lambda (entry) (car entry))
3097 (setq entries (nreverse entries)))
3100 (setq infos (nreverse infos)))
3101 ;; Go through all the infos and replace the old entries
3102 ;; with the new infos.
3104 (setcar (car entries) (pop infos))
3106 ;; Update the hashtable.
3107 (gnus-make-hashtable-from-newsrc-alist)))
3109 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3110 "Sort the group buffer alphabetically by group name.
3111 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3112 sort in reverse order."
3113 (interactive (gnus-interactive "P\ny"))
3114 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3116 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3117 "Sort the group buffer alphabetically by real group name.
3118 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3119 sort in reverse order."
3120 (interactive (gnus-interactive "P\ny"))
3121 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3123 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3124 "Sort the group buffer by number of unread articles.
3125 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3126 sort in reverse order."
3127 (interactive (gnus-interactive "P\ny"))
3128 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3130 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3131 "Sort the group buffer by group level.
3132 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3133 sort in reverse order."
3134 (interactive (gnus-interactive "P\ny"))
3135 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3137 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3138 "Sort the group buffer by group score.
3139 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3140 sort in reverse order."
3141 (interactive (gnus-interactive "P\ny"))
3142 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3144 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3145 "Sort the group buffer by group rank.
3146 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3147 sort in reverse order."
3148 (interactive (gnus-interactive "P\ny"))
3149 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3151 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3152 "Sort the group buffer alphabetically by back end name.
3153 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3154 sort in reverse order."
3155 (interactive (gnus-interactive "P\ny"))
3156 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3158 ;;; Sorting predicates.
3160 (defun gnus-group-sort-by-alphabet (info1 info2)
3161 "Sort alphabetically."
3162 (string< (gnus-info-group info1) (gnus-info-group info2)))
3164 (defun gnus-group-sort-by-real-name (info1 info2)
3165 "Sort alphabetically on real (unprefixed) names."
3166 (string< (gnus-group-real-name (gnus-info-group info1))
3167 (gnus-group-real-name (gnus-info-group info2))))
3169 (defun gnus-group-sort-by-unread (info1 info2)
3170 "Sort by number of unread articles."
3171 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
3172 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
3173 (< (or (and (numberp n1) n1) 0)
3174 (or (and (numberp n2) n2) 0))))
3176 (defun gnus-group-sort-by-level (info1 info2)
3178 (< (gnus-info-level info1) (gnus-info-level info2)))
3180 (defun gnus-group-sort-by-method (info1 info2)
3181 "Sort alphabetically by back end name."
3182 (string< (car (gnus-find-method-for-group
3183 (gnus-info-group info1) info1))
3184 (car (gnus-find-method-for-group
3185 (gnus-info-group info2) info2))))
3187 (defun gnus-group-sort-by-server (info1 info2)
3188 "Sort alphabetically by server name."
3189 (string< (gnus-method-to-full-server-name
3190 (gnus-find-method-for-group
3191 (gnus-info-group info1) info1))
3192 (gnus-method-to-full-server-name
3193 (gnus-find-method-for-group
3194 (gnus-info-group info2) info2))))
3196 (defun gnus-group-sort-by-score (info1 info2)
3197 "Sort by group score."
3198 (> (gnus-info-score info1) (gnus-info-score info2)))
3200 (defun gnus-group-sort-by-rank (info1 info2)
3201 "Sort by level and score."
3202 (let ((level1 (gnus-info-level info1))
3203 (level2 (gnus-info-level info2)))
3204 (or (< level1 level2)
3205 (and (= level1 level2)
3206 (> (gnus-info-score info1) (gnus-info-score info2))))))
3210 (defun gnus-group-clear-data (&optional arg)
3211 "Clear all marks and read ranges from the current group.
3212 Obeys the process/prefix convention."
3214 (gnus-group-iterate arg
3217 (gnus-info-clear-data (setq info (gnus-get-info group)))
3218 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3219 (when (gnus-group-goto-group group)
3220 (gnus-group-update-group-line))))))
3222 (defun gnus-group-clear-data-on-native-groups ()
3223 "Clear all marks and read ranges from all native groups."
3225 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3226 (let ((alist (cdr gnus-newsrc-alist))
3228 (while (setq info (pop alist))
3229 (when (gnus-group-native-p (gnus-info-group info))
3230 (gnus-info-clear-data info)))
3231 (gnus-get-unread-articles)
3232 (gnus-dribble-touch)
3233 (when (gnus-y-or-n-p
3234 "Move the cache away to avoid problems in the future? ")
3235 (call-interactively 'gnus-cache-move-cache)))))
3237 (defun gnus-info-clear-data (info)
3238 "Clear all marks and read ranges from INFO."
3239 (let ((group (gnus-info-group info))
3241 (dolist (el (gnus-info-marks info))
3242 (push `(,(cdr el) add (,(car el))) action))
3243 (push `(,(gnus-info-read info) add (read)) action)
3246 (gnus-request-set-mark ,group ',action)
3247 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3248 (gnus-info-set-read ',info ',(gnus-info-read info))
3249 (when (gnus-group-goto-group ,group)
3250 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3251 (gnus-group-update-group-line))))
3252 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3254 (gnus-request-set-mark group action)
3255 (gnus-info-set-read info nil)
3256 (when (gnus-info-marks info)
3257 (gnus-info-set-marks info nil))))
3259 ;; Group catching up.
3261 (defun gnus-group-catchup-current (&optional n all)
3262 "Mark all unread articles in the current newsgroup as read.
3263 If prefix argument N is numeric, the next N newsgroups will be
3264 caught up. If ALL is non-nil, marked articles will also be marked as
3265 read. Cross references (Xref: header) of articles are ignored.
3266 The number of newsgroups that this function was unable to catch
3269 (let ((groups (gnus-group-process-prefix n))
3272 (unless groups (error "No groups selected"))
3274 (or (not gnus-interactive-catchup) ;Without confirmation?
3279 "Do you really want to mark all articles in %s as read? "
3280 "Mark all unread articles in %s as read? ")
3281 (if (= (length groups) 1)
3282 (gnus-group-decoded-name (car groups))
3283 (format "these %d groups" (length groups)))))))
3285 (while (setq group (pop groups))
3286 (gnus-group-remove-mark group)
3287 ;; Virtual groups have to be given special treatment.
3288 (let ((method (gnus-find-method-for-group group)))
3289 (when (eq 'nnvirtual (car method))
3290 (nnvirtual-catchup-group
3291 (gnus-group-real-name group) (nth 1 method) all)))
3292 (if (>= (gnus-group-level group) gnus-level-zombie)
3293 (gnus-message 2 "Dead groups can't be caught up")
3295 (gnus-group-goto-group group)
3296 (gnus-group-catchup group all))
3297 (gnus-group-update-group-line)
3298 (setq ret (1+ ret)))))
3299 (gnus-group-next-unread-group 1)
3302 (defun gnus-group-catchup-current-all (&optional n)
3303 "Mark all articles in current newsgroup as read.
3304 Cross references (Xref: header) of articles are ignored."
3306 (gnus-group-catchup-current n 'all))
3308 (defun gnus-group-catchup (group &optional all)
3309 "Mark all articles in GROUP as read.
3310 If ALL is non-nil, all articles are marked as read.
3311 The return value is the number of articles that were marked as read,
3312 or nil if no action could be taken."
3313 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3315 (marks (nth 3 (nth 2 entry)))
3316 (unread (gnus-sequence-of-unread-articles group)))
3317 ;; Remove entries for this group.
3318 (nnmail-purge-split-history (gnus-group-real-name group))
3319 ;; Do the updating only if the newsgroup isn't killed.
3320 (if (not (numberp (car entry)))
3321 (gnus-message 1 "Can't catch up %s; non-active group" group)
3322 (gnus-update-read-articles group nil)
3324 ;; Nix out the lists of marks and dormants.
3325 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3327 (list (cdr (assq 'dormant marks))
3329 (setq unread (gnus-range-add (gnus-range-add
3330 unread (cdr (assq 'dormant marks)))
3331 (cdr (assq 'tick marks))))
3332 (gnus-add-marked-articles group 'tick nil nil 'force)
3333 (gnus-add-marked-articles group 'dormant nil nil 'force))
3334 ;; Do auto-expirable marks if that's required.
3335 (when (gnus-group-auto-expirable-p group)
3336 (gnus-range-map (lambda (article)
3337 (gnus-add-marked-articles group 'expire (list article))
3338 (gnus-request-set-mark group (list (list (list article) 'add '(expire)))))
3340 (let ((gnus-newsgroup-name group))
3341 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3344 (defun gnus-group-expire-articles (&optional n)
3345 "Expire all expirable articles in the current newsgroup.
3346 Uses the process/prefix convention."
3348 (let ((groups (gnus-group-process-prefix n))
3351 (error "No groups to expire"))
3352 (while (setq group (pop groups))
3353 (gnus-group-remove-mark group)
3354 (gnus-group-expire-articles-1 group)
3355 (gnus-dribble-touch)
3356 (gnus-group-position-point))))
3358 (defun gnus-group-expire-articles-1 (group)
3359 (when (gnus-check-backend-function 'request-expire-articles group)
3360 (gnus-message 6 "Expiring articles in %s..."
3361 (gnus-group-decoded-name group))
3362 (let* ((info (gnus-get-info group))
3363 (expirable (if (gnus-group-total-expirable-p group)
3364 (cons nil (gnus-list-of-read-articles group))
3365 (assq 'expire (gnus-info-marks info))))
3366 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3367 (nnmail-expiry-target
3368 (or (gnus-group-find-parameter group 'expiry-target)
3369 nnmail-expiry-target)))
3371 (gnus-check-group group)
3374 (gnus-compress-sequence
3376 ;; We set the expiry variables to the group
3378 (let ((nnmail-expiry-wait-function nil)
3379 (nnmail-expiry-wait expiry-wait))
3380 (gnus-request-expire-articles
3381 (gnus-uncompress-sequence (cdr expirable)) group))
3382 ;; Just expire using the normal expiry values.
3383 (gnus-request-expire-articles
3384 (gnus-uncompress-sequence (cdr expirable)) group))))
3385 (gnus-close-group group))
3386 (gnus-message 6 "Expiring articles in %s...done"
3387 (gnus-group-decoded-name group))
3388 ;; Return the list of un-expired articles.
3391 (defun gnus-group-expire-all-groups ()
3392 "Expire all expirable articles in all newsgroups."
3395 (gnus-message 5 "Expiring...")
3396 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3397 (cdr gnus-newsrc-alist))))
3398 (gnus-group-expire-articles nil)))
3399 (gnus-group-position-point)
3400 (gnus-message 5 "Expiring...done"))
3402 (defun gnus-group-set-current-level (n level)
3403 "Set the level of the next N groups to LEVEL."
3408 (unless (gnus-group-process-prefix current-prefix-arg)
3409 (error "No group on the current line"))
3411 (let ((s (read-string
3412 (format "Level (default %s): "
3413 (or (gnus-group-group-level)
3414 gnus-level-default-subscribed)))))
3415 (if (string-match "^\\s-*$" s)
3416 (int-to-string (or (gnus-group-group-level)
3417 gnus-level-default-subscribed))
3419 (unless (and (>= level 1) (<= level gnus-level-killed))
3420 (error "Invalid level: %d" level))
3421 (let ((groups (gnus-group-process-prefix n))
3423 (while (setq group (pop groups))
3424 (gnus-group-remove-mark group)
3425 (gnus-message 6 "Changed level of %s from %d to %d"
3426 (gnus-group-decoded-name group)
3427 (or (gnus-group-group-level) gnus-level-killed)
3429 (gnus-group-change-level
3430 group level (or (gnus-group-group-level) gnus-level-killed))
3431 (gnus-group-update-group-line)))
3432 (gnus-group-position-point))
3434 (defun gnus-group-unsubscribe (&optional n)
3435 "Unsubscribe the current group."
3437 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3439 (defun gnus-group-subscribe (&optional n)
3440 "Subscribe the current group."
3442 (gnus-group-unsubscribe-current-group n 'subscribe))
3444 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3445 "Toggle subscription of the current group.
3446 If given numerical prefix, toggle the N next groups."
3448 (dolist (group (gnus-group-process-prefix n))
3449 (gnus-group-remove-mark group)
3450 (gnus-group-unsubscribe-group
3453 ((eq do-sub 'unsubscribe)
3454 gnus-level-default-unsubscribed)
3455 ((eq do-sub 'subscribe)
3456 gnus-level-default-subscribed)
3457 ((<= (gnus-group-group-level) gnus-level-subscribed)
3458 gnus-level-default-unsubscribed)
3460 gnus-level-default-subscribed))
3462 (gnus-group-update-group-line))
3463 (gnus-group-next-group 1))
3465 (defun gnus-group-unsubscribe-group (group &optional level silent)
3466 "Toggle subscription to GROUP.
3467 Killed newsgroups are subscribed. If SILENT, don't try to update the
3470 (list (completing-read
3471 "Group: " gnus-active-hashtb nil
3472 (gnus-read-active-file-p)
3474 'gnus-group-history)))
3475 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3477 ((string-match "^[ \t]*$" group)
3478 (error "Empty group name"))
3480 ;; Toggle subscription flag.
3481 (gnus-group-change-level
3482 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3483 gnus-level-subscribed)
3484 (1+ gnus-level-subscribed)
3485 gnus-level-default-subscribed)))
3487 (gnus-group-update-group group)))
3488 ((and (stringp group)
3489 (or (not (gnus-read-active-file-p))
3490 (gnus-active group)))
3491 ;; Add new newsgroup.
3492 (gnus-group-change-level
3494 (if level level gnus-level-default-subscribed)
3495 (or (and (member group gnus-zombie-list)
3498 (when (gnus-group-group-name)
3499 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
3501 (gnus-group-update-group group)))
3502 (t (error "No such newsgroup: %s" group)))
3503 (gnus-group-position-point)))
3505 (defun gnus-group-transpose-groups (n)
3506 "Move the current newsgroup up N places.
3507 If given a negative prefix, move down instead. The difference between
3508 N and the number of steps taken is returned."
3510 (unless (gnus-group-group-name)
3511 (error "No group on current line"))
3512 (gnus-group-kill-group 1)
3514 (forward-line (- n))
3515 (gnus-group-yank-group)
3516 (gnus-group-position-point)))
3518 (defun gnus-group-kill-all-zombies (&optional dummy)
3519 "Kill all zombie newsgroups.
3520 The optional DUMMY should always be nil."
3521 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3523 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3524 (setq gnus-zombie-list nil)
3525 (gnus-dribble-touch)
3526 (gnus-group-list-groups)))
3528 (defun gnus-group-kill-region (begin end)
3529 "Kill newsgroups in current region (excluding current point).
3530 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3545 (beginning-of-line) ;Important when LINES < 1
3546 (gnus-group-kill-group lines)))
3548 (defun gnus-group-kill-group (&optional n discard)
3549 "Kill the next N groups.
3550 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3551 However, only groups that were alive can be yanked; already killed
3552 groups or zombie groups can't be yanked.
3553 The return value is the name of the group that was killed, or a list
3556 (let ((buffer-read-only nil)
3557 (groups (gnus-group-process-prefix n))
3558 group entry level out)
3559 (if (< (length groups) 10)
3560 ;; This is faster when there are few groups.
3562 (push (setq group (pop groups)) out)
3563 (gnus-group-remove-mark group)
3564 (setq level (gnus-group-group-level))
3566 (when (and (not discard)
3567 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
3570 (gnus-group-goto-group ,(gnus-group-group-name))
3571 (gnus-group-yank-group)))
3572 (push (cons (car entry) (nth 2 entry))
3573 gnus-list-of-killed-groups))
3574 (gnus-group-change-level
3575 (if entry entry group) gnus-level-killed (if entry nil level))
3576 (message "Killed group %s" (gnus-group-decoded-name group)))
3577 ;; If there are lots and lots of groups to be killed, we use
3578 ;; this thing instead.
3579 (dolist (group (nreverse groups))
3580 (gnus-group-remove-mark group)
3582 (push group gnus-killed-list)
3583 (setq gnus-newsrc-alist
3584 (delq (assoc group gnus-newsrc-alist)
3586 (when gnus-group-change-level-function
3587 (funcall gnus-group-change-level-function
3588 group gnus-level-killed 3))
3590 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
3591 (push (cons (car entry) (nth 2 entry))
3592 gnus-list-of-killed-groups)
3593 (setcdr (cdr entry) (cdddr entry)))
3594 ((member group gnus-zombie-list)
3595 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3596 ;; There may be more than one instance displayed.
3597 (while (gnus-group-goto-group group)
3598 (gnus-delete-line)))
3599 (gnus-make-hashtable-from-newsrc-alist))
3601 (gnus-group-position-point)
3602 (if (< (length out) 2) (car out) (nreverse out))))
3604 (defun gnus-group-yank-group (&optional arg)
3605 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3606 The numeric ARG specifies how many newsgroups are to be yanked. The
3607 name of the newsgroup yanked is returned, or (if several groups are
3608 yanked) a list of yanked groups is returned."
3610 (setq arg (or arg 1))
3611 (let (info group prev out)
3612 (while (>= (decf arg) 0)
3613 (when (not (setq info (pop gnus-list-of-killed-groups)))
3614 (error "No more newsgroups to yank"))
3615 (push (setq group (nth 1 info)) out)
3616 ;; Find which newsgroup to insert this one before - search
3617 ;; backward until something suitable is found. If there are no
3618 ;; other newsgroups in this buffer, just make this newsgroup the
3620 (setq prev (gnus-group-group-name))
3621 (gnus-group-change-level
3622 info (gnus-info-level (cdr info)) gnus-level-killed
3623 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
3625 (gnus-group-insert-group-line-info group)
3627 `(when (gnus-group-goto-group ,group)
3628 (gnus-group-kill-group 1))))
3630 (gnus-group-position-point)
3631 (if (< (length out) 2) (car out) (nreverse out))))
3633 (defun gnus-group-kill-level (level)
3634 "Kill all groups that is on a certain LEVEL."
3635 (interactive "nKill all groups on level: ")
3637 ((= level gnus-level-zombie)
3638 (setq gnus-killed-list
3639 (nconc gnus-zombie-list gnus-killed-list))
3640 (setq gnus-zombie-list nil))
3641 ((and (< level gnus-level-zombie)
3643 (or gnus-expert-user
3646 "Do you really want to kill all groups on level %d? "
3648 (let* ((prev gnus-newsrc-alist)
3651 (if (= (gnus-info-level (car alist)) level)
3653 (push (gnus-info-group (car alist)) gnus-killed-list)
3654 (setcdr prev (cdr alist)))
3656 (setq alist (cdr alist)))
3657 (gnus-make-hashtable-from-newsrc-alist)
3658 (gnus-group-list-groups)))
3660 (error "Can't kill; invalid level: %d" level))))
3662 (defun gnus-group-list-all-groups (&optional arg)
3663 "List all newsgroups with level ARG or lower.
3664 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3665 unsubscribed groups."
3667 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3669 ;; Redefine this to list ALL killed groups if prefix arg used.
3670 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3671 (defun gnus-group-list-killed (&optional arg)
3672 "List all killed newsgroups in the group buffer.
3673 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3674 entail asking the server for the groups."
3676 ;; Find all possible killed newsgroups if arg.
3678 (gnus-get-killed-groups))
3679 (if (not gnus-killed-list)
3680 (gnus-message 6 "No killed groups")
3681 (let (gnus-group-list-mode)
3682 (funcall gnus-group-prepare-function
3683 gnus-level-killed t gnus-level-killed))
3684 (goto-char (point-min)))
3685 (gnus-group-position-point))
3687 (defun gnus-group-list-zombies ()
3688 "List all zombie newsgroups in the group buffer."
3690 (if (not gnus-zombie-list)
3691 (gnus-message 6 "No zombie groups")
3692 (let (gnus-group-list-mode)
3693 (funcall gnus-group-prepare-function
3694 gnus-level-zombie t gnus-level-zombie))
3695 (goto-char (point-min)))
3696 (gnus-group-position-point))
3698 (defun gnus-group-list-active ()
3699 "List all groups that are available from the server(s)."
3701 ;; First we make sure that we have really read the active file.
3702 (unless (gnus-read-active-file-p)
3703 (let ((gnus-read-active-file t)
3704 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3705 (gnus-read-active-file)))
3706 ;; Find all groups and sort them.
3714 (push (symbol-name sym) list)))
3718 (buffer-read-only nil)
3722 (setq group (pop groups))
3723 (gnus-add-text-properties
3724 (point) (prog1 (1+ (point))
3726 (gnus-group-decoded-name group)
3728 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
3730 'gnus-level (inline (gnus-group-level group)))))
3731 (goto-char (point-min))))
3733 (defun gnus-activate-all-groups (level)
3734 "Activate absolutely all groups."
3735 (interactive (list gnus-level-unsubscribed))
3736 (let ((gnus-activate-level level)
3737 (gnus-activate-foreign-newsgroups level))
3738 (gnus-group-get-new-news)))
3740 (defun gnus-group-get-new-news (&optional arg)
3741 "Get newly arrived articles.
3742 If ARG is a number, it specifies which levels you are interested in
3743 re-scanning. If ARG is non-nil and not a number, this will force
3744 \"hard\" re-reading of the active files from all servers."
3747 (let ((gnus-inhibit-demon t)
3748 ;; Binding this variable will inhibit multiple fetchings
3749 ;; of the same mail source.
3750 (nnmail-fetched-sources (list t)))
3751 (gnus-run-hooks 'gnus-get-top-new-news-hook)
3752 (gnus-run-hooks 'gnus-get-new-news-hook)
3754 ;; Read any slave files.
3756 (gnus-master-read-slave-newsrc))
3758 ;; We might read in new NoCeM messages here.
3759 (when (and gnus-use-nocem
3760 (or (and (numberp gnus-use-nocem)
3762 (>= arg gnus-use-nocem))
3764 (gnus-nocem-scan-groups))
3765 ;; If ARG is not a number, then we read the active file.
3766 (when (and arg (not (numberp arg)))
3767 (let ((gnus-read-active-file t))
3768 (gnus-read-active-file))
3771 ;; If the user wants it, we scan for new groups.
3772 (when (eq gnus-check-new-newsgroups 'always)
3773 (gnus-find-new-newsgroups)))
3775 (setq arg (gnus-group-default-level arg t))
3776 (if (and gnus-read-active-file (not arg))
3778 (gnus-read-active-file)
3779 (gnus-get-unread-articles arg))
3780 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
3781 (gnus-get-unread-articles arg)))
3782 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
3783 (gnus-group-list-groups (and (numberp arg)
3784 (max (car gnus-group-list-mode) arg)))))
3786 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
3787 "Check for newly arrived news in the current group (and the N-1 next groups).
3788 The difference between N and the number of newsgroup checked is returned.
3789 If N is negative, this group and the N-1 previous groups will be checked.
3790 If DONT-SCAN is non-nil, scan non-activated groups as well."
3792 (let* ((groups (gnus-group-process-prefix n))
3793 (ret (if (numberp n) (- n (length groups)) 0))
3797 (gnus-inhibit-demon t)
3798 ;; Binding this variable will inhibit multiple fetchings
3799 ;; of the same mail source.
3800 (nnmail-fetched-sources (list t)))
3801 (gnus-run-hooks 'gnus-get-new-news-hook)
3802 (while (setq group (pop groups))
3803 (gnus-group-remove-mark group)
3804 ;; Bypass any previous denials from the server.
3805 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
3806 (if (gnus-activate-group group (if dont-scan nil 'scan))
3808 (gnus-get-unread-articles-in-group
3809 (gnus-get-info group) (gnus-active group) t)
3810 (unless (gnus-virtual-group-p group)
3811 (gnus-close-group group))
3813 (gnus-agent-save-group-info
3814 method (gnus-group-real-name group) (gnus-active group)))
3815 (gnus-group-update-group group))
3816 (if (eq (gnus-server-status (gnus-find-method-for-group group))
3818 (gnus-error 3 "Server denied access")
3819 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
3822 (when gnus-goto-next-group-when-activating
3823 (gnus-group-next-unread-group 1 t))
3824 (gnus-summary-position-point)
3827 (defun gnus-group-fetch-faq (group &optional faq-dir)
3828 "Fetch the FAQ for the current group.
3829 If given a prefix argument, prompt for the FAQ dir
3833 (gnus-group-group-name)
3834 (when current-prefix-arg
3836 "FAQ dir: " (and (listp gnus-group-faq-directory)
3838 gnus-group-faq-directory))))))
3840 (error "No group name given"))
3841 (let ((dirs (or faq-dir gnus-group-faq-directory))
3843 (unless (listp dirs)
3844 (setq dirs (list dirs)))
3845 (while (and (not found)
3846 (setq dir (pop dirs)))
3847 (let ((name (gnus-group-real-name group)))
3848 (setq file (expand-file-name name dir)))
3849 (if (not (file-exists-p file))
3850 (gnus-message 1 "No such file: %s" file)
3851 (let ((enable-local-variables nil))
3855 (defun gnus-group-fetch-charter (group)
3856 "Fetch the charter for the current group.
3857 If given a prefix argument, prompt for a group."
3859 (list (or (when current-prefix-arg
3860 (completing-read "Group: " gnus-active-hashtb))
3861 (gnus-group-group-name)
3862 gnus-newsgroup-name)))
3864 (error "No group name given"))
3866 (condition-case nil (require 'url-http) (error nil))
3867 (let ((name (mm-url-form-encode-xwfu (gnus-group-real-name group)))
3869 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3870 (setq hierarchy (match-string 1 name))
3871 (if (and (setq url (cdr (assoc hierarchy gnus-group-charter-alist)))
3872 (if (fboundp 'url-http-file-exists-p)
3873 (url-http-file-exists-p (eval url))
3875 (browse-url (eval url))
3876 (setq url (concat "http://" hierarchy
3877 ".news-admin.org/charters/" name))
3878 (if (and (fboundp 'url-http-file-exists-p)
3879 (url-http-file-exists-p url))
3881 (gnus-group-fetch-control group))))))
3883 (defun gnus-group-fetch-control (group)
3884 "Fetch the archived control messages for the current group.
3885 If given a prefix argument, prompt for a group."
3887 (list (or (when current-prefix-arg
3888 (completing-read "Group: " gnus-active-hashtb))
3889 (gnus-group-group-name)
3890 gnus-newsgroup-name)))
3892 (error "No group name given"))
3893 (let ((name (gnus-group-real-name group))
3895 (when (string-match "\\(^[^\\.]+\\)\\..*" name)
3896 (setq hierarchy (match-string 1 name))
3897 (if gnus-group-fetch-control-use-browse-url
3898 (browse-url (concat "ftp://ftp.isc.org/usenet/control/"
3899 hierarchy "/" name ".gz"))
3900 (let ((enable-local-variables nil))
3901 (gnus-group-read-ephemeral-group
3903 `(nndoc ,group (nndoc-address
3904 ,(find-file-noselect
3905 (concat "/ftp@ftp.isc.org:/usenet/control/"
3906 hierarchy "/" name ".gz")))
3907 (nndoc-article-type mbox)) t nil nil))))))
3909 (defun gnus-group-describe-group (force &optional group)
3910 "Display a description of the current newsgroup."
3911 (interactive (list current-prefix-arg (gnus-group-group-name)))
3912 (let* ((method (gnus-find-method-for-group group))
3913 (mname (gnus-group-prefixed-name "" method))
3916 gnus-description-hashtb)
3917 (gnus-sethash mname nil gnus-description-hashtb))
3919 (error "No group name given"))
3920 (when (or (and gnus-description-hashtb
3921 ;; We check whether this group's method has been
3922 ;; queried for a description file.
3923 (gnus-gethash mname gnus-description-hashtb))
3924 (setq desc (gnus-group-get-description group))
3925 (gnus-read-descriptions-file method))
3927 (or desc (gnus-gethash group gnus-description-hashtb)
3928 "No description available")))))
3930 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3931 (defun gnus-group-describe-all-groups (&optional force)
3932 "Pop up a buffer with descriptions of all newsgroups."
3935 (setq gnus-description-hashtb nil))
3936 (when (not (or gnus-description-hashtb
3937 (gnus-read-all-descriptions-files)))
3938 (error "Couldn't request descriptions file"))
3939 (let ((buffer-read-only nil)
3945 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
3946 (insert (format " *: %-20s %s\n"
3947 (gnus-group-name-decode
3948 (symbol-name group) charset)
3949 (gnus-group-name-decode
3950 (symbol-value group) charset))))
3951 (gnus-add-text-properties
3952 b (1+ b) (list 'gnus-group group
3953 'gnus-unread t 'gnus-marked nil
3954 'gnus-level (1+ gnus-level-subscribed))))
3955 gnus-description-hashtb)
3956 (goto-char (point-min))
3957 (gnus-group-position-point)))
3959 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
3960 (defun gnus-group-apropos (regexp &optional search-description)
3961 "List all newsgroups that have names that match a regexp."
3962 (interactive "sGnus apropos (regexp): ")
3964 (obuf (current-buffer))
3966 ;; Go through all newsgroups that are known to Gnus.
3969 (and (symbol-name group)
3970 (string-match regexp (symbol-name group))
3971 (symbol-value group)
3972 (push (symbol-name group) groups)))
3974 ;; Also go through all descriptions that are known to Gnus.
3975 (when search-description
3978 (and (string-match regexp (symbol-value group))
3979 (push (symbol-name group) groups)))
3980 gnus-description-hashtb))
3982 (gnus-message 3 "No groups matched \"%s\"." regexp)
3983 ;; Print out all the groups.
3985 (pop-to-buffer "*Gnus Help*")
3986 (buffer-disable-undo)
3988 (setq groups (sort groups 'string<))
3990 ;; Groups may be entered twice into the list of groups.
3991 (when (not (string= (car groups) prev))
3992 (setq prev (car groups))
3993 (let ((charset (gnus-group-name-charset nil prev)))
3994 (insert (gnus-group-name-decode prev charset) "\n")
3995 (when (and gnus-description-hashtb
3996 (setq des (gnus-gethash (car groups)
3997 gnus-description-hashtb)))
3998 (insert " " (gnus-group-name-decode des charset) "\n"))))
3999 (setq groups (cdr groups)))
4000 (goto-char (point-min))))
4001 (pop-to-buffer obuf)))
4003 (defun gnus-group-description-apropos (regexp)
4004 "List all newsgroups that have names or descriptions that match REGEXP."
4005 (interactive "sGnus description apropos (regexp): ")
4006 (when (not (or gnus-description-hashtb
4007 (gnus-read-all-descriptions-files)))
4008 (error "Couldn't request descriptions file"))
4009 (gnus-group-apropos regexp t))
4011 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4012 (defun gnus-group-list-matching (level regexp &optional all lowest)
4013 "List all groups with unread articles that match REGEXP.
4014 If the prefix LEVEL is non-nil, it should be a number that says which
4015 level to cut off listing groups.
4016 If ALL, also list groups with no unread articles.
4017 If LOWEST, don't list groups with level lower than LOWEST.
4019 This command may read the active file."
4020 (interactive "P\nsList newsgroups matching: ")
4021 ;; First make sure active file has been read.
4023 (> (prefix-numeric-value level) gnus-level-killed))
4024 (gnus-get-killed-groups))
4025 (funcall gnus-group-prepare-function
4026 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
4027 (goto-char (point-min))
4028 (gnus-group-position-point))
4030 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4031 "List all groups that match REGEXP.
4032 If the prefix LEVEL is non-nil, it should be a number that says which
4033 level to cut off listing groups.
4034 If LOWEST, don't list groups with level lower than LOWEST."
4035 (interactive "P\nsList newsgroups matching: ")
4037 (setq level (prefix-numeric-value level)))
4038 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4040 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4041 (defun gnus-group-save-newsrc (&optional force)
4042 "Save the Gnus startup files.
4043 If FORCE, force saving whether it is necessary or not."
4045 (gnus-save-newsrc-file force))
4047 (defun gnus-group-restart (&optional arg)
4048 "Force Gnus to read the .newsrc file."
4050 (when (gnus-yes-or-no-p
4051 (format "Are you sure you want to restart Gnus? "))
4052 (gnus-save-newsrc-file)
4056 (defun gnus-group-read-init-file ()
4057 "Read the Gnus elisp init file."
4059 (gnus-read-init-file)
4060 (gnus-message 5 "Read %s" gnus-init-file))
4062 (defun gnus-group-check-bogus-groups (&optional silent)
4063 "Check bogus newsgroups.
4064 If given a prefix, don't ask for confirmation before removing a bogus
4067 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4068 (gnus-group-list-groups))
4070 (defun gnus-group-find-new-groups (&optional arg)
4071 "Search for new groups and add them.
4072 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
4073 With 1 C-u, use the `ask-server' method to query the server for new
4075 With 2 C-u's, use most complete method possible to query the server
4076 for new groups, and subscribe the new groups as zombies."
4078 (gnus-find-new-newsgroups (or arg 1))
4079 (gnus-group-list-groups))
4081 (defun gnus-group-edit-global-kill (&optional article group)
4082 "Edit the global kill file.
4083 If GROUP, edit that local kill file instead."
4085 (setq gnus-current-kill-article article)
4086 (gnus-kill-file-edit-file group)
4089 (substitute-command-keys
4090 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
4091 (if group "local" "global")))))
4093 (defun gnus-group-edit-local-kill (article group)
4094 "Edit a local kill file."
4095 (interactive (list nil (gnus-group-group-name)))
4096 (gnus-group-edit-global-kill article group))
4098 (defun gnus-group-force-update ()
4099 "Update `.newsrc' file."
4101 (gnus-save-newsrc-file))
4103 (defvar gnus-backlog-articles)
4105 (defun gnus-group-suspend ()
4106 "Suspend the current Gnus session.
4107 In fact, cleanup buffers except for group mode buffer.
4108 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4110 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4111 (gnus-offer-save-summaries)
4112 ;; Kill Gnus buffers except for group mode buffer.
4113 (let ((group-buf (get-buffer gnus-group-buffer)))
4114 (mapcar (lambda (buf)
4115 (unless (or (member buf (list group-buf gnus-dribble-buffer))
4119 (eq major-mode 'message-mode))))
4120 (gnus-kill-buffer buf)))
4122 (setq gnus-backlog-articles nil)
4123 (gnus-kill-gnus-frames)
4125 (bury-buffer group-buf)
4126 (delete-windows-on group-buf t))))
4128 (defun gnus-group-clear-dribble ()
4129 "Clear all information from the dribble buffer."
4131 (gnus-dribble-clear)
4132 (gnus-message 7 "Cleared dribble buffer"))
4134 (defun gnus-group-exit ()
4135 "Quit reading news after updating .newsrc.eld and .newsrc.
4136 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4139 (or noninteractive ;For gnus-batch-kill
4140 (not gnus-interactive-exit) ;Without confirmation
4142 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4143 (gnus-run-hooks 'gnus-exit-gnus-hook)
4144 ;; Offer to save data from non-quitted summary buffers.
4145 (gnus-offer-save-summaries)
4146 ;; Save the newsrc file(s).
4147 (gnus-save-newsrc-file)
4149 (gnus-close-backends)
4150 ;; Reset everything.
4152 ;; Allow the user to do things after cleaning up.
4153 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4155 (defun gnus-group-quit ()
4156 "Quit reading news without updating .newsrc.eld or .newsrc.
4157 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4159 (when (or noninteractive ;For gnus-batch-kill
4160 (zerop (buffer-size))
4161 (not (gnus-server-opened gnus-select-method))
4163 (not gnus-current-startup-file)
4165 (format "Quit reading news without saving %s? "
4166 (file-name-nondirectory gnus-current-startup-file))))
4167 (gnus-run-hooks 'gnus-exit-gnus-hook)
4168 (gnus-configure-windows 'group t)
4169 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4170 (not (zerop (save-excursion
4171 (set-buffer gnus-dribble-buffer)
4174 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4176 (gnus-close-backends)
4178 (gnus-kill-buffer gnus-group-buffer)
4179 ;; Allow the user to do things after cleaning up.
4180 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4182 (defun gnus-group-describe-briefly ()
4183 "Give a one line description of the group mode commands."
4185 (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")))
4187 (defun gnus-group-browse-foreign-server (method)
4188 "Browse a foreign news server.
4189 If called interactively, this function will ask for a select method
4190 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4191 If not, METHOD should be a list where the first element is the method
4192 and the second element is the address."
4194 (list (let ((how (completing-read
4196 (append gnus-valid-select-methods gnus-server-alist)
4197 nil t (cons "nntp" 0) 'gnus-method-history)))
4198 ;; We either got a back end name or a virtual server name.
4199 ;; If the first, we also need an address.
4200 (if (assoc how gnus-valid-select-methods)
4202 ;; Suggested by mapjph@bath.ac.uk.
4205 (mapcar (lambda (server) (list server))
4206 gnus-secondary-servers)))
4207 ;; We got a server name.
4209 (gnus-browse-foreign-server method))
4211 (defun gnus-group-set-info (info &optional method-only-group part)
4212 (when (or info part)
4213 (let* ((entry (gnus-gethash
4214 (or method-only-group (gnus-info-group info))
4215 gnus-newsrc-hashtb))
4217 (info (if method-only-group (nth 2 entry) info))
4219 (when method-only-group
4221 (error "Trying to change non-existent group %s" method-only-group))
4222 ;; We have received parts of the actual group info - either the
4223 ;; select method or the group parameters. We first check
4224 ;; whether we have to extend the info, and if so, do that.
4225 (let ((len (length info))
4226 (total (if (eq part 'method) 5 6)))
4228 (setcdr (nthcdr (1- len) info)
4229 (make-list (- total len) nil)))
4230 ;; Then we enter the new info.
4231 (setcar (nthcdr (1- total) info) part-info)))
4233 ;; This is a new group, so we just create it.
4235 (set-buffer gnus-group-buffer)
4236 (setq method (gnus-info-method info))
4237 (when (gnus-server-equal method "native")
4240 (set-buffer gnus-group-buffer)
4242 ;; It's a foreign group...
4243 (gnus-group-make-group
4244 (gnus-group-real-name (gnus-info-group info))
4245 (if (stringp method) method
4246 (prin1-to-string (car method)))
4248 (nth 1 (gnus-info-method info))))
4249 ;; It's a native group.
4250 (gnus-group-make-group (gnus-info-group info))))
4251 (gnus-message 6 "Note: New group created")
4253 (gnus-gethash (gnus-group-prefixed-name
4254 (gnus-group-real-name (gnus-info-group info))
4255 (or (gnus-info-method info) gnus-select-method))
4256 gnus-newsrc-hashtb))))
4257 ;; Whether it was a new group or not, we now have the entry, so we
4258 ;; can do the update.
4261 (setcar (nthcdr 2 entry) info)
4262 (when (and (not (eq (car entry) t))
4263 (gnus-active (gnus-info-group info)))
4264 (setcar entry (length
4265 (gnus-list-of-unread-articles (car info))))))
4266 (error "No such group: %s" (gnus-info-group info))))))
4268 (defun gnus-group-set-method-info (group select-method)
4269 (gnus-group-set-info select-method group 'method))
4271 (defun gnus-group-set-params-info (group params)
4272 (gnus-group-set-info params group 'params))
4274 (defun gnus-add-marked-articles (group type articles &optional info force)
4275 ;; Add ARTICLES of TYPE to the info of GROUP.
4276 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4277 ;; add, but replace marked articles of TYPE with ARTICLES.
4278 (let ((info (or info (gnus-get-info group)))
4281 (and (not (setq marked (nthcdr 3 info)))
4283 (setcdr (nthcdr 2 info)
4284 (list (list (cons type (gnus-compress-sequence
4286 (and (not (setq m (assq type (car marked))))
4289 (cons (cons type (gnus-compress-sequence articles t) )
4293 (setcar (nthcdr 3 info)
4294 (gnus-delete-alist type (car marked)))
4295 (setcdr m (gnus-compress-sequence articles t)))
4296 (setcdr m (gnus-compress-sequence
4297 (sort (nconc (gnus-uncompress-range (cdr m))
4298 (copy-sequence articles)) '<) t))))))
4300 (defun gnus-add-mark (group mark article)
4301 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4302 (let ((buffer (gnus-summary-buffer-name group)))
4303 (if (gnus-buffer-live-p buffer)
4305 (set-buffer (get-buffer buffer))
4306 (gnus-summary-add-mark article mark))
4307 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4311 ;;; Group timestamps
4314 (defun gnus-group-set-timestamp ()
4315 "Change the timestamp of the current group to the current time.
4316 This function can be used in hooks like `gnus-select-group-hook'
4317 or `gnus-group-catchup-group-hook'."
4318 (when gnus-newsgroup-name
4319 (let ((time (current-time)))
4320 (setcdr (cdr time) nil)
4321 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4323 (defsubst gnus-group-timestamp (group)
4324 "Return the timestamp for GROUP."
4325 (gnus-group-get-parameter group 'timestamp t))
4327 (defun gnus-group-timestamp-delta (group)
4328 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4329 (let* ((time (or (gnus-group-timestamp group)
4331 (delta (subtract-time (current-time) time)))
4332 (+ (* (nth 0 delta) 65536.0)
4335 (defun gnus-group-timestamp-string (group)
4336 "Return a string of the timestamp for GROUP."
4337 (let ((time (gnus-group-timestamp group)))
4340 (gnus-time-iso8601 time))))
4342 (defun gnus-group-list-cached (level &optional lowest)
4343 "List all groups with cached articles.
4344 If the prefix LEVEL is non-nil, it should be a number that says which
4345 level to cut off listing groups.
4346 If LOWEST, don't list groups with level lower than LOWEST.
4348 This command may read the active file."
4351 (setq level (prefix-numeric-value level)))
4352 (when (or (not level) (>= level gnus-level-zombie))
4354 (funcall gnus-group-prepare-function
4355 (or level gnus-level-subscribed)
4357 (let ((marks (gnus-info-marks info)))
4358 (assq 'cache marks)))
4361 (or (gnus-gethash group
4362 gnus-cache-active-hashtb)
4363 ;; Cache active file might use "."
4366 (mapconcat 'identity
4367 (split-string group ":")
4369 gnus-cache-active-hashtb))))
4370 (goto-char (point-min))
4371 (gnus-group-position-point))
4373 (defun gnus-group-list-dormant (level &optional lowest)
4374 "List all groups with dormant articles.
4375 If the prefix LEVEL is non-nil, it should be a number that says which
4376 level to cut off listing groups.
4377 If LOWEST, don't list groups with level lower than LOWEST.
4379 This command may read the active file."
4382 (setq level (prefix-numeric-value level)))
4383 (when (or (not level) (>= level gnus-level-zombie))
4385 (funcall gnus-group-prepare-function
4386 (or level gnus-level-subscribed)
4388 (let ((marks (gnus-info-marks info)))
4389 (assq 'dormant marks)))
4392 (goto-char (point-min))
4393 (gnus-group-position-point))
4395 (defun gnus-group-listed-groups ()
4396 "Return a list of listed groups."
4398 (goto-char (point-min))
4399 (while (setq point (text-property-not-all (point) (point-max)
4402 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4406 (defun gnus-group-list-plus (&optional args)
4407 "List groups plus the current selection."
4409 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4410 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4412 (push last-command-event unread-command-events)
4413 (if (featurep 'xemacs)
4414 (push (make-event 'key-press '(key ?A)) unread-command-events)
4415 (push ?A unread-command-events))
4416 (let (gnus-pick-mode keys)
4417 (setq keys (if (featurep 'xemacs)
4418 (events-to-keys (read-key-sequence nil))
4419 (read-key-sequence nil)))
4420 (setq func (lookup-key (current-local-map) keys)))
4424 (call-interactively func))))
4426 (defun gnus-group-list-flush (&optional args)
4427 "Flush groups from the current selection."
4429 (let ((gnus-group-list-option 'flush))
4430 (gnus-group-list-plus args)))
4432 (defun gnus-group-list-limit (&optional args)
4433 "List groups limited within the current selection."
4435 (let ((gnus-group-list-option 'limit))
4436 (gnus-group-list-plus args)))
4438 (defun gnus-group-mark-article-read (group article)
4439 "Mark ARTICLE read."
4440 (let ((buffer (gnus-summary-buffer-name group))
4441 (mark gnus-read-mark)
4443 (if (get-buffer buffer)
4444 (with-current-buffer buffer
4445 (setq active gnus-newsgroup-active)
4446 (gnus-activate-group group)
4447 (when gnus-newsgroup-prepared
4448 (when (and gnus-newsgroup-auto-expire
4449 (memq mark gnus-auto-expirable-marks))
4450 (setq mark gnus-expirable-mark))
4451 (setq mark (gnus-request-update-mark
4452 group article mark))
4453 (gnus-mark-article-as-read article mark)
4454 (setq gnus-newsgroup-active (gnus-active group))
4456 (setq n (1+ (cdr active)))
4457 (while (<= n (cdr gnus-newsgroup-active))
4458 (unless (eq n article)
4459 (push n gnus-newsgroup-unselected))
4461 (setq gnus-newsgroup-unselected
4462 (nreverse gnus-newsgroup-unselected)))))
4463 (gnus-activate-group group)
4464 (gnus-group-make-articles-read group (list article))
4465 (when (gnus-group-auto-expirable-p group)
4466 (gnus-add-marked-articles
4467 group 'expire (list article))))))
4469 (provide 'gnus-group)
4471 ;;; arch-tag: 2eb5440f-0bca-4091-814c-e37817536af6
4472 ;;; gnus-group.el ends here