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 (defvar 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
456 ;;; Internal variables
458 (defvar gnus-group-is-exiting-p nil)
459 (defvar gnus-group-is-exiting-without-update-p nil)
460 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
461 "Function for sorting the group buffer.")
463 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
464 "Function for sorting the selected groups in the group buffer.")
466 (defvar gnus-group-indentation-function nil)
467 (defvar gnus-goto-missing-group-function nil)
468 (defvar gnus-group-update-group-function nil)
469 (defvar gnus-group-goto-next-group-function nil
470 "Function to override finding the next group after listing groups.")
472 (defvar gnus-group-edit-buffer nil)
474 (defvar gnus-tmp-news-method)
475 (defvar gnus-tmp-colon)
476 (defvar gnus-tmp-news-server)
477 (defvar gnus-tmp-decoded-group)
478 (defvar gnus-tmp-header)
479 (defvar gnus-tmp-process-marked)
480 (defvar gnus-tmp-summary-live)
481 (defvar gnus-tmp-news-method-string)
482 (defvar gnus-tmp-group-icon)
483 (defvar gnus-tmp-moderated-string)
484 (defvar gnus-tmp-newsgroup-description)
485 (defvar gnus-tmp-comment)
486 (defvar gnus-tmp-qualified-group)
487 (defvar gnus-tmp-subscribed)
488 (defvar gnus-tmp-number-of-read)
489 (defvar gnus-inhibit-demon)
490 (defvar gnus-pick-mode)
491 (defvar gnus-tmp-marked-mark)
492 (defvar gnus-tmp-number-of-unread)
494 (defvar gnus-group-line-format-alist
495 `((?M gnus-tmp-marked-mark ?c)
496 (?S gnus-tmp-subscribed ?c)
497 (?L gnus-tmp-level ?d)
498 (?N (cond ((eq number t) "*" )
502 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
503 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
505 (?R gnus-tmp-number-of-read ?s)
506 (?U (if (gnus-active gnus-tmp-group)
507 (gnus-number-of-unseen-articles-in-group gnus-tmp-group)
510 (?t gnus-tmp-number-total ?d)
511 (?y gnus-tmp-number-of-unread ?s)
512 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
513 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
514 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
515 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
516 (?g (if (boundp 'gnus-tmp-decoded-group)
517 gnus-tmp-decoded-group
520 (?G gnus-tmp-qualified-group ?s)
521 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
522 gnus-tmp-decoded-group
525 (?C gnus-tmp-comment ?s)
526 (?D gnus-tmp-newsgroup-description ?s)
527 (?o gnus-tmp-moderated ?c)
528 (?O gnus-tmp-moderated-string ?s)
529 (?p gnus-tmp-process-marked ?c)
530 (?s gnus-tmp-news-server ?s)
531 (?n gnus-tmp-news-method ?s)
532 (?P gnus-group-indentation ?s)
533 (?E gnus-tmp-group-icon ?s)
534 (?B gnus-tmp-summary-live ?c)
535 (?z gnus-tmp-news-method-string ?s)
536 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
537 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
538 (?u gnus-tmp-user-defined ?s)
539 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
542 (defvar gnus-group-mode-line-format-alist
543 `((?S gnus-tmp-news-server ?s)
544 (?M gnus-tmp-news-method ?s)
545 (?u gnus-tmp-user-defined ?s)
546 (?: gnus-tmp-colon ?s)))
548 (defvar gnus-topic-topology nil
549 "The complete topic hierarchy.")
551 (defvar gnus-topic-alist nil
552 "The complete topic-group alist.")
554 (defvar gnus-group-marked nil)
556 (defvar gnus-group-list-mode nil)
559 (defvar gnus-group-listed-groups nil)
560 (defvar gnus-group-list-option nil)
566 (put 'gnus-group-mode 'mode-class 'special)
568 (gnus-define-keys gnus-group-mode-map
569 " " gnus-group-read-group
570 "=" gnus-group-select-group
571 "\r" gnus-group-select-group
572 "\M-\r" gnus-group-quick-select-group
573 "\M- " gnus-group-visible-select-group
574 [(meta control return)] gnus-group-select-group-ephemerally
575 "j" gnus-group-jump-to-group
576 "n" gnus-group-next-unread-group
577 "p" gnus-group-prev-unread-group
578 "\177" gnus-group-prev-unread-group
579 [delete] gnus-group-prev-unread-group
580 "N" gnus-group-next-group
581 "P" gnus-group-prev-group
582 "\M-n" gnus-group-next-unread-group-same-level
583 "\M-p" gnus-group-prev-unread-group-same-level
584 "," gnus-group-best-unread-group
585 "." gnus-group-first-unread-group
586 "u" gnus-group-unsubscribe-current-group
587 "U" gnus-group-unsubscribe-group
588 "c" gnus-group-catchup-current
589 "C" gnus-group-catchup-current-all
590 "\M-c" gnus-group-clear-data
591 "l" gnus-group-list-groups
592 "L" gnus-group-list-all-groups
595 "g" gnus-group-get-new-news
596 "\M-g" gnus-group-get-new-news-this-group
597 "R" gnus-group-restart
598 "r" gnus-group-read-init-file
599 "B" gnus-group-browse-foreign-server
600 "b" gnus-group-check-bogus-groups
601 "F" gnus-group-find-new-groups
602 "\C-c\C-d" gnus-group-describe-group
603 "\M-d" gnus-group-describe-all-groups
604 "\C-c\C-a" gnus-group-apropos
605 "\C-c\M-\C-a" gnus-group-description-apropos
606 "a" gnus-group-post-news
607 "\ek" gnus-group-edit-local-kill
608 "\eK" gnus-group-edit-global-kill
609 "\C-k" gnus-group-kill-group
610 "\C-y" gnus-group-yank-group
611 "\C-w" gnus-group-kill-region
612 "\C-x\C-t" gnus-group-transpose-groups
613 "\C-c\C-l" gnus-group-list-killed
614 "\C-c\C-x" gnus-group-expire-articles
615 "\C-c\M-\C-x" gnus-group-expire-all-groups
617 "s" gnus-group-save-newsrc
618 "z" gnus-group-suspend
621 "?" gnus-group-describe-briefly
622 "\C-c\C-i" gnus-info-find-node
623 "\M-e" gnus-group-edit-group-method
624 "^" gnus-group-enter-server-mode
625 [mouse-2] gnus-mouse-pick-group
626 [follow-link] 'mouse-face
627 "<" beginning-of-buffer
630 "\C-c\C-s" gnus-group-sort-groups
632 "\C-c\M-g" gnus-activate-all-groups
633 "\M-&" gnus-group-universal-argument
634 "#" gnus-group-mark-group
635 "\M-#" gnus-group-unmark-group)
637 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
638 "m" gnus-group-mark-group
639 "u" gnus-group-unmark-group
640 "w" gnus-group-mark-region
641 "b" gnus-group-mark-buffer
642 "r" gnus-group-mark-regexp
643 "U" gnus-group-unmark-all-groups)
645 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
646 "u" gnus-sieve-update
647 "g" gnus-sieve-generate)
649 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
650 "d" gnus-group-make-directory-group
651 "h" gnus-group-make-help-group
652 "u" gnus-group-make-useful-group
653 "l" gnus-group-nnimap-edit-acl
654 "m" gnus-group-make-group
655 "E" gnus-group-edit-group
656 "e" gnus-group-edit-group-method
657 "p" gnus-group-edit-group-parameters
658 "v" gnus-group-add-to-virtual
659 "V" gnus-group-make-empty-virtual
660 "D" gnus-group-enter-directory
661 "f" gnus-group-make-doc-group
662 "w" gnus-group-make-web-group
663 "G" gnus-group-make-nnir-group
664 "M" gnus-group-read-ephemeral-group
665 "r" gnus-group-rename-group
666 "R" gnus-group-make-rss-group
667 "c" gnus-group-customize
668 "z" gnus-group-compact-group
669 "x" gnus-group-expunge-group
670 "\177" gnus-group-delete-group
671 [delete] gnus-group-delete-group)
673 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
674 "s" gnus-group-sort-groups
675 "a" gnus-group-sort-groups-by-alphabet
676 "u" gnus-group-sort-groups-by-unread
677 "l" gnus-group-sort-groups-by-level
678 "v" gnus-group-sort-groups-by-score
679 "r" gnus-group-sort-groups-by-rank
680 "m" gnus-group-sort-groups-by-method
681 "n" gnus-group-sort-groups-by-real-name)
683 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
684 "s" gnus-group-sort-selected-groups
685 "a" gnus-group-sort-selected-groups-by-alphabet
686 "u" gnus-group-sort-selected-groups-by-unread
687 "l" gnus-group-sort-selected-groups-by-level
688 "v" gnus-group-sort-selected-groups-by-score
689 "r" gnus-group-sort-selected-groups-by-rank
690 "m" gnus-group-sort-selected-groups-by-method
691 "n" gnus-group-sort-selected-groups-by-real-name)
693 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
694 "k" gnus-group-list-killed
695 "z" gnus-group-list-zombies
696 "s" gnus-group-list-groups
697 "u" gnus-group-list-all-groups
698 "A" gnus-group-list-active
699 "a" gnus-group-apropos
700 "d" gnus-group-description-apropos
701 "m" gnus-group-list-matching
702 "M" gnus-group-list-all-matching
703 "l" gnus-group-list-level
704 "c" gnus-group-list-cached
705 "?" gnus-group-list-dormant
706 "!" gnus-group-list-ticked)
708 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
709 "k" gnus-group-list-limit
710 "z" gnus-group-list-limit
711 "s" gnus-group-list-limit
712 "u" gnus-group-list-limit
713 "A" gnus-group-list-limit
714 "m" gnus-group-list-limit
715 "M" gnus-group-list-limit
716 "l" gnus-group-list-limit
717 "c" gnus-group-list-limit
718 "?" gnus-group-list-limit
719 "!" gnus-group-list-limit)
721 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
722 "k" gnus-group-list-flush
723 "z" gnus-group-list-flush
724 "s" gnus-group-list-flush
725 "u" gnus-group-list-flush
726 "A" gnus-group-list-flush
727 "m" gnus-group-list-flush
728 "M" gnus-group-list-flush
729 "l" gnus-group-list-flush
730 "c" gnus-group-list-flush
731 "?" gnus-group-list-flush
732 "!" gnus-group-list-flush)
734 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
735 "k" gnus-group-list-plus
736 "z" gnus-group-list-plus
737 "s" gnus-group-list-plus
738 "u" gnus-group-list-plus
739 "A" gnus-group-list-plus
740 "m" gnus-group-list-plus
741 "M" gnus-group-list-plus
742 "l" gnus-group-list-plus
743 "c" gnus-group-list-plus
744 "?" gnus-group-list-plus
745 "!" gnus-group-list-plus)
747 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
748 "f" gnus-score-flush-cache
749 "e" gnus-score-edit-all-score)
751 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
752 "d" gnus-group-describe-group
755 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
756 "l" gnus-group-set-current-level
757 "t" gnus-group-unsubscribe-current-group
758 "s" gnus-group-unsubscribe-group
759 "k" gnus-group-kill-group
760 "y" gnus-group-yank-group
761 "w" gnus-group-kill-region
762 "\C-k" gnus-group-kill-level
763 "z" gnus-group-kill-all-zombies)
765 (defun gnus-topic-mode-p ()
766 "Return non-nil in `gnus-topic-mode'."
767 (and (boundp 'gnus-topic-mode)
768 (symbol-value 'gnus-topic-mode)))
770 (defun gnus-group-make-menu-bar ()
771 (unless (boundp 'gnus-group-reading-menu)
774 gnus-group-reading-menu gnus-group-mode-map ""
776 ["Read" gnus-group-read-group
777 :included (not (gnus-topic-mode-p))
778 :active (gnus-group-group-name)]
779 ["Read " gnus-topic-read-group
780 :included (gnus-topic-mode-p)]
781 ["Select" gnus-group-select-group
782 :included (not (gnus-topic-mode-p))
783 :active (gnus-group-group-name)]
784 ["Select " gnus-topic-select-group
785 :included (gnus-topic-mode-p)]
786 ["See old articles" (gnus-group-select-group 'all)
787 :keys "C-u SPC" :active (gnus-group-group-name)]
788 ["Catch up" gnus-group-catchup-current
789 :included (not (gnus-topic-mode-p))
790 :active (gnus-group-group-name)
791 :help "Mark unread articles in the current group as read"]
792 ["Catch up " gnus-topic-catchup-articles
793 :included (gnus-topic-mode-p)
794 :help "Mark unread articles in the current group or topic as read"]
795 ["Catch up all articles" gnus-group-catchup-current-all
796 (gnus-group-group-name)]
797 ["Check for new articles" gnus-group-get-new-news-this-group
798 :included (not (gnus-topic-mode-p))
799 :active (gnus-group-group-name)
800 :help "Check for new messages in current group"]
801 ["Check for new articles " gnus-topic-get-new-news-this-topic
802 :included (gnus-topic-mode-p)
803 :help "Check for new messages in current group or topic"]
804 ["Toggle subscription" gnus-group-unsubscribe-current-group
805 (gnus-group-group-name)]
806 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
807 :help "Kill (remove) current group"]
808 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
809 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
810 :help "Display description of the current group"]
811 ;; Actually one should check, if any of the marked groups gives t for
812 ;; (gnus-check-backend-function 'request-expire-articles ...)
813 ["Expire articles" gnus-group-expire-articles
814 :included (not (gnus-topic-mode-p))
815 :active (or (and (gnus-group-group-name)
816 (gnus-check-backend-function
817 'request-expire-articles
818 (gnus-group-group-name))) gnus-group-marked)]
819 ["Expire articles " gnus-topic-expire-articles
820 :included (gnus-topic-mode-p)]
821 ["Set group level..." gnus-group-set-current-level
822 (gnus-group-group-name)]
823 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
824 ["Customize" gnus-group-customize (gnus-group-group-name)]
825 ["Compact" gnus-group-compact-group
826 :active (gnus-group-group-name)]
828 ["Parameters" gnus-group-edit-group-parameters
829 :included (not (gnus-topic-mode-p))
830 :active (gnus-group-group-name)]
831 ["Parameters " gnus-topic-edit-parameters
832 :included (gnus-topic-mode-p)]
833 ["Select method" gnus-group-edit-group-method
834 (gnus-group-group-name)]
835 ["Info" gnus-group-edit-group (gnus-group-group-name)]
836 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
837 ["Global kill file" gnus-group-edit-global-kill t])))
840 gnus-group-group-menu gnus-group-mode-map ""
843 ["List unread subscribed groups" gnus-group-list-groups t]
844 ["List (un)subscribed groups" gnus-group-list-all-groups t]
845 ["List killed groups" gnus-group-list-killed gnus-killed-list]
846 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
847 ["List level..." gnus-group-list-level t]
848 ["Describe all groups" gnus-group-describe-all-groups t]
849 ["Group apropos..." gnus-group-apropos t]
850 ["Group and description apropos..." gnus-group-description-apropos t]
851 ["List groups matching..." gnus-group-list-matching t]
852 ["List all groups matching..." gnus-group-list-all-matching t]
853 ["List active file" gnus-group-list-active t]
854 ["List groups with cached" gnus-group-list-cached t]
855 ["List groups with dormant" gnus-group-list-dormant t]
856 ["List groups with ticked" gnus-group-list-ticked t])
858 ["Default sort" gnus-group-sort-groups t]
859 ["Sort by method" gnus-group-sort-groups-by-method t]
860 ["Sort by rank" gnus-group-sort-groups-by-rank t]
861 ["Sort by score" gnus-group-sort-groups-by-score t]
862 ["Sort by level" gnus-group-sort-groups-by-level t]
863 ["Sort by unread" gnus-group-sort-groups-by-unread t]
864 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
865 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
866 ("Sort process/prefixed"
867 ["Default sort" gnus-group-sort-selected-groups
868 (not (gnus-topic-mode-p))]
869 ["Sort by method" gnus-group-sort-selected-groups-by-method
870 (not (gnus-topic-mode-p))]
871 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
872 (not (gnus-topic-mode-p))]
873 ["Sort by score" gnus-group-sort-selected-groups-by-score
874 (not (gnus-topic-mode-p))]
875 ["Sort by level" gnus-group-sort-selected-groups-by-level
876 (not (gnus-topic-mode-p))]
877 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
878 (not (gnus-topic-mode-p))]
879 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
880 (not (gnus-topic-mode-p))]
881 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
882 (not (gnus-topic-mode-p))])
884 ["Mark group" gnus-group-mark-group
885 (and (gnus-group-group-name)
886 (not (memq (gnus-group-group-name) gnus-group-marked)))]
887 ["Unmark group" gnus-group-unmark-group
888 (and (gnus-group-group-name)
889 (memq (gnus-group-group-name) gnus-group-marked))]
890 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
891 ["Mark regexp..." gnus-group-mark-regexp t]
892 ["Mark region" gnus-group-mark-region :active mark-active]
893 ["Mark buffer" gnus-group-mark-buffer t]
894 ["Execute command" gnus-group-universal-argument
895 (or gnus-group-marked (gnus-group-group-name))])
897 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
898 ["Kill all newsgroups in region" gnus-group-kill-region
900 ["Kill all zombie groups" gnus-group-kill-all-zombies
902 ["Kill all groups on level..." gnus-group-kill-level t])
904 ["Make a foreign group..." gnus-group-make-group t]
905 ["Add a directory group..." gnus-group-make-directory-group t]
906 ["Add the help group" gnus-group-make-help-group t]
907 ["Make a doc group..." gnus-group-make-doc-group t]
908 ["Make a web group..." gnus-group-make-web-group t]
909 ["Make a search group..." gnus-group-make-nnir-group t]
910 ["Make a virtual group..." gnus-group-make-empty-virtual t]
911 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
912 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
913 ["Make an RSS group..." gnus-group-make-rss-group t]
914 ["Rename group..." gnus-group-rename-group
915 (gnus-check-backend-function
916 'request-rename-group (gnus-group-group-name))]
917 ["Delete group" gnus-group-delete-group
918 (gnus-check-backend-function
919 'request-delete-group (gnus-group-group-name))])
921 ["Next" gnus-group-next-group t]
922 ["Previous" gnus-group-prev-group t]
923 ["Next unread" gnus-group-next-unread-group t]
924 ["Previous unread" gnus-group-prev-unread-group t]
925 ["Next unread same level" gnus-group-next-unread-group-same-level t]
926 ["Previous unread same level"
927 gnus-group-prev-unread-group-same-level t]
928 ["Jump to group..." gnus-group-jump-to-group t]
929 ["First unread group" gnus-group-first-unread-group t]
930 ["Best unread group" gnus-group-best-unread-group t])
932 ["Generate" gnus-sieve-generate t]
933 ["Generate and update" gnus-sieve-update t])
934 ["Delete bogus groups" gnus-group-check-bogus-groups t]
935 ["Find new newsgroups" gnus-group-find-new-groups t]
936 ["Transpose" gnus-group-transpose-groups
937 (gnus-group-group-name)]
938 ["Read a directory as a group..." gnus-group-enter-directory t]))
941 gnus-group-misc-menu gnus-group-mode-map ""
943 ["Send a mail" gnus-group-mail t]
944 ["Send a message (mail or news)" gnus-group-post-news t]
945 ["Create a local message" gnus-group-news t]
946 ["Check for new news" gnus-group-get-new-news
947 :help "Get newly arrived articles"]
948 ["Send queued messages" gnus-delay-send-queue
949 :help "Send all messages that are scheduled to be sent now"]
950 ["Activate all groups" gnus-activate-all-groups t]
951 ["Restart Gnus" gnus-group-restart t]
952 ["Read init file" gnus-group-read-init-file t]
953 ["Browse foreign server..." gnus-group-browse-foreign-server t]
954 ["Enter server buffer" gnus-group-enter-server-mode t]
955 ["Expire all expirable articles" gnus-group-expire-all-groups t]
956 ["Gnus version" gnus-version t]
957 ["Save .newsrc files" gnus-group-save-newsrc t]
958 ["Suspend Gnus" gnus-group-suspend t]
959 ["Clear dribble buffer" gnus-group-clear-dribble t]
960 ["Read manual" gnus-info-find-node t]
961 ["Flush score cache" gnus-score-flush-cache t]
962 ["Toggle topics" gnus-topic-mode t]
963 ["Send a bug report" gnus-bug t]
964 ["Exit from Gnus" gnus-group-exit :help "Quit reading news"]
965 ["Exit without saving" gnus-group-quit t]))
967 (gnus-run-hooks 'gnus-group-menu-hook)))
970 (defvar gnus-group-tool-bar-map nil)
972 (defun gnus-group-tool-bar-update (&optional symbol value)
973 "Update group buffer toolbar.
974 Setter function for custom variables."
976 (set-default symbol value))
977 ;; (setq-default gnus-group-tool-bar-map nil)
978 ;; (use-local-map gnus-group-mode-map)
980 (with-current-buffer gnus-group-buffer
981 (gnus-group-make-tool-bar t))))
983 (defcustom gnus-group-tool-bar (if (eq gmm-tool-bar-style 'gnome)
984 'gnus-group-tool-bar-gnome
985 'gnus-group-tool-bar-retro)
986 "Specifies the Gnus group tool bar.
988 It can be either a list or a symbol referring to a list. See
989 `gmm-tool-bar-from-list' for the format of the list. The
990 default key map is `gnus-group-mode-map'.
992 Pre-defined symbols include `gnus-group-tool-bar-gnome' and
993 `gnus-group-tool-bar-retro'."
994 :type '(choice (const :tag "GNOME style" gnus-group-tool-bar-gnome)
995 (const :tag "Retro look" gnus-group-tool-bar-retro)
996 (repeat :tag "User defined list" gmm-tool-bar-item)
998 :version "23.1" ;; No Gnus
999 :initialize 'custom-initialize-default
1000 :set 'gnus-group-tool-bar-update
1003 (defcustom gnus-group-tool-bar-gnome
1004 '((gnus-group-post-news "mail/compose")
1005 ;; Some useful agent icons? I don't use the agent so agent users should
1006 ;; suggest useful commands:
1007 (gnus-agent-toggle-plugged "unplugged" t
1008 :help "Gnus is currently unplugged. Click to work online."
1009 :visible (and gnus-agent (not gnus-plugged)))
1010 (gnus-agent-toggle-plugged "plugged" t
1011 :help "Gnus is currently plugged. Click to work offline."
1012 :visible (and gnus-agent gnus-plugged))
1013 ;; FIXME: gnus-agent-toggle-plugged (in gnus-agent-group-make-menu-bar)
1014 ;; should have a better help text.
1015 (gnus-group-send-queue "mail/outbox" t
1016 :visible (and gnus-agent gnus-plugged)
1017 :help "Send articles from the queue group")
1018 (gnus-group-get-new-news "mail/inbox" nil
1019 :visible (or (not gnus-agent)
1021 ;; FIXME: gnus-*-read-group should have a better help text.
1022 (gnus-topic-read-group "open" nil
1023 :visible (and (boundp 'gnus-topic-mode)
1025 (gnus-group-read-group "open" nil
1026 :visible (not (and (boundp 'gnus-topic-mode)
1028 ;; (gnus-group-find-new-groups "???" nil)
1029 (gnus-group-save-newsrc "save")
1030 (gnus-group-describe-group "describe")
1031 (gnus-group-unsubscribe-current-group "gnus/toggle-subscription")
1032 (gnus-group-prev-unread-group "left-arrow")
1033 (gnus-group-next-unread-group "right-arrow")
1034 (gnus-group-exit "exit")
1035 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
1036 (gnus-info-find-node "help"))
1037 "List of functions for the group tool bar (GNOME style).
1039 See `gmm-tool-bar-from-list' for the format of the list."
1040 :type '(repeat gmm-tool-bar-item)
1041 :version "23.1" ;; No Gnus
1042 :initialize 'custom-initialize-default
1043 :set 'gnus-group-tool-bar-update
1046 (defcustom gnus-group-tool-bar-retro
1047 '((gnus-group-get-new-news "gnus/get-news")
1048 (gnus-group-get-new-news-this-group "gnus/gnntg")
1049 (gnus-group-catchup-current "gnus/catchup")
1050 (gnus-group-describe-group "gnus/describe-group")
1051 (gnus-group-subscribe "gnus/subscribe" t
1052 :help "Subscribe to the current group")
1053 (gnus-group-unsubscribe "gnus/unsubscribe" t
1054 :help "Unsubscribe from the current group")
1055 (gnus-group-exit "gnus/exit-gnus" gnus-group-mode-map))
1056 "List of functions for the group tool bar (retro look).
1058 See `gmm-tool-bar-from-list' for the format of the list."
1059 :type '(repeat gmm-tool-bar-item)
1060 :version "23.1" ;; No Gnus
1061 :initialize 'custom-initialize-default
1062 :set 'gnus-group-tool-bar-update
1065 (defcustom gnus-group-tool-bar-zap-list t
1066 "List of icon items from the global tool bar.
1067 These items are not displayed in the Gnus group mode tool bar.
1069 See `gmm-tool-bar-from-list' for the format of the list."
1070 :type 'gmm-tool-bar-zap-list
1071 :version "23.1" ;; No Gnus
1072 :initialize 'custom-initialize-default
1073 :set 'gnus-group-tool-bar-update
1076 (defvar image-load-path)
1077 (defvar tool-bar-map)
1079 (defun gnus-group-make-tool-bar (&optional force)
1080 "Make a group mode tool bar from `gnus-group-tool-bar'.
1081 When FORCE, rebuild the tool bar."
1082 (when (and (boundp 'tool-bar-mode)
1085 (or (not gnus-group-tool-bar-map) force))
1087 (image-load-path-for-library
1088 "gnus" "gnus/toggle-subscription.xpm" nil t))
1089 (image-load-path (cons (car load-path) image-load-path))
1090 (map (gmm-tool-bar-from-list gnus-group-tool-bar
1091 gnus-group-tool-bar-zap-list
1092 'gnus-group-mode-map)))
1094 (set (make-local-variable 'tool-bar-map) map))))
1095 gnus-group-tool-bar-map)
1097 (define-derived-mode gnus-group-mode fundamental-mode "Group"
1098 "Major mode for reading news.
1100 All normal editing commands are switched off.
1101 \\<gnus-group-mode-map>
1102 The group buffer lists (some of) the groups available. For instance,
1103 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1104 lists all zombie groups.
1106 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1107 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1109 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1111 The following commands are available:
1113 \\{gnus-group-mode-map}"
1114 (when (gnus-visual-p 'group-menu 'menu)
1115 (gnus-group-make-menu-bar)
1116 (gnus-group-make-tool-bar))
1117 (gnus-simplify-mode-line)
1118 (gnus-group-set-mode-line)
1119 (setq mode-line-process nil)
1120 (buffer-disable-undo)
1121 (setq truncate-lines t)
1122 (setq buffer-read-only t
1123 show-trailing-whitespace nil)
1124 (gnus-set-default-directory)
1125 (gnus-update-format-specifications nil 'group 'group-mode)
1126 (gnus-update-group-mark-positions)
1132 (defun gnus-update-group-mark-positions ()
1134 (let ((gnus-process-mark ?\200)
1135 (gnus-group-update-hook nil)
1136 (gnus-group-marked '("dummy.group"))
1137 (gnus-active-hashtb (make-vector 10 0)))
1138 (gnus-set-active "dummy.group" '(0 . 0))
1139 (gnus-set-work-buffer)
1140 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1141 (goto-char (point-min))
1142 (setq gnus-group-mark-positions
1143 (list (cons 'process (and (search-forward
1144 (string-to-multibyte "\200") nil t)
1145 (- (point) (point-min) 1))))))))
1147 (defun gnus-mouse-pick-group (e)
1148 "Enter the group under the mouse pointer."
1151 (gnus-group-read-group nil))
1153 (defun gnus-group-default-list-level ()
1154 "Return the real value for `gnus-group-default-list-level'."
1155 (if (functionp gnus-group-default-list-level)
1156 (funcall gnus-group-default-list-level)
1157 gnus-group-default-list-level))
1159 ;; Look at LEVEL and find out what the level is really supposed to be.
1160 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1161 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1162 (defun gnus-group-default-level (&optional level number-or-nil)
1164 (gnus-group-use-permanent-levels
1165 (or (setq gnus-group-use-permanent-levels
1166 (or level (if (numberp gnus-group-use-permanent-levels)
1167 gnus-group-use-permanent-levels
1168 (or (gnus-group-default-list-level)
1169 gnus-level-subscribed))))
1170 (gnus-group-default-list-level) gnus-level-subscribed))
1174 (or level (gnus-group-default-list-level) gnus-level-subscribed))))
1176 (defun gnus-group-setup-buffer ()
1177 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1178 (unless (derived-mode-p 'gnus-group-mode)
1181 (defun gnus-group-name-charset (method group)
1183 (setq method (gnus-find-method-for-group group)))
1184 (when (stringp method)
1185 (setq method (gnus-server-to-method method)))
1186 (if (eq (car method) 'nnimap)
1187 ;; IMAP groups should not be encoded, since they do the encoding
1188 ;; in utf7 in the protocol.
1190 (let ((item (or (assoc method gnus-group-name-charset-method-alist)
1192 (assoc (list (car method) (cadr method))
1193 gnus-group-name-charset-method-alist))))
1194 (alist gnus-group-name-charset-group-alist)
1198 (while (setq item (pop alist))
1199 (if (string-match (car item) group)
1201 result (cdr item))))
1204 (defun gnus-group-name-decode (string charset)
1205 ;; Fixme: Don't decode in unibyte mode.
1206 (if (and string charset)
1207 (decode-coding-string string charset)
1210 (defun gnus-group-decoded-name (string)
1211 (let ((charset (gnus-group-name-charset nil string)))
1212 (gnus-group-name-decode string charset)))
1214 (defun gnus-group-list-groups (&optional level unread lowest)
1215 "List newsgroups with level LEVEL or lower that have unread articles.
1216 Default is all subscribed groups.
1217 If argument UNREAD is non-nil, groups with no unread articles are also
1220 Also see the `gnus-group-use-permanent-levels' variable."
1222 (list (if current-prefix-arg
1223 (prefix-numeric-value current-prefix-arg)
1225 (gnus-group-default-level nil t)
1226 (gnus-group-default-list-level)
1227 gnus-level-subscribed))))
1229 (setq level (car gnus-group-list-mode)
1230 unread (cdr gnus-group-list-mode)))
1231 (setq level (gnus-group-default-level level))
1232 (gnus-group-setup-buffer)
1233 (gnus-update-format-specifications nil 'group 'group-mode)
1234 (let ((case-fold-search nil)
1235 (props (text-properties-at (point-at-bol)))
1236 (empty (= (point-min) (point-max)))
1237 (group (gnus-group-group-name))
1239 (set-buffer gnus-group-buffer)
1240 (setq number (funcall gnus-group-prepare-function level unread lowest))
1241 (when (or (and (numberp number)
1243 (zerop (buffer-size)))
1244 ;; No groups in the buffer.
1245 (gnus-message 5 "%s" gnus-no-groups-message))
1246 ;; We have some groups displayed.
1247 (goto-char (point-max))
1248 (when (or (not gnus-group-goto-next-group-function)
1249 (not (funcall gnus-group-goto-next-group-function
1253 (goto-char (point-min)))
1255 ;; Go to the first group with unread articles.
1256 (gnus-group-search-forward t))
1258 ;; Find the right group to put point on. If the current group
1259 ;; has disappeared in the new listing, try to find the next
1260 ;; one. If no next one can be found, just leave point at the
1261 ;; first newsgroup in the buffer.
1262 (when (not (gnus-goto-char
1264 (point-min) (point-max)
1265 'gnus-group (gnus-intern-safe
1266 group gnus-active-hashtb))))
1267 (let ((newsrc (cdddr (gnus-group-entry group))))
1269 (not (gnus-goto-char
1271 (point-min) (point-max) 'gnus-group
1273 (caar newsrc) gnus-active-hashtb)))))
1274 (setq newsrc (cdr newsrc)))
1276 (goto-char (point-max))
1277 (forward-line -1)))))))
1278 ;; Adjust cursor point.
1279 (gnus-group-position-point)))
1281 (defun gnus-group-list-level (level &optional all)
1282 "List groups on LEVEL.
1283 If ALL (the prefix), also list groups that have no unread articles."
1284 (interactive "nList groups on level: \nP")
1285 (gnus-group-list-groups level all level))
1287 (defun gnus-group-prepare-logic (group test)
1288 (or (and gnus-group-listed-groups
1289 (null gnus-group-list-option)
1290 (member group gnus-group-listed-groups))
1292 ((null gnus-group-listed-groups) test)
1293 ((null gnus-group-list-option) test)
1294 (t (and (member group gnus-group-listed-groups)
1295 (if (eq gnus-group-list-option 'flush)
1299 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1300 "List all newsgroups with unread articles of level LEVEL or lower.
1301 If PREDICATE is a function, list groups that the function returns non-nil;
1302 if it is t, list groups that have no unread articles.
1303 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1304 If REGEXP is a function, list dead groups that the function returns non-nil;
1305 if it is a string, only list groups matching REGEXP."
1306 (set-buffer gnus-group-buffer)
1307 (let ((buffer-read-only nil)
1308 (newsrc (cdr gnus-newsrc-alist))
1309 (lowest (or lowest 1))
1310 (not-in-list (and gnus-group-listed-groups
1311 (copy-sequence gnus-group-listed-groups)))
1312 info clevel unread group params)
1314 (when (or (< lowest gnus-level-zombie)
1315 gnus-group-listed-groups)
1316 ;; List living groups.
1318 (setq info (car newsrc)
1319 group (gnus-info-group info)
1320 params (gnus-info-params info)
1322 unread (gnus-group-unread group))
1324 (setq not-in-list (delete group not-in-list)))
1325 (when (gnus-group-prepare-logic
1327 (and (or unread ; This group might be unchecked
1328 predicate) ; Check if this group should be listed
1329 (or (not (stringp regexp))
1330 (string-match regexp group))
1331 (<= (setq clevel (gnus-info-level info)) level)
1334 ((functionp predicate)
1335 (funcall predicate info))
1336 (predicate t) ; We list all groups?
1339 (if (eq unread t) ; Inactive?
1340 gnus-group-list-inactive-groups
1342 (and (numberp unread) (> unread 0)))
1343 ; We list groups with unread articles
1344 (and gnus-list-groups-with-ticked-articles
1345 (cdr (assq 'tick (gnus-info-marks info))))
1346 ; And groups with ticked articles
1347 ;; Check for permanent visibility.
1348 (and gnus-permanently-visible-groups
1349 (string-match gnus-permanently-visible-groups
1351 (memq 'visible params)
1352 (cdr (assq 'visible params)))))))
1353 (gnus-group-insert-group-line
1354 group (gnus-info-level info)
1355 (gnus-info-marks info) unread (gnus-info-method info)))))
1357 ;; List dead groups.
1358 (when (or gnus-group-listed-groups
1359 (and (>= level gnus-level-zombie)
1360 (<= lowest gnus-level-zombie)))
1361 (gnus-group-prepare-flat-list-dead
1362 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1363 gnus-level-zombie ?Z
1366 (dolist (group gnus-zombie-list)
1367 (setq not-in-list (delete group not-in-list))))
1368 (when (or gnus-group-listed-groups
1369 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1370 (gnus-group-prepare-flat-list-dead
1373 (setq gnus-killed-list (sort gnus-killed-list 'string<))
1375 gnus-level-killed ?K regexp))
1377 (gnus-group-set-mode-line)
1378 (setq gnus-group-list-mode (cons level predicate))
1379 (gnus-run-hooks 'gnus-group-prepare-hook)
1382 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1383 ;; List zombies and killed lists somewhat faster, which was
1384 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1385 ;; this by ignoring the group format specification altogether.
1387 (if (> (length groups) gnus-group-listing-limit)
1389 (setq group (pop groups))
1390 (when (gnus-group-prepare-logic
1393 (and (stringp regexp) (string-match regexp group))
1394 (and (functionp regexp) (funcall regexp group))))
1395 (add-text-properties
1396 (point) (prog1 (1+ (point))
1397 (insert " " mark " *: "
1398 (gnus-group-decoded-name group)
1400 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1402 'gnus-level level))))
1404 (setq group (pop groups))
1405 (when (gnus-group-prepare-logic
1408 (and (stringp regexp) (string-match regexp group))
1409 (and (functionp regexp) (funcall regexp group))))
1410 (gnus-group-insert-group-line
1412 (let ((active (gnus-active group)))
1414 (if (zerop (cdr active))
1416 (- (1+ (cdr active)) (car active)))
1418 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1420 (defun gnus-group-update-group-line ()
1421 "Update the current line in the group buffer."
1422 (let* ((buffer-read-only nil)
1423 (group (gnus-group-group-name))
1424 (entry (and group (gnus-group-entry group)))
1425 gnus-group-indentation)
1428 (not (gnus-ephemeral-group-p group))
1430 (concat "(gnus-group-set-info '"
1431 (gnus-prin1-to-string (nth 2 entry))
1433 (concat "^(gnus-group-set-info '(\"" (regexp-quote group) "\"")))
1434 (setq gnus-group-indentation (gnus-group-group-indentation))
1436 (gnus-group-insert-group-line-info group)
1438 (gnus-group-position-point))))
1440 (defun gnus-group-insert-group-line-info (group)
1441 "Insert GROUP on the current line."
1442 (let ((entry (gnus-group-entry group))
1443 (gnus-group-indentation (gnus-group-group-indentation))
1447 ;; (Un)subscribed group.
1448 (setq info (nth 2 entry))
1449 (gnus-group-insert-group-line
1450 group (gnus-info-level info) (gnus-info-marks info)
1451 (or (car entry) t) (gnus-info-method info)))
1452 ;; This group is dead.
1453 (gnus-group-insert-group-line
1455 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1457 (if (setq active (gnus-active group))
1458 (if (zerop (cdr active))
1460 (- (1+ (cdr active)) (car active)))
1462 (gnus-method-simplify (gnus-find-method-for-group group))))))
1464 (defun gnus-number-of-unseen-articles-in-group (group)
1465 (let* ((info (nth 2 (gnus-group-entry group)))
1466 (marked (gnus-info-marks info))
1467 (seen (cdr (assq 'seen marked)))
1468 (active (gnus-active group)))
1471 (length (gnus-uncompress-range
1472 (gnus-range-difference
1473 (gnus-range-difference (list active) (gnus-info-read info))
1476 ;; Moving through the Group buffer (in topic mode) e.g. with C-n doesn't
1477 ;; update the state (enabled/disabled) of the icon `gnus-group-describe-group'
1478 ;; automatically. After `C-l' the state is correct. See the following report
1480 ;; <http://thread.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de>:
1481 ;; From: Reiner Steib
1482 ;; Subject: tool bar icons not updated according to :active condition
1483 ;; Newsgroups: gmane.emacs.devel
1484 ;; Date: Mon, 23 Jan 2006 19:59:13 +0100
1485 ;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
1487 ;; Using `redraw-frame' (see `gnus-tool-bar-update') in Emacs might
1488 ;; be confusing, so maybe we shouldn't call it by default.
1489 (defcustom gnus-group-update-tool-bar (and (boundp 'tool-bar-mode)
1491 "Force updating the group buffer tool bar."
1494 :initialize 'custom-initialize-default
1495 :set (lambda (symbol value)
1496 (set-default symbol value)
1497 (when (gnus-alive-p)
1498 (with-current-buffer gnus-group-buffer
1499 ;; FIXME: Is there a better way to redraw the group buffer?
1500 (gnus-group-get-new-news 0))))
1503 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1504 gnus-tmp-marked number
1506 "Insert a group line in the group buffer."
1507 (let* ((gnus-tmp-method
1508 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1509 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1511 (gnus-tmp-active (gnus-active gnus-tmp-group))
1512 (gnus-tmp-number-total
1514 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1516 (gnus-tmp-number-of-unread
1517 (if (numberp number) (int-to-string (max 0 number))
1519 (gnus-tmp-number-of-read
1520 (if (numberp number)
1521 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1523 (gnus-tmp-subscribed
1524 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1525 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1526 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1528 (gnus-tmp-qualified-group
1529 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1530 group-name-charset))
1532 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1534 (gnus-tmp-newsgroup-description
1535 (if gnus-description-hashtb
1536 (or (gnus-group-name-decode
1537 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1538 group-name-charset) "")
1541 (if (and gnus-moderated-hashtb
1542 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1544 (gnus-tmp-moderated-string
1545 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1546 (gnus-tmp-group-icon (gnus-group-get-icon gnus-tmp-group))
1547 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1548 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1549 (gnus-tmp-news-method-string
1551 (format "(%s:%s)" (car gnus-tmp-method)
1552 (cadr gnus-tmp-method)) ""))
1553 (gnus-tmp-marked-mark
1554 (if (and (numberp number)
1556 (cdr (assq 'tick gnus-tmp-marked)))
1558 (gnus-tmp-summary-live
1559 (if (and (not gnus-group-is-exiting-p)
1560 (gnus-buffer-live-p (gnus-summary-buffer-name
1563 (gnus-tmp-process-marked
1564 (if (member gnus-tmp-group gnus-group-marked)
1565 gnus-process-mark ? ))
1566 (buffer-read-only nil)
1568 gnus-tmp-header) ; passed as parameter to user-funcs.
1571 (add-text-properties
1575 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1576 gnus-tmp-group group-name-charset)))
1577 (eval gnus-group-line-format-spec)))
1578 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1579 gnus-unread ,(if (numberp number)
1580 (string-to-number gnus-tmp-number-of-unread)
1582 gnus-marked ,gnus-tmp-marked-mark
1583 gnus-indentation ,gnus-group-indentation
1584 gnus-level ,gnus-tmp-level))
1586 (gnus-group--setup-tool-bar-update beg end)
1588 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1589 (gnus-group-highlight-line gnus-tmp-group beg end))
1590 (gnus-run-hooks 'gnus-group-update-hook)
1593 (defun gnus-group--setup-tool-bar-update (beg end)
1594 (when gnus-group-update-tool-bar
1595 (if (fboundp 'cursor-sensor-mode)
1597 (unless (bound-and-true-p cursor-sensor-mode)
1598 (cursor-sensor-mode 1))
1599 (put-text-property beg end 'cursor-sensor-functions
1600 '(gnus-tool-bar-update)))
1601 (put-text-property beg end 'point-entered
1602 #'gnus-tool-bar-update)
1603 (put-text-property beg end 'point-left
1604 #'gnus-tool-bar-update))))
1606 (defun gnus-group-update-eval-form (group list)
1607 "Eval `car' of each element of LIST, and return the first that return t.
1608 Some value are bound so the form can use them."
1610 (let* ((entry (gnus-group-entry group))
1611 (active (gnus-active group))
1612 (info (nth 2 entry))
1613 (method (inline (gnus-server-get-method
1614 group (gnus-info-method info))))
1615 (marked (gnus-info-marks info))
1618 (cons 'unread (if (numberp (car entry)) (car entry) 0))
1619 (cons 'total (if active (1+ (- (cdr active) (car active))) 0))
1626 (car (or method gnus-select-method)))
1627 gnus-valid-select-methods)))
1628 '(mail post-mail))))
1629 (cons 'level (or (gnus-info-level info) gnus-level-killed))
1630 (cons 'score (or (gnus-info-score info) 0))
1631 (cons 'ticked (gnus-range-length (cdr (assq 'tick marked))))
1632 (cons 'group-age (gnus-group-timestamp-delta group)))))
1634 (not (eval (caar list) env)))
1635 (setq list (cdr list)))
1638 (defun gnus-group-highlight-line (group beg end)
1639 "Highlight the current line according to `gnus-group-highlight'.
1640 GROUP is current group, and the line to highlight starts at BEG
1642 (let ((face (cdar (gnus-group-update-eval-form
1644 gnus-group-highlight))))
1645 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces
1647 (let ((inhibit-read-only t))
1648 (gnus-put-text-property-excluding-characters-with-faces
1650 (if (boundp face) (symbol-value face) face))))))
1652 (defun gnus-group-get-icon (group)
1653 "Return an icon for GROUP according to `gnus-group-icon-list'."
1654 (if gnus-group-icon-list
1656 (cdar (gnus-group-update-eval-form group gnus-group-icon-list))))
1661 (gnus-create-image (expand-file-name image-path))
1667 (defun gnus-group-refresh-group (group)
1668 (gnus-activate-group group)
1669 (gnus-get-unread-articles-in-group (gnus-get-info group)
1670 (gnus-active group))
1671 (gnus-group-update-group group))
1673 (defun gnus-group-update-group (group &optional visible-only
1675 "Update all lines where GROUP appear.
1676 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1677 already. If INFO-UNCHANGED is non-nil, dribble buffer is not updated."
1678 (with-current-buffer gnus-group-buffer
1680 ;; The buffer may be narrowed.
1683 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1685 found buffer-read-only)
1686 (unless info-unchanged
1687 ;; Enter the current status into the dribble buffer.
1688 (let ((entry (gnus-group-entry group)))
1690 (not (gnus-ephemeral-group-p group)))
1692 (concat "(gnus-group-set-info '"
1693 (gnus-prin1-to-string (nth 2 entry))
1695 (concat "^(gnus-group-set-info '(\""
1696 (regexp-quote group) "\"")))))
1697 ;; Find all group instances. If topics are in use, each group
1698 ;; may be listed in more than once.
1699 (while (setq loc (text-property-any
1700 loc (point-max) 'gnus-group ident))
1703 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1705 (gnus-group-insert-group-line-info group)
1708 (gnus-run-hooks 'gnus-group-update-group-hook)))
1709 (setq loc (1+ loc)))
1710 (unless (or found visible-only)
1711 ;; No such line in the buffer, find out where it's supposed to
1712 ;; go, and insert it there (or at the end of the buffer).
1713 (if gnus-goto-missing-group-function
1714 (funcall gnus-goto-missing-group-function group)
1715 (let ((entry (cddr (gnus-group-entry group))))
1716 (while (and entry (car entry)
1720 (point-min) (point-max)
1721 'gnus-group (gnus-intern-safe
1723 gnus-active-hashtb)))))
1724 (setq entry (cdr entry)))
1725 (or entry (goto-char (point-max)))))
1726 ;; Finally insert the line.
1727 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1728 (gnus-group-insert-group-line-info group)
1731 (gnus-run-hooks 'gnus-group-update-group-hook))))
1732 (when gnus-group-update-group-function
1733 (funcall gnus-group-update-group-function group))
1734 (gnus-group-set-mode-line))))))
1736 (defun gnus-group-set-mode-line ()
1737 "Update the mode line in the group buffer."
1738 (when (memq 'group gnus-updated-mode-lines)
1739 ;; Yes, we want to keep this mode line updated.
1740 (with-current-buffer gnus-group-buffer
1741 (let* ((gformat (or gnus-group-mode-line-format-spec
1742 (gnus-set-format 'group-mode)))
1743 (gnus-tmp-news-server (cadr gnus-select-method))
1744 (gnus-tmp-news-method (car gnus-select-method))
1745 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1747 gnus-tmp-header ;Dummy binding for user-defined formats
1748 ;; Get the resulting string.
1750 (and gnus-dribble-buffer
1751 (buffer-name gnus-dribble-buffer)
1752 (buffer-modified-p gnus-dribble-buffer)
1753 (with-current-buffer gnus-dribble-buffer
1754 (not (zerop (buffer-size))))))
1755 (mode-string (eval gformat)))
1756 ;; Say whether the dribble buffer has been modified.
1757 (setq mode-line-modified
1758 (if modified "**" "--"))
1759 ;; If the line is too long, we chop it off.
1760 (when (> (length mode-string) max-len)
1761 (setq mode-string (substring mode-string 0 (- max-len 4))))
1763 (setq mode-line-buffer-identification
1764 (gnus-mode-line-buffer-identification
1765 (list mode-string)))
1766 (set-buffer-modified-p modified))))))
1768 (defun gnus-group-group-name ()
1769 "Get the name of the newsgroup on the current line."
1770 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1774 (symbol-name group)))))
1776 (defun gnus-group-group-level ()
1777 "Get the level of the newsgroup on the current line."
1778 (get-text-property (point-at-bol) 'gnus-level))
1780 (defun gnus-group-group-indentation ()
1781 "Get the indentation of the newsgroup on the current line."
1782 (or (get-text-property (point-at-bol) 'gnus-indentation)
1783 (and gnus-group-indentation-function
1784 (funcall gnus-group-indentation-function))
1787 (defun gnus-group-group-unread ()
1788 "Get the number of unread articles of the newsgroup on the current line."
1789 (get-text-property (point-at-bol) 'gnus-unread))
1791 (defun gnus-group-new-mail (group)
1792 (if (nnmail-new-mail-p (gnus-group-real-name group))
1796 (defun gnus-group-level (group)
1797 "Return the estimated level of GROUP."
1798 (or (gnus-info-level (gnus-get-info group))
1799 (and (member group gnus-zombie-list) gnus-level-zombie)
1802 (defun gnus-group-search-forward (&optional backward all level first-too)
1803 "Find the next newsgroup with unread articles.
1804 If BACKWARD is non-nil, find the previous newsgroup instead.
1805 If ALL is non-nil, just find any newsgroup.
1806 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1808 If FIRST-TOO, the current line is also eligible as a target."
1809 (let ((way (if backward -1 1))
1810 (low gnus-level-killed)
1813 (if (and backward (progn (beginning-of-line)) (bobp))
1822 (get-text-property (point) 'gnus-group)
1826 (get-text-property (point) 'gnus-unread)))
1827 (and (numberp unread) (> unread 0)))
1828 (setq lev (get-text-property (point)
1830 (<= lev gnus-level-subscribed)))
1832 (and (setq lev (get-text-property (point)
1841 (zerop (forward-line way)))))
1843 (progn (gnus-group-position-point) t)
1844 (goto-char (or pos beg))
1847 (defun gnus-total-fetched-for (group)
1848 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1849 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1850 (size (+ size-in-cache size-in-agent))
1851 (suffix '("B" "K" "M" "G"))
1854 (while (> size cutoff)
1855 (setq size (/ size scale)
1856 suffix (cdr suffix)))
1857 (format "%5.1f%s" size (car suffix))))
1859 ;;; Gnus group mode commands
1863 (defun gnus-group-mark-line-p ()
1866 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1867 (eq (char-after) gnus-process-mark)))
1869 (defun gnus-group-mark-group (n &optional unmark no-advance)
1870 "Mark the current group."
1872 (let ((buffer-read-only nil)
1876 (when (setq group (gnus-group-group-name))
1877 ;; Go to the mark position.
1879 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1883 (setq gnus-group-marked (delete group gnus-group-marked))
1884 (insert-char ? 1 t))
1885 (setq gnus-group-marked
1886 (cons group (delete group gnus-group-marked)))
1887 (insert-char gnus-process-mark 1 t)))
1889 (gnus-group-next-group 1))
1891 (gnus-group-position-point)
1894 (defun gnus-group-unmark-group (n)
1895 "Remove the mark from the current group."
1897 (gnus-group-mark-group n 'unmark)
1898 (gnus-group-position-point))
1900 (defun gnus-group-unmark-all-groups ()
1901 "Unmark all groups."
1904 (mapc 'gnus-group-remove-mark gnus-group-marked))
1905 (gnus-group-position-point))
1907 (defun gnus-group-mark-region (unmark beg end)
1908 "Mark all groups between point and mark.
1909 If UNMARK, remove the mark instead."
1910 (interactive "P\nr")
1911 (let ((num (count-lines beg end)))
1914 (- num (gnus-group-mark-group num unmark)))))
1916 (defun gnus-group-mark-buffer (&optional unmark)
1917 "Mark all groups in the buffer.
1918 If UNMARK, remove the mark instead."
1920 (gnus-group-mark-region unmark (point-min) (point-max)))
1922 (defun gnus-group-mark-regexp (regexp)
1923 "Mark all groups that match some regexp."
1924 (interactive "sMark (regexp): ")
1925 (let ((alist (cdr gnus-newsrc-alist))
1929 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1930 (gnus-group-jump-to-group group)
1931 (gnus-group-set-mark group)))))
1932 (gnus-group-position-point))
1934 (defun gnus-group-remove-mark (group &optional test-marked)
1935 "Remove the process mark from GROUP and move point there.
1936 Return nil if the group isn't displayed."
1937 (if (gnus-group-goto-group group nil test-marked)
1939 (gnus-group-mark-group 1 'unmark t)
1941 (setq gnus-group-marked
1942 (delete group gnus-group-marked))
1945 (defun gnus-group-set-mark (group)
1946 "Set the process mark on GROUP."
1947 (if (gnus-group-goto-group group)
1949 (gnus-group-mark-group 1 nil t))
1950 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1952 (defun gnus-group-universal-argument (arg &optional groups func)
1953 "Perform any command on all groups according to the process/prefix convention."
1955 (if (eq (setq func (or func
1958 (substitute-command-keys
1959 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1961 (gnus-error 1 "Undefined key")
1962 (gnus-group-iterate arg
1964 (command-execute func))))
1965 (gnus-group-position-point))
1967 (defun gnus-group-process-prefix (n)
1968 "Return a list of groups to work on.
1969 Take into consideration N (the prefix) and the list of marked groups."
1972 (setq n (prefix-numeric-value n))
1973 ;; There is a prefix, so we return a list of the N next
1975 (let ((way (if (< n 0) -1 1))
1980 (if (setq group (gnus-group-group-name))
1981 (push group groups))
1983 (gnus-group-next-group way)))
1985 ((and transient-mark-mode mark-active (mark))
1986 ;; Work on the region between point and mark.
1987 (let ((max (max (point) (mark)))
1990 (goto-char (min (point) (mark)))
1993 (push (gnus-group-group-name) groups)
1994 (zerop (gnus-group-next-group 1))
1996 (nreverse groups))))
1998 ;; No prefix, but a list of marked articles.
1999 (reverse gnus-group-marked))
2001 ;; Neither marked articles or a prefix, so we return the
2003 (let ((group (gnus-group-group-name)))
2004 (and group (list group))))))
2006 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
2007 ;;; imagine why I went through these contortions...
2009 (let ((function (make-symbol "gnus-group-iterate-function"))
2010 (window (make-symbol "gnus-group-iterate-window"))
2011 (groups (make-symbol "gnus-group-iterate-groups"))
2012 (group (make-symbol "gnus-group-iterate-group")))
2014 `(defun gnus-group-iterate (arg ,function)
2015 "Iterate FUNCTION over all process/prefixed groups.
2016 FUNCTION will be called with the group name as the parameter
2017 and with point over the group in question."
2018 (let ((,groups (gnus-group-process-prefix arg))
2019 (,window (selected-window))
2022 (setq ,group (car ,groups)
2023 ,groups (cdr ,groups))
2024 (select-window ,window)
2025 (gnus-group-remove-mark ,group)
2026 (save-selected-window
2028 (funcall ,function ,group)))))))))
2030 (put 'gnus-group-iterate 'lisp-indent-function 1)
2032 ;; Selecting groups.
2034 (defun gnus-group-read-group (&optional all no-article group select-articles)
2035 "Read news in this newsgroup.
2036 If the prefix argument ALL is non-nil, already read articles become
2039 If ALL is a positive number, fetch this number of the latest
2040 articles in the group. If ALL is a negative number, fetch this
2041 number of the earliest articles in the group.
2043 If the optional argument NO-ARTICLE is non-nil, no article will
2044 be auto-selected upon group entry. If GROUP is non-nil, fetch
2047 (let ((no-display (eq all 0))
2048 (group (or group (gnus-group-group-name)))
2049 number active marked entry)
2053 (error "No group on current line"))
2054 (setq marked (gnus-info-marks
2055 (nth 2 (setq entry (gnus-group-entry group)))))
2056 ;; This group might be a dead group. In that case we have to get
2057 ;; the number of unread articles from `gnus-active-hashtb'.
2059 (cond ((numberp all) all)
2061 ((setq active (gnus-active group))
2062 (- (1+ (cdr active)) (car active)))))
2063 (gnus-summary-read-group
2064 group (or all (and (numberp number)
2065 (zerop (+ number (gnus-range-length
2066 (cdr (assq 'tick marked)))
2068 (cdr (assq 'dormant marked)))))))
2069 no-article nil no-display nil select-articles)))
2071 (defun gnus-group-select-group (&optional all)
2072 "Select this newsgroup.
2073 No article is selected automatically.
2074 If the group is opened, just switch the summary buffer.
2075 If ALL is non-nil, already read articles become readable.
2076 If ALL is a positive number, fetch this number of the latest
2077 articles in the group.
2078 If ALL is a negative number, fetch this number of the earliest
2079 articles in the group."
2081 (when (and (eobp) (not (gnus-group-group-name)))
2083 (gnus-group-read-group all t))
2085 (defun gnus-group-quick-select-group (&optional all group)
2086 "Select the GROUP \"quickly\".
2087 This means that no highlighting or scoring will be performed. If
2088 ALL (the prefix argument) is 0, don't even generate the summary
2089 buffer. If GROUP is nil, use current group.
2091 This might be useful if you want to toggle threading
2092 before entering the group."
2094 (require 'gnus-score)
2096 gnus-score-find-score-files-function
2097 gnus-home-score-file
2098 gnus-apply-kill-hook
2099 gnus-summary-expunge-below)
2100 (gnus-group-read-group all t group)))
2102 (defun gnus-group-visible-select-group (&optional all)
2103 "Select the current group without hiding any articles."
2105 (let ((gnus-inhibit-limiting t))
2106 (gnus-group-read-group all t)))
2108 (defun gnus-group-select-group-ephemerally ()
2109 "Select the current group without doing any processing whatsoever.
2110 You will actually be entered into a group that's a copy of
2111 the current group; no changes you make while in this group will
2114 (require 'gnus-score)
2116 gnus-score-find-score-files-function gnus-apply-kill-hook
2117 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2118 gnus-summary-mode-hook gnus-select-group-hook
2119 (group (gnus-group-group-name))
2120 (method (gnus-find-method-for-group group)))
2121 (gnus-group-read-ephemeral-group
2122 (gnus-group-prefixed-name group method) method)))
2124 (defun gnus-group-name-at-point ()
2125 "Return a group name from around point if it exists, or nil."
2126 (if (derived-mode-p 'gnus-group-mode)
2127 (let ((group (gnus-group-group-name)))
2129 (gnus-group-decoded-name group)))
2130 (let ((regexp "[][\C-@-\t\v-*,/:-@\\^`{-\C-?]*\
2131 \\(nn[a-z]+\\(?:\\+[^][\C-@-*,/:-@\\^`{-\C-?]+\\)?:\
2132 [^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)*\
2133 \\|[^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)+\\)")
2135 (case-fold-search nil))
2137 (if (or (and (not (or (eobp)
2138 (looking-at "[][\C-@-*,/;-@\\^`{-\C-?]")))
2140 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2142 (and (looking-at "[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*$")
2144 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2145 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2147 (string-match "\\`[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*\\'"
2148 (buffer-substring (point-at-bol) (point))))
2149 (when (looking-at regexp)
2151 (let (group distance)
2152 (when (looking-at regexp)
2153 (setq group (match-string 1)
2154 distance (- (match-beginning 1) (match-beginning 0))))
2155 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2156 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2158 (if (looking-at regexp)
2159 (if (and group (<= distance (- start (match-end 0))))
2163 (goto-char start)))))
2165 (defun gnus-group-completing-read (&optional prompt collection
2166 require-match initial-input hist
2168 "Read a group name with completion. Non-ASCII group names are allowed.
2169 The arguments are the same as `completing-read' except that COLLECTION
2170 and HIST default to `gnus-active-hashtb' and `gnus-group-history'
2171 respectively if they are omitted. Regards COLLECTION as a hash table
2172 if it is not a list."
2173 (or collection (setq collection gnus-active-hashtb))
2174 (let (choices group)
2175 (if (listp collection)
2176 (dolist (symbol collection)
2177 (setq group (symbol-name symbol))
2178 (push (if (string-match "[^\000-\177]" group)
2179 (gnus-group-decoded-name group)
2182 (mapatoms (lambda (symbol)
2183 (setq group (symbol-name symbol))
2184 (push (if (string-match "[^\000-\177]" group)
2185 (gnus-group-decoded-name group)
2189 (setq group (gnus-completing-read (or prompt "Group") (nreverse choices)
2190 require-match initial-input
2191 (or hist 'gnus-group-history)
2193 (unless (if (listp collection)
2194 (member group (mapcar 'symbol-name collection))
2195 (symbol-value (intern-soft group collection)))
2197 (encode-coding-string
2198 group (gnus-group-name-charset nil group))))
2199 (replace-regexp-in-string "\n" "" group)))
2202 (defun gnus-fetch-group (group &optional articles)
2203 "Start Gnus if necessary and enter GROUP.
2204 If ARTICLES, display those articles.
2205 Returns whether the fetching was successful or not."
2206 (interactive (list (gnus-group-completing-read nil
2208 (gnus-group-name-at-point))))
2209 (unless (gnus-alive-p)
2211 (gnus-group-read-group (if articles nil t) nil group articles))
2214 (defun gnus-fetch-group-other-frame (group)
2215 "Pop up a frame and enter GROUP."
2217 (let ((window (get-buffer-window gnus-group-buffer)))
2219 (select-frame (window-frame window)))
2220 ((= (length (frame-list)) 1)
2221 (select-frame (make-frame)))
2224 (gnus-fetch-group group))
2226 (defcustom gnus-large-ephemeral-newsgroup 200
2227 "The number of articles which indicates a large ephemeral newsgroup.
2228 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2230 If the number of articles in a newsgroup is greater than this value,
2231 confirmation is required for selecting the newsgroup. If it is nil, no
2232 confirmation is required."
2234 :group 'gnus-group-select
2235 :type '(choice (const :tag "No limit" nil)
2238 (defcustom gnus-fetch-old-ephemeral-headers nil
2239 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2242 :type '(choice (const :tag "off" nil)
2245 (sexp :menu-tag "other" t)))
2247 ;; Enter a group that is not in the group buffer. Non-nil is returned
2248 ;; if selection was successful.
2249 (defun gnus-group-read-ephemeral-group (group method &optional activate
2250 quit-config request-only
2254 "Read GROUP from METHOD as an ephemeral group.
2255 If ACTIVATE, request the group first.
2256 If QUIT-CONFIG, use that Gnus window configuration name when
2257 exiting from the ephemeral group.
2258 If REQUEST-ONLY, don't actually read the group; just request it.
2259 If SELECT-ARTICLES, only select those articles.
2260 If PARAMETERS, use those as the group parameters.
2261 If NUMBER, fetch this number of articles.
2263 Return the name of the group if selection was successful."
2266 ;; (gnus-read-group "Group name: ")
2267 (gnus-group-completing-read)
2268 (gnus-read-method "From method")))
2269 (unless (gnus-alive-p)
2270 (nnheader-init-server-buffer)
2271 ;; Necessary because of funky inlining.
2272 (require 'gnus-cache)
2273 (setq gnus-newsrc-hashtb (gnus-make-hashtable)))
2274 ;; Transform the select method into a unique server.
2275 (when (stringp method)
2276 (setq method (gnus-server-to-method method)))
2278 (intern (format "%s-address" (car method)))))
2280 (if (assq address-slot (cddr method))
2281 `(,(car method) ,(concat (cadr method) "-ephemeral")
2283 `(,(car method) ,(concat (cadr method) "-ephemeral")
2284 (,address-slot ,(cadr method))
2286 (let ((group (if (gnus-group-foreign-p group) group
2287 (gnus-group-prefixed-name (gnus-group-real-name group)
2289 (gnus-set-active group nil)
2293 ,gnus-level-default-subscribed nil nil ,method
2299 ((assq gnus-current-window-configuration
2300 gnus-buffer-configuration)
2301 (cons gnus-summary-buffer
2302 gnus-current-window-configuration))
2304 (cons (current-buffer)
2305 (current-window-configuration)))))
2308 (push method gnus-ephemeral-servers)
2309 (when (gnus-buffer-live-p gnus-group-buffer)
2310 (set-buffer gnus-group-buffer))
2311 (unless (gnus-check-server method)
2312 (error "Unable to contact server: %s" (gnus-status-message method)))
2314 (gnus-activate-group group 'scan)
2315 (unless (gnus-request-group group)
2316 (error "Couldn't request group: %s"
2317 (nnheader-get-report (car method)))))
2321 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2322 (gnus-fetch-old-headers
2323 gnus-fetch-old-ephemeral-headers))
2324 (gnus-group-read-group (or number t) t group select-articles))
2329 (message "Quit reading the ephemeral group"))
2332 (defcustom gnus-gmane-group-download-format
2333 "http://download.gmane.org/%s/%s/%s"
2334 "URL for downloading mbox files.
2335 It must contain three \"%s\". They correspond to the group, the
2336 minimal and maximal article numbers, respectively."
2337 :group 'gnus-group-foreign
2338 :version "23.1" ;; No Gnus
2341 (autoload 'url-insert-file-contents "url-handlers")
2343 ;; - Add documentation, menu, key bindings, ...
2345 (defun gnus-read-ephemeral-gmane-group (group start &optional range)
2346 "Read articles from Gmane group GROUP as an ephemeral group.
2347 START is the first article. RANGE specifies how many articles
2348 are fetched. The articles are downloaded via HTTP using the URL
2349 specified by `gnus-gmane-group-download-format'."
2350 ;; See <http://gmane.org/export.php> for more information.
2353 (gnus-group-completing-read "Gmane group")
2354 (read-number "Start article number: ")
2355 (read-number "How many articles: ")))
2356 (unless range (setq range 500))
2358 (error "Invalid range: %s" range))
2359 (let ((tmpfile (make-temp-file
2360 (format "%s.start-%s.range-%s." group start range)))
2361 (gnus-thread-sort-functions '(gnus-thread-sort-by-number)))
2362 (with-temp-file tmpfile
2363 (url-insert-file-contents
2364 (format gnus-gmane-group-download-format
2365 group start (+ start range)))
2366 (write-region (point-min) (point-max) tmpfile)
2367 (gnus-group-read-ephemeral-group
2368 (format "nndoc+ephemeral:%s.start-%s.range-%s" group start range)
2370 (nndoc-article-type mbox))))
2371 (delete-file tmpfile)))
2373 (defun gnus-read-ephemeral-gmane-group-url (url)
2374 "Create an ephemeral Gmane group from URL.
2376 Valid input formats include:
2377 \"http://thread.gmane.org/gmane.foo.bar/12300/focus=12399\",
2378 \"http://thread.gmane.org/gmane.foo.bar/12345/\",
2379 \"http://article.gmane.org/gmane.foo.bar/12345/\",
2380 \"http://news.gmane.org/group/gmane.foo.bar/thread=12345\""
2381 ;; - Feel free to add other useful Gmane URLs here! Maybe the URLs should
2383 ;; - The URLs should be added to `gnus-button-alist'. Probably we should
2384 ;; prompt the user to decide: "View via `browse-url' or in Gnus? "
2385 ;; (`gnus-read-ephemeral-gmane-group-url')
2387 (list (gnus-group-completing-read "Gmane URL")))
2388 (let (group start range)
2390 ;; URLs providing `group', `start' and `range':
2392 ;; http://thread.gmane.org/gmane.emacs.devel/86326/focus=86525
2393 "^http://thread\\.gmane\\.org/\\([^/]+\\)/\\([0-9]+\\)/focus=\\([0-9]+\\)$"
2395 (setq group (match-string 1 url)
2396 start (string-to-number (match-string 2 url))
2397 ;; Ensure that `range' is large enough to ensure focus article is
2399 range (- (string-to-number (match-string 3 url))
2401 ;; URLs providing `group' and `start':
2403 ;; http://article.gmane.org/gmane.comp.gnu.make.bugs/3584
2404 "^http://\\(?:thread\\|article\\|permalink\\)\\.gmane\\.org/\\([^/]+\\)/\\([0-9]+\\)"
2407 ;; Don't advertise these in the doc string yet:
2408 "^\\(?:nntp\\|news\\)://news\\.gmane\\.org/\\([^/]+\\)/\\([0-9]+\\)"
2411 ;; http://news.gmane.org/group/gmane.emacs.gnus.general/thread=65099/force_load=t
2412 "^http://news\\.gmane\\.org/group/\\([^/]+\\)/thread=\\([0-9]+\\)"
2414 (setq group (match-string 1 url)
2415 start (string-to-number (match-string 2 url))))
2417 (error "Can't parse URL %s" url)))
2418 (gnus-read-ephemeral-gmane-group group start range)))
2420 (defcustom gnus-bug-group-download-format-alist
2421 '((emacs . "http://debbugs.gnu.org/cgi/bugreport.cgi?bug=%s;mboxmaint=yes;mboxstat=yes")
2423 . "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%s&mbox=yes;mboxmaint=yes"))
2424 "Alist of symbols for bug trackers and the corresponding URL format string.
2425 The URL format string must contain a single \"%s\", specifying
2426 the bug number, and browsing the URL must return mbox output."
2427 :group 'gnus-group-foreign
2428 ;; Added mboxmaint=yes. This gets the version with the messages as
2429 ;; they went out, not as they came in.
2430 ;; Eg bug-gnu-emacs is replaced by ###@debbugs.
2432 :type '(repeat (cons (symbol) (string :tag "URL format string"))))
2434 (defun gnus-read-ephemeral-bug-group (ids mbox-url &optional window-conf)
2435 "Browse bug NUMBER as ephemeral group."
2436 (interactive (list (read-string "Enter bug number: "
2437 (thing-at-point 'word) nil)
2438 ;; FIXME: Add completing-read from
2439 ;; `gnus-emacs-bug-group-download-format' ...
2440 (cdr (assoc 'emacs gnus-bug-group-download-format-alist))))
2442 (setq ids (string-to-number ids)))
2444 (setq ids (list ids)))
2445 (let ((tmpfile (make-temp-file "gnus-temp-group-")))
2446 (let ((coding-system-for-write 'binary)
2447 (coding-system-for-read 'binary))
2448 (with-temp-file tmpfile
2449 (mm-disable-multibyte)
2451 (let ((file (format "~/.emacs.d/debbugs-cache/%s" id)))
2452 (if (and (not gnus-plugged)
2453 (file-exists-p file))
2454 (insert-file-contents file)
2455 (url-insert-file-contents (format mbox-url id)))))
2456 (goto-char (point-min))
2457 ;; Add the debbugs address so that we can respond to reports easily.
2458 (while (re-search-forward "^To: " nil t)
2460 (insert (format ", %s@%s" (car ids)
2461 (replace-regexp-in-string
2463 (replace-regexp-in-string "^http://" "" mbox-url)))))))
2464 (gnus-group-read-ephemeral-group
2465 (format "nndoc+ephemeral:bug#%s"
2466 (mapconcat 'number-to-string ids ","))
2468 (nndoc-article-type mbox))
2470 (delete-file tmpfile)))
2472 (defun gnus-read-ephemeral-debian-bug-group (number)
2473 "Browse Debian bug NUMBER as ephemeral group."
2474 (interactive (list (read-string "Enter bug number: "
2475 (thing-at-point 'word) nil)))
2476 (gnus-read-ephemeral-bug-group
2478 (cdr (assoc 'debian gnus-bug-group-download-format-alist))))
2480 (defvar debbugs-gnu-bug-number) ; debbugs-gnu
2482 (defun gnus-read-ephemeral-emacs-bug-group (ids &optional window-conf)
2483 "Browse Emacs bugs IDS as an ephemeral group."
2484 (interactive (list (string-to-number
2485 (read-string "Enter bug number: "
2486 (thing-at-point 'word) nil))))
2488 (setq ids (list ids)))
2489 (gnus-read-ephemeral-bug-group
2491 (cdr (assoc 'emacs gnus-bug-group-download-format-alist))
2493 (when (fboundp 'debbugs-gnu-summary-mode)
2494 (with-current-buffer (window-buffer (selected-window))
2495 (debbugs-gnu-summary-mode 1)
2496 (set (make-local-variable 'debbugs-gnu-bug-number) (car ids)))))
2498 (defun gnus-group-jump-to-group (group &optional prompt)
2499 "Jump to newsgroup GROUP.
2501 If PROMPT (the prefix) is a number, use the prompt specified in
2502 `gnus-group-jump-to-group-prompt'."
2504 (list (gnus-group-completing-read
2506 (if current-prefix-arg
2507 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2508 (or (and (stringp gnus-group-jump-to-group-prompt)
2509 gnus-group-jump-to-group-prompt)
2510 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2511 (and (stringp p) p)))))))
2513 (when (equal group "")
2514 (error "Empty group name"))
2516 (unless (gnus-ephemeral-group-p group)
2517 ;; Either go to the line in the group buffer...
2518 (unless (gnus-group-goto-group group)
2519 ;; ... or insert the line.
2520 (gnus-group-update-group group)
2521 (gnus-group-goto-group group)))
2522 ;; Adjust cursor point.
2523 (gnus-group-position-point))
2525 (defun gnus-group-goto-group (group &optional far test-marked)
2526 "Goto to newsgroup GROUP.
2527 If FAR, it is likely that the group is not on the current line.
2528 If TEST-MARKED, the line must be marked."
2532 ;; It's quite likely that we are on the right line, so
2533 ;; we check the current line first.
2535 (eq (get-text-property (point) 'gnus-group)
2536 (gnus-intern-safe group gnus-active-hashtb))
2537 (or (not test-marked) (gnus-group-mark-line-p)))
2539 ;; Previous and next line are also likely, so we check them as well.
2543 (and (eq (get-text-property (point) 'gnus-group)
2544 (gnus-intern-safe group gnus-active-hashtb))
2545 (or (not test-marked) (gnus-group-mark-line-p)))))
2551 (and (eq (get-text-property (point) 'gnus-group)
2552 (gnus-intern-safe group gnus-active-hashtb))
2553 (or (not test-marked) (gnus-group-mark-line-p)))))
2557 (goto-char (point-min))
2559 (while (and (not found)
2564 (gnus-intern-safe group gnus-active-hashtb))))
2565 (if (gnus-group-mark-line-p)
2570 ;; Search through the entire buffer.
2573 (point-min) (point-max)
2574 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2576 (defun gnus-group-next-group (n &optional silent)
2577 "Go to next N'th newsgroup.
2578 If N is negative, search backward instead.
2579 Returns the difference between N and the number of skips actually
2582 (gnus-group-next-unread-group n t nil silent))
2584 (defun gnus-group-next-unread-group (n &optional all level silent)
2585 "Go to next N'th unread newsgroup.
2586 If N is negative, search backward instead.
2587 If ALL is non-nil, choose any newsgroup, unread or not.
2588 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2589 such group can be found, the next group with a level higher than
2591 Returns the difference between N and the number of skips actually
2594 (let ((backward (< n 0))
2597 (gnus-group-search-forward
2598 backward (or (not gnus-group-goto-unread) all) level))
2602 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2603 (if level " on this level or higher" "")))
2606 (defun gnus-group-prev-group (n)
2607 "Go to previous N'th newsgroup.
2608 Returns the difference between N and the number of skips actually
2611 (gnus-group-next-unread-group (- n) t))
2613 (defun gnus-group-prev-unread-group (n)
2614 "Go to previous N'th unread newsgroup.
2615 Returns the difference between N and the number of skips actually
2618 (gnus-group-next-unread-group (- n)))
2620 (defun gnus-group-next-unread-group-same-level (n)
2621 "Go to next N'th unread newsgroup on the same level.
2622 If N is negative, search backward instead.
2623 Returns the difference between N and the number of skips actually
2626 (gnus-group-next-unread-group n t (gnus-group-group-level))
2627 (gnus-group-position-point))
2629 (defun gnus-group-prev-unread-group-same-level (n)
2630 "Go to next N'th unread newsgroup on the same level.
2631 Returns the difference between N and the number of skips actually
2634 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2635 (gnus-group-position-point))
2637 (defun gnus-group-best-unread-group (&optional exclude-group)
2638 "Go to the group with the highest level.
2639 If EXCLUDE-GROUP, do not go to that group."
2641 (goto-char (point-min))
2645 (setq unread (get-text-property (point) 'gnus-unread))
2646 (when (and (numberp unread) (> unread 0))
2647 (when (and (get-text-property (point) 'gnus-level)
2648 (< (get-text-property (point) 'gnus-level) best)
2649 (or (not exclude-group)
2650 (not (equal exclude-group (gnus-group-group-name)))))
2651 (setq best (get-text-property (point) 'gnus-level))
2652 (setq best-point (point))))
2655 (goto-char best-point))
2656 (gnus-group-position-point)
2657 (and best-point (gnus-group-group-name))))
2659 ;; Is there something like an after-point-motion-hook?
2660 ;; (inhibit-point-motion-hooks?). Is there a tool-bar-update function?
2662 ;; (defun gnus-group-menu-bar-update ()
2663 ;; (let* ((buf (list (with-current-buffer gnus-group-buffer
2664 ;; (current-buffer))))
2665 ;; (name (buffer-name (car buf))))
2667 ;; (if (> (length name) 27)
2668 ;; (concat (substring name 0 12)
2670 ;; (substring name -12))
2672 ;; (menu-bar-update-buffers-1 buf)))
2674 ;; (defun gnus-group-position-point ()
2675 ;; (gnus-goto-colon)
2676 ;; (gnus-group-menu-bar-update))
2678 (defun gnus-group-first-unread-group ()
2679 "Go to the first group with unread articles."
2682 (let ((opoint (point))
2684 (goto-char (point-min))
2685 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2686 (and (numberp unread) ; Not a topic.
2687 (not (zerop unread))) ; Has unread articles.
2688 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2691 nil)) ; Not success.
2692 (gnus-group-position-point)))
2694 (defun gnus-group-enter-server-mode ()
2695 "Jump to the server buffer."
2697 (gnus-enter-server-buffer))
2699 (defun gnus-group-make-group-simple (&optional group)
2700 "Add a new newsgroup.
2701 The user will be prompted for GROUP."
2702 (interactive (list (gnus-group-completing-read)))
2703 (gnus-group-make-group (gnus-group-real-name group)
2704 (gnus-group-server group)
2707 (defun gnus-group-make-group (name &optional method address args encoded)
2708 "Add a new newsgroup.
2709 The user will be prompted for a NAME, for a select METHOD, and an
2710 ADDRESS. NAME should be a human-readable string (i.e., not be encoded
2711 even if it contains non-ASCII characters) unless ENCODED is non-nil.
2713 If the backend supports it, the group will also be created on the
2717 (gnus-read-group "Group name: ")
2718 (gnus-read-method "Select method for new group (use tab for completion)")))
2720 (when (stringp method)
2721 (setq method (or (gnus-server-to-method method) method)))
2723 (setq name (encode-coding-string
2725 (gnus-group-name-charset method name))))
2726 (let* ((meth (gnus-method-simplify
2728 (not (gnus-server-equal method gnus-select-method)))
2729 (if address (list (intern method) address)
2731 (nname (if method (gnus-group-prefixed-name name meth) name))
2733 (when (gnus-group-entry nname)
2734 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2735 ;; Subscribe to the new group.
2736 (gnus-group-change-level
2737 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2738 gnus-level-default-subscribed gnus-level-killed
2739 (and (gnus-group-group-name)
2740 (gnus-group-entry (gnus-group-group-name)))
2743 (gnus-set-active nname (cons 1 0))
2744 (unless (gnus-ephemeral-group-p name)
2746 (concat "(gnus-group-set-info '"
2747 (gnus-prin1-to-string (cdr info)) ")")
2748 (concat "^(gnus-group-set-info '(\"" (regexp-quote name) "\"")))
2750 (gnus-group-insert-group-line-info nname)
2752 (gnus-group-position-point)
2754 ;; Load the back end and try to make the back end create
2755 ;; the group as well.
2756 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2758 gnus-valid-select-methods)
2760 (gnus-check-server meth)
2761 (when (gnus-check-backend-function 'request-create-group nname)
2762 (unless (gnus-request-create-group nname nil args)
2763 (error "Could not create group on server: %s"
2764 (nnheader-get-report backend))))
2767 (defun gnus-group-delete-groups (&optional arg)
2768 "Delete the current group. Only meaningful with editable groups."
2770 (let ((n (length (gnus-group-process-prefix arg))))
2771 (when (gnus-yes-or-no-p
2773 "Delete this 1 group? "
2774 (format "Delete these %d groups? " n)))
2775 (gnus-group-iterate arg
2777 (gnus-group-delete-group group nil t))))))
2779 (defun gnus-group-delete-articles (group &optional oldp)
2780 "Delete all articles in the current group.
2781 If OLDP (the prefix), only delete articles that are \"old\",
2782 according to the expiry settings. Note that this will delete old
2783 not-expirable articles, too."
2784 (interactive (list (gnus-group-group-name)
2785 current-prefix-arg))
2786 (let ((articles (gnus-uncompress-range (gnus-active group))))
2787 (when (gnus-yes-or-no-p
2788 (format "Do you really want to delete these %d articles forever? "
2790 (gnus-request-expire-articles articles group
2791 (if current-prefix-arg
2795 (defun gnus-group-delete-group (group &optional force no-prompt)
2796 "Delete the current group. Only meaningful with editable groups.
2797 If FORCE (the prefix) is non-nil, all the articles in the group will
2798 be deleted. This is \"deleted\" as in \"removed forever from the face
2799 of the Earth\". There is no undo. The user will be prompted before
2801 Note that you also have to specify FORCE if you want the group to
2802 be removed from the server, even when it's empty."
2804 (list (gnus-group-group-name)
2805 current-prefix-arg))
2807 (error "No group to delete"))
2808 (unless (gnus-check-backend-function 'request-delete-group group)
2809 (error "This back end does not support group deletion"))
2811 (let ((group-decoded (gnus-group-decoded-name group)))
2812 (if (and (not no-prompt)
2813 (not (gnus-yes-or-no-p
2815 "Do you really want to delete %s%s? "
2816 group-decoded (if force " and all its contents" "")))))
2818 (gnus-message 6 "Deleting group %s..." group-decoded)
2819 (if (not (gnus-request-delete-group group force))
2820 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2821 (gnus-message 6 "Deleting group %s...done" group-decoded)
2822 (gnus-group-goto-group group)
2823 (gnus-group-kill-group 1 t)
2824 (gnus-set-active group nil)
2826 (gnus-group-position-point)))
2828 (defun gnus-group-rename-group (group new-name)
2829 "Rename group from GROUP to NEW-NAME.
2830 When used interactively, GROUP is the group under point
2831 and NEW-NAME will be prompted for."
2833 (let ((group (gnus-group-group-name))
2835 (unless (gnus-check-backend-function 'request-rename-group group)
2836 (error "This back end does not support renaming groups"))
2837 (setq new-name (gnus-read-group
2839 (gnus-group-real-name (gnus-group-decoded-name group)))
2840 method (gnus-info-method (gnus-get-info group)))
2841 (list group (encode-coding-string
2843 (gnus-group-name-charset
2845 (gnus-group-prefixed-name new-name method))))))
2847 (unless (gnus-check-backend-function 'request-rename-group group)
2848 (error "This back end does not support renaming groups"))
2850 (error "No group to rename"))
2851 (when (equal (gnus-group-real-name group) new-name)
2852 (error "Can't rename to the same name"))
2854 ;; We find the proper prefixed name.
2856 (if (gnus-group-native-p group)
2860 (gnus-group-prefixed-name
2861 (gnus-group-real-name new-name)
2862 (gnus-info-method (gnus-get-info group)))))
2864 (let ((decoded-group (gnus-group-decoded-name group))
2865 (decoded-new-name (gnus-group-decoded-name new-name)))
2866 (when (gnus-active new-name)
2867 (error "The group %s already exists" decoded-new-name))
2869 (gnus-message 6 "Renaming group %s to %s..."
2870 decoded-group decoded-new-name)
2873 (gnus-group-goto-group group)
2874 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2875 (gnus-request-rename-group group new-name))))
2876 (gnus-error 3 "Couldn't rename group %s to %s"
2877 decoded-group decoded-new-name)
2878 ;; We rename the group internally by killing it...
2879 (gnus-group-kill-group)
2880 ;; ... changing its name ...
2881 (setcar (cdar gnus-list-of-killed-groups) new-name)
2882 ;; ... and then yanking it. Magic!
2883 (gnus-group-yank-group)
2884 (gnus-set-active new-name (gnus-active group))
2885 (gnus-message 6 "Renaming group %s to %s...done"
2886 decoded-group decoded-new-name)
2888 (setq gnus-killed-list (delete group gnus-killed-list))
2889 (gnus-set-active group nil)
2890 (gnus-dribble-touch)
2891 (gnus-group-position-point))))
2893 (defun gnus-group-edit-group (group &optional part)
2894 "Edit the group on the current line."
2895 (interactive (list (gnus-group-group-name)))
2896 (let ((part (or part 'info))
2899 (error "No group on current line"))
2900 (unless (setq info (gnus-get-info group))
2901 (error "Killed group; can't be edited"))
2903 (gnus-close-group group))
2905 ;; Find the proper form to edit.
2906 (cond ((eq part 'method)
2907 (or (gnus-info-method info) "native"))
2909 (gnus-info-params info))
2911 ;; The proper documentation.
2913 "Editing the %s for `%s'."
2915 ((eq part 'method) "select method")
2916 ((eq part 'params) "group parameters")
2918 (gnus-group-decoded-name group))
2920 (gnus-group-edit-group-done ',part ,group form)))
2923 (gnus-create-info-command
2926 "(gnus)Select Methods")
2928 "(gnus)Group Parameters")
2930 "(gnus)Group Info"))))))
2932 (defun gnus-group-edit-group-method (group)
2933 "Edit the select method of GROUP."
2934 (interactive (list (gnus-group-group-name)))
2935 (gnus-group-edit-group group 'method))
2937 (defun gnus-group-edit-group-parameters (group)
2938 "Edit the group parameters of GROUP."
2939 (interactive (list (gnus-group-group-name)))
2940 (gnus-group-edit-group group 'params))
2942 (defun gnus-group-edit-group-done (part group form)
2944 (let* ((method (cond ((eq part 'info) (nth 4 form))
2945 ((eq part 'method) form)
2947 (info (cond ((eq part 'info) form)
2948 ((eq part 'method) (gnus-get-info group))
2951 (if (or (not method)
2953 gnus-select-method method))
2954 (gnus-group-real-name (car info))
2955 (gnus-group-prefixed-name
2956 (gnus-group-real-name (car info)) method))
2958 (when (and new-group
2959 (not (equal new-group group)))
2960 (when (gnus-group-goto-group group)
2961 (gnus-group-kill-group 1))
2962 (gnus-activate-group new-group))
2964 (if (not (and info new-group))
2965 (gnus-group-set-info form (or new-group group) part)
2966 (setq info (gnus-copy-sequence info))
2967 (setcar info new-group)
2968 (unless (gnus-server-equal method "native")
2969 (unless (nthcdr 3 info)
2970 (nconc info (list nil nil)))
2971 (unless (nthcdr 4 info)
2972 (nconc info (list nil)))
2973 (gnus-info-set-method info method))
2974 (gnus-group-set-info info))
2975 (gnus-group-update-group (or new-group group))
2976 (gnus-group-position-point)))
2978 (defun gnus-group-make-useful-group (group method)
2979 "Create one of the groups described in `gnus-useful-groups'."
2981 (let ((entry (assoc (gnus-completing-read "Create group"
2982 (mapcar 'car gnus-useful-groups)
2984 gnus-useful-groups)))
2986 ;; Don't use `caddr' here since macros within the `interactive'
2987 ;; form won't be expanded.
2988 (car (cddr entry)))))
2989 (setq method (gnus-copy-sequence method))
2991 (while (setq entry (memq (assq 'eval method) method))
2992 (setcar entry (eval (cadar entry)))))
2993 (gnus-group-make-group group method))
2995 (defun gnus-group-make-help-group (&optional noerror)
2996 "Create the Gnus documentation group.
2997 Optional argument NOERROR modifies the behavior of this function when the
2998 group already exists:
2999 - if not given, and error is signaled,
3000 - if t, stay silent,
3001 - if anything else, just print a message."
3003 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
3004 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
3005 (if (gnus-group-entry name)
3006 (cond ((eq noerror nil)
3007 (error "Documentation group already exists"))
3012 (gnus-message 1 "Documentation group already exists")))
3015 (gnus-message 1 "Couldn't find doc group")
3016 (gnus-group-make-group
3017 (gnus-group-real-name name)
3018 (list 'nndoc "gnus-help"
3019 (list 'nndoc-address file)
3020 (list 'nndoc-article-type 'mbox))))
3022 (gnus-group-position-point))
3024 (defun gnus-group-make-doc-group (file type)
3025 "Create a group that uses a single file as the source.
3027 If called with a prefix argument, ask for the file type."
3029 (list (read-file-name "File name: ")
3030 (and current-prefix-arg 'ask)))
3031 (when (eq type 'ask)
3036 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
3038 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
3039 ((= char ?b) 'babyl)
3040 ((= char ?d) 'digest)
3041 ((= char ?f) 'forward)
3043 ((= char ?g) 'guess)
3044 (t (setq err (format "%c unknown. " char))
3047 (setq file (expand-file-name file))
3048 (let* ((name (gnus-generate-new-group-name
3049 (gnus-group-prefixed-name
3050 (file-name-nondirectory file) '(nndoc ""))))
3051 (method (list 'nndoc file
3052 (list 'nndoc-address file)
3053 (list 'nndoc-article-type (or type 'guess))))
3054 (coding (gnus-group-name-charset method name)))
3055 (setcar (cdr method) (encode-coding-string file coding))
3056 (gnus-group-make-group
3057 (encode-coding-string (gnus-group-real-name name) coding)
3060 (defvar nnweb-type-definition)
3061 (defvar gnus-group-web-type-history nil)
3062 (defvar gnus-group-web-search-history nil)
3063 (defun gnus-group-make-web-group (&optional solid)
3064 "Create an ephemeral nnweb group.
3065 If SOLID (the prefix), create a solid group."
3069 (if solid (gnus-read-group "Group name: ")
3070 (message-unique-id)))
3071 (default-type (or (car gnus-group-web-type-history)
3072 (symbol-name (caar nnweb-type-definition))))
3075 (gnus-completing-read
3076 "Search engine type"
3077 (mapcar (lambda (elem) (symbol-name (car elem)))
3078 nnweb-type-definition)
3079 t nil 'gnus-group-web-type-history)
3084 (cons (or (car gnus-group-web-search-history) "") 0)
3085 'gnus-group-web-search-history))
3087 `(nnweb ,group (nnweb-search ,search)
3088 (nnweb-type ,(intern type))
3089 (nnweb-ephemeral-p t))))
3092 (gnus-alist-pull 'nnweb-ephemeral-p method)
3093 (gnus-group-make-group group method))
3094 (gnus-group-read-ephemeral-group
3096 (cons (current-buffer)
3097 (if (derived-mode-p 'gnus-summary-mode) 'summary 'group))))))
3099 (defvar nnrss-group-alist)
3101 (defun nnrss-discover-feed (_arg))
3102 (defun nnrss-save-server-data (_arg)))
3103 (defun gnus-group-make-rss-group (&optional url)
3104 "Given a URL, discover if there is an RSS feed.
3105 If there is, use Gnus to create an nnrss group"
3109 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
3110 (let ((feedinfo (nnrss-discover-feed url)))
3112 (let* ((title (gnus-newsgroup-savable-name
3113 (read-from-minibuffer "Title: "
3114 (gnus-newsgroup-savable-name
3118 (or (cdr (assoc 'title
3122 (desc (read-from-minibuffer "Description: "
3126 (or (cdr (assoc 'description
3130 (href (cdr (assoc 'href feedinfo)))
3131 (coding (gnus-group-name-charset '(nnrss "") title)))
3133 ;; Unify non-ASCII text.
3134 (setq title (decode-coding-string
3135 (encode-coding-string title coding)
3137 (gnus-group-make-group title '(nnrss ""))
3138 (push (list title href desc) nnrss-group-alist)
3139 (nnrss-save-server-data nil))
3140 (error "No feeds found for %s" url))))
3142 (defun gnus-group-make-directory-group (dir)
3143 "Create an nndir group.
3144 The user will be prompted for a directory. The contents of this
3145 directory will be used as a newsgroup. The directory should contain
3146 mail messages or news articles in files that have numeric names."
3148 (list (read-directory-name "Create group from directory: ")))
3149 (unless (file-exists-p dir)
3150 (error "No such directory"))
3151 (unless (file-directory-p dir)
3152 (error "Not a directory"))
3156 (while (or (not group) (gnus-group-entry group))
3158 (gnus-group-prefixed-name
3159 (expand-file-name ext dir)
3161 (setq ext (format "<%d>" (setq i (1+ i)))))
3162 (gnus-group-make-group
3163 (gnus-group-real-name group)
3164 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
3166 (defun gnus-group-add-to-virtual (n vgroup)
3167 "Add the current group to a virtual group."
3169 (list current-prefix-arg
3170 (gnus-group-completing-read "Add to virtual group"
3171 nil t "nnvirtual:")))
3172 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
3173 (error "%s is not an nnvirtual group" vgroup))
3174 (gnus-close-group vgroup)
3175 (let* ((groups (gnus-group-process-prefix n))
3176 (method (gnus-info-method (gnus-get-info vgroup))))
3177 (setcar (cdr method)
3179 (nth 1 method) "\\|"
3182 (gnus-group-remove-mark s)
3183 (concat "\\(^" (regexp-quote s) "$\\)"))
3185 (gnus-group-position-point))
3187 (defun gnus-group-make-empty-virtual (group)
3188 "Create a new, fresh, empty virtual group."
3189 (interactive "sCreate new, empty virtual group: ")
3190 (let* ((method (list 'nnvirtual "^$"))
3191 (pgroup (gnus-group-prefixed-name group method)))
3192 ;; Check whether it exists already.
3193 (when (gnus-group-entry pgroup)
3194 (error "Group %s already exists" pgroup))
3195 ;; Subscribe the new group after the group on the current line.
3196 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
3197 (gnus-group-update-group pgroup)
3199 (gnus-group-position-point)))
3201 (defun gnus-group-enter-directory (dir)
3202 "Enter an ephemeral nneething group."
3203 (interactive "DDirectory to read: ")
3204 (let* ((method (list 'nneething dir '(nneething-read-only t)))
3205 (leaf (gnus-group-prefixed-name
3206 (file-name-nondirectory (directory-file-name dir))
3208 (name (gnus-generate-new-group-name leaf)))
3209 (unless (gnus-group-read-ephemeral-group
3211 (cons (current-buffer)
3212 (if (derived-mode-p 'gnus-summary-mode)
3214 (error "Couldn't enter %s" dir))))
3216 (defun gnus-group-expunge-group (group)
3217 "Expunge deleted articles in current nnimap GROUP."
3218 (interactive (list (gnus-group-group-name)))
3219 (let ((method (gnus-find-method-for-group group)))
3220 (if (not (gnus-check-backend-function
3221 'request-expunge-group (car method)))
3222 (error "%s does not support expunging" (car method))
3223 (gnus-request-expunge-group group method))))
3225 (autoload 'nnimap-acl-get "nnimap")
3226 (autoload 'nnimap-acl-edit "nnimap")
3228 (defun gnus-group-nnimap-edit-acl (group)
3229 "Edit the Access Control List of current nnimap GROUP."
3230 (interactive (list (gnus-group-group-name)))
3231 (let ((mailbox (gnus-group-real-name group)) method acl)
3233 (error "No group on current line"))
3234 (unless (gnus-get-info group)
3235 (error "Killed group; can't be edited"))
3236 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
3237 (error "%s is not an nnimap group" group))
3238 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
3239 (error "Server does not support ACL's"))
3240 (gnus-edit-form acl (format-message "\
3241 Editing the access control list for `%s'.
3243 An access control list is a list of (identifier . rights) elements.
3245 The identifier string specifies the corresponding user. The
3246 identifier \"anyone\" is reserved to refer to the universal identity.
3248 Rights is a string listing a (possibly empty) set of alphanumeric
3249 characters, each character listing a set of operations which is being
3250 controlled. Letters are reserved for \"standard\" rights, listed
3251 below. Digits are reserved for implementation or site defined rights.
3253 l - lookup (mailbox is visible to LIST/LSUB commands)
3254 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
3255 SEARCH, COPY from mailbox)
3256 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
3257 w - write (STORE flags other than \\SEEN and \\DELETED)
3258 i - insert (perform APPEND, COPY into mailbox)
3259 p - post (send mail to submission address for mailbox,
3260 not enforced by IMAP4 itself)
3261 c - create and delete mailbox (CREATE new sub-mailboxes in any
3262 implementation-defined hierarchy, RENAME or DELETE mailbox)
3263 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
3264 a - administer (perform SETACL)" group)
3267 ,mailbox ',method ',acl form)))))
3269 ;; Group sorting commands
3270 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3272 (defun gnus-group-sort-groups (func &optional reverse)
3273 "Sort the group buffer according to FUNC.
3274 When used interactively, the sorting function used will be
3275 determined by the `gnus-group-sort-function' variable.
3276 If REVERSE (the prefix), reverse the sorting order."
3277 (interactive (list gnus-group-sort-function current-prefix-arg))
3278 (funcall gnus-group-sort-alist-function
3279 (gnus-make-sort-function func) reverse)
3280 (gnus-group-unmark-all-groups)
3281 (gnus-group-list-groups)
3282 (gnus-dribble-touch))
3284 (defun gnus-group-sort-flat (func reverse)
3285 ;; We peel off the dummy group from the alist.
3287 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
3288 (pop gnus-newsrc-alist))
3290 (setq gnus-newsrc-alist
3291 (sort gnus-newsrc-alist func))
3293 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
3294 ;; Regenerate the hash table.
3295 (gnus-make-hashtable-from-newsrc-alist)))
3297 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
3298 "Sort the group buffer alphabetically by group name.
3299 If REVERSE, sort in reverse order."
3301 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
3303 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
3304 "Sort the group buffer alphabetically by real (unprefixed) group name.
3305 If REVERSE, sort in reverse order."
3307 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
3309 (defun gnus-group-sort-groups-by-unread (&optional reverse)
3310 "Sort the group buffer by number of unread articles.
3311 If REVERSE, sort in reverse order."
3313 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
3315 (defun gnus-group-sort-groups-by-level (&optional reverse)
3316 "Sort the group buffer by group level.
3317 If REVERSE, sort in reverse order."
3319 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
3321 (defun gnus-group-sort-groups-by-score (&optional reverse)
3322 "Sort the group buffer by group score.
3323 If REVERSE, sort in reverse order."
3325 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
3327 (defun gnus-group-sort-groups-by-rank (&optional reverse)
3328 "Sort the group buffer by group rank.
3329 If REVERSE, sort in reverse order."
3331 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
3333 (defun gnus-group-sort-groups-by-method (&optional reverse)
3334 "Sort the group buffer alphabetically by back end name.
3335 If REVERSE, sort in reverse order."
3337 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
3339 (defun gnus-group-sort-groups-by-server (&optional reverse)
3340 "Sort the group buffer alphabetically by server name.
3341 If REVERSE, sort in reverse order."
3343 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
3345 ;;; Selected group sorting.
3347 (defun gnus-group-sort-selected-groups (n func &optional reverse)
3348 "Sort the process/prefixed groups."
3349 (interactive (list current-prefix-arg gnus-group-sort-function))
3350 (let ((groups (gnus-group-process-prefix n)))
3351 (funcall gnus-group-sort-selected-function
3352 groups (gnus-make-sort-function func) reverse)
3353 (gnus-group-unmark-all-groups)
3354 (gnus-group-list-groups)
3355 (gnus-dribble-touch)))
3357 (defun gnus-group-sort-selected-flat (groups func reverse)
3358 (let (entries infos)
3359 ;; First find all the group entries for these groups.
3361 (push (nthcdr 2 (gnus-group-entry (pop groups)))
3363 ;; Then sort the infos.
3367 (lambda (entry) (car entry))
3368 (setq entries (nreverse entries)))
3371 (setq infos (nreverse infos)))
3372 ;; Go through all the infos and replace the old entries
3373 ;; with the new infos.
3375 (setcar (car entries) (pop infos))
3377 ;; Update the hashtable.
3378 (gnus-make-hashtable-from-newsrc-alist)))
3380 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3381 "Sort the group buffer alphabetically by group name.
3382 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3383 sort in reverse order."
3384 (interactive (gnus-interactive "P\ny"))
3385 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3387 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3388 "Sort the group buffer alphabetically by real group name.
3389 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3390 sort in reverse order."
3391 (interactive (gnus-interactive "P\ny"))
3392 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3394 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3395 "Sort the group buffer by number of unread articles.
3396 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3397 sort in reverse order."
3398 (interactive (gnus-interactive "P\ny"))
3399 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3401 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3402 "Sort the group buffer by group level.
3403 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3404 sort in reverse order."
3405 (interactive (gnus-interactive "P\ny"))
3406 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3408 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3409 "Sort the group buffer by group score.
3410 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3411 sort in reverse order."
3412 (interactive (gnus-interactive "P\ny"))
3413 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3415 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3416 "Sort the group buffer by group rank.
3417 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3418 sort in reverse order."
3419 (interactive (gnus-interactive "P\ny"))
3420 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3422 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3423 "Sort the group buffer alphabetically by back end name.
3424 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3425 sort in reverse order."
3426 (interactive (gnus-interactive "P\ny"))
3427 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3429 ;;; Sorting predicates.
3431 (defun gnus-group-sort-by-alphabet (info1 info2)
3432 "Sort alphabetically."
3433 (string< (gnus-info-group info1) (gnus-info-group info2)))
3435 (defun gnus-group-sort-by-real-name (info1 info2)
3436 "Sort alphabetically on real (unprefixed) names."
3437 (string< (gnus-group-real-name (gnus-info-group info1))
3438 (gnus-group-real-name (gnus-info-group info2))))
3440 (defun gnus-group-sort-by-unread (info1 info2)
3441 "Sort by number of unread articles."
3442 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3443 (n2 (gnus-group-unread (gnus-info-group info2))))
3444 (< (or (and (numberp n1) n1) 0)
3445 (or (and (numberp n2) n2) 0))))
3447 (defun gnus-group-sort-by-level (info1 info2)
3449 (< (gnus-info-level info1) (gnus-info-level info2)))
3451 (defun gnus-group-sort-by-method (info1 info2)
3452 "Sort alphabetically by back end name."
3453 (string< (car (gnus-find-method-for-group
3454 (gnus-info-group info1) info1))
3455 (car (gnus-find-method-for-group
3456 (gnus-info-group info2) info2))))
3458 (defun gnus-group-sort-by-server (info1 info2)
3459 "Sort alphabetically by server name."
3460 (string< (gnus-method-to-full-server-name
3461 (gnus-find-method-for-group
3462 (gnus-info-group info1) info1))
3463 (gnus-method-to-full-server-name
3464 (gnus-find-method-for-group
3465 (gnus-info-group info2) info2))))
3467 (defun gnus-group-sort-by-score (info1 info2)
3468 "Sort by group score."
3469 (> (gnus-info-score info1) (gnus-info-score info2)))
3471 (defun gnus-group-sort-by-rank (info1 info2)
3472 "Sort by level and score."
3473 (let ((level1 (gnus-info-level info1))
3474 (level2 (gnus-info-level info2)))
3475 (or (< level1 level2)
3476 (and (= level1 level2)
3477 (> (gnus-info-score info1) (gnus-info-score info2))))))
3481 (defun gnus-group-clear-data (&optional arg)
3482 "Clear all marks and read ranges from the current group.
3483 Obeys the process/prefix convention."
3485 (when (gnus-y-or-n-p "Really clear data? ")
3486 (gnus-group-iterate arg
3489 (gnus-info-clear-data (setq info (gnus-get-info group)))
3490 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3491 (when (gnus-group-goto-group group)
3492 (gnus-group-update-group-line)))))))
3494 (defun gnus-group-clear-data-on-native-groups ()
3495 "Clear all marks and read ranges from all native groups."
3497 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3498 (let ((alist (cdr gnus-newsrc-alist))
3500 (while (setq info (pop alist))
3501 (when (gnus-group-native-p (gnus-info-group info))
3502 (gnus-info-clear-data info)))
3503 (gnus-get-unread-articles)
3504 (gnus-dribble-touch)
3505 (when (gnus-y-or-n-p
3506 "Move the cache away to avoid problems in the future? ")
3507 (call-interactively 'gnus-cache-move-cache)))))
3509 (defun gnus-info-clear-data (info)
3510 "Clear all marks and read ranges from INFO."
3511 (let ((group (gnus-info-group info))
3513 (dolist (el (gnus-info-marks info))
3514 (push `(,(cdr el) add (,(car el))) action))
3515 (push `(,(gnus-info-read info) add (read)) action)
3518 (gnus-request-set-mark ,group ',action)
3519 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3520 (gnus-info-set-read ',info ',(gnus-info-read info))
3521 (when (gnus-group-goto-group ,group)
3522 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3523 (gnus-group-update-group-line))))
3524 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3526 (gnus-request-set-mark group action)
3527 (gnus-info-set-read info nil)
3528 (when (gnus-info-marks info)
3529 (gnus-info-set-marks info nil))))
3531 ;; Group catching up.
3533 (defun gnus-group-catchup-current (&optional n all)
3534 "Mark all unread articles in the current newsgroup as read.
3535 If prefix argument N is numeric, the next N newsgroups will be
3536 caught up. If ALL is non-nil, marked articles will also be marked as
3537 read. Cross references (Xref: header) of articles are ignored.
3538 The number of newsgroups that this function was unable to catch
3541 (let ((groups (gnus-group-process-prefix n))
3544 (unless groups (error "No groups selected"))
3546 (or (not gnus-interactive-catchup) ;Without confirmation?
3551 "Do you really want to mark all articles in %s as read? "
3552 "Mark all unread articles in %s as read? ")
3553 (if (= (length groups) 1)
3554 (gnus-group-decoded-name (car groups))
3555 (format "these %d groups" (length groups)))))))
3557 (while (setq group (pop groups))
3558 (gnus-group-remove-mark group)
3559 ;; Virtual groups have to be given special treatment.
3560 (let ((method (gnus-find-method-for-group group)))
3561 (when (eq 'nnvirtual (car method))
3562 (nnvirtual-catchup-group
3563 (gnus-group-real-name group) (nth 1 method) all)))
3565 ((>= (gnus-group-level group) gnus-level-zombie)
3566 (gnus-message 2 "Dead groups can't be caught up"))
3568 (gnus-group-goto-group group)
3569 (gnus-group-catchup group all))
3570 (gnus-group-update-group-line))
3572 (setq ret (1+ ret)))))
3573 (gnus-group-next-unread-group 1)
3576 (defun gnus-group-catchup-current-all (&optional n)
3577 "Mark all articles in current newsgroup as read.
3578 Cross references (Xref: header) of articles are ignored."
3580 (gnus-group-catchup-current n 'all))
3582 (declare-function gnus-sequence-of-unread-articles "gnus-sum" (group))
3584 (defun gnus-group-catchup (group &optional all)
3585 "Mark all articles in GROUP as read.
3586 If ALL is non-nil, all articles are marked as read.
3587 The return value is the number of articles that were marked as read,
3588 or nil if no action could be taken."
3589 (let* ((entry (gnus-group-entry group))
3591 (marks (gnus-info-marks (nth 2 entry)))
3592 (unread (gnus-sequence-of-unread-articles group)))
3593 ;; Remove entries for this group.
3594 (nnmail-purge-split-history (gnus-group-real-name group))
3595 ;; Do the updating only if the newsgroup isn't killed.
3596 (if (not (numberp (car entry)))
3597 (gnus-message 1 "Can't catch up %s; non-active group" group)
3598 (gnus-update-read-articles group nil)
3600 ;; Nix out the lists of marks and dormants.
3601 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3603 (list (cdr (assq 'dormant marks))
3605 (setq unread (gnus-range-add (gnus-range-add
3606 unread (cdr (assq 'dormant marks)))
3607 (cdr (assq 'tick marks))))
3608 (gnus-add-marked-articles group 'tick nil nil 'force)
3609 (gnus-add-marked-articles group 'dormant nil nil 'force))
3610 ;; Do auto-expirable marks if that's required.
3611 (when (and (gnus-group-auto-expirable-p group)
3612 (not (gnus-group-read-only-p group)))
3615 (gnus-add-marked-articles group 'expire (list article))
3616 (gnus-request-set-mark group (list (list (list article)
3619 (let ((gnus-newsgroup-name group))
3620 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3623 (defun gnus-group-expire-articles (&optional n)
3624 "Expire all expirable articles in the current newsgroup.
3625 Uses the process/prefix convention."
3627 (let ((groups (gnus-group-process-prefix n))
3630 (error "No groups to expire"))
3631 (while (setq group (pop groups))
3632 (gnus-group-remove-mark group)
3633 (gnus-group-expire-articles-1 group)
3634 (gnus-dribble-touch)
3635 (gnus-group-position-point))))
3637 (defun gnus-group-expire-articles-1 (group)
3638 (when (gnus-check-backend-function 'request-expire-articles group)
3639 (gnus-message 6 "Expiring articles in %s..."
3640 (gnus-group-decoded-name group))
3641 (let* ((info (gnus-get-info group))
3642 (expirable (if (gnus-group-total-expirable-p group)
3643 (cons nil (gnus-list-of-read-articles group))
3644 (assq 'expire (gnus-info-marks info))))
3646 (gnus-list-range-difference
3647 (gnus-uncompress-sequence (cdr expirable))
3648 (cdr (assq 'unexist (gnus-info-marks info)))))
3649 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3650 (nnmail-expiry-target
3651 (or (gnus-group-find-parameter group 'expiry-target)
3652 nnmail-expiry-target)))
3654 (gnus-check-group group)
3657 (gnus-compress-sequence
3659 ;; We set the expiry variables to the group
3661 (let ((nnmail-expiry-wait-function nil)
3662 (nnmail-expiry-wait expiry-wait))
3663 (gnus-request-expire-articles articles-to-expire group))
3664 ;; Just expire using the normal expiry values.
3665 (gnus-request-expire-articles articles-to-expire group))))
3666 (gnus-close-group group))
3667 (gnus-message 6 "Expiring articles in %s...done"
3668 (gnus-group-decoded-name group))
3669 ;; Return the list of un-expired articles.
3672 (defun gnus-group-expire-all-groups ()
3673 "Expire all expirable articles in all newsgroups."
3676 (gnus-message 5 "Expiring...")
3677 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3678 (cdr gnus-newsrc-alist))))
3679 (gnus-group-expire-articles nil)))
3680 (gnus-group-position-point)
3681 (gnus-message 5 "Expiring...done"))
3683 (defun gnus-group-set-current-level (n level)
3684 "Set the level of the next N groups to LEVEL."
3689 (unless (gnus-group-process-prefix current-prefix-arg)
3690 (error "No group on the current line"))
3692 (let ((s (read-string
3693 (format "Level (default %s): "
3694 (or (gnus-group-group-level)
3695 gnus-level-default-subscribed)))))
3696 (if (string-match "^\\s-*$" s)
3697 (int-to-string (or (gnus-group-group-level)
3698 gnus-level-default-subscribed))
3700 (unless (and (>= level 1) (<= level gnus-level-killed))
3701 (error "Invalid level: %d" level))
3702 (dolist (group (gnus-group-process-prefix n))
3703 (gnus-group-remove-mark group)
3704 (gnus-message 6 "Changed level of %s from %d to %d"
3705 (gnus-group-decoded-name group)
3706 (or (gnus-group-group-level) gnus-level-killed)
3708 (gnus-group-change-level
3709 group level (or (gnus-group-group-level) gnus-level-killed))
3710 (gnus-group-update-group-line))
3711 (gnus-group-position-point))
3713 (defun gnus-group-unsubscribe (&optional n)
3714 "Unsubscribe the current group."
3716 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3718 (defun gnus-group-subscribe (&optional n)
3719 "Subscribe the current group."
3721 (gnus-group-unsubscribe-current-group n 'subscribe))
3723 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3724 "Toggle subscription of the current group.
3725 If given numerical prefix, toggle the N next groups."
3727 (dolist (group (gnus-group-process-prefix n))
3728 (gnus-group-remove-mark group)
3729 (gnus-group-unsubscribe-group
3732 ((eq do-sub 'unsubscribe)
3733 gnus-level-default-unsubscribed)
3734 ((eq do-sub 'subscribe)
3735 gnus-level-default-subscribed)
3736 ((<= (gnus-group-group-level) gnus-level-subscribed)
3737 gnus-level-default-unsubscribed)
3739 gnus-level-default-subscribed))
3741 (gnus-group-update-group-line))
3742 (gnus-group-next-group 1))
3744 (defun gnus-group-unsubscribe-group (group &optional level silent)
3745 "Toggle subscription to GROUP.
3746 Killed newsgroups are subscribed. If SILENT, don't try to update the
3748 (interactive (list (gnus-group-completing-read
3749 nil nil (gnus-read-active-file-p))))
3750 (let ((newsrc (gnus-group-entry group)))
3752 ((string-match "\\`[ \t]*\\'" group)
3753 (error "Empty group name"))
3755 ;; Toggle subscription flag.
3756 (gnus-group-change-level
3757 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3758 gnus-level-subscribed)
3759 (1+ gnus-level-subscribed)
3760 gnus-level-default-subscribed)))
3762 (gnus-group-update-group group)))
3763 ((and (stringp group)
3764 (or (not (gnus-read-active-file-p))
3765 (gnus-active group)))
3766 ;; Add new newsgroup.
3767 (gnus-group-change-level
3769 (if level level gnus-level-default-subscribed)
3770 (or (and (member group gnus-zombie-list)
3773 (when (gnus-group-group-name)
3774 (gnus-group-entry (gnus-group-group-name))))
3776 (gnus-group-update-group group)))
3777 (t (error "No such newsgroup: %s" group)))
3778 (gnus-group-position-point)))
3780 (defun gnus-group-transpose-groups (n)
3781 "Move the current newsgroup up N places.
3782 If given a negative prefix, move down instead. The difference between
3783 N and the number of steps taken is returned."
3785 (unless (gnus-group-group-name)
3786 (error "No group on current line"))
3787 (gnus-group-kill-group 1)
3789 (forward-line (- n))
3790 (gnus-group-yank-group)
3791 (gnus-group-position-point)))
3793 (defun gnus-group-kill-all-zombies (&optional dummy)
3794 "Kill all zombie newsgroups.
3795 The optional DUMMY should always be nil."
3796 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3798 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3799 (setq gnus-zombie-list nil)
3800 (gnus-dribble-touch)
3801 (gnus-group-list-groups)))
3803 (defun gnus-group-kill-region (begin end)
3804 "Kill newsgroups in current region (excluding current point).
3805 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3818 (beginning-of-line) ;Important when LINES < 1
3819 (gnus-group-kill-group lines)))
3821 (defun gnus-group-kill-group (&optional n discard)
3822 "Kill the next N groups.
3823 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3824 However, only groups that were alive can be yanked; already killed
3825 groups or zombie groups can't be yanked.
3826 The return value is the name of the group that was killed, or a list
3829 (let ((buffer-read-only nil)
3830 (groups (gnus-group-process-prefix n))
3831 group entry level out)
3832 (if (< (length groups) 10)
3833 ;; This is faster when there are few groups.
3835 (push (setq group (pop groups)) out)
3836 (gnus-group-remove-mark group)
3837 (setq level (gnus-group-group-level))
3839 (when (and (not discard)
3840 (setq entry (gnus-group-entry group)))
3843 (gnus-group-goto-group ,(gnus-group-group-name))
3844 (gnus-group-yank-group)))
3845 (push (cons (car entry) (nth 2 entry))
3846 gnus-list-of-killed-groups))
3847 (gnus-group-change-level
3848 (if entry entry group) gnus-level-killed (if entry nil level))
3849 (when (numberp (gnus-group-unread group))
3850 (gnus-request-update-group-status group 'unsubscribe))
3851 (message "Killed group %s" (gnus-group-decoded-name group)))
3852 ;; If there are lots and lots of groups to be killed, we use
3853 ;; this thing instead.
3854 (dolist (group (nreverse groups))
3855 (gnus-group-remove-mark group)
3857 (push group gnus-killed-list)
3858 (setq gnus-newsrc-alist
3859 (delq (assoc group gnus-newsrc-alist)
3861 (when gnus-group-change-level-function
3862 (funcall gnus-group-change-level-function
3863 group gnus-level-killed 3))
3865 ((setq entry (gnus-group-entry group))
3866 (push (cons (car entry) (nth 2 entry))
3867 gnus-list-of-killed-groups)
3868 (setcdr (cdr entry) (cdddr entry)))
3869 ((member group gnus-zombie-list)
3870 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3871 ;; There may be more than one instance displayed.
3872 (while (gnus-group-goto-group group)
3874 (when (numberp (gnus-group-unread group))
3875 (gnus-request-update-group-status group 'unsubscribe)))
3876 (gnus-make-hashtable-from-newsrc-alist))
3878 (gnus-group-position-point)
3879 (if (< (length out) 2) (car out) (nreverse out))))
3881 (defun gnus-group-yank-group (&optional arg)
3882 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3883 The numeric ARG specifies how many newsgroups are to be yanked. The
3884 name of the newsgroup yanked is returned, or (if several groups are
3885 yanked) a list of yanked groups is returned."
3887 (setq arg (or arg 1))
3888 (let (info group prev out)
3889 (while (>= (decf arg) 0)
3890 (when (not (setq info (pop gnus-list-of-killed-groups)))
3891 (error "No more newsgroups to yank"))
3892 (push (setq group (nth 1 info)) out)
3893 ;; Find which newsgroup to insert this one before - search
3894 ;; backward until something suitable is found. If there are no
3895 ;; other newsgroups in this buffer, just make this newsgroup the
3897 (setq prev (gnus-group-group-name))
3898 (gnus-group-change-level
3899 info (gnus-info-level (cdr info)) gnus-level-killed
3900 (and prev (gnus-group-entry prev))
3902 (gnus-group-insert-group-line-info group)
3903 (gnus-request-update-group-status group 'subscribe)
3905 `(when (gnus-group-goto-group ,group)
3906 (gnus-group-kill-group 1))))
3908 (gnus-group-position-point)
3909 (if (< (length out) 2) (car out) (nreverse out))))
3911 (defun gnus-group-kill-level (level)
3912 "Kill all groups that is on a certain LEVEL."
3913 (interactive "nKill all groups on level: ")
3915 ((= level gnus-level-zombie)
3916 (setq gnus-killed-list
3917 (nconc gnus-zombie-list gnus-killed-list))
3918 (setq gnus-zombie-list nil))
3919 ((and (< level gnus-level-zombie)
3921 (or gnus-expert-user
3924 "Do you really want to kill all groups on level %d? "
3926 (let* ((prev gnus-newsrc-alist)
3929 (if (= (gnus-info-level (car alist)) level)
3931 (push (gnus-info-group (car alist)) gnus-killed-list)
3932 (setcdr prev (cdr alist)))
3934 (setq alist (cdr alist)))
3935 (gnus-make-hashtable-from-newsrc-alist)
3936 (gnus-group-list-groups)))
3938 (error "Can't kill; invalid level: %d" level))))
3940 (defun gnus-group-list-all-groups (&optional arg)
3941 "List all newsgroups with level ARG or lower.
3942 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3943 unsubscribed groups."
3945 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3947 ;; Redefine this to list ALL killed groups if prefix arg used.
3948 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3949 (defun gnus-group-list-killed (&optional arg)
3950 "List all killed newsgroups in the group buffer.
3951 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3952 entail asking the server for the groups."
3954 ;; Find all possible killed newsgroups if arg.
3956 (gnus-get-killed-groups))
3957 (if (not gnus-killed-list)
3958 (gnus-message 6 "No killed groups")
3959 (let (gnus-group-list-mode)
3960 (funcall gnus-group-prepare-function
3961 gnus-level-killed t gnus-level-killed))
3962 (goto-char (point-min)))
3963 (gnus-group-position-point))
3965 (defun gnus-group-list-zombies ()
3966 "List all zombie newsgroups in the group buffer."
3968 (if (not gnus-zombie-list)
3969 (gnus-message 6 "No zombie groups")
3970 (let (gnus-group-list-mode)
3971 (funcall gnus-group-prepare-function
3972 gnus-level-zombie t gnus-level-zombie))
3973 (goto-char (point-min)))
3974 (gnus-group-position-point))
3976 (defun gnus-group-list-active ()
3977 "List all groups that are available from the server(s)."
3979 ;; First we make sure that we have really read the active file.
3980 (unless (gnus-read-active-file-p)
3981 (let ((gnus-read-active-file t)
3982 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
3983 (gnus-read-active-file)))
3984 ;; Find all groups and sort them.
3992 (push (symbol-name sym) list)))
3996 (buffer-read-only nil)
4000 (setq group (pop groups))
4001 (add-text-properties
4002 (point) (prog1 (1+ (point))
4004 (gnus-group-decoded-name group)
4006 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4008 'gnus-level (inline (gnus-group-level group)))))
4009 (goto-char (point-min))))
4011 (defun gnus-activate-all-groups (level)
4012 "Activate absolutely all groups."
4013 (interactive (list gnus-level-unsubscribed))
4014 (let ((gnus-activate-level level)
4015 (gnus-activate-foreign-newsgroups level))
4016 (gnus-group-get-new-news)))
4018 (defun gnus-group-get-new-news (&optional arg one-level)
4019 "Get newly arrived articles.
4020 If ARG is a number, it specifies which levels you are interested in
4021 re-scanning. If ARG is non-nil and not a number, this will force
4022 \"hard\" re-reading of the active files from all servers.
4023 If ONE-LEVEL is not nil, then re-scan only the specified level,
4024 otherwise all levels below ARG will be scanned too."
4027 (let ((gnus-inhibit-demon t)
4028 ;; Binding this variable will inhibit multiple fetchings
4029 ;; of the same mail source.
4030 (nnmail-fetched-sources (list t)))
4031 (gnus-run-hooks 'gnus-get-top-new-news-hook)
4032 (gnus-run-hooks 'gnus-get-new-news-hook)
4034 ;; Read any slave files.
4036 (gnus-master-read-slave-newsrc))
4038 (gnus-get-unread-articles (gnus-group-default-level arg t)
4041 ;; If the user wants it, we scan for new groups.
4042 (when (eq gnus-check-new-newsgroups 'always)
4043 (gnus-find-new-newsgroups))
4045 (gnus-check-reasonable-setup)
4046 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
4047 (gnus-group-list-groups (and (numberp arg)
4048 (max (car gnus-group-list-mode) arg)))))
4050 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
4051 "Check for newly arrived news in the current group (and the N-1 next groups).
4052 The difference between N and the number of newsgroup checked is returned.
4053 If N is negative, this group and the N-1 previous groups will be checked.
4054 If DONT-SCAN is non-nil, scan non-activated groups as well."
4056 (let* ((groups (gnus-group-process-prefix n))
4057 (ret (if (numberp n) (- n (length groups)) 0))
4061 (gnus-inhibit-demon t)
4062 ;; Binding this variable will inhibit multiple fetchings
4063 ;; of the same mail source.
4064 (nnmail-fetched-sources (list t)))
4065 (gnus-run-hooks 'gnus-get-new-news-hook)
4066 (while (setq group (pop groups))
4067 (gnus-group-remove-mark group)
4068 ;; Bypass any previous denials from the server.
4069 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
4070 (if (or (and (not dont-scan)
4071 (gnus-request-group-scan group (gnus-get-info group)))
4072 (gnus-activate-group group (if dont-scan nil 'scan) nil method))
4073 (let ((info (gnus-get-info group))
4074 (active (gnus-active group)))
4076 (gnus-request-update-info info method))
4077 (gnus-get-unread-articles-in-group info active)
4078 (unless (gnus-virtual-group-p group)
4079 (gnus-close-group group))
4081 (gnus-agent-save-group-info
4082 method (gnus-group-real-name group) active))
4083 (gnus-group-update-group group nil t))
4084 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
4087 (when gnus-goto-next-group-when-activating
4088 (gnus-group-next-unread-group 1 t))
4089 (gnus-group-position-point)
4092 (defun gnus-group-describe-group (force &optional group)
4093 "Display a description of the current newsgroup."
4094 (interactive (list current-prefix-arg (gnus-group-group-name)))
4095 (let* ((method (gnus-find-method-for-group group))
4096 (mname (gnus-group-prefixed-name "" method))
4099 gnus-description-hashtb)
4100 (gnus-sethash mname nil gnus-description-hashtb))
4102 (error "No group name given"))
4103 (when (or (and gnus-description-hashtb
4104 ;; We check whether this group's method has been
4105 ;; queried for a description file.
4106 (gnus-gethash mname gnus-description-hashtb))
4107 (setq desc (gnus-group-get-description group))
4108 (gnus-read-descriptions-file method))
4109 (gnus-message 1 "%s"
4110 (or desc (gnus-gethash group gnus-description-hashtb)
4111 "No description available")))))
4113 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4114 (defun gnus-group-describe-all-groups (&optional force)
4115 "Pop up a buffer with descriptions of all newsgroups."
4118 (setq gnus-description-hashtb nil))
4119 (when (not (or gnus-description-hashtb
4120 (gnus-read-all-descriptions-files)))
4121 (error "Couldn't request descriptions file"))
4122 (let ((buffer-read-only nil)
4126 (push (symbol-name group) groups))
4127 gnus-description-hashtb)
4128 (setq groups (sort groups 'string<))
4130 (dolist (group groups)
4132 (let ((charset (gnus-group-name-charset nil group)))
4133 (insert (format " *: %-20s %s\n"
4134 (gnus-group-name-decode group charset)
4135 (gnus-group-name-decode group charset))))
4136 (add-text-properties
4137 b (1+ b) (list 'gnus-group (intern group gnus-description-hashtb)
4138 'gnus-unread t 'gnus-marked nil
4139 'gnus-level (1+ gnus-level-subscribed))))
4140 (goto-char (point-min))
4141 (gnus-group-position-point)))
4143 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
4144 (defun gnus-group-apropos (regexp &optional search-description)
4145 "List all newsgroups that have names that match a regexp."
4146 (interactive "sGnus apropos (regexp): ")
4148 (obuf (current-buffer))
4150 ;; Go through all newsgroups that are known to Gnus.
4153 (and (symbol-name group)
4154 (string-match regexp (symbol-name group))
4155 (symbol-value group)
4156 (push (symbol-name group) groups)))
4158 ;; Also go through all descriptions that are known to Gnus.
4159 (when search-description
4162 (and (string-match regexp (symbol-value group))
4163 (push (symbol-name group) groups)))
4164 gnus-description-hashtb))
4166 (gnus-message 3 "No groups matched \"%s\"." regexp)
4167 ;; Print out all the groups.
4169 (pop-to-buffer "*Gnus Help*")
4170 (buffer-disable-undo)
4172 (setq groups (sort groups 'string<))
4174 ;; Groups may be entered twice into the list of groups.
4175 (when (not (string= (car groups) prev))
4176 (setq prev (car groups))
4177 (let ((charset (gnus-group-name-charset nil prev)))
4178 (insert (gnus-group-name-decode prev charset) "\n")
4179 (when (and gnus-description-hashtb
4180 (setq des (gnus-gethash (car groups)
4181 gnus-description-hashtb)))
4182 (insert " " (gnus-group-name-decode des charset) "\n"))))
4183 (setq groups (cdr groups)))
4184 (goto-char (point-min))))
4185 (pop-to-buffer obuf)))
4187 (defun gnus-group-description-apropos (regexp)
4188 "List all newsgroups that have names or descriptions that match REGEXP."
4189 (interactive "sGnus description apropos (regexp): ")
4190 (when (not (or gnus-description-hashtb
4191 (gnus-read-all-descriptions-files)))
4192 (error "Couldn't request descriptions file"))
4193 (gnus-group-apropos regexp t))
4195 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4196 (defun gnus-group-list-matching (level regexp &optional all lowest)
4197 "List all groups with unread articles that match REGEXP.
4198 If the prefix LEVEL is non-nil, it should be a number that says which
4199 level to cut off listing groups.
4200 If ALL, also list groups with no unread articles.
4201 If LOWEST, don't list groups with level lower than LOWEST.
4203 This command may read the active file."
4204 (interactive "P\nsList newsgroups matching: ")
4205 ;; First make sure active file has been read.
4207 (> (prefix-numeric-value level) gnus-level-killed))
4208 (gnus-get-killed-groups))
4209 (funcall gnus-group-prepare-function
4210 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
4211 (goto-char (point-min))
4212 (gnus-group-position-point))
4214 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4215 "List all groups that match REGEXP.
4216 If the prefix LEVEL is non-nil, it should be a number that says which
4217 level to cut off listing groups.
4218 If LOWEST, don't list groups with level lower than LOWEST."
4219 (interactive "P\nsList newsgroups matching: ")
4221 (setq level (prefix-numeric-value level)))
4222 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4224 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4225 (defun gnus-group-save-newsrc (&optional force)
4226 "Save the Gnus startup files.
4227 If FORCE, force saving whether it is necessary or not."
4229 (gnus-save-newsrc-file force))
4231 (defun gnus-group-restart (&optional arg)
4232 "Force Gnus to read the .newsrc file."
4234 (when (gnus-yes-or-no-p
4235 (format "Are you sure you want to restart Gnus? "))
4236 (gnus-save-newsrc-file)
4240 (defun gnus-group-read-init-file ()
4241 "Read the Gnus elisp init file."
4243 (gnus-read-init-file)
4244 (gnus-message 5 "Read %s" gnus-init-file))
4246 (defun gnus-group-check-bogus-groups (&optional silent)
4247 "Check bogus newsgroups.
4248 If given a prefix, don't ask for confirmation before removing a bogus
4251 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4252 (gnus-group-list-groups))
4254 (defun gnus-group-find-new-groups (&optional arg)
4255 "Search for new groups and add them.
4256 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
4257 With 1 C-u, use the `ask-server' method to query the server for new
4259 With 2 C-u's, use most complete method possible to query the server
4260 for new groups, and subscribe the new groups as zombies."
4262 (let ((new-groups (gnus-find-new-newsgroups (or arg 1)))
4264 (gnus-group-list-groups)
4265 (setq current-group (gnus-group-group-name))
4266 (dolist (group new-groups)
4267 (gnus-group-jump-to-group group))
4269 (gnus-group-jump-to-group current-group))))
4271 (defun gnus-group-edit-global-kill (&optional article group)
4272 "Edit the global kill file.
4273 If GROUP, edit that local kill file instead."
4275 (setq gnus-current-kill-article article)
4276 (gnus-kill-file-edit-file group)
4277 (gnus-message 6 "Editing a %s kill file (Type %s to exit)"
4278 (if group "local" "global")
4279 (substitute-command-keys "\\[gnus-kill-file-exit]")))
4281 (defun gnus-group-edit-local-kill (article group)
4282 "Edit a local kill file."
4283 (interactive (list nil (gnus-group-group-name)))
4284 (gnus-group-edit-global-kill article group))
4286 (defun gnus-group-force-update ()
4287 "Update `.newsrc' file."
4289 (gnus-save-newsrc-file))
4291 (defvar gnus-backlog-articles)
4293 (defun gnus-group-suspend ()
4294 "Suspend the current Gnus session.
4295 In fact, cleanup buffers except for group mode buffer.
4296 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4298 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4299 (gnus-offer-save-summaries)
4300 ;; Kill Gnus buffers except for group mode buffer.
4301 (let ((group-buf (get-buffer gnus-group-buffer)))
4302 (dolist (buf (gnus-buffers))
4303 (unless (or (eq buf group-buf)
4304 (eq buf gnus-dribble-buffer)
4305 (with-current-buffer buf
4306 (derived-mode-p 'message-mode)))
4307 (gnus-kill-buffer buf)))
4308 (setq gnus-backlog-articles nil)
4309 (gnus-kill-gnus-frames)
4310 ;; Closing all the backends is useful (for instance) when when the
4311 ;; IP addresses have changed and you need to reconnect.
4312 (dolist (elem gnus-opened-servers)
4313 (gnus-close-server (car elem))
4314 (setcar (cdr elem) 'closed))
4316 (bury-buffer group-buf)
4317 (delete-windows-on group-buf t))))
4319 (defun gnus-group-clear-dribble ()
4320 "Clear all information from the dribble buffer."
4322 (gnus-dribble-clear)
4323 (gnus-message 7 "Cleared dribble buffer"))
4325 (defun gnus-group-exit ()
4326 "Quit reading news after updating .newsrc.eld and .newsrc.
4327 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4330 (or noninteractive ;For gnus-batch-kill
4331 (not gnus-interactive-exit) ;Without confirmation
4333 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4334 (gnus-run-hooks 'gnus-exit-gnus-hook)
4335 ;; Offer to save data from non-quitted summary buffers.
4336 (gnus-offer-save-summaries)
4337 ;; Save the newsrc file(s).
4338 (gnus-save-newsrc-file)
4340 (gnus-close-backends)
4341 ;; Reset everything.
4343 ;; Allow the user to do things after cleaning up.
4344 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4346 (defun gnus-group-quit ()
4347 "Quit reading news without updating .newsrc.eld or .newsrc.
4348 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4350 (when (or noninteractive ;For gnus-batch-kill
4351 (zerop (buffer-size))
4352 (not (gnus-server-opened gnus-select-method))
4354 (not gnus-current-startup-file)
4356 (format "Quit reading news without saving %s? "
4357 (file-name-nondirectory gnus-current-startup-file))))
4358 (gnus-run-hooks 'gnus-exit-gnus-hook)
4359 (gnus-configure-windows 'group t)
4360 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4361 (not (zerop (with-current-buffer gnus-dribble-buffer
4364 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4366 (gnus-close-backends)
4368 (gnus-kill-buffer gnus-group-buffer)
4369 ;; Allow the user to do things after cleaning up.
4370 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4372 (defun gnus-group-describe-briefly ()
4373 "Give a one line description of the group mode commands."
4375 (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")))
4377 (defun gnus-group-browse-foreign-server (method)
4378 "Browse a foreign news server.
4379 If called interactively, this function will ask for a select method
4380 (nntp, nnspool, etc.) and a server address (e.g., nntp.some.where).
4381 If not, METHOD should be a list where the first element is the method
4382 and the second element is the address."
4384 (list (let ((how (gnus-completing-read
4386 (mapcar 'car (append gnus-valid-select-methods
4388 t (cons "nntp" 0) 'gnus-method-history)))
4389 ;; We either got a back end name or a virtual server name.
4390 ;; If the first, we also need an address.
4391 (if (assoc how gnus-valid-select-methods)
4393 ;; Suggested by mapjph@bath.ac.uk.
4394 (gnus-completing-read
4396 ;; FIXME? gnus-secondary-servers is obsolete,
4397 ;; and it is not obvious that there is anything
4398 ;; sensible to use instead in this particular case.
4399 (if (boundp 'gnus-secondary-servers)
4400 gnus-secondary-servers
4401 (cdr gnus-select-method))))
4402 ;; We got a server name.
4404 (gnus-browse-foreign-server method))
4406 (defun gnus-group-set-info (info &optional method-only-group part)
4407 (when (or info part)
4408 (let* ((entry (gnus-group-entry
4409 (or method-only-group (gnus-info-group info))))
4411 (info (if method-only-group (nth 2 entry) info))
4413 (when method-only-group
4415 (error "Trying to change non-existent group %s" method-only-group))
4416 ;; We have received parts of the actual group info - either the
4417 ;; select method or the group parameters. We first check
4418 ;; whether we have to extend the info, and if so, do that.
4419 (let ((len (length info))
4420 (total (if (eq part 'method) 5 6)))
4422 (setcdr (nthcdr (1- len) info)
4423 (make-list (- total len) nil)))
4424 ;; Then we enter the new info.
4425 (setcar (nthcdr (1- total) info) part-info)))
4427 ;; This is a new group, so we just create it.
4428 (with-current-buffer gnus-group-buffer
4429 (setq method (gnus-info-method info))
4430 (when (gnus-server-equal method "native")
4432 (with-current-buffer gnus-group-buffer
4434 ;; It's a foreign group...
4435 (gnus-group-make-group
4436 (gnus-group-real-name (gnus-info-group info))
4437 (if (stringp method) method
4438 (prin1-to-string (car method)))
4440 (nth 1 (gnus-info-method info)))
4442 ;; It's a native group.
4443 (gnus-group-make-group (gnus-info-group info) nil nil nil t)))
4444 (gnus-message 6 "Note: New group created")
4446 (gnus-group-entry (gnus-group-prefixed-name
4447 (gnus-group-real-name (gnus-info-group info))
4448 (or (gnus-info-method info) gnus-select-method))))))
4449 ;; Whether it was a new group or not, we now have the entry, so we
4450 ;; can do the update.
4453 (setcar (nthcdr 2 entry) info)
4454 (when (and (not (eq (car entry) t))
4455 (gnus-active (gnus-info-group info)))
4456 (setcar entry (length
4457 (gnus-list-of-unread-articles (car info))))))
4458 (error "No such group: %s" (gnus-info-group info))))))
4460 ;; Ad-hoc function for inserting data from a different newsrc.eld
4461 ;; file. Use with caution, if at all.
4462 (defun gnus-import-other-newsrc-file (file)
4464 (insert-file-contents file)
4466 (while (ignore-errors
4467 (setq form (read (current-buffer))))
4468 (when (and (consp form)
4469 (eq (cadr form) 'gnus-newsrc-alist))
4470 (let ((infos (cadr (nth 2 form))))
4471 (dolist (info infos)
4472 (when (gnus-get-info (car info))
4473 (gnus-set-info (car info) info)))))))))
4475 (defun gnus-add-marked-articles (group type articles &optional info force)
4476 ;; Add ARTICLES of TYPE to the info of GROUP.
4477 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4478 ;; add, but replace marked articles of TYPE with ARTICLES.
4479 (let ((info (or info (gnus-get-info group)))
4482 (and (not (setq marked (nthcdr 3 info)))
4484 (setcdr (nthcdr 2 info)
4485 (list (list (cons type (gnus-compress-sequence
4487 (and (not (setq m (assq type (car marked))))
4490 (cons (cons type (gnus-compress-sequence articles t) )
4494 (setcar (nthcdr 3 info)
4495 (assq-delete-all type (car marked)))
4496 (setcdr m (gnus-compress-sequence articles t)))
4497 (setcdr m (gnus-compress-sequence
4498 (sort (nconc (gnus-uncompress-range (cdr m))
4499 (copy-sequence articles)) '<) t))))))
4501 (declare-function gnus-summary-add-mark "gnus-sum" (article type))
4503 (defun gnus-add-mark (group mark article)
4504 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4505 (let ((buffer (gnus-summary-buffer-name group)))
4506 (if (gnus-buffer-live-p buffer)
4507 (with-current-buffer (get-buffer buffer)
4508 (gnus-summary-add-mark article mark))
4509 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4513 ;;; Group timestamps
4516 (defun gnus-group-set-timestamp ()
4517 "Change the timestamp of the current group to the current time.
4518 This function can be used in hooks like `gnus-select-group-hook'
4519 or `gnus-group-catchup-group-hook'."
4520 (when gnus-newsgroup-name
4521 (let ((time (current-time)))
4522 (setcdr (cdr time) nil)
4523 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4525 (defsubst gnus-group-timestamp (group)
4526 "Return the timestamp for GROUP."
4527 (gnus-group-get-parameter group 'timestamp t))
4529 (defun gnus-group-timestamp-delta (group)
4530 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4531 (let* ((time (or (gnus-group-timestamp group)
4533 (delta (subtract-time (current-time) time)))
4534 (+ (* (nth 0 delta) 65536.0)
4537 (defun gnus-group-timestamp-string (group)
4538 "Return a string of the timestamp for GROUP."
4539 (let ((time (gnus-group-timestamp group)))
4542 (gnus-time-iso8601 time))))
4544 (defun gnus-group-list-cached (level &optional lowest)
4545 "List all groups with cached articles.
4546 If the prefix LEVEL is non-nil, it should be a number that says which
4547 level to cut off listing groups.
4548 If LOWEST, don't list groups with level lower than LOWEST.
4550 This command may read the active file."
4553 (setq level (prefix-numeric-value level)))
4554 (when (or (not level) (>= level gnus-level-zombie))
4556 (funcall gnus-group-prepare-function
4557 (or level gnus-level-subscribed)
4559 (let ((marks (gnus-info-marks info)))
4560 (assq 'cache marks)))
4563 (or (gnus-gethash group
4564 gnus-cache-active-hashtb)
4565 ;; Cache active file might use "."
4568 (mapconcat 'identity
4569 (split-string group ":")
4571 gnus-cache-active-hashtb))))
4572 (goto-char (point-min))
4573 (gnus-group-position-point))
4575 (defun gnus-group-list-dormant (level &optional lowest)
4576 "List all groups with dormant articles.
4577 If the prefix LEVEL is non-nil, it should be a number that says which
4578 level to cut off listing groups.
4579 If LOWEST, don't list groups with level lower than LOWEST.
4581 This command may read the active file."
4584 (setq level (prefix-numeric-value level)))
4585 (when (or (not level) (>= level gnus-level-zombie))
4587 (funcall gnus-group-prepare-function
4588 (or level gnus-level-subscribed)
4590 (let ((marks (gnus-info-marks info)))
4591 (assq 'dormant marks)))
4594 (goto-char (point-min))
4595 (gnus-group-position-point))
4597 (defun gnus-group-list-ticked (level &optional lowest)
4598 "List all groups with ticked articles.
4599 If the prefix LEVEL is non-nil, it should be a number that says which
4600 level to cut off listing groups.
4601 If LOWEST, don't list groups with level lower than LOWEST.
4603 This command may read the active file."
4606 (setq level (prefix-numeric-value level)))
4607 (when (or (not level) (>= level gnus-level-zombie))
4609 (funcall gnus-group-prepare-function
4610 (or level gnus-level-subscribed)
4612 (let ((marks (gnus-info-marks info)))
4613 (assq 'tick marks)))
4616 (goto-char (point-min))
4617 (gnus-group-position-point))
4619 (defun gnus-group-listed-groups ()
4620 "Return a list of listed groups."
4622 (goto-char (point-min))
4623 (while (setq point (text-property-not-all (point) (point-max)
4626 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4630 (defun gnus-group-list-plus (&optional args)
4631 "List groups plus the current selection."
4633 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4634 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4636 (push last-command-event unread-command-events)
4637 (push ?A unread-command-events)
4638 (let (gnus-pick-mode keys)
4639 (setq keys (read-key-sequence nil)
4640 func (lookup-key (current-local-map) keys)))
4644 (call-interactively func))))
4646 (defun gnus-group-list-flush (&optional args)
4647 "Flush groups from the current selection."
4649 (let ((gnus-group-list-option 'flush))
4650 (gnus-group-list-plus args)))
4652 (defun gnus-group-list-limit (&optional args)
4653 "List groups limited within the current selection.
4654 If you've limited the groups, you can further limit the selection
4655 with this command. If you've first limited to groups with
4656 dormant articles with `A ?', you can then further limit with
4657 `A / c', which will then limit to groups with cached articles, giving
4658 you the groups that have both dormant articles and cached articles."
4660 (let ((gnus-group-list-option 'limit))
4661 (gnus-group-list-plus args)))
4663 (declare-function gnus-mark-article-as-read "gnus-sum" (article &optional mark))
4664 (declare-function gnus-group-make-articles-read "gnus-sum" (group articles))
4666 (defun gnus-group-mark-article-read (group article)
4667 "Mark ARTICLE read."
4668 (let ((buffer (gnus-summary-buffer-name group))
4669 (mark gnus-read-mark)
4671 (if (get-buffer buffer)
4672 (with-current-buffer buffer
4673 (setq active gnus-newsgroup-active)
4674 (gnus-activate-group group)
4675 (when gnus-newsgroup-prepared
4676 (when (and gnus-newsgroup-auto-expire
4677 (memq mark gnus-auto-expirable-marks))
4678 (setq mark gnus-expirable-mark))
4679 (setq mark (gnus-request-update-mark
4680 group article mark))
4681 (gnus-request-set-mark
4682 group (list (list (list article) 'add '(read))))
4683 (gnus-mark-article-as-read article mark)
4684 (setq gnus-newsgroup-active (gnus-active group))
4686 (setq n (1+ (cdr active)))
4687 (while (<= n (cdr gnus-newsgroup-active))
4688 (unless (eq n article)
4689 (push n gnus-newsgroup-unselected))
4691 (setq gnus-newsgroup-unselected
4692 (sort gnus-newsgroup-unselected '<)))))
4693 (gnus-activate-group group)
4694 (gnus-group-make-articles-read group (list article))
4695 (when (and (gnus-group-auto-expirable-p group)
4696 (not (gnus-group-read-only-p group)))
4697 (gnus-add-marked-articles
4698 group 'expire (list article))))))
4702 ;;; Group compaction. -- dvl
4705 (defun gnus-group-compact-group (group)
4706 "Compact the current group.
4707 Compaction means removing gaps between article numbers. Hence, this
4708 operation is only meaningful for back ends using one file per article
4711 Note: currently only implemented in nnml."
4712 (interactive (list (gnus-group-group-name)))
4714 (error "No group to compact"))
4715 (unless (gnus-check-backend-function 'request-compact-group group)
4716 (error "This back end does not support group compaction"))
4717 (let ((group-decoded (gnus-group-decoded-name group)))
4719 Compacting group %s... (this may take a long time)"
4722 (if (not (gnus-request-compact-group group))
4723 (gnus-error 3 "Couldn't compact group %s" group-decoded)
4724 (gnus-message 6 "Compacting group %s...done" group-decoded)
4726 ;; Invalidate the "original article" buffer which might be out of date.
4727 ;; #### NOTE: Yes, this might be a bit rude, but since compaction
4728 ;; #### will not happen very often, I think this is acceptable.
4729 (let ((original (get-buffer gnus-original-article-buffer)))
4730 (and original (gnus-kill-buffer original)))
4731 ;; Update the group line to reflect new information (art number etc).
4732 (gnus-group-update-group-line))))
4734 (provide 'gnus-group)
4736 ;;; gnus-group.el ends here