1 ;;; gnus-group.el --- group mode commands for Gnus
3 ;; Copyright (C) 1996-2016 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
29 (defvar tool-bar-mode)
44 (let ((features (cons 'gnus-group features)))
46 (unless (boundp 'gnus-cache-active-hashtb)
47 (defvar gnus-cache-active-hashtb nil)))
49 (autoload 'gnus-agent-total-fetched-for "gnus-agent")
50 (autoload 'gnus-cache-total-fetched-for "gnus-cache")
52 (autoload 'gnus-group-make-nnir-group "nnir")
54 (defcustom gnus-no-groups-message "No news is good news"
55 "Message displayed by Gnus when no groups are available."
59 (defcustom gnus-keep-same-level nil
60 "Non-nil means that the next newsgroup after the current will be on the same level.
61 When you type, for instance, `n' after reading the last article in the
62 current newsgroup, you will go to the next newsgroup. If this variable
63 is nil, the next newsgroup will be the next from the group
65 If this variable is non-nil, Gnus will either put you in the
66 next newsgroup with the same level, or, if no such newsgroup is
67 available, the next newsgroup with the lowest possible level higher
68 than the current level.
69 If this variable is `best', Gnus will make the next newsgroup the one
71 :group 'gnus-group-levels
72 :type '(choice (const nil)
74 (sexp :tag "other" t)))
76 (defcustom gnus-group-goto-unread t
77 "If non-nil, movement commands will go to the next unread and subscribed group."
78 :link '(custom-manual "(gnus)Group Maneuvering")
79 :group 'gnus-group-various
82 (defcustom gnus-goto-next-group-when-activating t
83 "If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
84 :link '(custom-manual "(gnus)Scanning New Messages")
85 :group 'gnus-group-various
88 (defcustom gnus-permanently-visible-groups nil
89 "Regexp to match groups that should always be listed in the group buffer.
90 This means that they will still be listed even when there are no
91 unread articles in the groups.
93 If nil, no groups are permanently visible."
94 :group 'gnus-group-listing
95 :type '(choice regexp (const nil)))
97 (defcustom gnus-safe-html-newsgroups "\\`nnrss[+:]"
98 "Groups in which links in html articles are considered all safe.
99 The value may be a regexp matching those groups, a list of group names,
100 or nil. This overrides `mm-w3m-safe-url-regexp' (which see). This is
101 effective only when emacs-w3m renders html articles, i.e., in the case
102 `mm-text-html-renderer' is set to `w3m'."
104 :group 'gnus-group-various
105 :type '(choice regexp
106 (repeat :tag "List of group names" (string :tag "Group"))
109 (defcustom gnus-list-groups-with-ticked-articles t
110 "If non-nil, list groups that have only ticked articles.
111 If nil, only list groups that have unread articles."
112 :group 'gnus-group-listing
115 (defcustom gnus-group-default-list-level gnus-level-subscribed
116 "Default listing level.
117 Ignored if `gnus-group-use-permanent-levels' is non-nil."
118 :group 'gnus-group-listing
119 :type '(choice (integer :tag "Level")
120 (function :tag "Function returning level")))
122 (defcustom gnus-group-list-inactive-groups t
123 "If non-nil, inactive groups will be listed."
124 :group 'gnus-group-listing
125 :group 'gnus-group-levels
128 (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet
129 "Function used for sorting the group buffer.
130 This function will be called with group info entries as the arguments
131 for the groups to be sorted. Pre-made functions include
132 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
133 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
134 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
135 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
137 This variable can also be a list of sorting functions. In that case,
138 the most significant sort function should be the last function in the
140 :group 'gnus-group-listing
141 :link '(custom-manual "(gnus)Sorting Groups")
142 :type '(repeat :value-to-internal (lambda (widget value)
143 (if (listp value) value (list value)))
144 :match (lambda (widget value)
146 (widget-editable-list-match widget value)))
147 (choice (function-item gnus-group-sort-by-alphabet)
148 (function-item gnus-group-sort-by-real-name)
149 (function-item gnus-group-sort-by-unread)
150 (function-item gnus-group-sort-by-level)
151 (function-item gnus-group-sort-by-score)
152 (function-item gnus-group-sort-by-method)
153 (function-item gnus-group-sort-by-server)
154 (function-item gnus-group-sort-by-rank)
155 (function :tag "other" nil))))
157 (defcustom gnus-group-line-format "%M\ %S\ %p\ %P\ %5y:%B%(%g%)\n"
158 "Format of group lines.
159 It works along the same lines as a normal formatting string,
160 with some simple extensions.
162 %M Only marked articles (character, \"*\" or \" \")
163 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
164 %L Level of subscribedness (integer)
165 %N Number of unread articles (integer)
166 %I Number of dormant articles (integer)
167 %i Number of ticked and dormant (integer)
168 %T Number of ticked articles (integer)
169 %R Number of read articles (integer)
170 %U Number of unseen articles (integer)
171 %t Estimated total number of articles (integer)
172 %y Number of unread, unticked articles (integer)
173 %G Group name (string)
174 %g Qualified group name (string)
175 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
176 %C Group comment (string)
177 %D Group description (string)
178 %s Select method (string)
179 %o Moderated group (char, \"m\")
180 %p Process mark (char)
181 %B Whether a summary buffer for the group is open (char, \"*\")
182 %O Moderated group (string, \"(m)\" or \"\")
183 %P Topic indentation (string)
184 %m Whether there is new(ish) mail in the group (char, \"%\")
185 %n Select from where (string)
186 %z A string that look like `<%s:%n>' if a foreign select method is used
187 %d The date the group was last entered.
188 %E Icon as defined by `gnus-group-icon-list'.
189 %F The disk space used by the articles fetched by both the cache and agent.
190 %u User defined specifier. The next character in the format string should
191 be a letter. Gnus will call the function gnus-user-format-function-X,
192 where X is the letter following %u. The function will be passed a
193 single dummy parameter as argument. The function should return a
194 string, which will be inserted into the buffer just like information
195 from any other group specifier.
197 Note that this format specification is not always respected. For
198 reasons of efficiency, when listing killed groups, this specification
199 is ignored altogether. If the spec is changed considerably, your
200 output may end up looking strange when listing both alive and killed
203 If you use %o or %O, reading the active file will be slower and quite
204 a bit of extra memory will be used. %D and %F will also worsen
205 performance. Also note that if you change the format specification to
206 include any of these specs, you must probably re-start Gnus to see
209 General format specifiers can also be used.
210 See Info node `(gnus)Formatting Variables'."
211 :link '(custom-manual "(gnus)Formatting Variables")
212 :group 'gnus-group-visual
215 (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\ %:%S}"
216 "The format specification for the group mode line.
217 It works along the same lines as a normal formatting string,
218 with some simple extensions:
220 %S The native news server.
221 %M The native select method.
222 %: \":\" if %S isn't \"\"."
223 :group 'gnus-group-visual
226 (defcustom gnus-group-menu-hook nil
227 "Hook run after the creation of the group mode menu."
228 :group 'gnus-group-various
231 (defcustom gnus-group-catchup-group-hook nil
232 "Hook run when catching up a group from the group buffer."
233 :group 'gnus-group-various
234 :link '(custom-manual "(gnus)Group Data")
237 (defcustom gnus-group-update-group-hook nil
238 "Hook called when updating group lines."
239 :group 'gnus-group-visual
242 (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat
243 "A function that is called to generate the group buffer.
244 The function is called with three arguments: The first is a number;
245 all group with a level less or equal to that number should be listed,
246 if the second is non-nil, empty groups should also be displayed. If
247 the third is non-nil, it is a number. No groups with a level lower
248 than this number should be displayed.
250 The only current function implemented is `gnus-group-prepare-flat'."
251 :group 'gnus-group-listing
254 (defcustom gnus-group-prepare-hook nil
255 "Hook called after the group buffer has been generated.
256 If you want to modify the group buffer, you can use this hook."
257 :group 'gnus-group-listing
260 (defcustom gnus-suspend-gnus-hook nil
261 "Hook called when suspending (not exiting) Gnus."
265 (defcustom gnus-exit-gnus-hook nil
266 "Hook called when exiting Gnus."
270 (defcustom gnus-after-exiting-gnus-hook nil
271 "Hook called after exiting Gnus."
275 (defcustom gnus-group-update-hook nil
276 "Hook called when a group line is changed."
277 :group 'gnus-group-visual
281 (defcustom gnus-useful-groups
282 '(("(ding) mailing list mirrored at gmane.org"
283 "gmane.emacs.gnus.general"
285 (nntp-address "news.gmane.org")))
288 (nntp "news.gnus.org"
289 (nntp-address "news.gnus.org")))
290 ("Local Gnus help group"
293 (nndoc-article-type mbox)
294 (eval `(nndoc-address
295 ,(let ((file (nnheader-find-etc-directory
298 (error "Couldn't find doc group"))
300 "Alist of useful group-server pairs."
301 :group 'gnus-group-listing
302 :type '(repeat (list (string :tag "Description")
304 (sexp :tag "Method"))))
306 (defcustom gnus-group-highlight
308 ((and mailp (= unread 0) (eq level 1)) .
309 gnus-group-mail-1-empty)
310 ((and mailp (eq level 1)) .
312 ((and mailp (= unread 0) (eq level 2)) .
313 gnus-group-mail-2-empty)
314 ((and mailp (eq level 2)) .
316 ((and mailp (= unread 0) (eq level 3)) .
317 gnus-group-mail-3-empty)
318 ((and mailp (eq level 3)) .
320 ((and mailp (= unread 0)) .
321 gnus-group-mail-low-empty)
325 ((and (= unread 0) (eq level 1)) .
326 gnus-group-news-1-empty)
327 ((and (eq level 1)) .
329 ((and (= unread 0) (eq level 2)) .
330 gnus-group-news-2-empty)
331 ((and (eq level 2)) .
333 ((and (= unread 0) (eq level 3)) .
334 gnus-group-news-3-empty)
335 ((and (eq level 3)) .
337 ((and (= unread 0) (eq level 4)) .
338 gnus-group-news-4-empty)
339 ((and (eq level 4)) .
341 ((and (= unread 0) (eq level 5)) .
342 gnus-group-news-5-empty)
343 ((and (eq level 5)) .
345 ((and (= unread 0) (eq level 6)) .
346 gnus-group-news-6-empty)
347 ((and (eq level 6)) .
349 ((and (= unread 0)) .
350 gnus-group-news-low-empty)
352 gnus-group-news-low))
353 "Controls the highlighting of group buffer lines.
355 Below is a list of `Form'/`Face' pairs. When deciding how a
356 particular group line should be displayed, each form is
357 evaluated. The content of the face field after the first true form is
358 used. You can change how those group lines are displayed by
359 editing the face field.
361 It is also possible to change and add form fields, but currently that
362 requires an understanding of Lisp expressions. Hopefully this will
363 change in a future release. For now, you can use the following
364 variables in the Lisp expression:
366 group: The name of the group.
367 unread: The number of unread articles in the group.
368 method: The select method used.
369 mailp: Whether it's a mail group or not.
370 level: The level of the group.
371 score: The score of the group.
372 ticked: The number of ticked articles."
373 :group 'gnus-group-visual
374 :type '(repeat (cons (sexp :tag "Form") face)))
375 (put 'gnus-group-highlight 'risky-local-variable t)
377 (defcustom gnus-new-mail-mark ?%
378 "Mark used for groups with new mail."
379 :group 'gnus-group-visual
382 (defgroup gnus-group-icons nil
383 "Add Icons to your group buffer."
384 :group 'gnus-group-visual)
386 (defcustom gnus-group-icon-list
388 "Controls the insertion of icons into group buffer lines.
390 Below is a list of `Form'/`File' pairs. When deciding how a
391 particular group line should be displayed, each form is evaluated.
392 The icon from the file field after the first true form is used. You
393 can change how those group lines are displayed by editing the file
394 field. The File will either be found in the
395 `gnus-group-glyph-directory' or by designating absolute name of the
398 It is also possible to change and add form fields, but currently that
399 requires an understanding of Lisp expressions. Hopefully this will
400 change in a future release. For now, you can use the following
401 variables in the Lisp expression:
403 group: The name of the group.
404 unread: The number of unread articles in the group.
405 method: The select method used.
406 mailp: Whether it's a mail group or not.
407 level: The level of the group.
408 score: The score of the group.
409 ticked: The number of ticked articles."
410 :group 'gnus-group-icons
411 :type '(repeat (cons (sexp :tag "Form") file)))
412 (put 'gnus-group-icon-list 'risky-local-variable t)
414 (defcustom gnus-group-name-charset-method-alist nil
415 "Alist of method and the charset for group names.
418 (((nntp \"news.com.cn\") . cn-gb-2312))"
421 :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
423 (defcustom gnus-group-name-charset-group-alist
424 (if (mm-coding-system-p 'utf-8)
427 "Alist of group regexp and the charset for group names.
430 ((\"\\.com\\.cn:\" . cn-gb-2312))"
432 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
434 (defcustom gnus-group-jump-to-group-prompt nil
435 "Default prompt for `gnus-group-jump-to-group'.
437 If non-nil, the value should be a string or an alist. If it is a string,
438 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
439 nnml:\" in the minibuffer prompt.
441 If it is an alist, it must consist of \(NUMBER . PROMPT) pairs, for example:
442 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
443 used when no prefix argument is given to `gnus-group-jump-to-group'."
445 :group 'gnus-group-various
446 :type '(choice (string :tag "Prompt string")
447 (const :tag "Empty" nil)
448 (repeat (cons (integer :tag "Argument")
449 (string :tag "Prompt string")))))
451 (defcustom gnus-group-listing-limit 1000
452 "A limit of the number of groups when listing.
453 If the number of groups is larger than the limit, list them in a
455 :group 'gnus-group-listing
458 ;;; Internal variables
460 (defvar gnus-group-is-exiting-p nil)
461 (defvar gnus-group-is-exiting-without-update-p nil)
462 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
463 "Function for sorting the group buffer.")
465 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
466 "Function for sorting the selected groups in the group buffer.")
468 (defvar gnus-group-indentation-function nil)
469 (defvar gnus-goto-missing-group-function nil)
470 (defvar gnus-group-update-group-function nil)
471 (defvar gnus-group-goto-next-group-function nil
472 "Function to override finding the next group after listing groups.")
474 (defvar gnus-group-edit-buffer nil)
476 (defvar gnus-tmp-news-method)
477 (defvar gnus-tmp-colon)
478 (defvar gnus-tmp-news-server)
479 (defvar gnus-tmp-decoded-group)
480 (defvar gnus-tmp-header)
481 (defvar gnus-tmp-process-marked)
482 (defvar gnus-tmp-summary-live)
483 (defvar gnus-tmp-news-method-string)
484 (defvar gnus-tmp-group-icon)
485 (defvar gnus-tmp-moderated-string)
486 (defvar gnus-tmp-newsgroup-description)
487 (defvar gnus-tmp-comment)
488 (defvar gnus-tmp-qualified-group)
489 (defvar gnus-tmp-subscribed)
490 (defvar gnus-tmp-number-of-read)
491 (defvar gnus-inhibit-demon)
492 (defvar gnus-pick-mode)
493 (defvar gnus-tmp-marked-mark)
494 (defvar gnus-tmp-number-of-unread)
496 (defvar gnus-group-line-format-alist
497 `((?M gnus-tmp-marked-mark ?c)
498 (?S gnus-tmp-subscribed ?c)
499 (?L gnus-tmp-level ?d)
500 (?N (cond ((eq number t) "*" )
504 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
505 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
507 (?R gnus-tmp-number-of-read ?s)
508 (?U (if (gnus-active gnus-tmp-group)
509 (gnus-number-of-unseen-articles-in-group gnus-tmp-group)
512 (?t gnus-tmp-number-total ?d)
513 (?y gnus-tmp-number-of-unread ?s)
514 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
515 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
516 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
517 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
518 (?g (if (boundp 'gnus-tmp-decoded-group)
519 gnus-tmp-decoded-group
522 (?G gnus-tmp-qualified-group ?s)
523 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
524 gnus-tmp-decoded-group
527 (?C gnus-tmp-comment ?s)
528 (?D gnus-tmp-newsgroup-description ?s)
529 (?o gnus-tmp-moderated ?c)
530 (?O gnus-tmp-moderated-string ?s)
531 (?p gnus-tmp-process-marked ?c)
532 (?s gnus-tmp-news-server ?s)
533 (?n gnus-tmp-news-method ?s)
534 (?P gnus-group-indentation ?s)
535 (?E gnus-tmp-group-icon ?s)
536 (?B gnus-tmp-summary-live ?c)
537 (?z gnus-tmp-news-method-string ?s)
538 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
539 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
540 (?u gnus-tmp-user-defined ?s)
541 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
544 (defvar gnus-group-mode-line-format-alist
545 `((?S gnus-tmp-news-server ?s)
546 (?M gnus-tmp-news-method ?s)
547 (?u gnus-tmp-user-defined ?s)
548 (?: gnus-tmp-colon ?s)))
550 (defvar gnus-topic-topology nil
551 "The complete topic hierarchy.")
553 (defvar gnus-topic-alist nil
554 "The complete topic-group alist.")
556 (defvar gnus-group-marked nil)
558 (defvar gnus-group-list-mode nil)
561 (defvar gnus-group-listed-groups nil)
562 (defvar gnus-group-list-option nil)
568 (put 'gnus-group-mode 'mode-class 'special)
570 (gnus-define-keys gnus-group-mode-map
571 " " gnus-group-read-group
572 "=" gnus-group-select-group
573 "\r" gnus-group-select-group
574 "\M-\r" gnus-group-quick-select-group
575 "\M- " gnus-group-visible-select-group
576 [(meta control return)] gnus-group-select-group-ephemerally
577 "j" gnus-group-jump-to-group
578 "n" gnus-group-next-unread-group
579 "p" gnus-group-prev-unread-group
580 "\177" gnus-group-prev-unread-group
581 [delete] gnus-group-prev-unread-group
582 "N" gnus-group-next-group
583 "P" gnus-group-prev-group
584 "\M-n" gnus-group-next-unread-group-same-level
585 "\M-p" gnus-group-prev-unread-group-same-level
586 "," gnus-group-best-unread-group
587 "." gnus-group-first-unread-group
588 "u" gnus-group-unsubscribe-current-group
589 "U" gnus-group-unsubscribe-group
590 "c" gnus-group-catchup-current
591 "C" gnus-group-catchup-current-all
592 "\M-c" gnus-group-clear-data
593 "l" gnus-group-list-groups
594 "L" gnus-group-list-all-groups
597 "g" gnus-group-get-new-news
598 "\M-g" gnus-group-get-new-news-this-group
599 "R" gnus-group-restart
600 "r" gnus-group-read-init-file
601 "B" gnus-group-browse-foreign-server
602 "b" gnus-group-check-bogus-groups
603 "F" gnus-group-find-new-groups
604 "\C-c\C-d" gnus-group-describe-group
605 "\M-d" gnus-group-describe-all-groups
606 "\C-c\C-a" gnus-group-apropos
607 "\C-c\M-\C-a" gnus-group-description-apropos
608 "a" gnus-group-post-news
609 "\ek" gnus-group-edit-local-kill
610 "\eK" gnus-group-edit-global-kill
611 "\C-k" gnus-group-kill-group
612 "\C-y" gnus-group-yank-group
613 "\C-w" gnus-group-kill-region
614 "\C-x\C-t" gnus-group-transpose-groups
615 "\C-c\C-l" gnus-group-list-killed
616 "\C-c\C-x" gnus-group-expire-articles
617 "\C-c\M-\C-x" gnus-group-expire-all-groups
619 "s" gnus-group-save-newsrc
620 "z" gnus-group-suspend
623 "?" gnus-group-describe-briefly
624 "\C-c\C-i" gnus-info-find-node
625 "\M-e" gnus-group-edit-group-method
626 "^" gnus-group-enter-server-mode
627 [mouse-2] gnus-mouse-pick-group
628 [follow-link] 'mouse-face
629 "<" beginning-of-buffer
632 "\C-c\C-s" gnus-group-sort-groups
634 "\C-c\M-g" gnus-activate-all-groups
635 "\M-&" gnus-group-universal-argument
636 "#" gnus-group-mark-group
637 "\M-#" gnus-group-unmark-group)
639 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
640 "m" gnus-group-mark-group
641 "u" gnus-group-unmark-group
642 "w" gnus-group-mark-region
643 "b" gnus-group-mark-buffer
644 "r" gnus-group-mark-regexp
645 "U" gnus-group-unmark-all-groups)
647 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
648 "u" gnus-sieve-update
649 "g" gnus-sieve-generate)
651 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
652 "d" gnus-group-make-directory-group
653 "h" gnus-group-make-help-group
654 "u" gnus-group-make-useful-group
655 "l" gnus-group-nnimap-edit-acl
656 "m" gnus-group-make-group
657 "E" gnus-group-edit-group
658 "e" gnus-group-edit-group-method
659 "p" gnus-group-edit-group-parameters
660 "v" gnus-group-add-to-virtual
661 "V" gnus-group-make-empty-virtual
662 "D" gnus-group-enter-directory
663 "f" gnus-group-make-doc-group
664 "w" gnus-group-make-web-group
665 "G" gnus-group-make-nnir-group
666 "M" gnus-group-read-ephemeral-group
667 "r" gnus-group-rename-group
668 "R" gnus-group-make-rss-group
669 "c" gnus-group-customize
670 "z" gnus-group-compact-group
671 "x" gnus-group-expunge-group
672 "\177" gnus-group-delete-group
673 [delete] gnus-group-delete-group)
675 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
676 "s" gnus-group-sort-groups
677 "a" gnus-group-sort-groups-by-alphabet
678 "u" gnus-group-sort-groups-by-unread
679 "l" gnus-group-sort-groups-by-level
680 "v" gnus-group-sort-groups-by-score
681 "r" gnus-group-sort-groups-by-rank
682 "m" gnus-group-sort-groups-by-method
683 "n" gnus-group-sort-groups-by-real-name)
685 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
686 "s" gnus-group-sort-selected-groups
687 "a" gnus-group-sort-selected-groups-by-alphabet
688 "u" gnus-group-sort-selected-groups-by-unread
689 "l" gnus-group-sort-selected-groups-by-level
690 "v" gnus-group-sort-selected-groups-by-score
691 "r" gnus-group-sort-selected-groups-by-rank
692 "m" gnus-group-sort-selected-groups-by-method
693 "n" gnus-group-sort-selected-groups-by-real-name)
695 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
696 "k" gnus-group-list-killed
697 "z" gnus-group-list-zombies
698 "s" gnus-group-list-groups
699 "u" gnus-group-list-all-groups
700 "A" gnus-group-list-active
701 "a" gnus-group-apropos
702 "d" gnus-group-description-apropos
703 "m" gnus-group-list-matching
704 "M" gnus-group-list-all-matching
705 "l" gnus-group-list-level
706 "c" gnus-group-list-cached
707 "?" gnus-group-list-dormant
708 "!" gnus-group-list-ticked)
710 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
711 "k" gnus-group-list-limit
712 "z" gnus-group-list-limit
713 "s" gnus-group-list-limit
714 "u" gnus-group-list-limit
715 "A" gnus-group-list-limit
716 "m" gnus-group-list-limit
717 "M" gnus-group-list-limit
718 "l" gnus-group-list-limit
719 "c" gnus-group-list-limit
720 "?" gnus-group-list-limit
721 "!" gnus-group-list-limit)
723 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
724 "k" gnus-group-list-flush
725 "z" gnus-group-list-flush
726 "s" gnus-group-list-flush
727 "u" gnus-group-list-flush
728 "A" gnus-group-list-flush
729 "m" gnus-group-list-flush
730 "M" gnus-group-list-flush
731 "l" gnus-group-list-flush
732 "c" gnus-group-list-flush
733 "?" gnus-group-list-flush
734 "!" gnus-group-list-flush)
736 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
737 "k" gnus-group-list-plus
738 "z" gnus-group-list-plus
739 "s" gnus-group-list-plus
740 "u" gnus-group-list-plus
741 "A" gnus-group-list-plus
742 "m" gnus-group-list-plus
743 "M" gnus-group-list-plus
744 "l" gnus-group-list-plus
745 "c" gnus-group-list-plus
746 "?" gnus-group-list-plus
747 "!" gnus-group-list-plus)
749 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
750 "f" gnus-score-flush-cache
751 "e" gnus-score-edit-all-score)
753 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
754 "d" gnus-group-describe-group
757 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
758 "l" gnus-group-set-current-level
759 "t" gnus-group-unsubscribe-current-group
760 "s" gnus-group-unsubscribe-group
761 "k" gnus-group-kill-group
762 "y" gnus-group-yank-group
763 "w" gnus-group-kill-region
764 "\C-k" gnus-group-kill-level
765 "z" gnus-group-kill-all-zombies)
767 (defun gnus-topic-mode-p ()
768 "Return non-nil in `gnus-topic-mode'."
769 (and (boundp 'gnus-topic-mode)
770 (symbol-value 'gnus-topic-mode)))
772 (defun gnus-group-make-menu-bar ()
773 (unless (boundp 'gnus-group-reading-menu)
776 gnus-group-reading-menu gnus-group-mode-map ""
778 ["Read" gnus-group-read-group
779 :included (not (gnus-topic-mode-p))
780 :active (gnus-group-group-name)]
781 ["Read " gnus-topic-read-group
782 :included (gnus-topic-mode-p)]
783 ["Select" gnus-group-select-group
784 :included (not (gnus-topic-mode-p))
785 :active (gnus-group-group-name)]
786 ["Select " gnus-topic-select-group
787 :included (gnus-topic-mode-p)]
788 ["See old articles" (gnus-group-select-group 'all)
789 :keys "C-u SPC" :active (gnus-group-group-name)]
790 ["Catch up" gnus-group-catchup-current
791 :included (not (gnus-topic-mode-p))
792 :active (gnus-group-group-name)
793 :help "Mark unread articles in the current group as read"]
794 ["Catch up " gnus-topic-catchup-articles
795 :included (gnus-topic-mode-p)
796 :help "Mark unread articles in the current group or topic as read"]
797 ["Catch up all articles" gnus-group-catchup-current-all
798 (gnus-group-group-name)]
799 ["Check for new articles" gnus-group-get-new-news-this-group
800 :included (not (gnus-topic-mode-p))
801 :active (gnus-group-group-name)
802 :help "Check for new messages in current group"]
803 ["Check for new articles " gnus-topic-get-new-news-this-topic
804 :included (gnus-topic-mode-p)
805 :help "Check for new messages in current group or topic"]
806 ["Toggle subscription" gnus-group-unsubscribe-current-group
807 (gnus-group-group-name)]
808 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
809 :help "Kill (remove) current group"]
810 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
811 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
812 :help "Display description of the current group"]
813 ;; Actually one should check, if any of the marked groups gives t for
814 ;; (gnus-check-backend-function 'request-expire-articles ...)
815 ["Expire articles" gnus-group-expire-articles
816 :included (not (gnus-topic-mode-p))
817 :active (or (and (gnus-group-group-name)
818 (gnus-check-backend-function
819 'request-expire-articles
820 (gnus-group-group-name))) gnus-group-marked)]
821 ["Expire articles " gnus-topic-expire-articles
822 :included (gnus-topic-mode-p)]
823 ["Set group level..." gnus-group-set-current-level
824 (gnus-group-group-name)]
825 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
826 ["Customize" gnus-group-customize (gnus-group-group-name)]
827 ["Compact" gnus-group-compact-group
828 :active (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]
858 ["List groups with ticked" gnus-group-list-ticked t])
860 ["Default sort" gnus-group-sort-groups t]
861 ["Sort by method" gnus-group-sort-groups-by-method t]
862 ["Sort by rank" gnus-group-sort-groups-by-rank t]
863 ["Sort by score" gnus-group-sort-groups-by-score t]
864 ["Sort by level" gnus-group-sort-groups-by-level t]
865 ["Sort by unread" gnus-group-sort-groups-by-unread t]
866 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
867 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
868 ("Sort process/prefixed"
869 ["Default sort" gnus-group-sort-selected-groups
870 (not (gnus-topic-mode-p))]
871 ["Sort by method" gnus-group-sort-selected-groups-by-method
872 (not (gnus-topic-mode-p))]
873 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
874 (not (gnus-topic-mode-p))]
875 ["Sort by score" gnus-group-sort-selected-groups-by-score
876 (not (gnus-topic-mode-p))]
877 ["Sort by level" gnus-group-sort-selected-groups-by-level
878 (not (gnus-topic-mode-p))]
879 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
880 (not (gnus-topic-mode-p))]
881 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
882 (not (gnus-topic-mode-p))]
883 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
884 (not (gnus-topic-mode-p))])
886 ["Mark group" gnus-group-mark-group
887 (and (gnus-group-group-name)
888 (not (memq (gnus-group-group-name) gnus-group-marked)))]
889 ["Unmark group" gnus-group-unmark-group
890 (and (gnus-group-group-name)
891 (memq (gnus-group-group-name) gnus-group-marked))]
892 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
893 ["Mark regexp..." gnus-group-mark-regexp t]
894 ["Mark region" gnus-group-mark-region :active mark-active]
895 ["Mark buffer" gnus-group-mark-buffer t]
896 ["Execute command" gnus-group-universal-argument
897 (or gnus-group-marked (gnus-group-group-name))])
899 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
900 ["Kill all newsgroups in region" gnus-group-kill-region
902 ["Kill all zombie groups" gnus-group-kill-all-zombies
904 ["Kill all groups on level..." gnus-group-kill-level t])
906 ["Make a foreign group..." gnus-group-make-group t]
907 ["Add a directory group..." gnus-group-make-directory-group t]
908 ["Add the help group" gnus-group-make-help-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 search group..." gnus-group-make-nnir-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 ""
945 ["Send a mail" gnus-group-mail t]
946 ["Send a message (mail or news)" gnus-group-post-news t]
947 ["Create a local message" gnus-group-news t]
948 ["Check for new news" gnus-group-get-new-news
949 :help "Get newly arrived articles"]
950 ["Send queued messages" gnus-delay-send-queue
951 :help "Send all messages that are scheduled to be sent now"]
952 ["Activate all groups" gnus-activate-all-groups t]
953 ["Restart Gnus" gnus-group-restart t]
954 ["Read init file" gnus-group-read-init-file t]
955 ["Browse foreign server..." gnus-group-browse-foreign-server t]
956 ["Enter server buffer" gnus-group-enter-server-mode t]
957 ["Expire all expirable articles" gnus-group-expire-all-groups t]
958 ["Gnus version" gnus-version t]
959 ["Save .newsrc files" gnus-group-save-newsrc t]
960 ["Suspend Gnus" gnus-group-suspend t]
961 ["Clear dribble buffer" gnus-group-clear-dribble t]
962 ["Read manual" gnus-info-find-node t]
963 ["Flush score cache" gnus-score-flush-cache t]
964 ["Toggle topics" gnus-topic-mode t]
965 ["Send a bug report" gnus-bug t]
966 ["Exit from Gnus" gnus-group-exit :help "Quit reading news"]
967 ["Exit without saving" gnus-group-quit t]))
969 (gnus-run-hooks 'gnus-group-menu-hook)))
972 (defvar gnus-group-tool-bar-map nil)
974 (defun gnus-group-tool-bar-update (&optional symbol value)
975 "Update group buffer toolbar.
976 Setter function for custom variables."
978 (set-default symbol value))
979 ;; (setq-default gnus-group-tool-bar-map nil)
980 ;; (use-local-map gnus-group-mode-map)
982 (with-current-buffer gnus-group-buffer
983 (gnus-group-make-tool-bar t))))
985 (defcustom gnus-group-tool-bar (if (eq gmm-tool-bar-style 'gnome)
986 'gnus-group-tool-bar-gnome
987 'gnus-group-tool-bar-retro)
988 "Specifies the Gnus group tool bar.
990 It can be either a list or a symbol referring to a list. See
991 `gmm-tool-bar-from-list' for the format of the list. The
992 default key map is `gnus-group-mode-map'.
994 Pre-defined symbols include `gnus-group-tool-bar-gnome' and
995 `gnus-group-tool-bar-retro'."
996 :type '(choice (const :tag "GNOME style" gnus-group-tool-bar-gnome)
997 (const :tag "Retro look" gnus-group-tool-bar-retro)
998 (repeat :tag "User defined list" gmm-tool-bar-item)
1000 :version "23.1" ;; No Gnus
1001 :initialize 'custom-initialize-default
1002 :set 'gnus-group-tool-bar-update
1005 (defcustom gnus-group-tool-bar-gnome
1006 '((gnus-group-post-news "mail/compose")
1007 ;; Some useful agent icons? I don't use the agent so agent users should
1008 ;; suggest useful commands:
1009 (gnus-agent-toggle-plugged "unplugged" t
1010 :help "Gnus is currently unplugged. Click to work online."
1011 :visible (and gnus-agent (not gnus-plugged)))
1012 (gnus-agent-toggle-plugged "plugged" t
1013 :help "Gnus is currently plugged. Click to work offline."
1014 :visible (and gnus-agent gnus-plugged))
1015 ;; FIXME: gnus-agent-toggle-plugged (in gnus-agent-group-make-menu-bar)
1016 ;; should have a better help text.
1017 (gnus-group-send-queue "mail/outbox" t
1018 :visible (and gnus-agent gnus-plugged)
1019 :help "Send articles from the queue group")
1020 (gnus-group-get-new-news "mail/inbox" nil
1021 :visible (or (not gnus-agent)
1023 ;; FIXME: gnus-*-read-group should have a better help text.
1024 (gnus-topic-read-group "open" nil
1025 :visible (and (boundp 'gnus-topic-mode)
1027 (gnus-group-read-group "open" nil
1028 :visible (not (and (boundp 'gnus-topic-mode)
1030 ;; (gnus-group-find-new-groups "???" nil)
1031 (gnus-group-save-newsrc "save")
1032 (gnus-group-describe-group "describe")
1033 (gnus-group-unsubscribe-current-group "gnus/toggle-subscription")
1034 (gnus-group-prev-unread-group "left-arrow")
1035 (gnus-group-next-unread-group "right-arrow")
1036 (gnus-group-exit "exit")
1037 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
1038 (gnus-info-find-node "help"))
1039 "List of functions for the group tool bar (GNOME style).
1041 See `gmm-tool-bar-from-list' for the format of the list."
1042 :type '(repeat gmm-tool-bar-item)
1043 :version "23.1" ;; No Gnus
1044 :initialize 'custom-initialize-default
1045 :set 'gnus-group-tool-bar-update
1048 (defcustom gnus-group-tool-bar-retro
1049 '((gnus-group-get-new-news "gnus/get-news")
1050 (gnus-group-get-new-news-this-group "gnus/gnntg")
1051 (gnus-group-catchup-current "gnus/catchup")
1052 (gnus-group-describe-group "gnus/describe-group")
1053 (gnus-group-subscribe "gnus/subscribe" t
1054 :help "Subscribe to the current group")
1055 (gnus-group-unsubscribe "gnus/unsubscribe" t
1056 :help "Unsubscribe from the current group")
1057 (gnus-group-exit "gnus/exit-gnus" gnus-group-mode-map))
1058 "List of functions for the group tool bar (retro look).
1060 See `gmm-tool-bar-from-list' for the format of the list."
1061 :type '(repeat gmm-tool-bar-item)
1062 :version "23.1" ;; No Gnus
1063 :initialize 'custom-initialize-default
1064 :set 'gnus-group-tool-bar-update
1067 (defcustom gnus-group-tool-bar-zap-list t
1068 "List of icon items from the global tool bar.
1069 These items are not displayed in the Gnus group mode tool bar.
1071 See `gmm-tool-bar-from-list' for the format of the list."
1072 :type 'gmm-tool-bar-zap-list
1073 :version "23.1" ;; No Gnus
1074 :initialize 'custom-initialize-default
1075 :set 'gnus-group-tool-bar-update
1078 (defvar image-load-path)
1079 (defvar tool-bar-map)
1081 (defun gnus-group-make-tool-bar (&optional force)
1082 "Make a group mode tool bar from `gnus-group-tool-bar'.
1083 When FORCE, rebuild the tool bar."
1084 (when (and (boundp 'tool-bar-mode)
1087 (or (not gnus-group-tool-bar-map) force))
1089 (image-load-path-for-library
1090 "gnus" "gnus/toggle-subscription.xpm" nil t))
1091 (image-load-path (cons (car load-path) image-load-path))
1092 (map (gmm-tool-bar-from-list gnus-group-tool-bar
1093 gnus-group-tool-bar-zap-list
1094 'gnus-group-mode-map)))
1096 (set (make-local-variable 'tool-bar-map) map))))
1097 gnus-group-tool-bar-map)
1099 (define-derived-mode gnus-group-mode fundamental-mode "Group"
1100 "Major mode for reading news.
1102 All normal editing commands are switched off.
1103 \\<gnus-group-mode-map>
1104 The group buffer lists (some of) the groups available. For instance,
1105 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1106 lists all zombie groups.
1108 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1109 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1111 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1113 The following commands are available:
1115 \\{gnus-group-mode-map}"
1116 (when (gnus-visual-p 'group-menu 'menu)
1117 (gnus-group-make-menu-bar)
1118 (gnus-group-make-tool-bar))
1119 (gnus-simplify-mode-line)
1120 (gnus-group-set-mode-line)
1121 (setq mode-line-process nil)
1122 (buffer-disable-undo)
1123 (setq truncate-lines t)
1124 (setq buffer-read-only t
1125 show-trailing-whitespace nil)
1126 (gnus-set-default-directory)
1127 (gnus-update-format-specifications nil 'group 'group-mode)
1128 (gnus-update-group-mark-positions)
1134 (defun gnus-update-group-mark-positions ()
1136 (let ((gnus-process-mark ?\200)
1137 (gnus-group-update-hook nil)
1138 (gnus-group-marked '("dummy.group"))
1139 (gnus-active-hashtb (make-vector 10 0)))
1140 (gnus-set-active "dummy.group" '(0 . 0))
1141 (gnus-set-work-buffer)
1142 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1143 (goto-char (point-min))
1144 (setq gnus-group-mark-positions
1145 (list (cons 'process (and (search-forward
1146 (string-to-multibyte "\200") nil t)
1147 (- (point) (point-min) 1))))))))
1149 (defun gnus-mouse-pick-group (e)
1150 "Enter the group under the mouse pointer."
1153 (gnus-group-read-group nil))
1155 (defun gnus-group-default-list-level ()
1156 "Return the real value for `gnus-group-default-list-level'."
1157 (if (functionp gnus-group-default-list-level)
1158 (funcall gnus-group-default-list-level)
1159 gnus-group-default-list-level))
1161 ;; Look at LEVEL and find out what the level is really supposed to be.
1162 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1163 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1164 (defun gnus-group-default-level (&optional level number-or-nil)
1166 (gnus-group-use-permanent-levels
1167 (or (setq gnus-group-use-permanent-levels
1168 (or level (if (numberp gnus-group-use-permanent-levels)
1169 gnus-group-use-permanent-levels
1170 (or (gnus-group-default-list-level)
1171 gnus-level-subscribed))))
1172 (gnus-group-default-list-level) gnus-level-subscribed))
1176 (or level (gnus-group-default-list-level) gnus-level-subscribed))))
1178 (defun gnus-group-setup-buffer ()
1179 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1180 (unless (derived-mode-p 'gnus-group-mode)
1183 (defun gnus-group-name-charset (method group)
1185 (setq method (gnus-find-method-for-group group)))
1186 (when (stringp method)
1187 (setq method (gnus-server-to-method method)))
1188 (if (eq (car method) 'nnimap)
1189 ;; IMAP groups should not be encoded, since they do the encoding
1190 ;; in utf7 in the protocol.
1192 (let ((item (or (assoc method gnus-group-name-charset-method-alist)
1194 (assoc (list (car method) (cadr method))
1195 gnus-group-name-charset-method-alist))))
1196 (alist gnus-group-name-charset-group-alist)
1200 (while (setq item (pop alist))
1201 (if (string-match (car item) group)
1203 result (cdr item))))
1206 (defun gnus-group-name-decode (string charset)
1207 ;; Fixme: Don't decode in unibyte mode.
1208 (if (and string charset)
1209 (decode-coding-string string charset)
1212 (defun gnus-group-decoded-name (string)
1213 (let ((charset (gnus-group-name-charset nil string)))
1214 (gnus-group-name-decode string charset)))
1216 (defun gnus-group-list-groups (&optional level unread lowest)
1217 "List newsgroups with level LEVEL or lower that have unread articles.
1218 Default is all subscribed groups.
1219 If argument UNREAD is non-nil, groups with no unread articles are also
1222 Also see the `gnus-group-use-permanent-levels' variable."
1224 (list (if current-prefix-arg
1225 (prefix-numeric-value current-prefix-arg)
1227 (gnus-group-default-level nil t)
1228 (gnus-group-default-list-level)
1229 gnus-level-subscribed))))
1231 (setq level (car gnus-group-list-mode)
1232 unread (cdr gnus-group-list-mode)))
1233 (setq level (gnus-group-default-level level))
1234 (gnus-group-setup-buffer)
1235 (gnus-update-format-specifications nil 'group 'group-mode)
1236 (let ((case-fold-search nil)
1237 (props (text-properties-at (point-at-bol)))
1238 (empty (= (point-min) (point-max)))
1239 (group (gnus-group-group-name))
1241 (set-buffer gnus-group-buffer)
1242 (setq number (funcall gnus-group-prepare-function level unread lowest))
1243 (when (or (and (numberp number)
1245 (zerop (buffer-size)))
1246 ;; No groups in the buffer.
1247 (gnus-message 5 "%s" gnus-no-groups-message))
1248 ;; We have some groups displayed.
1249 (goto-char (point-max))
1250 (when (or (not gnus-group-goto-next-group-function)
1251 (not (funcall gnus-group-goto-next-group-function
1255 (goto-char (point-min)))
1257 ;; Go to the first group with unread articles.
1258 (gnus-group-search-forward t))
1260 ;; Find the right group to put point on. If the current group
1261 ;; has disappeared in the new listing, try to find the next
1262 ;; one. If no next one can be found, just leave point at the
1263 ;; first newsgroup in the buffer.
1264 (when (not (gnus-goto-char
1266 (point-min) (point-max)
1267 'gnus-group (gnus-intern-safe
1268 group gnus-active-hashtb))))
1269 (let ((newsrc (cdddr (gnus-group-entry group))))
1271 (not (gnus-goto-char
1273 (point-min) (point-max) 'gnus-group
1275 (caar newsrc) gnus-active-hashtb)))))
1276 (setq newsrc (cdr newsrc)))
1278 (goto-char (point-max))
1279 (forward-line -1)))))))
1280 ;; Adjust cursor point.
1281 (gnus-group-position-point)))
1283 (defun gnus-group-list-level (level &optional all)
1284 "List groups on LEVEL.
1285 If ALL (the prefix), also list groups that have no unread articles."
1286 (interactive "nList groups on level: \nP")
1287 (gnus-group-list-groups level all level))
1289 (defun gnus-group-prepare-logic (group test)
1290 (or (and gnus-group-listed-groups
1291 (null gnus-group-list-option)
1292 (member group gnus-group-listed-groups))
1294 ((null gnus-group-listed-groups) test)
1295 ((null gnus-group-list-option) test)
1296 (t (and (member group gnus-group-listed-groups)
1297 (if (eq gnus-group-list-option 'flush)
1301 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1302 "List all newsgroups with unread articles of level LEVEL or lower.
1303 If PREDICATE is a function, list groups that the function returns non-nil;
1304 if it is t, list groups that have no unread articles.
1305 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1306 If REGEXP is a function, list dead groups that the function returns non-nil;
1307 if it is a string, only list groups matching REGEXP."
1308 (set-buffer gnus-group-buffer)
1309 (let ((buffer-read-only nil)
1310 (newsrc (cdr gnus-newsrc-alist))
1311 (lowest (or lowest 1))
1312 (not-in-list (and gnus-group-listed-groups
1313 (copy-sequence gnus-group-listed-groups)))
1314 info clevel unread group params)
1316 (when (or (< lowest gnus-level-zombie)
1317 gnus-group-listed-groups)
1318 ;; List living groups.
1320 (setq info (car newsrc)
1321 group (gnus-info-group info)
1322 params (gnus-info-params info)
1324 unread (gnus-group-unread group))
1326 (setq not-in-list (delete group not-in-list)))
1327 (when (gnus-group-prepare-logic
1329 (and (or unread ; This group might be unchecked
1330 predicate) ; Check if this group should be listed
1331 (or (not (stringp regexp))
1332 (string-match regexp group))
1333 (<= (setq clevel (gnus-info-level info)) level)
1336 ((functionp predicate)
1337 (funcall predicate info))
1338 (predicate t) ; We list all groups?
1341 (if (eq unread t) ; Inactive?
1342 gnus-group-list-inactive-groups
1344 (and (numberp unread) (> unread 0)))
1345 ; We list groups with unread articles
1346 (and gnus-list-groups-with-ticked-articles
1347 (cdr (assq 'tick (gnus-info-marks info))))
1348 ; And groups with ticked articles
1349 ;; Check for permanent visibility.
1350 (and gnus-permanently-visible-groups
1351 (string-match gnus-permanently-visible-groups
1353 (memq 'visible params)
1354 (cdr (assq 'visible params)))))))
1355 (gnus-group-insert-group-line
1356 group (gnus-info-level info)
1357 (gnus-info-marks info) unread (gnus-info-method info)))))
1359 ;; List dead groups.
1360 (when (or gnus-group-listed-groups
1361 (and (>= level gnus-level-zombie)
1362 (<= lowest gnus-level-zombie)))
1363 (gnus-group-prepare-flat-list-dead
1364 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1365 gnus-level-zombie ?Z
1368 (dolist (group gnus-zombie-list)
1369 (setq not-in-list (delete group not-in-list))))
1370 (when (or gnus-group-listed-groups
1371 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1372 (gnus-group-prepare-flat-list-dead
1375 (setq gnus-killed-list (sort gnus-killed-list 'string<))
1377 gnus-level-killed ?K regexp))
1379 (gnus-group-set-mode-line)
1380 (setq gnus-group-list-mode (cons level predicate))
1381 (gnus-run-hooks 'gnus-group-prepare-hook)
1384 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1385 ;; List zombies and killed lists somewhat faster, which was
1386 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1387 ;; this by ignoring the group format specification altogether.
1389 (if (> (length groups) gnus-group-listing-limit)
1391 (setq group (pop groups))
1392 (when (gnus-group-prepare-logic
1395 (and (stringp regexp) (string-match regexp group))
1396 (and (functionp regexp) (funcall regexp group))))
1397 (add-text-properties
1398 (point) (prog1 (1+ (point))
1399 (insert " " mark " *: "
1400 (gnus-group-decoded-name group)
1402 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1404 'gnus-level level))))
1406 (setq group (pop groups))
1407 (when (gnus-group-prepare-logic
1410 (and (stringp regexp) (string-match regexp group))
1411 (and (functionp regexp) (funcall regexp group))))
1412 (gnus-group-insert-group-line
1414 (let ((active (gnus-active group)))
1416 (if (zerop (cdr active))
1418 (- (1+ (cdr active)) (car active)))
1420 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1422 (defun gnus-group-update-group-line ()
1423 "Update the current line in the group buffer."
1424 (let* ((buffer-read-only nil)
1425 (group (gnus-group-group-name))
1426 (entry (and group (gnus-group-entry group)))
1427 gnus-group-indentation)
1430 (not (gnus-ephemeral-group-p group))
1432 (concat "(gnus-group-set-info '"
1433 (gnus-prin1-to-string (nth 2 entry))
1435 (concat "^(gnus-group-set-info '(\"" (regexp-quote group) "\"")))
1436 (setq gnus-group-indentation (gnus-group-group-indentation))
1438 (gnus-group-insert-group-line-info group)
1440 (gnus-group-position-point))))
1442 (defun gnus-group-insert-group-line-info (group)
1443 "Insert GROUP on the current line."
1444 (let ((entry (gnus-group-entry group))
1445 (gnus-group-indentation (gnus-group-group-indentation))
1449 ;; (Un)subscribed group.
1450 (setq info (nth 2 entry))
1451 (gnus-group-insert-group-line
1452 group (gnus-info-level info) (gnus-info-marks info)
1453 (or (car entry) t) (gnus-info-method info)))
1454 ;; This group is dead.
1455 (gnus-group-insert-group-line
1457 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1459 (if (setq active (gnus-active group))
1460 (if (zerop (cdr active))
1462 (- (1+ (cdr active)) (car active)))
1464 (gnus-method-simplify (gnus-find-method-for-group group))))))
1466 (defun gnus-number-of-unseen-articles-in-group (group)
1467 (let* ((info (nth 2 (gnus-group-entry group)))
1468 (marked (gnus-info-marks info))
1469 (seen (cdr (assq 'seen marked)))
1470 (active (gnus-active group)))
1473 (length (gnus-uncompress-range
1474 (gnus-range-difference
1475 (gnus-range-difference (list active) (gnus-info-read info))
1478 ;; Moving through the Group buffer (in topic mode) e.g. with C-n doesn't
1479 ;; update the state (enabled/disabled) of the icon `gnus-group-describe-group'
1480 ;; automatically. After `C-l' the state is correct. See the following report
1482 ;; <http://thread.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de>:
1483 ;; From: Reiner Steib
1484 ;; Subject: tool bar icons not updated according to :active condition
1485 ;; Newsgroups: gmane.emacs.devel
1486 ;; Date: Mon, 23 Jan 2006 19:59:13 +0100
1487 ;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
1489 ;; Using `redraw-frame' (see `gnus-tool-bar-update') in Emacs might
1490 ;; be confusing, so maybe we shouldn't call it by default.
1491 (defcustom gnus-group-update-tool-bar (and (boundp 'tool-bar-mode)
1493 "Force updating the group buffer tool bar."
1496 :initialize 'custom-initialize-default
1497 :set (lambda (symbol value)
1498 (set-default symbol value)
1499 (when (gnus-alive-p)
1500 (with-current-buffer gnus-group-buffer
1501 ;; FIXME: Is there a better way to redraw the group buffer?
1502 (gnus-group-get-new-news 0))))
1505 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1506 gnus-tmp-marked number
1508 "Insert a group line in the group buffer."
1509 (let* ((gnus-tmp-method
1510 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1511 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1513 (gnus-tmp-active (gnus-active gnus-tmp-group))
1514 (gnus-tmp-number-total
1516 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1518 (gnus-tmp-number-of-unread
1519 (if (numberp number) (int-to-string (max 0 number))
1521 (gnus-tmp-number-of-read
1522 (if (numberp number)
1523 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1525 (gnus-tmp-subscribed
1526 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1527 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1528 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1530 (gnus-tmp-qualified-group
1531 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1532 group-name-charset))
1534 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1536 (gnus-tmp-newsgroup-description
1537 (if gnus-description-hashtb
1538 (or (gnus-group-name-decode
1539 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1540 group-name-charset) "")
1543 (if (and gnus-moderated-hashtb
1544 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1546 (gnus-tmp-moderated-string
1547 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1548 (gnus-tmp-group-icon (gnus-group-get-icon gnus-tmp-group))
1549 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1550 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1551 (gnus-tmp-news-method-string
1553 (format "(%s:%s)" (car gnus-tmp-method)
1554 (cadr gnus-tmp-method)) ""))
1555 (gnus-tmp-marked-mark
1556 (if (and (numberp number)
1558 (cdr (assq 'tick gnus-tmp-marked)))
1560 (gnus-tmp-summary-live
1561 (if (and (not gnus-group-is-exiting-p)
1562 (gnus-buffer-live-p (gnus-summary-buffer-name
1565 (gnus-tmp-process-marked
1566 (if (member gnus-tmp-group gnus-group-marked)
1567 gnus-process-mark ? ))
1568 (buffer-read-only nil)
1570 gnus-tmp-header) ; passed as parameter to user-funcs.
1573 (add-text-properties
1577 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1578 gnus-tmp-group group-name-charset)))
1579 (eval gnus-group-line-format-spec)))
1580 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1581 gnus-unread ,(if (numberp number)
1582 (string-to-number gnus-tmp-number-of-unread)
1584 gnus-marked ,gnus-tmp-marked-mark
1585 gnus-indentation ,gnus-group-indentation
1586 gnus-level ,gnus-tmp-level))
1588 (gnus-group--setup-tool-bar-update beg end)
1590 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1591 (gnus-group-highlight-line gnus-tmp-group beg end))
1592 (gnus-run-hooks 'gnus-group-update-hook)
1595 (defun gnus-group--setup-tool-bar-update (beg end)
1596 (when gnus-group-update-tool-bar
1597 (if (fboundp 'cursor-sensor-mode)
1599 (unless (bound-and-true-p cursor-sensor-mode)
1600 (cursor-sensor-mode 1))
1601 (put-text-property beg end 'cursor-sensor-functions
1602 '(gnus-tool-bar-update)))
1603 (put-text-property beg end 'point-entered
1604 #'gnus-tool-bar-update)
1605 (put-text-property beg end 'point-left
1606 #'gnus-tool-bar-update))))
1608 (defun gnus-group-update-eval-form (group list)
1609 "Eval `car' of each element of LIST, and return the first that return t.
1610 Some value are bound so the form can use them."
1612 (let* ((entry (gnus-group-entry group))
1613 (active (gnus-active group))
1614 (info (nth 2 entry))
1615 (method (inline (gnus-server-get-method
1616 group (gnus-info-method info))))
1617 (marked (gnus-info-marks info))
1620 (cons 'unread (if (numberp (car entry)) (car entry) 0))
1621 (cons 'total (if active (1+ (- (cdr active) (car active))) 0))
1628 (car (or method gnus-select-method)))
1629 gnus-valid-select-methods)))
1630 '(mail post-mail))))
1631 (cons 'level (or (gnus-info-level info) gnus-level-killed))
1632 (cons 'score (or (gnus-info-score info) 0))
1633 (cons 'ticked (gnus-range-length (cdr (assq 'tick marked))))
1634 (cons 'group-age (gnus-group-timestamp-delta group)))))
1636 (not (eval (caar list) env)))
1637 (setq list (cdr list)))
1640 (defun gnus-group-highlight-line (group beg end)
1641 "Highlight the current line according to `gnus-group-highlight'.
1642 GROUP is current group, and the line to highlight starts at BEG
1644 (let ((face (cdar (gnus-group-update-eval-form
1646 gnus-group-highlight))))
1647 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces
1649 (let ((inhibit-read-only t))
1650 (gnus-put-text-property-excluding-characters-with-faces
1652 (if (boundp face) (symbol-value face) face))))))
1654 (defun gnus-group-get-icon (group)
1655 "Return an icon for GROUP according to `gnus-group-icon-list'."
1656 (if gnus-group-icon-list
1658 (cdar (gnus-group-update-eval-form group gnus-group-icon-list))))
1663 (gnus-create-image (expand-file-name image-path))
1669 (defun gnus-group-refresh-group (group)
1670 (gnus-activate-group group)
1671 (gnus-get-unread-articles-in-group (gnus-get-info group)
1672 (gnus-active group))
1673 (gnus-group-update-group group))
1675 (defun gnus-group-update-group (group &optional visible-only
1677 "Update all lines where GROUP appear.
1678 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1679 already. If INFO-UNCHANGED is non-nil, dribble buffer is not updated."
1680 (with-current-buffer gnus-group-buffer
1682 ;; The buffer may be narrowed.
1685 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1687 found buffer-read-only)
1688 (unless info-unchanged
1689 ;; Enter the current status into the dribble buffer.
1690 (let ((entry (gnus-group-entry group)))
1692 (not (gnus-ephemeral-group-p group)))
1694 (concat "(gnus-group-set-info '"
1695 (gnus-prin1-to-string (nth 2 entry))
1697 (concat "^(gnus-group-set-info '(\""
1698 (regexp-quote group) "\"")))))
1699 ;; Find all group instances. If topics are in use, each group
1700 ;; may be listed in more than once.
1701 (while (setq loc (text-property-any
1702 loc (point-max) 'gnus-group ident))
1705 (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 (setq loc (1+ loc)))
1712 (unless (or found visible-only)
1713 ;; No such line in the buffer, find out where it's supposed to
1714 ;; go, and insert it there (or at the end of the buffer).
1715 (if gnus-goto-missing-group-function
1716 (funcall gnus-goto-missing-group-function group)
1717 (let ((entry (cddr (gnus-group-entry group))))
1718 (while (and entry (car entry)
1722 (point-min) (point-max)
1723 'gnus-group (gnus-intern-safe
1725 gnus-active-hashtb)))))
1726 (setq entry (cdr entry)))
1727 (or entry (goto-char (point-max)))))
1728 ;; Finally insert the line.
1729 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1730 (gnus-group-insert-group-line-info group)
1733 (gnus-run-hooks 'gnus-group-update-group-hook))))
1734 (when gnus-group-update-group-function
1735 (funcall gnus-group-update-group-function group))
1736 (gnus-group-set-mode-line))))))
1738 (defun gnus-group-set-mode-line ()
1739 "Update the mode line in the group buffer."
1740 (when (memq 'group gnus-updated-mode-lines)
1741 ;; Yes, we want to keep this mode line updated.
1742 (with-current-buffer gnus-group-buffer
1743 (let* ((gformat (or gnus-group-mode-line-format-spec
1744 (gnus-set-format 'group-mode)))
1745 (gnus-tmp-news-server (cadr gnus-select-method))
1746 (gnus-tmp-news-method (car gnus-select-method))
1747 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1749 gnus-tmp-header ;Dummy binding for user-defined formats
1750 ;; Get the resulting string.
1752 (and gnus-dribble-buffer
1753 (buffer-name gnus-dribble-buffer)
1754 (buffer-modified-p gnus-dribble-buffer)
1755 (with-current-buffer gnus-dribble-buffer
1756 (not (zerop (buffer-size))))))
1757 (mode-string (eval gformat)))
1758 ;; Say whether the dribble buffer has been modified.
1759 (setq mode-line-modified
1760 (if modified "**" "--"))
1761 ;; If the line is too long, we chop it off.
1762 (when (> (length mode-string) max-len)
1763 (setq mode-string (substring mode-string 0 (- max-len 4))))
1765 (setq mode-line-buffer-identification
1766 (gnus-mode-line-buffer-identification
1767 (list mode-string)))
1768 (set-buffer-modified-p modified))))))
1770 (defun gnus-group-group-name ()
1771 "Get the name of the newsgroup on the current line."
1772 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1776 (symbol-name group)))))
1778 (defun gnus-group-group-level ()
1779 "Get the level of the newsgroup on the current line."
1780 (get-text-property (point-at-bol) 'gnus-level))
1782 (defun gnus-group-group-indentation ()
1783 "Get the indentation of the newsgroup on the current line."
1784 (or (get-text-property (point-at-bol) 'gnus-indentation)
1785 (and gnus-group-indentation-function
1786 (funcall gnus-group-indentation-function))
1789 (defun gnus-group-group-unread ()
1790 "Get the number of unread articles of the newsgroup on the current line."
1791 (get-text-property (point-at-bol) 'gnus-unread))
1793 (defun gnus-group-new-mail (group)
1794 (if (nnmail-new-mail-p (gnus-group-real-name group))
1798 (defun gnus-group-level (group)
1799 "Return the estimated level of GROUP."
1800 (or (gnus-info-level (gnus-get-info group))
1801 (and (member group gnus-zombie-list) gnus-level-zombie)
1804 (defun gnus-group-search-forward (&optional backward all level first-too)
1805 "Find the next newsgroup with unread articles.
1806 If BACKWARD is non-nil, find the previous newsgroup instead.
1807 If ALL is non-nil, just find any newsgroup.
1808 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1810 If FIRST-TOO, the current line is also eligible as a target."
1811 (let ((way (if backward -1 1))
1812 (low gnus-level-killed)
1815 (if (and backward (progn (beginning-of-line)) (bobp))
1824 (get-text-property (point) 'gnus-group)
1828 (get-text-property (point) 'gnus-unread)))
1829 (and (numberp unread) (> unread 0)))
1830 (setq lev (get-text-property (point)
1832 (<= lev gnus-level-subscribed)))
1834 (and (setq lev (get-text-property (point)
1843 (zerop (forward-line way)))))
1845 (progn (gnus-group-position-point) t)
1846 (goto-char (or pos beg))
1849 (defun gnus-total-fetched-for (group)
1850 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1851 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1852 (size (+ size-in-cache size-in-agent))
1853 (suffix '("B" "K" "M" "G"))
1856 (while (> size cutoff)
1857 (setq size (/ size scale)
1858 suffix (cdr suffix)))
1859 (format "%5.1f%s" size (car suffix))))
1861 ;;; Gnus group mode commands
1865 (defun gnus-group-mark-line-p ()
1868 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1869 (eq (char-after) gnus-process-mark)))
1871 (defun gnus-group-mark-group (n &optional unmark no-advance)
1872 "Mark the current group."
1874 (let ((buffer-read-only nil)
1878 (when (setq group (gnus-group-group-name))
1879 ;; Go to the mark position.
1881 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1885 (setq gnus-group-marked (delete group gnus-group-marked))
1886 (insert-char ? 1 t))
1887 (setq gnus-group-marked
1888 (cons group (delete group gnus-group-marked)))
1889 (insert-char gnus-process-mark 1 t)))
1891 (gnus-group-next-group 1))
1893 (gnus-group-position-point)
1896 (defun gnus-group-unmark-group (n)
1897 "Remove the mark from the current group."
1899 (gnus-group-mark-group n 'unmark)
1900 (gnus-group-position-point))
1902 (defun gnus-group-unmark-all-groups ()
1903 "Unmark all groups."
1906 (mapc 'gnus-group-remove-mark gnus-group-marked))
1907 (gnus-group-position-point))
1909 (defun gnus-group-mark-region (unmark beg end)
1910 "Mark all groups between point and mark.
1911 If UNMARK, remove the mark instead."
1912 (interactive "P\nr")
1913 (let ((num (count-lines beg end)))
1916 (- num (gnus-group-mark-group num unmark)))))
1918 (defun gnus-group-mark-buffer (&optional unmark)
1919 "Mark all groups in the buffer.
1920 If UNMARK, remove the mark instead."
1922 (gnus-group-mark-region unmark (point-min) (point-max)))
1924 (defun gnus-group-mark-regexp (regexp)
1925 "Mark all groups that match some regexp."
1926 (interactive "sMark (regexp): ")
1927 (let ((alist (cdr gnus-newsrc-alist))
1931 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1932 (gnus-group-jump-to-group group)
1933 (gnus-group-set-mark group)))))
1934 (gnus-group-position-point))
1936 (defun gnus-group-remove-mark (group &optional test-marked)
1937 "Remove the process mark from GROUP and move point there.
1938 Return nil if the group isn't displayed."
1939 (if (gnus-group-goto-group group nil test-marked)
1941 (gnus-group-mark-group 1 'unmark t)
1943 (setq gnus-group-marked
1944 (delete group gnus-group-marked))
1947 (defun gnus-group-set-mark (group)
1948 "Set the process mark on GROUP."
1949 (if (gnus-group-goto-group group)
1951 (gnus-group-mark-group 1 nil t))
1952 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1954 (defun gnus-group-universal-argument (arg &optional groups func)
1955 "Perform any command on all groups according to the process/prefix convention."
1957 (if (eq (setq func (or func
1960 (substitute-command-keys
1961 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1963 (gnus-error 1 "Undefined key")
1964 (gnus-group-iterate arg
1966 (command-execute func))))
1967 (gnus-group-position-point))
1969 (defun gnus-group-process-prefix (n)
1970 "Return a list of groups to work on.
1971 Take into consideration N (the prefix) and the list of marked groups."
1974 (setq n (prefix-numeric-value n))
1975 ;; There is a prefix, so we return a list of the N next
1977 (let ((way (if (< n 0) -1 1))
1982 (if (setq group (gnus-group-group-name))
1983 (push group groups))
1985 (gnus-group-next-group way)))
1987 ((and transient-mark-mode mark-active (mark))
1988 ;; Work on the region between point and mark.
1989 (let ((max (max (point) (mark)))
1992 (goto-char (min (point) (mark)))
1995 (push (gnus-group-group-name) groups)
1996 (zerop (gnus-group-next-group 1))
1998 (nreverse groups))))
2000 ;; No prefix, but a list of marked articles.
2001 (reverse gnus-group-marked))
2003 ;; Neither marked articles or a prefix, so we return the
2005 (let ((group (gnus-group-group-name)))
2006 (and group (list group))))))
2008 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
2009 ;;; imagine why I went through these contortions...
2011 (let ((function (make-symbol "gnus-group-iterate-function"))
2012 (window (make-symbol "gnus-group-iterate-window"))
2013 (groups (make-symbol "gnus-group-iterate-groups"))
2014 (group (make-symbol "gnus-group-iterate-group")))
2016 `(defun gnus-group-iterate (arg ,function)
2017 "Iterate FUNCTION over all process/prefixed groups.
2018 FUNCTION will be called with the group name as the parameter
2019 and with point over the group in question."
2020 (let ((,groups (gnus-group-process-prefix arg))
2021 (,window (selected-window))
2024 (setq ,group (car ,groups)
2025 ,groups (cdr ,groups))
2026 (select-window ,window)
2027 (gnus-group-remove-mark ,group)
2028 (save-selected-window
2030 (funcall ,function ,group)))))))))
2032 (put 'gnus-group-iterate 'lisp-indent-function 1)
2034 ;; Selecting groups.
2036 (defun gnus-group-read-group (&optional all no-article group select-articles)
2037 "Read news in this newsgroup.
2038 If the prefix argument ALL is non-nil, already read articles become
2041 If ALL is a positive number, fetch this number of the latest
2042 articles in the group. If ALL is a negative number, fetch this
2043 number of the earliest articles in the group.
2045 If the optional argument NO-ARTICLE is non-nil, no article will
2046 be auto-selected upon group entry. If GROUP is non-nil, fetch
2049 (let ((no-display (eq all 0))
2050 (group (or group (gnus-group-group-name)))
2051 number active marked entry)
2055 (error "No group on current line"))
2056 (setq marked (gnus-info-marks
2057 (nth 2 (setq entry (gnus-group-entry group)))))
2058 ;; This group might be a dead group. In that case we have to get
2059 ;; the number of unread articles from `gnus-active-hashtb'.
2061 (cond ((numberp all) all)
2063 ((setq active (gnus-active group))
2064 (- (1+ (cdr active)) (car active)))))
2065 (gnus-summary-read-group
2066 group (or all (and (numberp number)
2067 (zerop (+ number (gnus-range-length
2068 (cdr (assq 'tick marked)))
2070 (cdr (assq 'dormant marked)))))))
2071 no-article nil no-display nil select-articles)))
2073 (defun gnus-group-select-group (&optional all)
2074 "Select this newsgroup.
2075 No article is selected automatically.
2076 If the group is opened, just switch the summary buffer.
2077 If ALL is non-nil, already read articles become readable.
2078 If ALL is a positive number, fetch this number of the latest
2079 articles in the group.
2080 If ALL is a negative number, fetch this number of the earliest
2081 articles in the group."
2083 (when (and (eobp) (not (gnus-group-group-name)))
2085 (gnus-group-read-group all t))
2087 (defun gnus-group-quick-select-group (&optional all group)
2088 "Select the GROUP \"quickly\".
2089 This means that no highlighting or scoring will be performed. If
2090 ALL (the prefix argument) is 0, don't even generate the summary
2091 buffer. If GROUP is nil, use current group.
2093 This might be useful if you want to toggle threading
2094 before entering the group."
2096 (require 'gnus-score)
2098 gnus-score-find-score-files-function
2099 gnus-home-score-file
2100 gnus-apply-kill-hook
2101 gnus-summary-expunge-below)
2102 (gnus-group-read-group all t group)))
2104 (defun gnus-group-visible-select-group (&optional all)
2105 "Select the current group without hiding any articles."
2107 (let ((gnus-inhibit-limiting t))
2108 (gnus-group-read-group all t)))
2110 (defun gnus-group-select-group-ephemerally ()
2111 "Select the current group without doing any processing whatsoever.
2112 You will actually be entered into a group that's a copy of
2113 the current group; no changes you make while in this group will
2116 (require 'gnus-score)
2118 gnus-score-find-score-files-function gnus-apply-kill-hook
2119 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2120 gnus-summary-mode-hook gnus-select-group-hook
2121 (group (gnus-group-group-name))
2122 (method (gnus-find-method-for-group group)))
2123 (gnus-group-read-ephemeral-group
2124 (gnus-group-prefixed-name group method) method)))
2126 (defun gnus-group-name-at-point ()
2127 "Return a group name from around point if it exists, or nil."
2128 (if (derived-mode-p 'gnus-group-mode)
2129 (let ((group (gnus-group-group-name)))
2131 (gnus-group-decoded-name group)))
2132 (let ((regexp "[][\C-@-\t\v-*,/:-@\\^`{-\C-?]*\
2133 \\(nn[a-z]+\\(?:\\+[^][\C-@-*,/:-@\\^`{-\C-?]+\\)?:\
2134 [^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)*\
2135 \\|[^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)+\\)")
2137 (case-fold-search nil))
2139 (if (or (and (not (or (eobp)
2140 (looking-at "[][\C-@-*,/;-@\\^`{-\C-?]")))
2142 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2144 (and (looking-at "[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*$")
2146 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2147 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2149 (string-match "\\`[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*\\'"
2150 (buffer-substring (point-at-bol) (point))))
2151 (when (looking-at regexp)
2153 (let (group distance)
2154 (when (looking-at regexp)
2155 (setq group (match-string 1)
2156 distance (- (match-beginning 1) (match-beginning 0))))
2157 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2158 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2160 (if (looking-at regexp)
2161 (if (and group (<= distance (- start (match-end 0))))
2165 (goto-char start)))))
2167 (defun gnus-group-completing-read (&optional prompt collection
2168 require-match initial-input hist
2170 "Read a group name with completion. Non-ASCII group names are allowed.
2171 The arguments are the same as `completing-read' except that COLLECTION
2172 and HIST default to `gnus-active-hashtb' and `gnus-group-history'
2173 respectively if they are omitted. Regards COLLECTION as a hash table
2174 if it is not a list."
2175 (or collection (setq collection gnus-active-hashtb))
2176 (let (choices group)
2177 (if (listp collection)
2178 (dolist (symbol collection)
2179 (setq group (symbol-name symbol))
2180 (push (if (string-match "[^\000-\177]" group)
2181 (gnus-group-decoded-name group)
2184 (mapatoms (lambda (symbol)
2185 (setq group (symbol-name symbol))
2186 (push (if (string-match "[^\000-\177]" group)
2187 (gnus-group-decoded-name group)
2191 (setq group (gnus-completing-read (or prompt "Group") (nreverse choices)
2192 require-match initial-input
2193 (or hist 'gnus-group-history)
2195 (unless (if (listp collection)
2196 (member group (mapcar 'symbol-name collection))
2197 (symbol-value (intern-soft group collection)))
2199 (encode-coding-string
2200 group (gnus-group-name-charset nil group))))
2201 (replace-regexp-in-string "\n" "" group)))
2204 (defun gnus-fetch-group (group &optional articles)
2205 "Start Gnus if necessary and enter GROUP.
2206 If ARTICLES, display those articles.
2207 Returns whether the fetching was successful or not."
2208 (interactive (list (gnus-group-completing-read nil
2210 (gnus-group-name-at-point))))
2211 (unless (gnus-alive-p)
2213 (gnus-group-read-group (if articles nil t) nil group articles))
2216 (defun gnus-fetch-group-other-frame (group)
2217 "Pop up a frame and enter GROUP."
2219 (let ((window (get-buffer-window gnus-group-buffer)))
2221 (select-frame (window-frame window)))
2222 ((= (length (frame-list)) 1)
2223 (select-frame (make-frame)))
2226 (gnus-fetch-group group))
2228 (defcustom gnus-large-ephemeral-newsgroup 200
2229 "The number of articles which indicates a large ephemeral newsgroup.
2230 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2232 If the number of articles in a newsgroup is greater than this value,
2233 confirmation is required for selecting the newsgroup. If it is nil, no
2234 confirmation is required."
2236 :group 'gnus-group-select
2237 :type '(choice (const :tag "No limit" nil)
2240 (defcustom gnus-fetch-old-ephemeral-headers nil
2241 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2244 :type '(choice (const :tag "off" nil)
2247 (sexp :menu-tag "other" t)))
2249 ;; Enter a group that is not in the group buffer. Non-nil is returned
2250 ;; if selection was successful.
2251 (defun gnus-group-read-ephemeral-group (group method &optional activate
2252 quit-config request-only
2256 "Read GROUP from METHOD as an ephemeral group.
2257 If ACTIVATE, request the group first.
2258 If QUIT-CONFIG, use that Gnus window configuration name when
2259 exiting from the ephemeral group.
2260 If REQUEST-ONLY, don't actually read the group; just request it.
2261 If SELECT-ARTICLES, only select those articles.
2262 If PARAMETERS, use those as the group parameters.
2263 If NUMBER, fetch this number of articles.
2265 Return the name of the group if selection was successful."
2268 ;; (gnus-read-group "Group name: ")
2269 (gnus-group-completing-read)
2270 (gnus-read-method "From method")))
2271 (unless (gnus-alive-p)
2272 (nnheader-init-server-buffer)
2273 ;; Necessary because of funky inlining.
2274 (require 'gnus-cache)
2275 (setq gnus-newsrc-hashtb (gnus-make-hashtable)))
2276 ;; Transform the select method into a unique server.
2277 (when (stringp method)
2278 (setq method (gnus-server-to-method method)))
2280 (intern (format "%s-address" (car method)))))
2282 (if (assq address-slot (cddr method))
2283 `(,(car method) ,(concat (cadr method) "-ephemeral")
2285 `(,(car method) ,(concat (cadr method) "-ephemeral")
2286 (,address-slot ,(cadr method))
2288 (let ((group (if (gnus-group-foreign-p group) group
2289 (gnus-group-prefixed-name (gnus-group-real-name group)
2291 (gnus-set-active group nil)
2295 ,gnus-level-default-subscribed nil nil ,method
2301 ((assq gnus-current-window-configuration
2302 gnus-buffer-configuration)
2303 (cons gnus-summary-buffer
2304 gnus-current-window-configuration))
2306 (cons (current-buffer)
2307 (current-window-configuration)))))
2310 (push method gnus-ephemeral-servers)
2311 (when (gnus-buffer-live-p gnus-group-buffer)
2312 (set-buffer gnus-group-buffer))
2313 (unless (gnus-check-server method)
2314 (error "Unable to contact server: %s" (gnus-status-message method)))
2316 (gnus-activate-group group 'scan)
2317 (unless (gnus-request-group group)
2318 (error "Couldn't request group: %s"
2319 (nnheader-get-report (car method)))))
2323 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2324 (gnus-fetch-old-headers
2325 gnus-fetch-old-ephemeral-headers))
2326 (gnus-group-read-group (or number t) t group select-articles))
2331 (message "Quit reading the ephemeral group"))
2334 (defcustom gnus-gmane-group-download-format
2335 "http://download.gmane.org/%s/%s/%s"
2336 "URL for downloading mbox files.
2337 It must contain three \"%s\". They correspond to the group, the
2338 minimal and maximal article numbers, respectively."
2339 :group 'gnus-group-foreign
2340 :version "23.1" ;; No Gnus
2343 (autoload 'url-insert-file-contents "url-handlers")
2345 ;; - Add documentation, menu, key bindings, ...
2347 (defun gnus-read-ephemeral-gmane-group (group start &optional range)
2348 "Read articles from Gmane group GROUP as an ephemeral group.
2349 START is the first article. RANGE specifies how many articles
2350 are fetched. The articles are downloaded via HTTP using the URL
2351 specified by `gnus-gmane-group-download-format'."
2352 ;; See <http://gmane.org/export.php> for more information.
2355 (gnus-group-completing-read "Gmane group")
2356 (read-number "Start article number: ")
2357 (read-number "How many articles: ")))
2358 (unless range (setq range 500))
2360 (error "Invalid range: %s" range))
2361 (let ((tmpfile (make-temp-file
2362 (format "%s.start-%s.range-%s." group start range)))
2363 (gnus-thread-sort-functions '(gnus-thread-sort-by-number)))
2364 (with-temp-file tmpfile
2365 (url-insert-file-contents
2366 (format gnus-gmane-group-download-format
2367 group start (+ start range)))
2368 (write-region (point-min) (point-max) tmpfile)
2369 (gnus-group-read-ephemeral-group
2370 (format "nndoc+ephemeral:%s.start-%s.range-%s" group start range)
2372 (nndoc-article-type mbox))))
2373 (delete-file tmpfile)))
2375 (defun gnus-read-ephemeral-gmane-group-url (url)
2376 "Create an ephemeral Gmane group from URL.
2378 Valid input formats include:
2379 \"http://thread.gmane.org/gmane.foo.bar/12300/focus=12399\",
2380 \"http://thread.gmane.org/gmane.foo.bar/12345/\",
2381 \"http://article.gmane.org/gmane.foo.bar/12345/\",
2382 \"http://news.gmane.org/group/gmane.foo.bar/thread=12345\""
2383 ;; - Feel free to add other useful Gmane URLs here! Maybe the URLs should
2385 ;; - The URLs should be added to `gnus-button-alist'. Probably we should
2386 ;; prompt the user to decide: "View via `browse-url' or in Gnus? "
2387 ;; (`gnus-read-ephemeral-gmane-group-url')
2389 (list (gnus-group-completing-read "Gmane URL")))
2390 (let (group start range)
2392 ;; URLs providing `group', `start' and `range':
2394 ;; http://thread.gmane.org/gmane.emacs.devel/86326/focus=86525
2395 "^http://thread\\.gmane\\.org/\\([^/]+\\)/\\([0-9]+\\)/focus=\\([0-9]+\\)$"
2397 (setq group (match-string 1 url)
2398 start (string-to-number (match-string 2 url))
2399 ;; Ensure that `range' is large enough to ensure focus article is
2401 range (- (string-to-number (match-string 3 url))
2403 ;; URLs providing `group' and `start':
2405 ;; http://article.gmane.org/gmane.comp.gnu.make.bugs/3584
2406 "^http://\\(?:thread\\|article\\|permalink\\)\\.gmane\\.org/\\([^/]+\\)/\\([0-9]+\\)"
2409 ;; Don't advertise these in the doc string yet:
2410 "^\\(?:nntp\\|news\\)://news\\.gmane\\.org/\\([^/]+\\)/\\([0-9]+\\)"
2413 ;; http://news.gmane.org/group/gmane.emacs.gnus.general/thread=65099/force_load=t
2414 "^http://news\\.gmane\\.org/group/\\([^/]+\\)/thread=\\([0-9]+\\)"
2416 (setq group (match-string 1 url)
2417 start (string-to-number (match-string 2 url))))
2419 (error "Can't parse URL %s" url)))
2420 (gnus-read-ephemeral-gmane-group group start range)))
2422 (defcustom gnus-bug-group-download-format-alist
2423 '((emacs . "http://debbugs.gnu.org/cgi/bugreport.cgi?bug=%s;mboxmaint=yes;mboxstat=yes")
2425 . "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%s&mbox=yes;mboxmaint=yes"))
2426 "Alist of symbols for bug trackers and the corresponding URL format string.
2427 The URL format string must contain a single \"%s\", specifying
2428 the bug number, and browsing the URL must return mbox output."
2429 :group 'gnus-group-foreign
2430 ;; Added mboxmaint=yes. This gets the version with the messages as
2431 ;; they went out, not as they came in.
2432 ;; Eg bug-gnu-emacs is replaced by ###@debbugs.
2434 :type '(repeat (cons (symbol) (string :tag "URL format string"))))
2436 (defun gnus-read-ephemeral-bug-group (ids mbox-url &optional window-conf)
2437 "Browse bug NUMBER as ephemeral group."
2438 (interactive (list (read-string "Enter bug number: "
2439 (thing-at-point 'word) nil)
2440 ;; FIXME: Add completing-read from
2441 ;; `gnus-emacs-bug-group-download-format' ...
2442 (cdr (assoc 'emacs gnus-bug-group-download-format-alist))))
2444 (setq ids (string-to-number ids)))
2446 (setq ids (list ids)))
2447 (let ((tmpfile (make-temp-file "gnus-temp-group-")))
2448 (let ((coding-system-for-write 'binary)
2449 (coding-system-for-read 'binary))
2450 (with-temp-file tmpfile
2451 (mm-disable-multibyte)
2453 (let ((file (format "~/.emacs.d/debbugs-cache/%s" id)))
2454 (if (and (not gnus-plugged)
2455 (file-exists-p file))
2456 (insert-file-contents file)
2457 (url-insert-file-contents (format mbox-url id)))))
2458 (goto-char (point-min))
2459 ;; Add the debbugs address so that we can respond to reports easily.
2460 (while (re-search-forward "^To: " nil t)
2462 (insert (format ", %s@%s" (car ids)
2463 (replace-regexp-in-string
2465 (replace-regexp-in-string "^http://" "" mbox-url)))))))
2466 (gnus-group-read-ephemeral-group
2467 (format "nndoc+ephemeral:bug#%s"
2468 (mapconcat 'number-to-string ids ","))
2470 (nndoc-article-type mbox))
2472 (delete-file tmpfile)))
2474 (defun gnus-read-ephemeral-debian-bug-group (number)
2475 "Browse Debian bug NUMBER as ephemeral group."
2476 (interactive (list (read-string "Enter bug number: "
2477 (thing-at-point 'word) nil)))
2478 (gnus-read-ephemeral-bug-group
2480 (cdr (assoc 'debian gnus-bug-group-download-format-alist))))
2482 (defvar debbugs-gnu-bug-number) ; debbugs-gnu
2484 (defun gnus-read-ephemeral-emacs-bug-group (ids &optional window-conf)
2485 "Browse Emacs bugs IDS as an ephemeral group."
2486 (interactive (list (string-to-number
2487 (read-string "Enter bug number: "
2488 (thing-at-point 'word) nil))))
2490 (setq ids (list ids)))
2491 (gnus-read-ephemeral-bug-group
2493 (cdr (assoc 'emacs gnus-bug-group-download-format-alist))
2495 (when (fboundp 'debbugs-gnu-summary-mode)
2496 (with-current-buffer (window-buffer (selected-window))
2497 (debbugs-gnu-summary-mode 1)
2498 (set (make-local-variable 'debbugs-gnu-bug-number) (car ids)))))
2500 (defun gnus-group-jump-to-group (group &optional prompt)
2501 "Jump to newsgroup GROUP.
2503 If PROMPT (the prefix) is a number, use the prompt specified in
2504 `gnus-group-jump-to-group-prompt'."
2506 (list (gnus-group-completing-read
2508 (if current-prefix-arg
2509 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2510 (or (and (stringp gnus-group-jump-to-group-prompt)
2511 gnus-group-jump-to-group-prompt)
2512 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2513 (and (stringp p) p)))))))
2515 (when (equal group "")
2516 (error "Empty group name"))
2518 (unless (gnus-ephemeral-group-p group)
2519 ;; Either go to the line in the group buffer...
2520 (unless (gnus-group-goto-group group)
2521 ;; ... or insert the line.
2522 (gnus-group-update-group group)
2523 (gnus-group-goto-group group)))
2524 ;; Adjust cursor point.
2525 (gnus-group-position-point))
2527 (defun gnus-group-goto-group (group &optional far test-marked)
2528 "Goto to newsgroup GROUP.
2529 If FAR, it is likely that the group is not on the current line.
2530 If TEST-MARKED, the line must be marked."
2534 ;; It's quite likely that we are on the right line, so
2535 ;; we check the current line first.
2537 (eq (get-text-property (point) 'gnus-group)
2538 (gnus-intern-safe group gnus-active-hashtb))
2539 (or (not test-marked) (gnus-group-mark-line-p)))
2541 ;; Previous and next line are also likely, so we check them as well.
2545 (and (eq (get-text-property (point) 'gnus-group)
2546 (gnus-intern-safe group gnus-active-hashtb))
2547 (or (not test-marked) (gnus-group-mark-line-p)))))
2553 (and (eq (get-text-property (point) 'gnus-group)
2554 (gnus-intern-safe group gnus-active-hashtb))
2555 (or (not test-marked) (gnus-group-mark-line-p)))))
2559 (goto-char (point-min))
2561 (while (and (not found)
2566 (gnus-intern-safe group gnus-active-hashtb))))
2567 (if (gnus-group-mark-line-p)
2572 ;; Search through the entire buffer.
2575 (point-min) (point-max)
2576 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2578 (defun gnus-group-next-group (n &optional silent)
2579 "Go to next N'th newsgroup.
2580 If N is negative, search backward instead.
2581 Returns the difference between N and the number of skips actually
2584 (gnus-group-next-unread-group n t nil silent))
2586 (defun gnus-group-next-unread-group (n &optional all level silent)
2587 "Go to next N'th unread newsgroup.
2588 If N is negative, search backward instead.
2589 If ALL is non-nil, choose any newsgroup, unread or not.
2590 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2591 such group can be found, the next group with a level higher than
2593 Returns the difference between N and the number of skips actually
2596 (let ((backward (< n 0))
2599 (gnus-group-search-forward
2600 backward (or (not gnus-group-goto-unread) all) level))
2604 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2605 (if level " on this level or higher" "")))
2608 (defun gnus-group-prev-group (n)
2609 "Go to previous N'th newsgroup.
2610 Returns the difference between N and the number of skips actually
2613 (gnus-group-next-unread-group (- n) t))
2615 (defun gnus-group-prev-unread-group (n)
2616 "Go to previous N'th unread newsgroup.
2617 Returns the difference between N and the number of skips actually
2620 (gnus-group-next-unread-group (- n)))
2622 (defun gnus-group-next-unread-group-same-level (n)
2623 "Go to next N'th unread newsgroup on the same level.
2624 If N is negative, search backward instead.
2625 Returns the difference between N and the number of skips actually
2628 (gnus-group-next-unread-group n t (gnus-group-group-level))
2629 (gnus-group-position-point))
2631 (defun gnus-group-prev-unread-group-same-level (n)
2632 "Go to next N'th unread newsgroup on the same level.
2633 Returns the difference between N and the number of skips actually
2636 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2637 (gnus-group-position-point))
2639 (defun gnus-group-best-unread-group (&optional exclude-group)
2640 "Go to the group with the highest level.
2641 If EXCLUDE-GROUP, do not go to that group."
2643 (goto-char (point-min))
2647 (setq unread (get-text-property (point) 'gnus-unread))
2648 (when (and (numberp unread) (> unread 0))
2649 (when (and (get-text-property (point) 'gnus-level)
2650 (< (get-text-property (point) 'gnus-level) best)
2651 (or (not exclude-group)
2652 (not (equal exclude-group (gnus-group-group-name)))))
2653 (setq best (get-text-property (point) 'gnus-level))
2654 (setq best-point (point))))
2657 (goto-char best-point))
2658 (gnus-group-position-point)
2659 (and best-point (gnus-group-group-name))))
2661 ;; Is there something like an after-point-motion-hook?
2662 ;; (inhibit-point-motion-hooks?). Is there a tool-bar-update function?
2664 ;; (defun gnus-group-menu-bar-update ()
2665 ;; (let* ((buf (list (with-current-buffer gnus-group-buffer
2666 ;; (current-buffer))))
2667 ;; (name (buffer-name (car buf))))
2669 ;; (if (> (length name) 27)
2670 ;; (concat (substring name 0 12)
2672 ;; (substring name -12))
2674 ;; (menu-bar-update-buffers-1 buf)))
2676 ;; (defun gnus-group-position-point ()
2677 ;; (gnus-goto-colon)
2678 ;; (gnus-group-menu-bar-update))
2680 (defun gnus-group-first-unread-group ()
2681 "Go to the first group with unread articles."
2684 (let ((opoint (point))
2686 (goto-char (point-min))
2687 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2688 (and (numberp unread) ; Not a topic.
2689 (not (zerop unread))) ; Has unread articles.
2690 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2693 nil)) ; Not success.
2694 (gnus-group-position-point)))
2696 (defun gnus-group-enter-server-mode ()
2697 "Jump to the server buffer."
2699 (gnus-enter-server-buffer))
2701 (defun gnus-group-make-group-simple (&optional group)
2702 "Add a new newsgroup.
2703 The user will be prompted for GROUP."
2704 (interactive (list (gnus-group-completing-read)))
2705 (gnus-group-make-group (gnus-group-real-name group)
2706 (gnus-group-server group)
2709 (defun gnus-group-make-group (name &optional method address args encoded)
2710 "Add a new newsgroup.
2711 The user will be prompted for a NAME, for a select METHOD, and an
2712 ADDRESS. NAME should be a human-readable string (i.e., not be encoded
2713 even if it contains non-ASCII characters) unless ENCODED is non-nil.
2715 If the backend supports it, the group will also be created on the
2719 (gnus-read-group "Group name: ")
2720 (gnus-read-method "Select method for new group (use tab for completion)")))
2722 (when (stringp method)
2723 (setq method (or (gnus-server-to-method method) method)))
2725 (setq name (encode-coding-string
2727 (gnus-group-name-charset method name))))
2728 (let* ((meth (gnus-method-simplify
2730 (not (gnus-server-equal method gnus-select-method)))
2731 (if address (list (intern method) address)
2733 (nname (if method (gnus-group-prefixed-name name meth) name))
2735 (when (gnus-group-entry nname)
2736 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2737 ;; Subscribe to the new group.
2738 (gnus-group-change-level
2739 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2740 gnus-level-default-subscribed gnus-level-killed
2741 (and (gnus-group-group-name)
2742 (gnus-group-entry (gnus-group-group-name)))
2745 (gnus-set-active nname (cons 1 0))
2746 (unless (gnus-ephemeral-group-p name)
2748 (concat "(gnus-group-set-info '"
2749 (gnus-prin1-to-string (cdr info)) ")")
2750 (concat "^(gnus-group-set-info '(\"" (regexp-quote name) "\"")))
2752 (gnus-group-insert-group-line-info nname)
2754 (gnus-group-position-point)
2756 ;; Load the back end and try to make the back end create
2757 ;; the group as well.
2758 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2760 gnus-valid-select-methods)
2762 (gnus-check-server meth)
2763 (when (gnus-check-backend-function 'request-create-group nname)
2764 (unless (gnus-request-create-group nname nil args)
2765 (error "Could not create group on server: %s"
2766 (nnheader-get-report backend))))
2769 (defun gnus-group-delete-groups (&optional arg)
2770 "Delete the current group. Only meaningful with editable groups."
2772 (let ((n (length (gnus-group-process-prefix arg))))
2773 (when (gnus-yes-or-no-p
2775 "Delete this 1 group? "
2776 (format "Delete these %d groups? " n)))
2777 (gnus-group-iterate arg
2779 (gnus-group-delete-group group nil t))))))
2781 (defun gnus-group-delete-articles (group &optional oldp)
2782 "Delete all articles in the current group.
2783 If OLDP (the prefix), only delete articles that are \"old\",
2784 according to the expiry settings. Note that this will delete old
2785 not-expirable articles, too."
2786 (interactive (list (gnus-group-group-name)
2787 current-prefix-arg))
2788 (let ((articles (gnus-uncompress-range (gnus-active group))))
2789 (when (gnus-yes-or-no-p
2790 (format "Do you really want to delete these %d articles forever? "
2792 (gnus-request-expire-articles articles group
2793 (if current-prefix-arg
2797 (defun gnus-group-delete-group (group &optional force no-prompt)
2798 "Delete the current group. Only meaningful with editable groups.
2799 If FORCE (the prefix) is non-nil, all the articles in the group will
2800 be deleted. This is \"deleted\" as in \"removed forever from the face
2801 of the Earth\". There is no undo. The user will be prompted before
2803 Note that you also have to specify FORCE if you want the group to
2804 be removed from the server, even when it's empty."
2806 (list (gnus-group-group-name)
2807 current-prefix-arg))
2809 (error "No group to delete"))
2810 (unless (gnus-check-backend-function 'request-delete-group group)
2811 (error "This back end does not support group deletion"))
2813 (let ((group-decoded (gnus-group-decoded-name group)))
2814 (if (and (not no-prompt)
2815 (not (gnus-yes-or-no-p
2817 "Do you really want to delete %s%s? "
2818 group-decoded (if force " and all its contents" "")))))
2820 (gnus-message 6 "Deleting group %s..." group-decoded)
2821 (if (not (gnus-request-delete-group group force))
2822 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2823 (gnus-message 6 "Deleting group %s...done" group-decoded)
2824 (gnus-group-goto-group group)
2825 (gnus-group-kill-group 1 t)
2826 (gnus-set-active group nil)
2828 (gnus-group-position-point)))
2830 (defun gnus-group-rename-group (group new-name)
2831 "Rename group from GROUP to NEW-NAME.
2832 When used interactively, GROUP is the group under point
2833 and NEW-NAME will be prompted for."
2835 (let ((group (gnus-group-group-name))
2837 (unless (gnus-check-backend-function 'request-rename-group group)
2838 (error "This back end does not support renaming groups"))
2839 (setq new-name (gnus-read-group
2841 (gnus-group-real-name (gnus-group-decoded-name group)))
2842 method (gnus-info-method (gnus-get-info group)))
2843 (list group (encode-coding-string
2845 (gnus-group-name-charset
2847 (gnus-group-prefixed-name new-name method))))))
2849 (unless (gnus-check-backend-function 'request-rename-group group)
2850 (error "This back end does not support renaming groups"))
2852 (error "No group to rename"))
2853 (when (equal (gnus-group-real-name group) new-name)
2854 (error "Can't rename to the same name"))
2856 ;; We find the proper prefixed name.
2858 (if (gnus-group-native-p group)
2862 (gnus-group-prefixed-name
2863 (gnus-group-real-name new-name)
2864 (gnus-info-method (gnus-get-info group)))))
2866 (let ((decoded-group (gnus-group-decoded-name group))
2867 (decoded-new-name (gnus-group-decoded-name new-name)))
2868 (when (gnus-active new-name)
2869 (error "The group %s already exists" decoded-new-name))
2871 (gnus-message 6 "Renaming group %s to %s..."
2872 decoded-group decoded-new-name)
2875 (gnus-group-goto-group group)
2876 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2877 (gnus-request-rename-group group new-name))))
2878 (gnus-error 3 "Couldn't rename group %s to %s"
2879 decoded-group decoded-new-name)
2880 ;; We rename the group internally by killing it...
2881 (gnus-group-kill-group)
2882 ;; ... changing its name ...
2883 (setcar (cdar gnus-list-of-killed-groups) new-name)
2884 ;; ... and then yanking it. Magic!
2885 (gnus-group-yank-group)
2886 (gnus-set-active new-name (gnus-active group))
2887 (gnus-message 6 "Renaming group %s to %s...done"
2888 decoded-group decoded-new-name)
2890 (setq gnus-killed-list (delete group gnus-killed-list))
2891 (gnus-set-active group nil)
2892 (gnus-dribble-touch)
2893 (gnus-group-position-point))))
2895 (defun gnus-group-edit-group (group &optional part)
2896 "Edit the group on the current line."
2897 (interactive (list (gnus-group-group-name)))
2898 (let ((part (or part 'info))
2901 (error "No group on current line"))
2902 (unless (setq info (gnus-get-info group))
2903 (error "Killed group; can't be edited"))
2905 (gnus-close-group group))
2907 ;; Find the proper form to edit.
2908 (cond ((eq part 'method)
2909 (or (gnus-info-method info) "native"))
2911 (gnus-info-params info))
2913 ;; The proper documentation.
2915 "Editing the %s for `%s'."
2917 ((eq part 'method) "select method")
2918 ((eq part 'params) "group parameters")
2920 (gnus-group-decoded-name group))
2922 (gnus-group-edit-group-done ',part ,group form)))
2925 (gnus-create-info-command
2928 "(gnus)Select Methods")
2930 "(gnus)Group Parameters")
2932 "(gnus)Group Info"))))))
2934 (defun gnus-group-edit-group-method (group)
2935 "Edit the select method of GROUP."
2936 (interactive (list (gnus-group-group-name)))
2937 (gnus-group-edit-group group 'method))
2939 (defun gnus-group-edit-group-parameters (group)
2940 "Edit the group parameters of GROUP."
2941 (interactive (list (gnus-group-group-name)))
2942 (gnus-group-edit-group group 'params))
2944 (defun gnus-group-edit-group-done (part group form)
2946 (let* ((method (cond ((eq part 'info) (nth 4 form))
2947 ((eq part 'method) form)
2949 (info (cond ((eq part 'info) form)
2950 ((eq part 'method) (gnus-get-info group))
2953 (if (or (not method)
2955 gnus-select-method method))
2956 (gnus-group-real-name (car info))
2957 (gnus-group-prefixed-name
2958 (gnus-group-real-name (car info)) method))
2960 (when (and new-group
2961 (not (equal new-group group)))
2962 (when (gnus-group-goto-group group)
2963 (gnus-group-kill-group 1))
2964 (gnus-activate-group new-group))
2966 (if (not (and info new-group))
2967 (gnus-group-set-info form (or new-group group) part)
2968 (setq info (gnus-copy-sequence info))
2969 (setcar info new-group)
2970 (unless (gnus-server-equal method "native")
2971 (unless (nthcdr 3 info)
2972 (nconc info (list nil nil)))
2973 (unless (nthcdr 4 info)
2974 (nconc info (list nil)))
2975 (gnus-info-set-method info method))
2976 (gnus-group-set-info info))
2977 (gnus-group-update-group (or new-group group))
2978 (gnus-group-position-point)))
2980 (defun gnus-group-make-useful-group (group method)
2981 "Create one of the groups described in `gnus-useful-groups'."
2983 (let ((entry (assoc (gnus-completing-read "Create group"
2984 (mapcar 'car gnus-useful-groups)
2986 gnus-useful-groups)))
2988 ;; Don't use `caddr' here since macros within the `interactive'
2989 ;; form won't be expanded.
2990 (car (cddr entry)))))
2991 (setq method (gnus-copy-sequence method))
2993 (while (setq entry (memq (assq 'eval method) method))
2994 (setcar entry (eval (cadar entry)))))
2995 (gnus-group-make-group group method))
2997 (defun gnus-group-make-help-group (&optional noerror)
2998 "Create the Gnus documentation group.
2999 Optional argument NOERROR modifies the behavior of this function when the
3000 group already exists:
3001 - if not given, and error is signaled,
3002 - if t, stay silent,
3003 - if anything else, just print a message."
3005 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
3006 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
3007 (if (gnus-group-entry name)
3008 (cond ((eq noerror nil)
3009 (error "Documentation group already exists"))
3014 (gnus-message 1 "Documentation group already exists")))
3017 (gnus-message 1 "Couldn't find doc group")
3018 (gnus-group-make-group
3019 (gnus-group-real-name name)
3020 (list 'nndoc "gnus-help"
3021 (list 'nndoc-address file)
3022 (list 'nndoc-article-type 'mbox))))
3024 (gnus-group-position-point))
3026 (defun gnus-group-make-doc-group (file type)
3027 "Create a group that uses a single file as the source.
3029 If called with a prefix argument, ask for the file type."
3031 (list (read-file-name "File name: ")
3032 (and current-prefix-arg 'ask)))
3033 (when (eq type 'ask)
3038 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
3040 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
3041 ((= char ?b) 'babyl)
3042 ((= char ?d) 'digest)
3043 ((= char ?f) 'forward)
3045 ((= char ?g) 'guess)
3046 (t (setq err (format "%c unknown. " char))
3049 (setq file (expand-file-name file))
3050 (let* ((name (gnus-generate-new-group-name
3051 (gnus-group-prefixed-name
3052 (file-name-nondirectory file) '(nndoc ""))))
3053 (method (list 'nndoc file
3054 (list 'nndoc-address file)
3055 (list 'nndoc-article-type (or type 'guess))))
3056 (coding (gnus-group-name-charset method name)))
3057 (setcar (cdr method) (encode-coding-string file coding))
3058 (gnus-group-make-group
3059 (encode-coding-string (gnus-group-real-name name) coding)
3062 (defvar nnweb-type-definition)
3063 (defvar gnus-group-web-type-history nil)
3064 (defvar gnus-group-web-search-history nil)
3065 (defun gnus-group-make-web-group (&optional solid)
3066 "Create an ephemeral nnweb group.
3067 If SOLID (the prefix), create a solid group."
3071 (if solid (gnus-read-group "Group name: ")
3072 (message-unique-id)))
3073 (default-type (or (car gnus-group-web-type-history)
3074 (symbol-name (caar nnweb-type-definition))))
3077 (gnus-completing-read
3078 "Search engine type"
3079 (mapcar (lambda (elem) (symbol-name (car elem)))
3080 nnweb-type-definition)
3081 t nil 'gnus-group-web-type-history)
3086 (cons (or (car gnus-group-web-search-history) "") 0)
3087 'gnus-group-web-search-history))
3089 `(nnweb ,group (nnweb-search ,search)
3090 (nnweb-type ,(intern type))
3091 (nnweb-ephemeral-p t))))
3094 (gnus-alist-pull 'nnweb-ephemeral-p method)
3095 (gnus-group-make-group group method))
3096 (gnus-group-read-ephemeral-group
3098 (cons (current-buffer)
3099 (if (derived-mode-p 'gnus-summary-mode) 'summary 'group))))))
3101 (defvar nnrss-group-alist)
3103 (defun nnrss-discover-feed (_arg))
3104 (defun nnrss-save-server-data (_arg)))
3105 (defun gnus-group-make-rss-group (&optional url)
3106 "Given a URL, discover if there is an RSS feed.
3107 If there is, use Gnus to create an nnrss group"
3111 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
3112 (let ((feedinfo (nnrss-discover-feed url)))
3114 (let* ((title (gnus-newsgroup-savable-name
3115 (read-from-minibuffer "Title: "
3116 (gnus-newsgroup-savable-name
3120 (or (cdr (assoc 'title
3124 (desc (read-from-minibuffer "Description: "
3128 (or (cdr (assoc 'description
3132 (href (cdr (assoc 'href feedinfo)))
3133 (coding (gnus-group-name-charset '(nnrss "") title)))
3135 ;; Unify non-ASCII text.
3136 (setq title (decode-coding-string
3137 (encode-coding-string title coding)
3139 (gnus-group-make-group title '(nnrss ""))
3140 (push (list title href desc) nnrss-group-alist)
3141 (nnrss-save-server-data nil))
3142 (error "No feeds found for %s" url))))
3144 (defun gnus-group-make-directory-group (dir)
3145 "Create an nndir group.
3146 The user will be prompted for a directory. The contents of this
3147 directory will be used as a newsgroup. The directory should contain
3148 mail messages or news articles in files that have numeric names."
3150 (list (read-directory-name "Create group from directory: ")))
3151 (unless (file-exists-p dir)
3152 (error "No such directory"))
3153 (unless (file-directory-p dir)
3154 (error "Not a directory"))
3158 (while (or (not group) (gnus-group-entry group))
3160 (gnus-group-prefixed-name
3161 (expand-file-name ext dir)
3163 (setq ext (format "<%d>" (setq i (1+ i)))))
3164 (gnus-group-make-group
3165 (gnus-group-real-name group)
3166 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
3168 (defun gnus-group-add-to-virtual (n vgroup)
3169 "Add the current group to a virtual group."
3171 (list current-prefix-arg
3172 (gnus-group-completing-read "Add to virtual group"
3173 nil t "nnvirtual:")))
3174 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
3175 (error "%s is not an nnvirtual group" vgroup))
3176 (gnus-close-group vgroup)
3177 (let* ((groups (gnus-group-process-prefix n))
3178 (method (gnus-info-method (gnus-get-info vgroup))))
3179 (setcar (cdr method)
3181 (nth 1 method) "\\|"
3184 (gnus-group-remove-mark s)
3185 (concat "\\(^" (regexp-quote s) "$\\)"))
3187 (gnus-group-position-point))
3189 (defun gnus-group-make-empty-virtual (group)
3190 "Create a new, fresh, empty virtual group."
3191 (interactive "sCreate new, empty virtual group: ")
3192 (let* ((method (list 'nnvirtual "^$"))
3193 (pgroup (gnus-group-prefixed-name group method)))
3194 ;; Check whether it exists already.
3195 (when (gnus-group-entry pgroup)
3196 (error "Group %s already exists" pgroup))
3197 ;; Subscribe the new group after the group on the current line.
3198 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
3199 (gnus-group-update-group pgroup)
3201 (gnus-group-position-point)))
3203 (defun gnus-group-enter-directory (dir)
3204 "Enter an ephemeral nneething group."
3205 (interactive "DDirectory to read: ")
3206 (let* ((method (list 'nneething dir '(nneething-read-only t)))
3207 (leaf (gnus-group-prefixed-name
3208 (file-name-nondirectory (directory-file-name dir))
3210 (name (gnus-generate-new-group-name leaf)))
3211 (unless (gnus-group-read-ephemeral-group
3213 (cons (current-buffer)
3214 (if (derived-mode-p 'gnus-summary-mode)
3216 (error "Couldn't enter %s" dir))))
3218 (defun gnus-group-expunge-group (group)
3219 "Expunge deleted articles in current nnimap GROUP."
3220 (interactive (list (gnus-group-group-name)))
3221 (let ((method (gnus-find-method-for-group group)))
3222 (if (not (gnus-check-backend-function
3223 'request-expunge-group (car method)))
3224 (error "%s does not support expunging" (car method))
3225 (gnus-request-expunge-group group method))))
3227 (autoload 'nnimap-acl-get "nnimap")
3228 (autoload 'nnimap-acl-edit "nnimap")
3230 (defun gnus-group-nnimap-edit-acl (group)
3231 "Edit the Access Control List of current nnimap GROUP."
3232 (interactive (list (gnus-group-group-name)))
3233 (let ((mailbox (gnus-group-real-name group)) method acl)
3235 (error "No group on current line"))
3236 (unless (gnus-get-info group)
3237 (error "Killed group; can't be edited"))
3238 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
3239 (error "%s is not an nnimap group" group))
3240 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
3241 (error "Server does not support ACL's"))
3242 (gnus-edit-form acl (format-message "\
3243 Editing the access control list for `%s'.
3245 An access control list is a list of (identifier . rights) elements.
3247 The identifier string specifies the corresponding user. The
3248 identifier \"anyone\" is reserved to refer to the universal identity.
3250 Rights is a string listing a (possibly empty) set of alphanumeric
3251 characters, each character listing a set of operations which is being
3252 controlled. Letters are reserved for \"standard\" rights, listed
3253 below. Digits are reserved for implementation or site defined rights.
3255 l - lookup (mailbox is visible to LIST/LSUB commands)
3256 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
3257 SEARCH, COPY from mailbox)
3258 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
3259 w - write (STORE flags other than \\SEEN and \\DELETED)
3260 i - insert (perform APPEND, COPY into mailbox)
3261 p - post (send mail to submission address for mailbox,
3262 not enforced by IMAP4 itself)
3263 c - create and delete mailbox (CREATE new sub-mailboxes in any
3264 implementation-defined hierarchy, RENAME or DELETE mailbox)
3265 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
3266 a - administer (perform SETACL)" group)
3269 ,mailbox ',method ',acl form)))))
3271 ;; Group sorting commands
3272 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3274 (defun gnus-group-sort-groups (func &optional reverse)
3275 "Sort the group buffer according to FUNC.
3276 When used interactively, the sorting function used will be
3277 determined by the `gnus-group-sort-function' variable.
3278 If REVERSE (the prefix), reverse the sorting order."
3279 (interactive (list gnus-group-sort-function current-prefix-arg))
3280 (funcall gnus-group-sort-alist-function
3281 (gnus-make-sort-function func) reverse)
3282 (gnus-group-unmark-all-groups)
3283 (gnus-group-list-groups)
3284 (gnus-dribble-touch))
3286 (defun gnus-group-sort-flat (func reverse)
3287 ;; We peel off the dummy group from the alist.
3289 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
3290 (pop gnus-newsrc-alist))
3292 (setq gnus-newsrc-alist
3293 (sort gnus-newsrc-alist func))
3295 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
3296 ;; Regenerate the hash table.
3297 (gnus-make-hashtable-from-newsrc-alist)))
3299 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
3300 "Sort the group buffer alphabetically by group name.
3301 If REVERSE, sort in reverse order."
3303 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
3305 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
3306 "Sort the group buffer alphabetically by real (unprefixed) group name.
3307 If REVERSE, sort in reverse order."
3309 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
3311 (defun gnus-group-sort-groups-by-unread (&optional reverse)
3312 "Sort the group buffer by number of unread articles.
3313 If REVERSE, sort in reverse order."
3315 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
3317 (defun gnus-group-sort-groups-by-level (&optional reverse)
3318 "Sort the group buffer by group level.
3319 If REVERSE, sort in reverse order."
3321 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
3323 (defun gnus-group-sort-groups-by-score (&optional reverse)
3324 "Sort the group buffer by group score.
3325 If REVERSE, sort in reverse order."
3327 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
3329 (defun gnus-group-sort-groups-by-rank (&optional reverse)
3330 "Sort the group buffer by group rank.
3331 If REVERSE, sort in reverse order."
3333 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
3335 (defun gnus-group-sort-groups-by-method (&optional reverse)
3336 "Sort the group buffer alphabetically by back end name.
3337 If REVERSE, sort in reverse order."
3339 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
3341 (defun gnus-group-sort-groups-by-server (&optional reverse)
3342 "Sort the group buffer alphabetically by server name.
3343 If REVERSE, sort in reverse order."
3345 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
3347 ;;; Selected group sorting.
3349 (defun gnus-group-sort-selected-groups (n func &optional reverse)
3350 "Sort the process/prefixed groups."
3351 (interactive (list current-prefix-arg gnus-group-sort-function))
3352 (let ((groups (gnus-group-process-prefix n)))
3353 (funcall gnus-group-sort-selected-function
3354 groups (gnus-make-sort-function func) reverse)
3355 (gnus-group-unmark-all-groups)
3356 (gnus-group-list-groups)
3357 (gnus-dribble-touch)))
3359 (defun gnus-group-sort-selected-flat (groups func reverse)
3360 (let (entries infos)
3361 ;; First find all the group entries for these groups.
3363 (push (nthcdr 2 (gnus-group-entry (pop groups)))
3365 ;; Then sort the infos.
3369 (lambda (entry) (car entry))
3370 (setq entries (nreverse entries)))
3373 (setq infos (nreverse infos)))
3374 ;; Go through all the infos and replace the old entries
3375 ;; with the new infos.
3377 (setcar (car entries) (pop infos))
3379 ;; Update the hashtable.
3380 (gnus-make-hashtable-from-newsrc-alist)))
3382 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3383 "Sort the group buffer alphabetically by group name.
3384 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3385 sort in reverse order."
3386 (interactive (gnus-interactive "P\ny"))
3387 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3389 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3390 "Sort the group buffer alphabetically by real group name.
3391 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3392 sort in reverse order."
3393 (interactive (gnus-interactive "P\ny"))
3394 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3396 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3397 "Sort the group buffer by number of unread articles.
3398 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3399 sort in reverse order."
3400 (interactive (gnus-interactive "P\ny"))
3401 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3403 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3404 "Sort the group buffer by group level.
3405 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3406 sort in reverse order."
3407 (interactive (gnus-interactive "P\ny"))
3408 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3410 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3411 "Sort the group buffer by group score.
3412 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3413 sort in reverse order."
3414 (interactive (gnus-interactive "P\ny"))
3415 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3417 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3418 "Sort the group buffer by group rank.
3419 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3420 sort in reverse order."
3421 (interactive (gnus-interactive "P\ny"))
3422 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3424 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3425 "Sort the group buffer alphabetically by back end name.
3426 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3427 sort in reverse order."
3428 (interactive (gnus-interactive "P\ny"))
3429 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3431 ;;; Sorting predicates.
3433 (defun gnus-group-sort-by-alphabet (info1 info2)
3434 "Sort alphabetically."
3435 (string< (gnus-info-group info1) (gnus-info-group info2)))
3437 (defun gnus-group-sort-by-real-name (info1 info2)
3438 "Sort alphabetically on real (unprefixed) names."
3439 (string< (gnus-group-real-name (gnus-info-group info1))
3440 (gnus-group-real-name (gnus-info-group info2))))
3442 (defun gnus-group-sort-by-unread (info1 info2)
3443 "Sort by number of unread articles."
3444 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3445 (n2 (gnus-group-unread (gnus-info-group info2))))
3446 (< (or (and (numberp n1) n1) 0)
3447 (or (and (numberp n2) n2) 0))))
3449 (defun gnus-group-sort-by-level (info1 info2)
3451 (< (gnus-info-level info1) (gnus-info-level info2)))
3453 (defun gnus-group-sort-by-method (info1 info2)
3454 "Sort alphabetically by back end name."
3455 (string< (car (gnus-find-method-for-group
3456 (gnus-info-group info1) info1))
3457 (car (gnus-find-method-for-group
3458 (gnus-info-group info2) info2))))
3460 (defun gnus-group-sort-by-server (info1 info2)
3461 "Sort alphabetically by server name."
3462 (string< (gnus-method-to-full-server-name
3463 (gnus-find-method-for-group
3464 (gnus-info-group info1) info1))
3465 (gnus-method-to-full-server-name
3466 (gnus-find-method-for-group
3467 (gnus-info-group info2) info2))))
3469 (defun gnus-group-sort-by-score (info1 info2)
3470 "Sort by group score."
3471 (> (gnus-info-score info1) (gnus-info-score info2)))
3473 (defun gnus-group-sort-by-rank (info1 info2)
3474 "Sort by level and score."
3475 (let ((level1 (gnus-info-level info1))
3476 (level2 (gnus-info-level info2)))
3477 (or (< level1 level2)
3478 (and (= level1 level2)
3479 (> (gnus-info-score info1) (gnus-info-score info2))))))
3483 (defun gnus-group-clear-data (&optional arg)
3484 "Clear all marks and read ranges from the current group.
3485 Obeys the process/prefix convention."
3487 (when (gnus-y-or-n-p "Really clear data? ")
3488 (gnus-group-iterate arg
3491 (gnus-info-clear-data (setq info (gnus-get-info group)))
3492 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3493 (when (gnus-group-goto-group group)
3494 (gnus-group-update-group-line)))))))
3496 (defun gnus-group-clear-data-on-native-groups ()
3497 "Clear all marks and read ranges from all native groups."
3499 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3500 (let ((alist (cdr gnus-newsrc-alist))
3502 (while (setq info (pop alist))
3503 (when (gnus-group-native-p (gnus-info-group info))
3504 (gnus-info-clear-data info)))
3505 (gnus-get-unread-articles)
3506 (gnus-dribble-touch)
3507 (when (gnus-y-or-n-p
3508 "Move the cache away to avoid problems in the future? ")
3509 (call-interactively 'gnus-cache-move-cache)))))
3511 (defun gnus-info-clear-data (info)
3512 "Clear all marks and read ranges from INFO."
3513 (let ((group (gnus-info-group info))
3515 (dolist (el (gnus-info-marks info))
3516 (push `(,(cdr el) add (,(car el))) action))
3517 (push `(,(gnus-info-read info) add (read)) action)
3520 (gnus-request-set-mark ,group ',action)
3521 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3522 (gnus-info-set-read ',info ',(gnus-info-read info))
3523 (when (gnus-group-goto-group ,group)
3524 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3525 (gnus-group-update-group-line))))
3526 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3528 (gnus-request-set-mark group action)
3529 (gnus-info-set-read info nil)
3530 (when (gnus-info-marks info)
3531 (gnus-info-set-marks info nil))))
3533 ;; Group catching up.
3535 (defun gnus-group-catchup-current (&optional n all)
3536 "Mark all unread articles in the current newsgroup as read.
3537 If prefix argument N is numeric, the next N newsgroups will be
3538 caught up. If ALL is non-nil, marked articles will also be marked as
3539 read. Cross references (Xref: header) of articles are ignored.
3540 The number of newsgroups that this function was unable to catch
3543 (let ((groups (gnus-group-process-prefix n))
3546 (unless groups (error "No groups selected"))
3548 (or (not gnus-interactive-catchup) ;Without confirmation?
3553 "Do you really want to mark all articles in %s as read? "
3554 "Mark all unread articles in %s as read? ")
3555 (if (= (length groups) 1)
3556 (gnus-group-decoded-name (car groups))
3557 (format "these %d groups" (length groups)))))))
3559 (while (setq group (pop groups))
3560 (gnus-group-remove-mark group)
3561 ;; Virtual groups have to be given special treatment.
3562 (let ((method (gnus-find-method-for-group group)))
3563 (when (eq 'nnvirtual (car method))
3564 (nnvirtual-catchup-group
3565 (gnus-group-real-name group) (nth 1 method) all)))
3567 ((>= (gnus-group-level group) gnus-level-zombie)
3568 (gnus-message 2 "Dead groups can't be caught up"))
3570 (gnus-group-goto-group group)
3571 (gnus-group-catchup group all))
3572 (gnus-group-update-group-line))
3574 (setq ret (1+ ret)))))
3575 (gnus-group-next-unread-group 1)
3578 (defun gnus-group-catchup-current-all (&optional n)
3579 "Mark all articles in current newsgroup as read.
3580 Cross references (Xref: header) of articles are ignored."
3582 (gnus-group-catchup-current n 'all))
3584 (declare-function gnus-sequence-of-unread-articles "gnus-sum" (group))
3586 (defun gnus-group-catchup (group &optional all)
3587 "Mark all articles in GROUP as read.
3588 If ALL is non-nil, all articles are marked as read.
3589 The return value is the number of articles that were marked as read,
3590 or nil if no action could be taken."
3591 (let* ((entry (gnus-group-entry group))
3593 (marks (gnus-info-marks (nth 2 entry)))
3594 (unread (gnus-sequence-of-unread-articles group)))
3595 ;; Remove entries for this group.
3596 (nnmail-purge-split-history (gnus-group-real-name group))
3597 ;; Do the updating only if the newsgroup isn't killed.
3598 (if (not (numberp (car entry)))
3599 (gnus-message 1 "Can't catch up %s; non-active group" group)
3600 (gnus-update-read-articles group nil)
3602 ;; Nix out the lists of marks and dormants.
3603 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3605 (list (cdr (assq 'dormant marks))
3607 (setq unread (gnus-range-add (gnus-range-add
3608 unread (cdr (assq 'dormant marks)))
3609 (cdr (assq 'tick marks))))
3610 (gnus-add-marked-articles group 'tick nil nil 'force)
3611 (gnus-add-marked-articles group 'dormant nil nil 'force))
3612 ;; Do auto-expirable marks if that's required.
3613 (when (and (gnus-group-auto-expirable-p group)
3614 (not (gnus-group-read-only-p group)))
3617 (gnus-add-marked-articles group 'expire (list article))
3618 (gnus-request-set-mark group (list (list (list article)
3621 (let ((gnus-newsgroup-name group))
3622 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3625 (defun gnus-group-expire-articles (&optional n)
3626 "Expire all expirable articles in the current newsgroup.
3627 Uses the process/prefix convention."
3629 (let ((groups (gnus-group-process-prefix n))
3632 (error "No groups to expire"))
3633 (while (setq group (pop groups))
3634 (gnus-group-remove-mark group)
3635 (gnus-group-expire-articles-1 group)
3636 (gnus-dribble-touch)
3637 (gnus-group-position-point))))
3639 (defun gnus-group-expire-articles-1 (group)
3640 (when (gnus-check-backend-function 'request-expire-articles group)
3641 (gnus-message 6 "Expiring articles in %s..."
3642 (gnus-group-decoded-name group))
3643 (let* ((info (gnus-get-info group))
3644 (expirable (if (gnus-group-total-expirable-p group)
3645 (cons nil (gnus-list-of-read-articles group))
3646 (assq 'expire (gnus-info-marks info))))
3648 (gnus-list-range-difference
3649 (gnus-uncompress-sequence (cdr expirable))
3650 (cdr (assq 'unexist (gnus-info-marks info)))))
3651 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3652 (nnmail-expiry-target
3653 (or (gnus-group-find-parameter group 'expiry-target)
3654 nnmail-expiry-target)))
3656 (gnus-check-group group)
3659 (gnus-compress-sequence
3661 ;; We set the expiry variables to the group
3663 (let ((nnmail-expiry-wait-function nil)
3664 (nnmail-expiry-wait expiry-wait))
3665 (gnus-request-expire-articles articles-to-expire group))
3666 ;; Just expire using the normal expiry values.
3667 (gnus-request-expire-articles articles-to-expire group))))
3668 (gnus-close-group group))
3669 (gnus-message 6 "Expiring articles in %s...done"
3670 (gnus-group-decoded-name group))
3671 ;; Return the list of un-expired articles.
3674 (defun gnus-group-expire-all-groups ()
3675 "Expire all expirable articles in all newsgroups."
3678 (gnus-message 5 "Expiring...")
3679 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3680 (cdr gnus-newsrc-alist))))
3681 (gnus-group-expire-articles nil)))
3682 (gnus-group-position-point)
3683 (gnus-message 5 "Expiring...done"))
3685 (defun gnus-group-set-current-level (n level)
3686 "Set the level of the next N groups to LEVEL."
3691 (unless (gnus-group-process-prefix current-prefix-arg)
3692 (error "No group on the current line"))
3694 (let ((s (read-string
3695 (format "Level (default %s): "
3696 (or (gnus-group-group-level)
3697 gnus-level-default-subscribed)))))
3698 (if (string-match "^\\s-*$" s)
3699 (int-to-string (or (gnus-group-group-level)
3700 gnus-level-default-subscribed))
3702 (unless (and (>= level 1) (<= level gnus-level-killed))
3703 (error "Invalid level: %d" level))
3704 (dolist (group (gnus-group-process-prefix n))
3705 (gnus-group-remove-mark group)
3706 (gnus-message 6 "Changed level of %s from %d to %d"
3707 (gnus-group-decoded-name group)
3708 (or (gnus-group-group-level) gnus-level-killed)
3710 (gnus-group-change-level
3711 group level (or (gnus-group-group-level) gnus-level-killed))
3712 (gnus-group-update-group-line))
3713 (gnus-group-position-point))
3715 (defun gnus-group-unsubscribe (&optional n)
3716 "Unsubscribe the current group."
3718 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3720 (defun gnus-group-subscribe (&optional n)
3721 "Subscribe the current group."
3723 (gnus-group-unsubscribe-current-group n 'subscribe))
3725 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3726 "Toggle subscription of the current group.
3727 If given numerical prefix, toggle the N next groups."
3729 (dolist (group (gnus-group-process-prefix n))
3730 (gnus-group-remove-mark group)
3731 (gnus-group-unsubscribe-group
3734 ((eq do-sub 'unsubscribe)
3735 gnus-level-default-unsubscribed)
3736 ((eq do-sub 'subscribe)
3737 gnus-level-default-subscribed)
3738 ((<= (gnus-group-group-level) gnus-level-subscribed)
3739 gnus-level-default-unsubscribed)
3741 gnus-level-default-subscribed))
3743 (gnus-group-update-group-line))
3744 (gnus-group-next-group 1))
3746 (defun gnus-group-unsubscribe-group (group &optional level silent)
3747 "Toggle subscription to GROUP.
3748 Killed newsgroups are subscribed. If SILENT, don't try to update the
3750 (interactive (list (gnus-group-completing-read
3751 nil nil (gnus-read-active-file-p))))
3752 (let ((newsrc (gnus-group-entry group)))
3754 ((string-match "\\`[ \t]*\\'" group)
3755 (error "Empty group name"))
3757 ;; Toggle subscription flag.
3758 (gnus-group-change-level
3759 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3760 gnus-level-subscribed)
3761 (1+ gnus-level-subscribed)
3762 gnus-level-default-subscribed)))
3764 (gnus-group-update-group group)))
3765 ((and (stringp group)
3766 (or (not (gnus-read-active-file-p))
3767 (gnus-active group)))
3768 ;; Add new newsgroup.
3769 (gnus-group-change-level
3771 (if level level gnus-level-default-subscribed)
3772 (or (and (member group gnus-zombie-list)
3775 (when (gnus-group-group-name)
3776 (gnus-group-entry (gnus-group-group-name))))
3778 (gnus-group-update-group group)))
3779 (t (error "No such newsgroup: %s" group)))
3780 (gnus-group-position-point)))
3782 (defun gnus-group-transpose-groups (n)
3783 "Move the current newsgroup up N places.
3784 If given a negative prefix, move down instead. The difference between
3785 N and the number of steps taken is returned."
3787 (unless (gnus-group-group-name)
3788 (error "No group on current line"))
3789 (gnus-group-kill-group 1)
3791 (forward-line (- n))
3792 (gnus-group-yank-group)
3793 (gnus-group-position-point)))
3795 (defun gnus-group-kill-all-zombies (&optional dummy)
3796 "Kill all zombie newsgroups.
3797 The optional DUMMY should always be nil."
3798 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3800 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3801 (setq gnus-zombie-list nil)
3802 (gnus-dribble-touch)
3803 (gnus-group-list-groups)))
3805 (defun gnus-group-kill-region (begin end)
3806 "Kill newsgroups in current region (excluding current point).
3807 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3820 (beginning-of-line) ;Important when LINES < 1
3821 (gnus-group-kill-group lines)))
3823 (defun gnus-group-kill-group (&optional n discard)
3824 "Kill the next N groups.
3825 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3826 However, only groups that were alive can be yanked; already killed
3827 groups or zombie groups can't be yanked.
3828 The return value is the name of the group that was killed, or a list
3831 (let ((buffer-read-only nil)
3832 (groups (gnus-group-process-prefix n))
3833 group entry level out)
3834 (if (< (length groups) 10)
3835 ;; This is faster when there are few groups.
3837 (push (setq group (pop groups)) out)
3838 (gnus-group-remove-mark group)
3839 (setq level (gnus-group-group-level))
3841 (when (and (not discard)
3842 (setq entry (gnus-group-entry group)))
3845 (gnus-group-goto-group ,(gnus-group-group-name))
3846 (gnus-group-yank-group)))
3847 (push (cons (car entry) (nth 2 entry))
3848 gnus-list-of-killed-groups))
3849 (gnus-group-change-level
3850 (if entry entry group) gnus-level-killed (if entry nil level))
3851 (when (numberp (gnus-group-unread group))
3852 (gnus-request-update-group-status group 'unsubscribe))
3853 (message "Killed group %s" (gnus-group-decoded-name group)))
3854 ;; If there are lots and lots of groups to be killed, we use
3855 ;; this thing instead.
3856 (dolist (group (nreverse groups))
3857 (gnus-group-remove-mark group)
3859 (push group gnus-killed-list)
3860 (setq gnus-newsrc-alist
3861 (delq (assoc group gnus-newsrc-alist)
3863 (when gnus-group-change-level-function
3864 (funcall gnus-group-change-level-function
3865 group gnus-level-killed 3))
3867 ((setq entry (gnus-group-entry group))
3868 (push (cons (car entry) (nth 2 entry))
3869 gnus-list-of-killed-groups)
3870 (setcdr (cdr entry) (cdddr entry)))
3871 ((member group gnus-zombie-list)
3872 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3873 ;; There may be more than one instance displayed.
3874 (while (gnus-group-goto-group group)
3876 (when (numberp (gnus-group-unread group))
3877 (gnus-request-update-group-status group 'unsubscribe)))
3878 (gnus-make-hashtable-from-newsrc-alist))
3880 (gnus-group-position-point)
3881 (if (< (length out) 2) (car out) (nreverse out))))
3883 (defun gnus-group-yank-group (&optional arg)
3884 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3885 The numeric ARG specifies how many newsgroups are to be yanked. The
3886 name of the newsgroup yanked is returned, or (if several groups are
3887 yanked) a list of yanked groups is returned."
3889 (setq arg (or arg 1))
3890 (let (info group prev out)
3891 (while (>= (decf arg) 0)
3892 (when (not (setq info (pop gnus-list-of-killed-groups)))
3893 (error "No more newsgroups to yank"))
3894 (push (setq group (nth 1 info)) out)
3895 ;; Find which newsgroup to insert this one before - search
3896 ;; backward until something suitable is found. If there are no
3897 ;; other newsgroups in this buffer, just make this newsgroup the
3899 (setq prev (gnus-group-group-name))
3900 (gnus-group-change-level
3901 info (gnus-info-level (cdr info)) gnus-level-killed
3902 (and prev (gnus-group-entry prev))
3904 (gnus-group-insert-group-line-info group)
3905 (gnus-request-update-group-status group 'subscribe)
3907 `(when (gnus-group-goto-group ,group)
3908 (gnus-group-kill-group 1))))
3910 (gnus-group-position-point)
3911 (if (< (length out) 2) (car out) (nreverse out))))
3913 (defun gnus-group-kill-level (level)
3914 "Kill all groups that is on a certain LEVEL."
3915 (interactive "nKill all groups on level: ")
3917 ((= level gnus-level-zombie)
3918 (setq gnus-killed-list
3919 (nconc gnus-zombie-list gnus-killed-list))
3920 (setq gnus-zombie-list nil))
3921 ((and (< level gnus-level-zombie)
3923 (or gnus-expert-user
3926 "Do you really want to kill all groups on level %d? "
3928 (let* ((prev gnus-newsrc-alist)
3931 (if (= (gnus-info-level (car alist)) level)
3933 (push (gnus-info-group (car alist)) gnus-killed-list)
3934 (setcdr prev (cdr alist)))
3936 (setq alist (cdr alist)))
3937 (gnus-make-hashtable-from-newsrc-alist)
3938 (gnus-group-list-groups)))
3940 (error "Can't kill; invalid level: %d" level))))
3942 (defun gnus-group-list-all-groups (&optional arg)
3943 "List all newsgroups with level ARG or lower.
3944 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3945 unsubscribed groups."
3947 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3949 ;; Redefine this to list ALL killed groups if prefix arg used.
3950 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3951 (defun gnus-group-list-killed (&optional arg)
3952 "List all killed newsgroups in the group buffer.
3953 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3954 entail asking the server for the groups."
3956 ;; Find all possible killed newsgroups if arg.
3958 (gnus-get-killed-groups))
3959 (if (not gnus-killed-list)
3960 (gnus-message 6 "No killed groups")
3961 (let (gnus-group-list-mode)
3962 (funcall gnus-group-prepare-function
3963 gnus-level-killed t gnus-level-killed))
3964 (goto-char (point-min)))
3965 (gnus-group-position-point))
3967 (defun gnus-group-list-zombies ()
3968 "List all zombie newsgroups in the group buffer."
3970 (if (not gnus-zombie-list)
3971 (gnus-message 6 "No zombie groups")
3972 (let (gnus-group-list-mode)
3973 (funcall gnus-group-prepare-function
3974 gnus-level-zombie t gnus-level-zombie))
3975 (goto-char (point-min)))
3976 (gnus-group-position-point))
3978 (defun gnus-group-list-active ()
3979 "List all groups that are available from the server(s)."
3981 ;; First we make sure that we have really read the active file.
3982 (unless (gnus-read-active-file-p)
3983 (let ((gnus-read-active-file t)
3984 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3985 (gnus-read-active-file)))
3986 ;; Find all groups and sort them.
3994 (push (symbol-name sym) list)))
3998 (buffer-read-only nil)
4002 (setq group (pop groups))
4003 (add-text-properties
4004 (point) (prog1 (1+ (point))
4006 (gnus-group-decoded-name group)
4008 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4010 'gnus-level (inline (gnus-group-level group)))))
4011 (goto-char (point-min))))
4013 (defun gnus-activate-all-groups (level)
4014 "Activate absolutely all groups."
4015 (interactive (list gnus-level-unsubscribed))
4016 (let ((gnus-activate-level level)
4017 (gnus-activate-foreign-newsgroups level))
4018 (gnus-group-get-new-news)))
4020 (defun gnus-group-get-new-news (&optional arg one-level)
4021 "Get newly arrived articles.
4022 If ARG is a number, it specifies which levels you are interested in
4023 re-scanning. If ARG is non-nil and not a number, this will force
4024 \"hard\" re-reading of the active files from all servers.
4025 If ONE-LEVEL is not nil, then re-scan only the specified level,
4026 otherwise all levels below ARG will be scanned too."
4029 (let ((gnus-inhibit-demon t)
4030 ;; Binding this variable will inhibit multiple fetchings
4031 ;; of the same mail source.
4032 (nnmail-fetched-sources (list t)))
4033 (gnus-run-hooks 'gnus-get-top-new-news-hook)
4034 (gnus-run-hooks 'gnus-get-new-news-hook)
4036 ;; Read any slave files.
4038 (gnus-master-read-slave-newsrc))
4040 (gnus-get-unread-articles (gnus-group-default-level arg t)
4043 ;; If the user wants it, we scan for new groups.
4044 (when (eq gnus-check-new-newsgroups 'always)
4045 (gnus-find-new-newsgroups))
4047 (gnus-check-reasonable-setup)
4048 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
4049 (gnus-group-list-groups (and (numberp arg)
4050 (max (car gnus-group-list-mode) arg)))))
4052 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
4053 "Check for newly arrived news in the current group (and the N-1 next groups).
4054 The difference between N and the number of newsgroup checked is returned.
4055 If N is negative, this group and the N-1 previous groups will be checked.
4056 If DONT-SCAN is non-nil, scan non-activated groups as well."
4058 (let* ((groups (gnus-group-process-prefix n))
4059 (ret (if (numberp n) (- n (length groups)) 0))
4063 (gnus-inhibit-demon t)
4064 ;; Binding this variable will inhibit multiple fetchings
4065 ;; of the same mail source.
4066 (nnmail-fetched-sources (list t)))
4067 (gnus-run-hooks 'gnus-get-new-news-hook)
4068 (while (setq group (pop groups))
4069 (gnus-group-remove-mark group)
4070 ;; Bypass any previous denials from the server.
4071 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
4072 (if (or (and (not dont-scan)
4073 (gnus-request-group-scan group (gnus-get-info group)))
4074 (gnus-activate-group group (if dont-scan nil 'scan) nil method))
4075 (let ((info (gnus-get-info group))
4076 (active (gnus-active group)))
4078 (gnus-request-update-info info method))
4079 (gnus-get-unread-articles-in-group info active)
4080 (unless (gnus-virtual-group-p group)
4081 (gnus-close-group group))
4083 (gnus-agent-save-group-info
4084 method (gnus-group-real-name group) active))
4085 (gnus-group-update-group group nil t))
4086 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
4089 (when gnus-goto-next-group-when-activating
4090 (gnus-group-next-unread-group 1 t))
4091 (gnus-group-position-point)
4094 (defun gnus-group-describe-group (force &optional group)
4095 "Display a description of the current newsgroup."
4096 (interactive (list current-prefix-arg (gnus-group-group-name)))
4097 (let* ((method (gnus-find-method-for-group group))
4098 (mname (gnus-group-prefixed-name "" method))
4101 gnus-description-hashtb)
4102 (gnus-sethash mname nil gnus-description-hashtb))
4104 (error "No group name given"))
4105 (when (or (and gnus-description-hashtb
4106 ;; We check whether this group's method has been
4107 ;; queried for a description file.
4108 (gnus-gethash mname gnus-description-hashtb))
4109 (setq desc (gnus-group-get-description group))
4110 (gnus-read-descriptions-file method))
4111 (gnus-message 1 "%s"
4112 (or desc (gnus-gethash group gnus-description-hashtb)
4113 "No description available")))))
4115 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4116 (defun gnus-group-describe-all-groups (&optional force)
4117 "Pop up a buffer with descriptions of all newsgroups."
4120 (setq gnus-description-hashtb nil))
4121 (when (not (or gnus-description-hashtb
4122 (gnus-read-all-descriptions-files)))
4123 (error "Couldn't request descriptions file"))
4124 (let ((buffer-read-only nil)
4128 (push (symbol-name group) groups))
4129 gnus-description-hashtb)
4130 (setq groups (sort groups 'string<))
4132 (dolist (group groups)
4134 (let ((charset (gnus-group-name-charset nil group)))
4135 (insert (format " *: %-20s %s\n"
4136 (gnus-group-name-decode group charset)
4137 (gnus-group-name-decode group charset))))
4138 (add-text-properties
4139 b (1+ b) (list 'gnus-group (intern group gnus-description-hashtb)
4140 'gnus-unread t 'gnus-marked nil
4141 'gnus-level (1+ gnus-level-subscribed))))
4142 (goto-char (point-min))
4143 (gnus-group-position-point)))
4145 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
4146 (defun gnus-group-apropos (regexp &optional search-description)
4147 "List all newsgroups that have names that match a regexp."
4148 (interactive "sGnus apropos (regexp): ")
4150 (obuf (current-buffer))
4152 ;; Go through all newsgroups that are known to Gnus.
4155 (and (symbol-name group)
4156 (string-match regexp (symbol-name group))
4157 (symbol-value group)
4158 (push (symbol-name group) groups)))
4160 ;; Also go through all descriptions that are known to Gnus.
4161 (when search-description
4164 (and (string-match regexp (symbol-value group))
4165 (push (symbol-name group) groups)))
4166 gnus-description-hashtb))
4168 (gnus-message 3 "No groups matched \"%s\"." regexp)
4169 ;; Print out all the groups.
4171 (pop-to-buffer "*Gnus Help*")
4172 (buffer-disable-undo)
4174 (setq groups (sort groups 'string<))
4176 ;; Groups may be entered twice into the list of groups.
4177 (when (not (string= (car groups) prev))
4178 (setq prev (car groups))
4179 (let ((charset (gnus-group-name-charset nil prev)))
4180 (insert (gnus-group-name-decode prev charset) "\n")
4181 (when (and gnus-description-hashtb
4182 (setq des (gnus-gethash (car groups)
4183 gnus-description-hashtb)))
4184 (insert " " (gnus-group-name-decode des charset) "\n"))))
4185 (setq groups (cdr groups)))
4186 (goto-char (point-min))))
4187 (pop-to-buffer obuf)))
4189 (defun gnus-group-description-apropos (regexp)
4190 "List all newsgroups that have names or descriptions that match REGEXP."
4191 (interactive "sGnus description apropos (regexp): ")
4192 (when (not (or gnus-description-hashtb
4193 (gnus-read-all-descriptions-files)))
4194 (error "Couldn't request descriptions file"))
4195 (gnus-group-apropos regexp t))
4197 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4198 (defun gnus-group-list-matching (level regexp &optional all lowest)
4199 "List all groups with unread articles that match REGEXP.
4200 If the prefix LEVEL is non-nil, it should be a number that says which
4201 level to cut off listing groups.
4202 If ALL, also list groups with no unread articles.
4203 If LOWEST, don't list groups with level lower than LOWEST.
4205 This command may read the active file."
4206 (interactive "P\nsList newsgroups matching: ")
4207 ;; First make sure active file has been read.
4209 (> (prefix-numeric-value level) gnus-level-killed))
4210 (gnus-get-killed-groups))
4211 (funcall gnus-group-prepare-function
4212 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
4213 (goto-char (point-min))
4214 (gnus-group-position-point))
4216 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4217 "List all groups that match REGEXP.
4218 If the prefix LEVEL is non-nil, it should be a number that says which
4219 level to cut off listing groups.
4220 If LOWEST, don't list groups with level lower than LOWEST."
4221 (interactive "P\nsList newsgroups matching: ")
4223 (setq level (prefix-numeric-value level)))
4224 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4226 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4227 (defun gnus-group-save-newsrc (&optional force)
4228 "Save the Gnus startup files.
4229 If FORCE, force saving whether it is necessary or not."
4231 (gnus-save-newsrc-file force))
4233 (defun gnus-group-restart (&optional arg)
4234 "Force Gnus to read the .newsrc file."
4236 (when (gnus-yes-or-no-p
4237 (format "Are you sure you want to restart Gnus? "))
4238 (gnus-save-newsrc-file)
4242 (defun gnus-group-read-init-file ()
4243 "Read the Gnus elisp init file."
4245 (gnus-read-init-file)
4246 (gnus-message 5 "Read %s" gnus-init-file))
4248 (defun gnus-group-check-bogus-groups (&optional silent)
4249 "Check bogus newsgroups.
4250 If given a prefix, don't ask for confirmation before removing a bogus
4253 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4254 (gnus-group-list-groups))
4256 (defun gnus-group-find-new-groups (&optional arg)
4257 "Search for new groups and add them.
4258 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
4259 With 1 C-u, use the `ask-server' method to query the server for new
4261 With 2 C-u's, use most complete method possible to query the server
4262 for new groups, and subscribe the new groups as zombies."
4264 (let ((new-groups (gnus-find-new-newsgroups (or arg 1)))
4266 (gnus-group-list-groups)
4267 (setq current-group (gnus-group-group-name))
4268 (dolist (group new-groups)
4269 (gnus-group-jump-to-group group))
4271 (gnus-group-jump-to-group current-group))))
4273 (defun gnus-group-edit-global-kill (&optional article group)
4274 "Edit the global kill file.
4275 If GROUP, edit that local kill file instead."
4277 (setq gnus-current-kill-article article)
4278 (gnus-kill-file-edit-file group)
4279 (gnus-message 6 "Editing a %s kill file (Type %s to exit)"
4280 (if group "local" "global")
4281 (substitute-command-keys "\\[gnus-kill-file-exit]")))
4283 (defun gnus-group-edit-local-kill (article group)
4284 "Edit a local kill file."
4285 (interactive (list nil (gnus-group-group-name)))
4286 (gnus-group-edit-global-kill article group))
4288 (defun gnus-group-force-update ()
4289 "Update `.newsrc' file."
4291 (gnus-save-newsrc-file))
4293 (defvar gnus-backlog-articles)
4295 (defun gnus-group-suspend ()
4296 "Suspend the current Gnus session.
4297 In fact, cleanup buffers except for group mode buffer.
4298 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4300 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4301 (gnus-offer-save-summaries)
4302 ;; Kill Gnus buffers except for group mode buffer.
4303 (let ((group-buf (get-buffer gnus-group-buffer)))
4304 (dolist (buf (gnus-buffers))
4305 (unless (or (eq buf group-buf)
4306 (eq buf gnus-dribble-buffer)
4307 (with-current-buffer buf
4308 (derived-mode-p 'message-mode)))
4309 (gnus-kill-buffer buf)))
4310 (setq gnus-backlog-articles nil)
4311 (gnus-kill-gnus-frames)
4312 ;; Closing all the backends is useful (for instance) when when the
4313 ;; IP addresses have changed and you need to reconnect.
4314 (dolist (elem gnus-opened-servers)
4315 (gnus-close-server (car elem))
4316 (setcar (cdr elem) 'closed))
4318 (bury-buffer group-buf)
4319 (delete-windows-on group-buf t))))
4321 (defun gnus-group-clear-dribble ()
4322 "Clear all information from the dribble buffer."
4324 (gnus-dribble-clear)
4325 (gnus-message 7 "Cleared dribble buffer"))
4327 (defun gnus-group-exit ()
4328 "Quit reading news after updating .newsrc.eld and .newsrc.
4329 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4332 (or noninteractive ;For gnus-batch-kill
4333 (not gnus-interactive-exit) ;Without confirmation
4335 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4336 (gnus-run-hooks 'gnus-exit-gnus-hook)
4337 ;; Offer to save data from non-quitted summary buffers.
4338 (gnus-offer-save-summaries)
4339 ;; Save the newsrc file(s).
4340 (gnus-save-newsrc-file)
4342 (gnus-close-backends)
4343 ;; Reset everything.
4345 ;; Allow the user to do things after cleaning up.
4346 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4348 (defun gnus-group-quit ()
4349 "Quit reading news without updating .newsrc.eld or .newsrc.
4350 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4352 (when (or noninteractive ;For gnus-batch-kill
4353 (zerop (buffer-size))
4354 (not (gnus-server-opened gnus-select-method))
4356 (not gnus-current-startup-file)
4358 (format "Quit reading news without saving %s? "
4359 (file-name-nondirectory gnus-current-startup-file))))
4360 (gnus-run-hooks 'gnus-exit-gnus-hook)
4361 (gnus-configure-windows 'group t)
4362 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4363 (not (zerop (with-current-buffer gnus-dribble-buffer
4366 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4368 (gnus-close-backends)
4370 (gnus-kill-buffer gnus-group-buffer)
4371 ;; Allow the user to do things after cleaning up.
4372 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4374 (defun gnus-group-describe-briefly ()
4375 "Give a one line description of the group mode commands."
4377 (gnus-message 7 "%s" (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-read-group]:Select \\[gnus-group-next-unread-group]:Forward \\[gnus-group-prev-unread-group]:Backward \\[gnus-group-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-group-describe-briefly]:This help")))
4379 (defun gnus-group-browse-foreign-server (method)
4380 "Browse a foreign news server.
4381 If called interactively, this function will ask for a select method
4382 (nntp, nnspool, etc.) and a server address (e.g., nntp.some.where).
4383 If not, METHOD should be a list where the first element is the method
4384 and the second element is the address."
4386 (list (let ((how (gnus-completing-read
4388 (mapcar 'car (append gnus-valid-select-methods
4390 t (cons "nntp" 0) 'gnus-method-history)))
4391 ;; We either got a back end name or a virtual server name.
4392 ;; If the first, we also need an address.
4393 (if (assoc how gnus-valid-select-methods)
4395 ;; Suggested by mapjph@bath.ac.uk.
4396 (gnus-completing-read
4398 ;; FIXME? gnus-secondary-servers is obsolete,
4399 ;; and it is not obvious that there is anything
4400 ;; sensible to use instead in this particular case.
4401 (if (boundp 'gnus-secondary-servers)
4402 gnus-secondary-servers
4403 (cdr gnus-select-method))))
4404 ;; We got a server name.
4406 (gnus-browse-foreign-server method))
4408 (defun gnus-group-set-info (info &optional method-only-group part)
4409 (when (or info part)
4410 (let* ((entry (gnus-group-entry
4411 (or method-only-group (gnus-info-group info))))
4413 (info (if method-only-group (nth 2 entry) info))
4415 (when method-only-group
4417 (error "Trying to change non-existent group %s" method-only-group))
4418 ;; We have received parts of the actual group info - either the
4419 ;; select method or the group parameters. We first check
4420 ;; whether we have to extend the info, and if so, do that.
4421 (let ((len (length info))
4422 (total (if (eq part 'method) 5 6)))
4424 (setcdr (nthcdr (1- len) info)
4425 (make-list (- total len) nil)))
4426 ;; Then we enter the new info.
4427 (setcar (nthcdr (1- total) info) part-info)))
4429 ;; This is a new group, so we just create it.
4430 (with-current-buffer gnus-group-buffer
4431 (setq method (gnus-info-method info))
4432 (when (gnus-server-equal method "native")
4434 (with-current-buffer gnus-group-buffer
4436 ;; It's a foreign group...
4437 (gnus-group-make-group
4438 (gnus-group-real-name (gnus-info-group info))
4439 (if (stringp method) method
4440 (prin1-to-string (car method)))
4442 (nth 1 (gnus-info-method info)))
4444 ;; It's a native group.
4445 (gnus-group-make-group (gnus-info-group info) nil nil nil t)))
4446 (gnus-message 6 "Note: New group created")
4448 (gnus-group-entry (gnus-group-prefixed-name
4449 (gnus-group-real-name (gnus-info-group info))
4450 (or (gnus-info-method info) gnus-select-method))))))
4451 ;; Whether it was a new group or not, we now have the entry, so we
4452 ;; can do the update.
4455 (setcar (nthcdr 2 entry) info)
4456 (when (and (not (eq (car entry) t))
4457 (gnus-active (gnus-info-group info)))
4458 (setcar entry (length
4459 (gnus-list-of-unread-articles (car info))))))
4460 (error "No such group: %s" (gnus-info-group info))))))
4462 ;; Ad-hoc function for inserting data from a different newsrc.eld
4463 ;; file. Use with caution, if at all.
4464 (defun gnus-import-other-newsrc-file (file)
4466 (insert-file-contents file)
4468 (while (ignore-errors
4469 (setq form (read (current-buffer))))
4470 (when (and (consp form)
4471 (eq (cadr form) 'gnus-newsrc-alist))
4472 (let ((infos (cadr (nth 2 form))))
4473 (dolist (info infos)
4474 (when (gnus-get-info (car info))
4475 (gnus-set-info (car info) info)))))))))
4477 (defun gnus-add-marked-articles (group type articles &optional info force)
4478 ;; Add ARTICLES of TYPE to the info of GROUP.
4479 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4480 ;; add, but replace marked articles of TYPE with ARTICLES.
4481 (let ((info (or info (gnus-get-info group)))
4484 (and (not (setq marked (nthcdr 3 info)))
4486 (setcdr (nthcdr 2 info)
4487 (list (list (cons type (gnus-compress-sequence
4489 (and (not (setq m (assq type (car marked))))
4492 (cons (cons type (gnus-compress-sequence articles t) )
4496 (setcar (nthcdr 3 info)
4497 (assq-delete-all type (car marked)))
4498 (setcdr m (gnus-compress-sequence articles t)))
4499 (setcdr m (gnus-compress-sequence
4500 (sort (nconc (gnus-uncompress-range (cdr m))
4501 (copy-sequence articles)) '<) t))))))
4503 (declare-function gnus-summary-add-mark "gnus-sum" (article type))
4505 (defun gnus-add-mark (group mark article)
4506 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4507 (let ((buffer (gnus-summary-buffer-name group)))
4508 (if (gnus-buffer-live-p buffer)
4509 (with-current-buffer (get-buffer buffer)
4510 (gnus-summary-add-mark article mark))
4511 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4515 ;;; Group timestamps
4518 (defun gnus-group-set-timestamp ()
4519 "Change the timestamp of the current group to the current time.
4520 This function can be used in hooks like `gnus-select-group-hook'
4521 or `gnus-group-catchup-group-hook'."
4522 (when gnus-newsgroup-name
4523 (let ((time (current-time)))
4524 (setcdr (cdr time) nil)
4525 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4527 (defsubst gnus-group-timestamp (group)
4528 "Return the timestamp for GROUP."
4529 (gnus-group-get-parameter group 'timestamp t))
4531 (defun gnus-group-timestamp-delta (group)
4532 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4533 (let* ((time (or (gnus-group-timestamp group)
4535 (delta (time-subtract (current-time) time)))
4536 (+ (* (nth 0 delta) 65536.0)
4539 (defun gnus-group-timestamp-string (group)
4540 "Return a string of the timestamp for GROUP."
4541 (let ((time (gnus-group-timestamp group)))
4544 (gnus-time-iso8601 time))))
4546 (defun gnus-group-list-cached (level &optional lowest)
4547 "List all groups with cached articles.
4548 If the prefix LEVEL is non-nil, it should be a number that says which
4549 level to cut off listing groups.
4550 If LOWEST, don't list groups with level lower than LOWEST.
4552 This command may read the active file."
4555 (setq level (prefix-numeric-value level)))
4556 (when (or (not level) (>= level gnus-level-zombie))
4558 (funcall gnus-group-prepare-function
4559 (or level gnus-level-subscribed)
4561 (let ((marks (gnus-info-marks info)))
4562 (assq 'cache marks)))
4565 (or (gnus-gethash group
4566 gnus-cache-active-hashtb)
4567 ;; Cache active file might use "."
4570 (mapconcat 'identity
4571 (split-string group ":")
4573 gnus-cache-active-hashtb))))
4574 (goto-char (point-min))
4575 (gnus-group-position-point))
4577 (defun gnus-group-list-dormant (level &optional lowest)
4578 "List all groups with dormant articles.
4579 If the prefix LEVEL is non-nil, it should be a number that says which
4580 level to cut off listing groups.
4581 If LOWEST, don't list groups with level lower than LOWEST.
4583 This command may read the active file."
4586 (setq level (prefix-numeric-value level)))
4587 (when (or (not level) (>= level gnus-level-zombie))
4589 (funcall gnus-group-prepare-function
4590 (or level gnus-level-subscribed)
4592 (let ((marks (gnus-info-marks info)))
4593 (assq 'dormant marks)))
4596 (goto-char (point-min))
4597 (gnus-group-position-point))
4599 (defun gnus-group-list-ticked (level &optional lowest)
4600 "List all groups with ticked articles.
4601 If the prefix LEVEL is non-nil, it should be a number that says which
4602 level to cut off listing groups.
4603 If LOWEST, don't list groups with level lower than LOWEST.
4605 This command may read the active file."
4608 (setq level (prefix-numeric-value level)))
4609 (when (or (not level) (>= level gnus-level-zombie))
4611 (funcall gnus-group-prepare-function
4612 (or level gnus-level-subscribed)
4614 (let ((marks (gnus-info-marks info)))
4615 (assq 'tick marks)))
4618 (goto-char (point-min))
4619 (gnus-group-position-point))
4621 (defun gnus-group-listed-groups ()
4622 "Return a list of listed groups."
4624 (goto-char (point-min))
4625 (while (setq point (text-property-not-all (point) (point-max)
4628 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4632 (defun gnus-group-list-plus (&optional args)
4633 "List groups plus the current selection."
4635 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4636 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4638 (push last-command-event unread-command-events)
4639 (push ?A unread-command-events)
4640 (let (gnus-pick-mode keys)
4641 (setq keys (read-key-sequence nil)
4642 func (lookup-key (current-local-map) keys)))
4646 (call-interactively func))))
4648 (defun gnus-group-list-flush (&optional args)
4649 "Flush groups from the current selection."
4651 (let ((gnus-group-list-option 'flush))
4652 (gnus-group-list-plus args)))
4654 (defun gnus-group-list-limit (&optional args)
4655 "List groups limited within the current selection.
4656 If you've limited the groups, you can further limit the selection
4657 with this command. If you've first limited to groups with
4658 dormant articles with `A ?', you can then further limit with
4659 `A / c', which will then limit to groups with cached articles, giving
4660 you the groups that have both dormant articles and cached articles."
4662 (let ((gnus-group-list-option 'limit))
4663 (gnus-group-list-plus args)))
4665 (declare-function gnus-mark-article-as-read "gnus-sum" (article &optional mark))
4666 (declare-function gnus-group-make-articles-read "gnus-sum" (group articles))
4668 (defun gnus-group-mark-article-read (group article)
4669 "Mark ARTICLE read."
4670 (let ((buffer (gnus-summary-buffer-name group))
4671 (mark gnus-read-mark)
4673 (if (get-buffer buffer)
4674 (with-current-buffer buffer
4675 (setq active gnus-newsgroup-active)
4676 (gnus-activate-group group)
4677 (when gnus-newsgroup-prepared
4678 (when (and gnus-newsgroup-auto-expire
4679 (memq mark gnus-auto-expirable-marks))
4680 (setq mark gnus-expirable-mark))
4681 (setq mark (gnus-request-update-mark
4682 group article mark))
4683 (gnus-request-set-mark
4684 group (list (list (list article) 'add '(read))))
4685 (gnus-mark-article-as-read article mark)
4686 (setq gnus-newsgroup-active (gnus-active group))
4688 (setq n (1+ (cdr active)))
4689 (while (<= n (cdr gnus-newsgroup-active))
4690 (unless (eq n article)
4691 (push n gnus-newsgroup-unselected))
4693 (setq gnus-newsgroup-unselected
4694 (sort gnus-newsgroup-unselected '<)))))
4695 (gnus-activate-group group)
4696 (gnus-group-make-articles-read group (list article))
4697 (when (and (gnus-group-auto-expirable-p group)
4698 (not (gnus-group-read-only-p group)))
4699 (gnus-add-marked-articles
4700 group 'expire (list article))))))
4704 ;;; Group compaction. -- dvl
4707 (defun gnus-group-compact-group (group)
4708 "Compact the current group.
4709 Compaction means removing gaps between article numbers. Hence, this
4710 operation is only meaningful for back ends using one file per article
4713 Note: currently only implemented in nnml."
4714 (interactive (list (gnus-group-group-name)))
4716 (error "No group to compact"))
4717 (unless (gnus-check-backend-function 'request-compact-group group)
4718 (error "This back end does not support group compaction"))
4719 (let ((group-decoded (gnus-group-decoded-name group)))
4721 Compacting group %s... (this may take a long time)"
4724 (if (not (gnus-request-compact-group group))
4725 (gnus-error 3 "Couldn't compact group %s" group-decoded)
4726 (gnus-message 6 "Compacting group %s...done" group-decoded)
4728 ;; Invalidate the "original article" buffer which might be out of date.
4729 ;; #### NOTE: Yes, this might be a bit rude, but since compaction
4730 ;; #### will not happen very often, I think this is acceptable.
4731 (let ((original (get-buffer gnus-original-article-buffer)))
4732 (and original (gnus-kill-buffer original)))
4733 ;; Update the group line to reflect new information (art number etc).
4734 (gnus-group-update-group-line))))
4736 (provide 'gnus-group)
4738 ;;; gnus-group.el ends here