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 (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
425 (mm-coding-system-p 'utf-8))
428 "Alist of group regexp and the charset for group names.
431 ((\"\\.com\\.cn:\" . cn-gb-2312))"
433 :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset"))))
435 (defcustom gnus-group-jump-to-group-prompt nil
436 "Default prompt for `gnus-group-jump-to-group'.
438 If non-nil, the value should be a string or an alist. If it is a string,
439 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
440 nnml:\" in the minibuffer prompt.
442 If it is an alist, it must consist of \(NUMBER . PROMPT) pairs, for example:
443 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
444 used when no prefix argument is given to `gnus-group-jump-to-group'."
446 :group 'gnus-group-various
447 :type '(choice (string :tag "Prompt string")
448 (const :tag "Empty" nil)
449 (repeat (cons (integer :tag "Argument")
450 (string :tag "Prompt string")))))
452 (defvar gnus-group-listing-limit 1000
453 "*A limit of the number of groups when listing.
454 If the number of groups is larger than the limit, list them in a
457 ;;; Internal variables
459 (defvar gnus-group-is-exiting-p nil)
460 (defvar gnus-group-is-exiting-without-update-p nil)
461 (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat
462 "Function for sorting the group buffer.")
464 (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat
465 "Function for sorting the selected groups in the group buffer.")
467 (defvar gnus-group-indentation-function nil)
468 (defvar gnus-goto-missing-group-function nil)
469 (defvar gnus-group-update-group-function nil)
470 (defvar gnus-group-goto-next-group-function nil
471 "Function to override finding the next group after listing groups.")
473 (defvar gnus-group-edit-buffer nil)
475 (defvar gnus-tmp-news-method)
476 (defvar gnus-tmp-colon)
477 (defvar gnus-tmp-news-server)
478 (defvar gnus-tmp-decoded-group)
479 (defvar gnus-tmp-header)
480 (defvar gnus-tmp-process-marked)
481 (defvar gnus-tmp-summary-live)
482 (defvar gnus-tmp-news-method-string)
483 (defvar gnus-tmp-group-icon)
484 (defvar gnus-tmp-moderated-string)
485 (defvar gnus-tmp-newsgroup-description)
486 (defvar gnus-tmp-comment)
487 (defvar gnus-tmp-qualified-group)
488 (defvar gnus-tmp-subscribed)
489 (defvar gnus-tmp-number-of-read)
490 (defvar gnus-inhibit-demon)
491 (defvar gnus-pick-mode)
492 (defvar gnus-tmp-marked-mark)
493 (defvar gnus-tmp-number-of-unread)
495 (defvar gnus-group-line-format-alist
496 `((?M gnus-tmp-marked-mark ?c)
497 (?S gnus-tmp-subscribed ?c)
498 (?L gnus-tmp-level ?d)
499 (?N (cond ((eq number t) "*" )
503 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
504 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
506 (?R gnus-tmp-number-of-read ?s)
507 (?U (if (gnus-active gnus-tmp-group)
508 (gnus-number-of-unseen-articles-in-group gnus-tmp-group)
511 (?t gnus-tmp-number-total ?d)
512 (?y gnus-tmp-number-of-unread ?s)
513 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
514 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
515 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
516 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
517 (?g (if (boundp 'gnus-tmp-decoded-group)
518 gnus-tmp-decoded-group
521 (?G gnus-tmp-qualified-group ?s)
522 (?c (gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group)
523 gnus-tmp-decoded-group
526 (?C gnus-tmp-comment ?s)
527 (?D gnus-tmp-newsgroup-description ?s)
528 (?o gnus-tmp-moderated ?c)
529 (?O gnus-tmp-moderated-string ?s)
530 (?p gnus-tmp-process-marked ?c)
531 (?s gnus-tmp-news-server ?s)
532 (?n gnus-tmp-news-method ?s)
533 (?P gnus-group-indentation ?s)
534 (?E gnus-tmp-group-icon ?s)
535 (?B gnus-tmp-summary-live ?c)
536 (?z gnus-tmp-news-method-string ?s)
537 (?m (gnus-group-new-mail gnus-tmp-group) ?c)
538 (?d (gnus-group-timestamp-string gnus-tmp-group) ?s)
539 (?u gnus-tmp-user-defined ?s)
540 (?F (gnus-total-fetched-for gnus-tmp-group) ?s)
543 (defvar gnus-group-mode-line-format-alist
544 `((?S gnus-tmp-news-server ?s)
545 (?M gnus-tmp-news-method ?s)
546 (?u gnus-tmp-user-defined ?s)
547 (?: gnus-tmp-colon ?s)))
549 (defvar gnus-topic-topology nil
550 "The complete topic hierarchy.")
552 (defvar gnus-topic-alist nil
553 "The complete topic-group alist.")
555 (defvar gnus-group-marked nil)
557 (defvar gnus-group-list-mode nil)
560 (defvar gnus-group-listed-groups nil)
561 (defvar gnus-group-list-option nil)
567 (put 'gnus-group-mode 'mode-class 'special)
569 (gnus-define-keys gnus-group-mode-map
570 " " gnus-group-read-group
571 "=" gnus-group-select-group
572 "\r" gnus-group-select-group
573 "\M-\r" gnus-group-quick-select-group
574 "\M- " gnus-group-visible-select-group
575 [(meta control return)] gnus-group-select-group-ephemerally
576 "j" gnus-group-jump-to-group
577 "n" gnus-group-next-unread-group
578 "p" gnus-group-prev-unread-group
579 "\177" gnus-group-prev-unread-group
580 [delete] gnus-group-prev-unread-group
581 "N" gnus-group-next-group
582 "P" gnus-group-prev-group
583 "\M-n" gnus-group-next-unread-group-same-level
584 "\M-p" gnus-group-prev-unread-group-same-level
585 "," gnus-group-best-unread-group
586 "." gnus-group-first-unread-group
587 "u" gnus-group-unsubscribe-current-group
588 "U" gnus-group-unsubscribe-group
589 "c" gnus-group-catchup-current
590 "C" gnus-group-catchup-current-all
591 "\M-c" gnus-group-clear-data
592 "l" gnus-group-list-groups
593 "L" gnus-group-list-all-groups
596 "g" gnus-group-get-new-news
597 "\M-g" gnus-group-get-new-news-this-group
598 "R" gnus-group-restart
599 "r" gnus-group-read-init-file
600 "B" gnus-group-browse-foreign-server
601 "b" gnus-group-check-bogus-groups
602 "F" gnus-group-find-new-groups
603 "\C-c\C-d" gnus-group-describe-group
604 "\M-d" gnus-group-describe-all-groups
605 "\C-c\C-a" gnus-group-apropos
606 "\C-c\M-\C-a" gnus-group-description-apropos
607 "a" gnus-group-post-news
608 "\ek" gnus-group-edit-local-kill
609 "\eK" gnus-group-edit-global-kill
610 "\C-k" gnus-group-kill-group
611 "\C-y" gnus-group-yank-group
612 "\C-w" gnus-group-kill-region
613 "\C-x\C-t" gnus-group-transpose-groups
614 "\C-c\C-l" gnus-group-list-killed
615 "\C-c\C-x" gnus-group-expire-articles
616 "\C-c\M-\C-x" gnus-group-expire-all-groups
618 "s" gnus-group-save-newsrc
619 "z" gnus-group-suspend
622 "?" gnus-group-describe-briefly
623 "\C-c\C-i" gnus-info-find-node
624 "\M-e" gnus-group-edit-group-method
625 "^" gnus-group-enter-server-mode
626 [mouse-2] gnus-mouse-pick-group
627 [follow-link] 'mouse-face
628 "<" beginning-of-buffer
631 "\C-c\C-s" gnus-group-sort-groups
633 "\C-c\M-g" gnus-activate-all-groups
634 "\M-&" gnus-group-universal-argument
635 "#" gnus-group-mark-group
636 "\M-#" gnus-group-unmark-group)
638 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
639 "m" gnus-group-mark-group
640 "u" gnus-group-unmark-group
641 "w" gnus-group-mark-region
642 "b" gnus-group-mark-buffer
643 "r" gnus-group-mark-regexp
644 "U" gnus-group-unmark-all-groups)
646 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
647 "u" gnus-sieve-update
648 "g" gnus-sieve-generate)
650 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
651 "d" gnus-group-make-directory-group
652 "h" gnus-group-make-help-group
653 "u" gnus-group-make-useful-group
654 "l" gnus-group-nnimap-edit-acl
655 "m" gnus-group-make-group
656 "E" gnus-group-edit-group
657 "e" gnus-group-edit-group-method
658 "p" gnus-group-edit-group-parameters
659 "v" gnus-group-add-to-virtual
660 "V" gnus-group-make-empty-virtual
661 "D" gnus-group-enter-directory
662 "f" gnus-group-make-doc-group
663 "w" gnus-group-make-web-group
664 "G" gnus-group-make-nnir-group
665 "M" gnus-group-read-ephemeral-group
666 "r" gnus-group-rename-group
667 "R" gnus-group-make-rss-group
668 "c" gnus-group-customize
669 "z" gnus-group-compact-group
670 "x" gnus-group-expunge-group
671 "\177" gnus-group-delete-group
672 [delete] gnus-group-delete-group)
674 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
675 "s" gnus-group-sort-groups
676 "a" gnus-group-sort-groups-by-alphabet
677 "u" gnus-group-sort-groups-by-unread
678 "l" gnus-group-sort-groups-by-level
679 "v" gnus-group-sort-groups-by-score
680 "r" gnus-group-sort-groups-by-rank
681 "m" gnus-group-sort-groups-by-method
682 "n" gnus-group-sort-groups-by-real-name)
684 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map)
685 "s" gnus-group-sort-selected-groups
686 "a" gnus-group-sort-selected-groups-by-alphabet
687 "u" gnus-group-sort-selected-groups-by-unread
688 "l" gnus-group-sort-selected-groups-by-level
689 "v" gnus-group-sort-selected-groups-by-score
690 "r" gnus-group-sort-selected-groups-by-rank
691 "m" gnus-group-sort-selected-groups-by-method
692 "n" gnus-group-sort-selected-groups-by-real-name)
694 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
695 "k" gnus-group-list-killed
696 "z" gnus-group-list-zombies
697 "s" gnus-group-list-groups
698 "u" gnus-group-list-all-groups
699 "A" gnus-group-list-active
700 "a" gnus-group-apropos
701 "d" gnus-group-description-apropos
702 "m" gnus-group-list-matching
703 "M" gnus-group-list-all-matching
704 "l" gnus-group-list-level
705 "c" gnus-group-list-cached
706 "?" gnus-group-list-dormant
707 "!" gnus-group-list-ticked)
709 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map)
710 "k" gnus-group-list-limit
711 "z" gnus-group-list-limit
712 "s" gnus-group-list-limit
713 "u" gnus-group-list-limit
714 "A" gnus-group-list-limit
715 "m" gnus-group-list-limit
716 "M" gnus-group-list-limit
717 "l" gnus-group-list-limit
718 "c" gnus-group-list-limit
719 "?" gnus-group-list-limit
720 "!" gnus-group-list-limit)
722 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map)
723 "k" gnus-group-list-flush
724 "z" gnus-group-list-flush
725 "s" gnus-group-list-flush
726 "u" gnus-group-list-flush
727 "A" gnus-group-list-flush
728 "m" gnus-group-list-flush
729 "M" gnus-group-list-flush
730 "l" gnus-group-list-flush
731 "c" gnus-group-list-flush
732 "?" gnus-group-list-flush
733 "!" gnus-group-list-flush)
735 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map)
736 "k" gnus-group-list-plus
737 "z" gnus-group-list-plus
738 "s" gnus-group-list-plus
739 "u" gnus-group-list-plus
740 "A" gnus-group-list-plus
741 "m" gnus-group-list-plus
742 "M" gnus-group-list-plus
743 "l" gnus-group-list-plus
744 "c" gnus-group-list-plus
745 "?" gnus-group-list-plus
746 "!" gnus-group-list-plus)
748 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
749 "f" gnus-score-flush-cache
750 "e" gnus-score-edit-all-score)
752 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
753 "d" gnus-group-describe-group
756 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
757 "l" gnus-group-set-current-level
758 "t" gnus-group-unsubscribe-current-group
759 "s" gnus-group-unsubscribe-group
760 "k" gnus-group-kill-group
761 "y" gnus-group-yank-group
762 "w" gnus-group-kill-region
763 "\C-k" gnus-group-kill-level
764 "z" gnus-group-kill-all-zombies)
766 (defun gnus-topic-mode-p ()
767 "Return non-nil in `gnus-topic-mode'."
768 (and (boundp 'gnus-topic-mode)
769 (symbol-value 'gnus-topic-mode)))
771 (defun gnus-group-make-menu-bar ()
772 (unless (boundp 'gnus-group-reading-menu)
775 gnus-group-reading-menu gnus-group-mode-map ""
777 ["Read" gnus-group-read-group
778 :included (not (gnus-topic-mode-p))
779 :active (gnus-group-group-name)]
780 ["Read " gnus-topic-read-group
781 :included (gnus-topic-mode-p)]
782 ["Select" gnus-group-select-group
783 :included (not (gnus-topic-mode-p))
784 :active (gnus-group-group-name)]
785 ["Select " gnus-topic-select-group
786 :included (gnus-topic-mode-p)]
787 ["See old articles" (gnus-group-select-group 'all)
788 :keys "C-u SPC" :active (gnus-group-group-name)]
789 ["Catch up" gnus-group-catchup-current
790 :included (not (gnus-topic-mode-p))
791 :active (gnus-group-group-name)
792 :help "Mark unread articles in the current group as read"]
793 ["Catch up " gnus-topic-catchup-articles
794 :included (gnus-topic-mode-p)
795 :help "Mark unread articles in the current group or topic as read"]
796 ["Catch up all articles" gnus-group-catchup-current-all
797 (gnus-group-group-name)]
798 ["Check for new articles" gnus-group-get-new-news-this-group
799 :included (not (gnus-topic-mode-p))
800 :active (gnus-group-group-name)
801 :help "Check for new messages in current group"]
802 ["Check for new articles " gnus-topic-get-new-news-this-topic
803 :included (gnus-topic-mode-p)
804 :help "Check for new messages in current group or topic"]
805 ["Toggle subscription" gnus-group-unsubscribe-current-group
806 (gnus-group-group-name)]
807 ["Kill" gnus-group-kill-group :active (gnus-group-group-name)
808 :help "Kill (remove) current group"]
809 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
810 ["Describe" gnus-group-describe-group :active (gnus-group-group-name)
811 :help "Display description of the current group"]
812 ;; Actually one should check, if any of the marked groups gives t for
813 ;; (gnus-check-backend-function 'request-expire-articles ...)
814 ["Expire articles" gnus-group-expire-articles
815 :included (not (gnus-topic-mode-p))
816 :active (or (and (gnus-group-group-name)
817 (gnus-check-backend-function
818 'request-expire-articles
819 (gnus-group-group-name))) gnus-group-marked)]
820 ["Expire articles " gnus-topic-expire-articles
821 :included (gnus-topic-mode-p)]
822 ["Set group level..." gnus-group-set-current-level
823 (gnus-group-group-name)]
824 ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
825 ["Customize" gnus-group-customize (gnus-group-group-name)]
826 ["Compact" gnus-group-compact-group
827 :active (gnus-group-group-name)]
829 ["Parameters" gnus-group-edit-group-parameters
830 :included (not (gnus-topic-mode-p))
831 :active (gnus-group-group-name)]
832 ["Parameters " gnus-topic-edit-parameters
833 :included (gnus-topic-mode-p)]
834 ["Select method" gnus-group-edit-group-method
835 (gnus-group-group-name)]
836 ["Info" gnus-group-edit-group (gnus-group-group-name)]
837 ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)]
838 ["Global kill file" gnus-group-edit-global-kill t])))
841 gnus-group-group-menu gnus-group-mode-map ""
844 ["List unread subscribed groups" gnus-group-list-groups t]
845 ["List (un)subscribed groups" gnus-group-list-all-groups t]
846 ["List killed groups" gnus-group-list-killed gnus-killed-list]
847 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
848 ["List level..." gnus-group-list-level t]
849 ["Describe all groups" gnus-group-describe-all-groups t]
850 ["Group apropos..." gnus-group-apropos t]
851 ["Group and description apropos..." gnus-group-description-apropos t]
852 ["List groups matching..." gnus-group-list-matching t]
853 ["List all groups matching..." gnus-group-list-all-matching t]
854 ["List active file" gnus-group-list-active t]
855 ["List groups with cached" gnus-group-list-cached t]
856 ["List groups with dormant" gnus-group-list-dormant t]
857 ["List groups with ticked" gnus-group-list-ticked t])
859 ["Default sort" gnus-group-sort-groups t]
860 ["Sort by method" gnus-group-sort-groups-by-method t]
861 ["Sort by rank" gnus-group-sort-groups-by-rank t]
862 ["Sort by score" gnus-group-sort-groups-by-score t]
863 ["Sort by level" gnus-group-sort-groups-by-level t]
864 ["Sort by unread" gnus-group-sort-groups-by-unread t]
865 ["Sort by name" gnus-group-sort-groups-by-alphabet t]
866 ["Sort by real name" gnus-group-sort-groups-by-real-name t])
867 ("Sort process/prefixed"
868 ["Default sort" gnus-group-sort-selected-groups
869 (not (gnus-topic-mode-p))]
870 ["Sort by method" gnus-group-sort-selected-groups-by-method
871 (not (gnus-topic-mode-p))]
872 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
873 (not (gnus-topic-mode-p))]
874 ["Sort by score" gnus-group-sort-selected-groups-by-score
875 (not (gnus-topic-mode-p))]
876 ["Sort by level" gnus-group-sort-selected-groups-by-level
877 (not (gnus-topic-mode-p))]
878 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
879 (not (gnus-topic-mode-p))]
880 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
881 (not (gnus-topic-mode-p))]
882 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
883 (not (gnus-topic-mode-p))])
885 ["Mark group" gnus-group-mark-group
886 (and (gnus-group-group-name)
887 (not (memq (gnus-group-group-name) gnus-group-marked)))]
888 ["Unmark group" gnus-group-unmark-group
889 (and (gnus-group-group-name)
890 (memq (gnus-group-group-name) gnus-group-marked))]
891 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
892 ["Mark regexp..." gnus-group-mark-regexp t]
893 ["Mark region" gnus-group-mark-region :active mark-active]
894 ["Mark buffer" gnus-group-mark-buffer t]
895 ["Execute command" gnus-group-universal-argument
896 (or gnus-group-marked (gnus-group-group-name))])
898 ["Subscribe to a group..." gnus-group-unsubscribe-group t]
899 ["Kill all newsgroups in region" gnus-group-kill-region
901 ["Kill all zombie groups" gnus-group-kill-all-zombies
903 ["Kill all groups on level..." gnus-group-kill-level t])
905 ["Make a foreign group..." gnus-group-make-group t]
906 ["Add a directory group..." gnus-group-make-directory-group t]
907 ["Add the help group" gnus-group-make-help-group t]
908 ["Make a doc group..." gnus-group-make-doc-group t]
909 ["Make a web group..." gnus-group-make-web-group t]
910 ["Make a search group..." gnus-group-make-nnir-group t]
911 ["Make a virtual group..." gnus-group-make-empty-virtual t]
912 ["Add a group to a virtual..." gnus-group-add-to-virtual t]
913 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t]
914 ["Make an RSS group..." gnus-group-make-rss-group t]
915 ["Rename group..." gnus-group-rename-group
916 (gnus-check-backend-function
917 'request-rename-group (gnus-group-group-name))]
918 ["Delete group" gnus-group-delete-group
919 (gnus-check-backend-function
920 'request-delete-group (gnus-group-group-name))])
922 ["Next" gnus-group-next-group t]
923 ["Previous" gnus-group-prev-group t]
924 ["Next unread" gnus-group-next-unread-group t]
925 ["Previous unread" gnus-group-prev-unread-group t]
926 ["Next unread same level" gnus-group-next-unread-group-same-level t]
927 ["Previous unread same level"
928 gnus-group-prev-unread-group-same-level t]
929 ["Jump to group..." gnus-group-jump-to-group t]
930 ["First unread group" gnus-group-first-unread-group t]
931 ["Best unread group" gnus-group-best-unread-group t])
933 ["Generate" gnus-sieve-generate t]
934 ["Generate and update" gnus-sieve-update t])
935 ["Delete bogus groups" gnus-group-check-bogus-groups t]
936 ["Find new newsgroups" gnus-group-find-new-groups t]
937 ["Transpose" gnus-group-transpose-groups
938 (gnus-group-group-name)]
939 ["Read a directory as a group..." gnus-group-enter-directory t]))
942 gnus-group-misc-menu gnus-group-mode-map ""
944 ["Send a mail" gnus-group-mail t]
945 ["Send a message (mail or news)" gnus-group-post-news t]
946 ["Create a local message" gnus-group-news t]
947 ["Check for new news" gnus-group-get-new-news
948 :help "Get newly arrived articles"]
949 ["Send queued messages" gnus-delay-send-queue
950 :help "Send all messages that are scheduled to be sent now"]
951 ["Activate all groups" gnus-activate-all-groups t]
952 ["Restart Gnus" gnus-group-restart t]
953 ["Read init file" gnus-group-read-init-file t]
954 ["Browse foreign server..." gnus-group-browse-foreign-server t]
955 ["Enter server buffer" gnus-group-enter-server-mode t]
956 ["Expire all expirable articles" gnus-group-expire-all-groups t]
957 ["Gnus version" gnus-version t]
958 ["Save .newsrc files" gnus-group-save-newsrc t]
959 ["Suspend Gnus" gnus-group-suspend t]
960 ["Clear dribble buffer" gnus-group-clear-dribble t]
961 ["Read manual" gnus-info-find-node t]
962 ["Flush score cache" gnus-score-flush-cache t]
963 ["Toggle topics" gnus-topic-mode t]
964 ["Send a bug report" gnus-bug t]
965 ["Exit from Gnus" gnus-group-exit :help "Quit reading news"]
966 ["Exit without saving" gnus-group-quit t]))
968 (gnus-run-hooks 'gnus-group-menu-hook)))
971 (defvar gnus-group-tool-bar-map nil)
973 (defun gnus-group-tool-bar-update (&optional symbol value)
974 "Update group buffer toolbar.
975 Setter function for custom variables."
977 (set-default symbol value))
978 ;; (setq-default gnus-group-tool-bar-map nil)
979 ;; (use-local-map gnus-group-mode-map)
981 (with-current-buffer gnus-group-buffer
982 (gnus-group-make-tool-bar t))))
984 (defcustom gnus-group-tool-bar (if (eq gmm-tool-bar-style 'gnome)
985 'gnus-group-tool-bar-gnome
986 'gnus-group-tool-bar-retro)
987 "Specifies the Gnus group tool bar.
989 It can be either a list or a symbol referring to a list. See
990 `gmm-tool-bar-from-list' for the format of the list. The
991 default key map is `gnus-group-mode-map'.
993 Pre-defined symbols include `gnus-group-tool-bar-gnome' and
994 `gnus-group-tool-bar-retro'."
995 :type '(choice (const :tag "GNOME style" gnus-group-tool-bar-gnome)
996 (const :tag "Retro look" gnus-group-tool-bar-retro)
997 (repeat :tag "User defined list" gmm-tool-bar-item)
999 :version "23.1" ;; No Gnus
1000 :initialize 'custom-initialize-default
1001 :set 'gnus-group-tool-bar-update
1004 (defcustom gnus-group-tool-bar-gnome
1005 '((gnus-group-post-news "mail/compose")
1006 ;; Some useful agent icons? I don't use the agent so agent users should
1007 ;; suggest useful commands:
1008 (gnus-agent-toggle-plugged "unplugged" t
1009 :help "Gnus is currently unplugged. Click to work online."
1010 :visible (and gnus-agent (not gnus-plugged)))
1011 (gnus-agent-toggle-plugged "plugged" t
1012 :help "Gnus is currently plugged. Click to work offline."
1013 :visible (and gnus-agent gnus-plugged))
1014 ;; FIXME: gnus-agent-toggle-plugged (in gnus-agent-group-make-menu-bar)
1015 ;; should have a better help text.
1016 (gnus-group-send-queue "mail/outbox" t
1017 :visible (and gnus-agent gnus-plugged)
1018 :help "Send articles from the queue group")
1019 (gnus-group-get-new-news "mail/inbox" nil
1020 :visible (or (not gnus-agent)
1022 ;; FIXME: gnus-*-read-group should have a better help text.
1023 (gnus-topic-read-group "open" nil
1024 :visible (and (boundp 'gnus-topic-mode)
1026 (gnus-group-read-group "open" nil
1027 :visible (not (and (boundp 'gnus-topic-mode)
1029 ;; (gnus-group-find-new-groups "???" nil)
1030 (gnus-group-save-newsrc "save")
1031 (gnus-group-describe-group "describe")
1032 (gnus-group-unsubscribe-current-group "gnus/toggle-subscription")
1033 (gnus-group-prev-unread-group "left-arrow")
1034 (gnus-group-next-unread-group "right-arrow")
1035 (gnus-group-exit "exit")
1036 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
1037 (gnus-info-find-node "help"))
1038 "List of functions for the group tool bar (GNOME style).
1040 See `gmm-tool-bar-from-list' for the format of the list."
1041 :type '(repeat gmm-tool-bar-item)
1042 :version "23.1" ;; No Gnus
1043 :initialize 'custom-initialize-default
1044 :set 'gnus-group-tool-bar-update
1047 (defcustom gnus-group-tool-bar-retro
1048 '((gnus-group-get-new-news "gnus/get-news")
1049 (gnus-group-get-new-news-this-group "gnus/gnntg")
1050 (gnus-group-catchup-current "gnus/catchup")
1051 (gnus-group-describe-group "gnus/describe-group")
1052 (gnus-group-subscribe "gnus/subscribe" t
1053 :help "Subscribe to the current group")
1054 (gnus-group-unsubscribe "gnus/unsubscribe" t
1055 :help "Unsubscribe from the current group")
1056 (gnus-group-exit "gnus/exit-gnus" gnus-group-mode-map))
1057 "List of functions for the group tool bar (retro look).
1059 See `gmm-tool-bar-from-list' for the format of the list."
1060 :type '(repeat gmm-tool-bar-item)
1061 :version "23.1" ;; No Gnus
1062 :initialize 'custom-initialize-default
1063 :set 'gnus-group-tool-bar-update
1066 (defcustom gnus-group-tool-bar-zap-list t
1067 "List of icon items from the global tool bar.
1068 These items are not displayed in the Gnus group mode tool bar.
1070 See `gmm-tool-bar-from-list' for the format of the list."
1071 :type 'gmm-tool-bar-zap-list
1072 :version "23.1" ;; No Gnus
1073 :initialize 'custom-initialize-default
1074 :set 'gnus-group-tool-bar-update
1077 (defvar image-load-path)
1078 (defvar tool-bar-map)
1080 (defun gnus-group-make-tool-bar (&optional force)
1081 "Make a group mode tool bar from `gnus-group-tool-bar'.
1082 When FORCE, rebuild the tool bar."
1083 (when (and (boundp 'tool-bar-mode)
1086 (or (not gnus-group-tool-bar-map) force))
1088 (gmm-image-load-path-for-library "gnus"
1089 "gnus/toggle-subscription.xpm"
1091 (image-load-path (cons (car load-path)
1092 (when (boundp 'image-load-path)
1094 (map (gmm-tool-bar-from-list gnus-group-tool-bar
1095 gnus-group-tool-bar-zap-list
1096 'gnus-group-mode-map)))
1098 (set (make-local-variable 'tool-bar-map) map))))
1099 gnus-group-tool-bar-map)
1101 (define-derived-mode gnus-group-mode fundamental-mode "Group"
1102 "Major mode for reading news.
1104 All normal editing commands are switched off.
1105 \\<gnus-group-mode-map>
1106 The group buffer lists (some of) the groups available. For instance,
1107 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1108 lists all zombie groups.
1110 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1111 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1113 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1115 The following commands are available:
1117 \\{gnus-group-mode-map}"
1118 (when (gnus-visual-p 'group-menu 'menu)
1119 (gnus-group-make-menu-bar)
1120 (gnus-group-make-tool-bar))
1121 (gnus-simplify-mode-line)
1122 (gnus-group-set-mode-line)
1123 (setq mode-line-process nil)
1124 (buffer-disable-undo)
1125 (setq truncate-lines t)
1126 (setq buffer-read-only t
1127 show-trailing-whitespace nil)
1128 (gnus-set-default-directory)
1129 (gnus-update-format-specifications nil 'group 'group-mode)
1130 (gnus-update-group-mark-positions)
1136 (defun gnus-update-group-mark-positions ()
1138 (let ((gnus-process-mark ?\200)
1139 (gnus-group-update-hook nil)
1140 (gnus-group-marked '("dummy.group"))
1141 (gnus-active-hashtb (make-vector 10 0)))
1142 (gnus-set-active "dummy.group" '(0 . 0))
1143 (gnus-set-work-buffer)
1144 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
1145 (goto-char (point-min))
1146 (setq gnus-group-mark-positions
1147 (list (cons 'process (and (search-forward
1148 (mm-string-to-multibyte "\200") nil t)
1149 (- (point) (point-min) 1))))))))
1151 (defun gnus-mouse-pick-group (e)
1152 "Enter the group under the mouse pointer."
1155 (gnus-group-read-group nil))
1157 (defun gnus-group-default-list-level ()
1158 "Return the real value for `gnus-group-default-list-level'."
1159 (if (functionp gnus-group-default-list-level)
1160 (funcall gnus-group-default-list-level)
1161 gnus-group-default-list-level))
1163 ;; Look at LEVEL and find out what the level is really supposed to be.
1164 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1165 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1166 (defun gnus-group-default-level (&optional level number-or-nil)
1168 (gnus-group-use-permanent-levels
1169 (or (setq gnus-group-use-permanent-levels
1170 (or level (if (numberp gnus-group-use-permanent-levels)
1171 gnus-group-use-permanent-levels
1172 (or (gnus-group-default-list-level)
1173 gnus-level-subscribed))))
1174 (gnus-group-default-list-level) gnus-level-subscribed))
1178 (or level (gnus-group-default-list-level) gnus-level-subscribed))))
1180 (defun gnus-group-setup-buffer ()
1181 (set-buffer (gnus-get-buffer-create gnus-group-buffer))
1182 (unless (derived-mode-p 'gnus-group-mode)
1185 (defun gnus-group-name-charset (method group)
1187 (setq method (gnus-find-method-for-group group)))
1188 (when (stringp method)
1189 (setq method (gnus-server-to-method method)))
1190 (if (eq (car method) 'nnimap)
1191 ;; IMAP groups should not be encoded, since they do the encoding
1192 ;; in utf7 in the protocol.
1194 (let ((item (or (assoc method gnus-group-name-charset-method-alist)
1196 (assoc (list (car method) (cadr method))
1197 gnus-group-name-charset-method-alist))))
1198 (alist gnus-group-name-charset-group-alist)
1202 (while (setq item (pop alist))
1203 (if (string-match (car item) group)
1205 result (cdr item))))
1208 (defun gnus-group-name-decode (string charset)
1209 ;; Fixme: Don't decode in unibyte mode.
1210 (if (and string charset (featurep 'mule))
1211 (mm-decode-coding-string string charset)
1214 (defun gnus-group-decoded-name (string)
1215 (let ((charset (gnus-group-name-charset nil string)))
1216 (gnus-group-name-decode string charset)))
1218 (defun gnus-group-list-groups (&optional level unread lowest)
1219 "List newsgroups with level LEVEL or lower that have unread articles.
1220 Default is all subscribed groups.
1221 If argument UNREAD is non-nil, groups with no unread articles are also
1224 Also see the `gnus-group-use-permanent-levels' variable."
1226 (list (if current-prefix-arg
1227 (prefix-numeric-value current-prefix-arg)
1229 (gnus-group-default-level nil t)
1230 (gnus-group-default-list-level)
1231 gnus-level-subscribed))))
1233 (setq level (car gnus-group-list-mode)
1234 unread (cdr gnus-group-list-mode)))
1235 (setq level (gnus-group-default-level level))
1236 (gnus-group-setup-buffer)
1237 (gnus-update-format-specifications nil 'group 'group-mode)
1238 (let ((case-fold-search nil)
1239 (props (text-properties-at (point-at-bol)))
1240 (empty (= (point-min) (point-max)))
1241 (group (gnus-group-group-name))
1243 (set-buffer gnus-group-buffer)
1244 (setq number (funcall gnus-group-prepare-function level unread lowest))
1245 (when (or (and (numberp number)
1247 (zerop (buffer-size)))
1248 ;; No groups in the buffer.
1249 (gnus-message 5 "%s" gnus-no-groups-message))
1250 ;; We have some groups displayed.
1251 (goto-char (point-max))
1252 (when (or (not gnus-group-goto-next-group-function)
1253 (not (funcall gnus-group-goto-next-group-function
1257 (goto-char (point-min)))
1259 ;; Go to the first group with unread articles.
1260 (gnus-group-search-forward t))
1262 ;; Find the right group to put point on. If the current group
1263 ;; has disappeared in the new listing, try to find the next
1264 ;; one. If no next one can be found, just leave point at the
1265 ;; first newsgroup in the buffer.
1266 (when (not (gnus-goto-char
1268 (point-min) (point-max)
1269 'gnus-group (gnus-intern-safe
1270 group gnus-active-hashtb))))
1271 (let ((newsrc (cdddr (gnus-group-entry group))))
1273 (not (gnus-goto-char
1275 (point-min) (point-max) 'gnus-group
1277 (caar newsrc) gnus-active-hashtb)))))
1278 (setq newsrc (cdr newsrc)))
1280 (goto-char (point-max))
1281 (forward-line -1)))))))
1282 ;; Adjust cursor point.
1283 (gnus-group-position-point)))
1285 (defun gnus-group-list-level (level &optional all)
1286 "List groups on LEVEL.
1287 If ALL (the prefix), also list groups that have no unread articles."
1288 (interactive "nList groups on level: \nP")
1289 (gnus-group-list-groups level all level))
1291 (defun gnus-group-prepare-logic (group test)
1292 (or (and gnus-group-listed-groups
1293 (null gnus-group-list-option)
1294 (member group gnus-group-listed-groups))
1296 ((null gnus-group-listed-groups) test)
1297 ((null gnus-group-list-option) test)
1298 (t (and (member group gnus-group-listed-groups)
1299 (if (eq gnus-group-list-option 'flush)
1303 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp)
1304 "List all newsgroups with unread articles of level LEVEL or lower.
1305 If PREDICATE is a function, list groups that the function returns non-nil;
1306 if it is t, list groups that have no unread articles.
1307 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1308 If REGEXP is a function, list dead groups that the function returns non-nil;
1309 if it is a string, only list groups matching REGEXP."
1310 (set-buffer gnus-group-buffer)
1311 (let ((buffer-read-only nil)
1312 (newsrc (cdr gnus-newsrc-alist))
1313 (lowest (or lowest 1))
1314 (not-in-list (and gnus-group-listed-groups
1315 (copy-sequence gnus-group-listed-groups)))
1316 info clevel unread group params)
1318 (when (or (< lowest gnus-level-zombie)
1319 gnus-group-listed-groups)
1320 ;; List living groups.
1322 (setq info (car newsrc)
1323 group (gnus-info-group info)
1324 params (gnus-info-params info)
1326 unread (gnus-group-unread group))
1328 (setq not-in-list (delete group not-in-list)))
1329 (when (gnus-group-prepare-logic
1331 (and (or unread ; This group might be unchecked
1332 predicate) ; Check if this group should be listed
1333 (or (not (stringp regexp))
1334 (string-match regexp group))
1335 (<= (setq clevel (gnus-info-level info)) level)
1338 ((functionp predicate)
1339 (funcall predicate info))
1340 (predicate t) ; We list all groups?
1343 (if (eq unread t) ; Inactive?
1344 gnus-group-list-inactive-groups
1346 (and (numberp unread) (> unread 0)))
1347 ; We list groups with unread articles
1348 (and gnus-list-groups-with-ticked-articles
1349 (cdr (assq 'tick (gnus-info-marks info))))
1350 ; And groups with ticked articles
1351 ;; Check for permanent visibility.
1352 (and gnus-permanently-visible-groups
1353 (string-match gnus-permanently-visible-groups
1355 (memq 'visible params)
1356 (cdr (assq 'visible params)))))))
1357 (gnus-group-insert-group-line
1358 group (gnus-info-level info)
1359 (gnus-info-marks info) unread (gnus-info-method info)))))
1361 ;; List dead groups.
1362 (when (or gnus-group-listed-groups
1363 (and (>= level gnus-level-zombie)
1364 (<= lowest gnus-level-zombie)))
1365 (gnus-group-prepare-flat-list-dead
1366 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
1367 gnus-level-zombie ?Z
1370 (dolist (group gnus-zombie-list)
1371 (setq not-in-list (delete group not-in-list))))
1372 (when (or gnus-group-listed-groups
1373 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
1374 (gnus-group-prepare-flat-list-dead
1377 (setq gnus-killed-list (sort gnus-killed-list 'string<))
1379 gnus-level-killed ?K regexp))
1381 (gnus-group-set-mode-line)
1382 (setq gnus-group-list-mode (cons level predicate))
1383 (gnus-run-hooks 'gnus-group-prepare-hook)
1386 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
1387 ;; List zombies and killed lists somewhat faster, which was
1388 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1389 ;; this by ignoring the group format specification altogether.
1391 (if (> (length groups) gnus-group-listing-limit)
1393 (setq group (pop groups))
1394 (when (gnus-group-prepare-logic
1397 (and (stringp regexp) (string-match regexp group))
1398 (and (functionp regexp) (funcall regexp group))))
1399 (gnus-add-text-properties
1400 (point) (prog1 (1+ (point))
1401 (insert " " mark " *: "
1402 (gnus-group-decoded-name group)
1404 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
1406 'gnus-level level))))
1408 (setq group (pop groups))
1409 (when (gnus-group-prepare-logic
1412 (and (stringp regexp) (string-match regexp group))
1413 (and (functionp regexp) (funcall regexp group))))
1414 (gnus-group-insert-group-line
1416 (let ((active (gnus-active group)))
1418 (if (zerop (cdr active))
1420 (- (1+ (cdr active)) (car active)))
1422 (gnus-method-simplify (gnus-find-method-for-group group))))))))
1424 (defun gnus-group-update-group-line ()
1425 "Update the current line in the group buffer."
1426 (let* ((buffer-read-only nil)
1427 (group (gnus-group-group-name))
1428 (entry (and group (gnus-group-entry group)))
1429 gnus-group-indentation)
1432 (not (gnus-ephemeral-group-p group))
1434 (concat "(gnus-group-set-info '"
1435 (gnus-prin1-to-string (nth 2 entry))
1437 (concat "^(gnus-group-set-info '(\"" (regexp-quote group) "\"")))
1438 (setq gnus-group-indentation (gnus-group-group-indentation))
1440 (gnus-group-insert-group-line-info group)
1442 (gnus-group-position-point))))
1444 (defun gnus-group-insert-group-line-info (group)
1445 "Insert GROUP on the current line."
1446 (let ((entry (gnus-group-entry group))
1447 (gnus-group-indentation (gnus-group-group-indentation))
1451 ;; (Un)subscribed group.
1452 (setq info (nth 2 entry))
1453 (gnus-group-insert-group-line
1454 group (gnus-info-level info) (gnus-info-marks info)
1455 (or (car entry) t) (gnus-info-method info)))
1456 ;; This group is dead.
1457 (gnus-group-insert-group-line
1459 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
1461 (if (setq active (gnus-active group))
1462 (if (zerop (cdr active))
1464 (- (1+ (cdr active)) (car active)))
1466 (gnus-method-simplify (gnus-find-method-for-group group))))))
1468 (defun gnus-number-of-unseen-articles-in-group (group)
1469 (let* ((info (nth 2 (gnus-group-entry group)))
1470 (marked (gnus-info-marks info))
1471 (seen (cdr (assq 'seen marked)))
1472 (active (gnus-active group)))
1475 (length (gnus-uncompress-range
1476 (gnus-range-difference
1477 (gnus-range-difference (list active) (gnus-info-read info))
1480 ;; Moving through the Group buffer (in topic mode) e.g. with C-n doesn't
1481 ;; update the state (enabled/disabled) of the icon `gnus-group-describe-group'
1482 ;; automatically. After `C-l' the state is correct. See the following report
1484 ;; <http://thread.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de>:
1485 ;; From: Reiner Steib
1486 ;; Subject: tool bar icons not updated according to :active condition
1487 ;; Newsgroups: gmane.emacs.devel
1488 ;; Date: Mon, 23 Jan 2006 19:59:13 +0100
1489 ;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
1491 (defcustom gnus-group-update-tool-bar
1492 (and (boundp 'tool-bar-mode)
1494 ;; Using `redraw-frame' (see `gnus-tool-bar-update') in Emacs might
1495 ;; be confusing, so maybe we shouldn't call it by default.
1496 (fboundp 'force-window-update))
1497 "Force updating the group buffer tool bar."
1500 :initialize 'custom-initialize-default
1501 :set (lambda (symbol value)
1502 (set-default symbol value)
1503 (when (gnus-alive-p)
1504 (with-current-buffer gnus-group-buffer
1505 ;; FIXME: Is there a better way to redraw the group buffer?
1506 (gnus-group-get-new-news 0))))
1509 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1510 gnus-tmp-marked number
1512 "Insert a group line in the group buffer."
1513 (let* ((gnus-tmp-method
1514 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
1515 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1517 (gnus-tmp-active (gnus-active gnus-tmp-group))
1518 (gnus-tmp-number-total
1520 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
1522 (gnus-tmp-number-of-unread
1523 (if (numberp number) (int-to-string (max 0 number))
1525 (gnus-tmp-number-of-read
1526 (if (numberp number)
1527 (int-to-string (max 0 (- gnus-tmp-number-total number)))
1529 (gnus-tmp-subscribed
1530 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
1531 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
1532 ((= gnus-tmp-level gnus-level-zombie) ?Z)
1534 (gnus-tmp-qualified-group
1535 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group)
1536 group-name-charset))
1538 (or (gnus-group-get-parameter gnus-tmp-group 'comment t)
1540 (gnus-tmp-newsgroup-description
1541 (if gnus-description-hashtb
1542 (or (gnus-group-name-decode
1543 (gnus-gethash gnus-tmp-group gnus-description-hashtb)
1544 group-name-charset) "")
1547 (if (and gnus-moderated-hashtb
1548 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
1550 (gnus-tmp-moderated-string
1551 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
1552 (gnus-tmp-group-icon (gnus-group-get-icon gnus-tmp-group))
1553 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
1554 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
1555 (gnus-tmp-news-method-string
1557 (format "(%s:%s)" (car gnus-tmp-method)
1558 (cadr gnus-tmp-method)) ""))
1559 (gnus-tmp-marked-mark
1560 (if (and (numberp number)
1562 (cdr (assq 'tick gnus-tmp-marked)))
1564 (gnus-tmp-summary-live
1565 (if (and (not gnus-group-is-exiting-p)
1566 (gnus-buffer-live-p (gnus-summary-buffer-name
1569 (gnus-tmp-process-marked
1570 (if (member gnus-tmp-group gnus-group-marked)
1571 gnus-process-mark ? ))
1572 (buffer-read-only nil)
1574 gnus-tmp-header) ; passed as parameter to user-funcs.
1577 (gnus-add-text-properties
1581 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1582 gnus-tmp-group group-name-charset)))
1583 (eval gnus-group-line-format-spec)))
1584 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
1585 gnus-unread ,(if (numberp number)
1586 (string-to-number gnus-tmp-number-of-unread)
1588 gnus-marked ,gnus-tmp-marked-mark
1589 gnus-indentation ,gnus-group-indentation
1590 gnus-level ,gnus-tmp-level))
1592 (gnus-group--setup-tool-bar-update beg end)
1594 (when (inline (gnus-visual-p 'group-highlight 'highlight))
1595 (gnus-group-highlight-line gnus-tmp-group beg end))
1596 (gnus-run-hooks 'gnus-group-update-hook)
1599 (defun gnus-group--setup-tool-bar-update (beg end)
1600 (when gnus-group-update-tool-bar
1601 (if (fboundp 'cursor-sensor-mode)
1603 (unless (bound-and-true-p cursor-sensor-mode)
1604 (cursor-sensor-mode 1))
1605 (gnus-put-text-property beg end 'cursor-sensor-functions
1606 '(gnus-tool-bar-update)))
1607 (gnus-put-text-property beg end 'point-entered
1608 #'gnus-tool-bar-update)
1609 (gnus-put-text-property beg end 'point-left
1610 #'gnus-tool-bar-update))))
1612 (defun gnus-group-update-eval-form (group list)
1613 "Eval `car' of each element of LIST, and return the first that return t.
1614 Some value are bound so the form can use them."
1615 (defvar group-age) (defvar ticked) (defvar score) (defvar level)
1616 (defvar mailp) (defvar total) (defvar unread)
1618 (let* ((entry (gnus-group-entry group))
1619 (unread (if (numberp (car entry)) (car entry) 0))
1620 (active (gnus-active group))
1621 (total (if active (1+ (- (cdr active) (car active))) 0))
1622 (info (nth 2 entry))
1623 (method (inline (gnus-server-get-method group (gnus-info-method info))))
1624 (marked (gnus-info-marks info))
1625 (mailp (apply 'append
1628 (memq x (assoc (symbol-name
1629 (car (or method gnus-select-method)))
1630 gnus-valid-select-methods)))
1631 '(mail post-mail))))
1632 (level (or (gnus-info-level info) gnus-level-killed))
1633 (score (or (gnus-info-score info) 0))
1634 (ticked (gnus-range-length (cdr (assq 'tick marked))))
1635 (group-age (gnus-group-timestamp-delta group)))
1636 ;; FIXME: http://thread.gmane.org/gmane.emacs.gnus.general/65451/focus=65465
1637 ;; ======================================================================
1638 ;; From: Richard Stallman
1639 ;; Subject: Re: Rewriting gnus-group-highlight-line (was: [...])
1640 ;; Cc: ding@gnus.org
1641 ;; Date: Sat, 27 Oct 2007 19:41:20 -0400
1642 ;; Message-ID: <E1IlvHM-0006TS-7t@fencepost.gnu.org>
1645 ;; The kludge is that the alist elements contain expressions that refer
1646 ;; to local variables with short names. Perhaps write your own tiny
1647 ;; evaluator that handles just `and', `or', and numeric comparisons
1648 ;; and just a few specific variables.
1649 ;; ======================================================================
1651 ;; Similar for other evaluated variables. Grep for risky-local-variable
1652 ;; to find them! -- rsteib
1654 ;; Eval the cars of the lists until we find a match.
1656 (not (eval (caar list))))
1657 (setq list (cdr list)))
1660 (defun gnus-group-highlight-line (group beg end)
1661 "Highlight the current line according to `gnus-group-highlight'.
1662 GROUP is current group, and the line to highlight starts at BEG
1664 (let ((face (cdar (gnus-group-update-eval-form
1666 gnus-group-highlight))))
1667 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
1668 (let ((inhibit-read-only t))
1669 (gnus-put-text-property-excluding-characters-with-faces
1671 (if (boundp face) (symbol-value face) face)))
1672 (gnus-extent-start-open beg))))
1674 (defun gnus-group-get-icon (group)
1675 "Return an icon for GROUP according to `gnus-group-icon-list'."
1676 (if gnus-group-icon-list
1678 (cdar (gnus-group-update-eval-form group gnus-group-icon-list))))
1683 (gnus-create-image (expand-file-name image-path))
1689 (defun gnus-group-refresh-group (group)
1690 (gnus-activate-group group)
1691 (gnus-get-unread-articles-in-group (gnus-get-info group)
1692 (gnus-active group))
1693 (gnus-group-update-group group))
1695 (defun gnus-group-update-group (group &optional visible-only
1697 "Update all lines where GROUP appear.
1698 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1699 already. If INFO-UNCHANGED is non-nil, dribble buffer is not updated."
1700 (with-current-buffer gnus-group-buffer
1702 ;; The buffer may be narrowed.
1705 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
1707 found buffer-read-only)
1708 (unless info-unchanged
1709 ;; Enter the current status into the dribble buffer.
1710 (let ((entry (gnus-group-entry group)))
1712 (not (gnus-ephemeral-group-p group)))
1714 (concat "(gnus-group-set-info '"
1715 (gnus-prin1-to-string (nth 2 entry))
1717 (concat "^(gnus-group-set-info '(\""
1718 (regexp-quote group) "\"")))))
1719 ;; Find all group instances. If topics are in use, each group
1720 ;; may be listed in more than once.
1721 (while (setq loc (text-property-any
1722 loc (point-max) 'gnus-group ident))
1725 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1727 (gnus-group-insert-group-line-info group)
1730 (gnus-run-hooks 'gnus-group-update-group-hook)))
1731 (setq loc (1+ loc)))
1732 (unless (or found visible-only)
1733 ;; No such line in the buffer, find out where it's supposed to
1734 ;; go, and insert it there (or at the end of the buffer).
1735 (if gnus-goto-missing-group-function
1736 (funcall gnus-goto-missing-group-function group)
1737 (let ((entry (cddr (gnus-group-entry group))))
1738 (while (and entry (car entry)
1742 (point-min) (point-max)
1743 'gnus-group (gnus-intern-safe
1745 gnus-active-hashtb)))))
1746 (setq entry (cdr entry)))
1747 (or entry (goto-char (point-max)))))
1748 ;; Finally insert the line.
1749 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1750 (gnus-group-insert-group-line-info group)
1753 (gnus-run-hooks 'gnus-group-update-group-hook))))
1754 (when gnus-group-update-group-function
1755 (funcall gnus-group-update-group-function group))
1756 (gnus-group-set-mode-line))))))
1758 (defun gnus-group-set-mode-line ()
1759 "Update the mode line in the group buffer."
1760 (when (memq 'group gnus-updated-mode-lines)
1761 ;; Yes, we want to keep this mode line updated.
1762 (with-current-buffer gnus-group-buffer
1763 (let* ((gformat (or gnus-group-mode-line-format-spec
1764 (gnus-set-format 'group-mode)))
1765 (gnus-tmp-news-server (cadr gnus-select-method))
1766 (gnus-tmp-news-method (car gnus-select-method))
1767 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
1769 gnus-tmp-header ;Dummy binding for user-defined formats
1770 ;; Get the resulting string.
1772 (and gnus-dribble-buffer
1773 (buffer-name gnus-dribble-buffer)
1774 (buffer-modified-p gnus-dribble-buffer)
1775 (with-current-buffer gnus-dribble-buffer
1776 (not (zerop (buffer-size))))))
1777 (mode-string (eval gformat)))
1778 ;; Say whether the dribble buffer has been modified.
1779 (setq mode-line-modified
1780 (if modified "**" "--"))
1781 ;; If the line is too long, we chop it off.
1782 (when (> (length mode-string) max-len)
1783 (setq mode-string (substring mode-string 0 (- max-len 4))))
1785 (setq mode-line-buffer-identification
1786 (gnus-mode-line-buffer-identification
1787 (list mode-string)))
1788 (set-buffer-modified-p modified))))))
1790 (defun gnus-group-group-name ()
1791 "Get the name of the newsgroup on the current line."
1792 (let ((group (get-text-property (point-at-bol) 'gnus-group)))
1796 (symbol-name group)))))
1798 (defun gnus-group-group-level ()
1799 "Get the level of the newsgroup on the current line."
1800 (get-text-property (point-at-bol) 'gnus-level))
1802 (defun gnus-group-group-indentation ()
1803 "Get the indentation of the newsgroup on the current line."
1804 (or (get-text-property (point-at-bol) 'gnus-indentation)
1805 (and gnus-group-indentation-function
1806 (funcall gnus-group-indentation-function))
1809 (defun gnus-group-group-unread ()
1810 "Get the number of unread articles of the newsgroup on the current line."
1811 (get-text-property (point-at-bol) 'gnus-unread))
1813 (defun gnus-group-new-mail (group)
1814 (if (nnmail-new-mail-p (gnus-group-real-name group))
1818 (defun gnus-group-level (group)
1819 "Return the estimated level of GROUP."
1820 (or (gnus-info-level (gnus-get-info group))
1821 (and (member group gnus-zombie-list) gnus-level-zombie)
1824 (defun gnus-group-search-forward (&optional backward all level first-too)
1825 "Find the next newsgroup with unread articles.
1826 If BACKWARD is non-nil, find the previous newsgroup instead.
1827 If ALL is non-nil, just find any newsgroup.
1828 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1830 If FIRST-TOO, the current line is also eligible as a target."
1831 (let ((way (if backward -1 1))
1832 (low gnus-level-killed)
1835 (if (and backward (progn (beginning-of-line)) (bobp))
1844 (get-text-property (point) 'gnus-group)
1848 (get-text-property (point) 'gnus-unread)))
1849 (and (numberp unread) (> unread 0)))
1850 (setq lev (get-text-property (point)
1852 (<= lev gnus-level-subscribed)))
1854 (and (setq lev (get-text-property (point)
1863 (zerop (forward-line way)))))
1865 (progn (gnus-group-position-point) t)
1866 (goto-char (or pos beg))
1869 (defun gnus-total-fetched-for (group)
1870 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group) 0))
1871 (size-in-agent (or (gnus-agent-total-fetched-for group) 0))
1872 (size (+ size-in-cache size-in-agent))
1873 (suffix '("B" "K" "M" "G"))
1876 (while (> size cutoff)
1877 (setq size (/ size scale)
1878 suffix (cdr suffix)))
1879 (format "%5.1f%s" size (car suffix))))
1881 ;;; Gnus group mode commands
1885 (defun gnus-group-mark-line-p ()
1888 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1889 (eq (char-after) gnus-process-mark)))
1891 (defun gnus-group-mark-group (n &optional unmark no-advance)
1892 "Mark the current group."
1894 (let ((buffer-read-only nil)
1898 (when (setq group (gnus-group-group-name))
1899 ;; Go to the mark position.
1901 (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2))
1905 (setq gnus-group-marked (delete group gnus-group-marked))
1906 (insert-char ? 1 t))
1907 (setq gnus-group-marked
1908 (cons group (delete group gnus-group-marked)))
1909 (insert-char gnus-process-mark 1 t)))
1911 (gnus-group-next-group 1))
1913 (gnus-group-position-point)
1916 (defun gnus-group-unmark-group (n)
1917 "Remove the mark from the current group."
1919 (gnus-group-mark-group n 'unmark)
1920 (gnus-group-position-point))
1922 (defun gnus-group-unmark-all-groups ()
1923 "Unmark all groups."
1926 (mapc 'gnus-group-remove-mark gnus-group-marked))
1927 (gnus-group-position-point))
1929 (defun gnus-group-mark-region (unmark beg end)
1930 "Mark all groups between point and mark.
1931 If UNMARK, remove the mark instead."
1932 (interactive "P\nr")
1933 (let ((num (count-lines beg end)))
1936 (- num (gnus-group-mark-group num unmark)))))
1938 (defun gnus-group-mark-buffer (&optional unmark)
1939 "Mark all groups in the buffer.
1940 If UNMARK, remove the mark instead."
1942 (gnus-group-mark-region unmark (point-min) (point-max)))
1944 (defun gnus-group-mark-regexp (regexp)
1945 "Mark all groups that match some regexp."
1946 (interactive "sMark (regexp): ")
1947 (let ((alist (cdr gnus-newsrc-alist))
1951 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
1952 (gnus-group-jump-to-group group)
1953 (gnus-group-set-mark group)))))
1954 (gnus-group-position-point))
1956 (defun gnus-group-remove-mark (group &optional test-marked)
1957 "Remove the process mark from GROUP and move point there.
1958 Return nil if the group isn't displayed."
1959 (if (gnus-group-goto-group group nil test-marked)
1961 (gnus-group-mark-group 1 'unmark t)
1963 (setq gnus-group-marked
1964 (delete group gnus-group-marked))
1967 (defun gnus-group-set-mark (group)
1968 "Set the process mark on GROUP."
1969 (if (gnus-group-goto-group group)
1971 (gnus-group-mark-group 1 nil t))
1972 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
1974 (defun gnus-group-universal-argument (arg &optional groups func)
1975 "Perform any command on all groups according to the process/prefix convention."
1977 (if (eq (setq func (or func
1980 (substitute-command-keys
1981 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
1983 (gnus-error 1 "Undefined key")
1984 (gnus-group-iterate arg
1986 (command-execute func))))
1987 (gnus-group-position-point))
1989 (defun gnus-group-process-prefix (n)
1990 "Return a list of groups to work on.
1991 Take into consideration N (the prefix) and the list of marked groups."
1994 (setq n (prefix-numeric-value n))
1995 ;; There is a prefix, so we return a list of the N next
1997 (let ((way (if (< n 0) -1 1))
2002 (if (setq group (gnus-group-group-name))
2003 (push group groups))
2005 (gnus-group-next-group way)))
2007 ((and transient-mark-mode mark-active (mark))
2008 ;; Work on the region between point and mark.
2009 (let ((max (max (point) (mark)))
2012 (goto-char (min (point) (mark)))
2015 (push (gnus-group-group-name) groups)
2016 (zerop (gnus-group-next-group 1))
2018 (nreverse groups))))
2020 ;; No prefix, but a list of marked articles.
2021 (reverse gnus-group-marked))
2023 ;; Neither marked articles or a prefix, so we return the
2025 (let ((group (gnus-group-group-name)))
2026 (and group (list group))))))
2028 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
2029 ;;; imagine why I went through these contortions...
2031 (let ((function (make-symbol "gnus-group-iterate-function"))
2032 (window (make-symbol "gnus-group-iterate-window"))
2033 (groups (make-symbol "gnus-group-iterate-groups"))
2034 (group (make-symbol "gnus-group-iterate-group")))
2036 `(defun gnus-group-iterate (arg ,function)
2037 "Iterate FUNCTION over all process/prefixed groups.
2038 FUNCTION will be called with the group name as the parameter
2039 and with point over the group in question."
2040 (let ((,groups (gnus-group-process-prefix arg))
2041 (,window (selected-window))
2044 (setq ,group (car ,groups)
2045 ,groups (cdr ,groups))
2046 (select-window ,window)
2047 (gnus-group-remove-mark ,group)
2048 (save-selected-window
2050 (funcall ,function ,group)))))))))
2052 (put 'gnus-group-iterate 'lisp-indent-function 1)
2054 ;; Selecting groups.
2056 (defun gnus-group-read-group (&optional all no-article group select-articles)
2057 "Read news in this newsgroup.
2058 If the prefix argument ALL is non-nil, already read articles become
2061 If ALL is a positive number, fetch this number of the latest
2062 articles in the group. If ALL is a negative number, fetch this
2063 number of the earliest articles in the group.
2065 If the optional argument NO-ARTICLE is non-nil, no article will
2066 be auto-selected upon group entry. If GROUP is non-nil, fetch
2069 (let ((no-display (eq all 0))
2070 (group (or group (gnus-group-group-name)))
2071 number active marked entry)
2075 (error "No group on current line"))
2076 (setq marked (gnus-info-marks
2077 (nth 2 (setq entry (gnus-group-entry group)))))
2078 ;; This group might be a dead group. In that case we have to get
2079 ;; the number of unread articles from `gnus-active-hashtb'.
2081 (cond ((numberp all) all)
2083 ((setq active (gnus-active group))
2084 (- (1+ (cdr active)) (car active)))))
2085 (gnus-summary-read-group
2086 group (or all (and (numberp number)
2087 (zerop (+ number (gnus-range-length
2088 (cdr (assq 'tick marked)))
2090 (cdr (assq 'dormant marked)))))))
2091 no-article nil no-display nil select-articles)))
2093 (defun gnus-group-select-group (&optional all)
2094 "Select this newsgroup.
2095 No article is selected automatically.
2096 If the group is opened, just switch the summary buffer.
2097 If ALL is non-nil, already read articles become readable.
2098 If ALL is a positive number, fetch this number of the latest
2099 articles in the group.
2100 If ALL is a negative number, fetch this number of the earliest
2101 articles in the group."
2103 (when (and (eobp) (not (gnus-group-group-name)))
2105 (gnus-group-read-group all t))
2107 (defun gnus-group-quick-select-group (&optional all group)
2108 "Select the GROUP \"quickly\".
2109 This means that no highlighting or scoring will be performed. If
2110 ALL (the prefix argument) is 0, don't even generate the summary
2111 buffer. If GROUP is nil, use current group.
2113 This might be useful if you want to toggle threading
2114 before entering the group."
2116 (require 'gnus-score)
2118 gnus-score-find-score-files-function
2119 gnus-home-score-file
2120 gnus-apply-kill-hook
2121 gnus-summary-expunge-below)
2122 (gnus-group-read-group all t group)))
2124 (defun gnus-group-visible-select-group (&optional all)
2125 "Select the current group without hiding any articles."
2127 (let ((gnus-inhibit-limiting t))
2128 (gnus-group-read-group all t)))
2130 (defun gnus-group-select-group-ephemerally ()
2131 "Select the current group without doing any processing whatsoever.
2132 You will actually be entered into a group that's a copy of
2133 the current group; no changes you make while in this group will
2136 (require 'gnus-score)
2138 gnus-score-find-score-files-function gnus-apply-kill-hook
2139 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2140 gnus-summary-mode-hook gnus-select-group-hook
2141 (group (gnus-group-group-name))
2142 (method (gnus-find-method-for-group group)))
2143 (gnus-group-read-ephemeral-group
2144 (gnus-group-prefixed-name group method) method)))
2146 (defun gnus-group-name-at-point ()
2147 "Return a group name from around point if it exists, or nil."
2148 (if (derived-mode-p 'gnus-group-mode)
2149 (let ((group (gnus-group-group-name)))
2151 (gnus-group-decoded-name group)))
2152 (let ((regexp "[][\C-@-\t\v-*,/:-@\\^`{-\C-?]*\
2153 \\(nn[a-z]+\\(?:\\+[^][\C-@-*,/:-@\\^`{-\C-?]+\\)?:\
2154 [^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)*\
2155 \\|[^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)+\\)")
2157 (case-fold-search nil))
2159 (if (or (and (not (or (eobp)
2160 (looking-at "[][\C-@-*,/;-@\\^`{-\C-?]")))
2162 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2164 (and (looking-at "[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*$")
2166 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2167 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2169 (string-match "\\`[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*\\'"
2170 (buffer-substring (point-at-bol) (point))))
2171 (when (looking-at regexp)
2173 (let (group distance)
2174 (when (looking-at regexp)
2175 (setq group (match-string 1)
2176 distance (- (match-beginning 1) (match-beginning 0))))
2177 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2178 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2180 (if (looking-at regexp)
2181 (if (and group (<= distance (- start (match-end 0))))
2185 (goto-char start)))))
2187 (defun gnus-group-completing-read (&optional prompt collection
2188 require-match initial-input hist
2190 "Read a group name with completion. Non-ASCII group names are allowed.
2191 The arguments are the same as `completing-read' except that COLLECTION
2192 and HIST default to `gnus-active-hashtb' and `gnus-group-history'
2193 respectively if they are omitted. Regards COLLECTION as a hash table
2194 if it is not a list."
2195 (or collection (setq collection gnus-active-hashtb))
2196 (let (choices group)
2197 (if (listp collection)
2198 (dolist (symbol collection)
2199 (setq group (symbol-name symbol))
2200 (push (if (string-match "[^\000-\177]" group)
2201 (gnus-group-decoded-name group)
2204 (mapatoms (lambda (symbol)
2205 (setq group (symbol-name symbol))
2206 (push (if (string-match "[^\000-\177]" group)
2207 (gnus-group-decoded-name group)
2211 (setq group (gnus-completing-read (or prompt "Group") (nreverse choices)
2212 require-match initial-input
2213 (or hist 'gnus-group-history)
2215 (unless (if (listp collection)
2216 (member group (mapcar 'symbol-name collection))
2217 (symbol-value (intern-soft group collection)))
2219 (mm-encode-coding-string
2220 group (gnus-group-name-charset nil group))))
2221 (replace-regexp-in-string group "\n" "")))
2224 (defun gnus-fetch-group (group &optional articles)
2225 "Start Gnus if necessary and enter GROUP.
2226 If ARTICLES, display those articles.
2227 Returns whether the fetching was successful or not."
2228 (interactive (list (gnus-group-completing-read nil
2230 (gnus-group-name-at-point))))
2231 (unless (gnus-alive-p)
2233 (gnus-group-read-group (if articles nil t) nil group articles))
2236 (defun gnus-fetch-group-other-frame (group)
2237 "Pop up a frame and enter GROUP."
2239 (let ((window (get-buffer-window gnus-group-buffer)))
2241 (select-frame (window-frame window)))
2242 ((= (length (frame-list)) 1)
2243 (select-frame (make-frame)))
2246 (gnus-fetch-group group))
2248 (defcustom gnus-large-ephemeral-newsgroup 200
2249 "The number of articles which indicates a large ephemeral newsgroup.
2250 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2252 If the number of articles in a newsgroup is greater than this value,
2253 confirmation is required for selecting the newsgroup. If it is nil, no
2254 confirmation is required."
2256 :group 'gnus-group-select
2257 :type '(choice (const :tag "No limit" nil)
2260 (defcustom gnus-fetch-old-ephemeral-headers nil
2261 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2264 :type '(choice (const :tag "off" nil)
2267 (sexp :menu-tag "other" t)))
2269 ;; Enter a group that is not in the group buffer. Non-nil is returned
2270 ;; if selection was successful.
2271 (defun gnus-group-read-ephemeral-group (group method &optional activate
2272 quit-config request-only
2276 "Read GROUP from METHOD as an ephemeral group.
2277 If ACTIVATE, request the group first.
2278 If QUIT-CONFIG, use that Gnus window configuration name when
2279 exiting from the ephemeral group.
2280 If REQUEST-ONLY, don't actually read the group; just request it.
2281 If SELECT-ARTICLES, only select those articles.
2282 If PARAMETERS, use those as the group parameters.
2283 If NUMBER, fetch this number of articles.
2285 Return the name of the group if selection was successful."
2288 ;; (gnus-read-group "Group name: ")
2289 (gnus-group-completing-read)
2290 (gnus-read-method "From method")))
2291 (unless (gnus-alive-p)
2292 (nnheader-init-server-buffer)
2293 ;; Necessary because of funky inlining.
2294 (require 'gnus-cache)
2295 (setq gnus-newsrc-hashtb (gnus-make-hashtable)))
2296 ;; Transform the select method into a unique server.
2297 (when (stringp method)
2298 (setq method (gnus-server-to-method method)))
2300 (intern (format "%s-address" (car method)))))
2302 (if (assq address-slot (cddr method))
2303 `(,(car method) ,(concat (cadr method) "-ephemeral")
2305 `(,(car method) ,(concat (cadr method) "-ephemeral")
2306 (,address-slot ,(cadr method))
2308 (let ((group (if (gnus-group-foreign-p group) group
2309 (gnus-group-prefixed-name (gnus-group-real-name group)
2311 (gnus-set-active group nil)
2315 ,gnus-level-default-subscribed nil nil ,method
2321 ((assq gnus-current-window-configuration
2322 gnus-buffer-configuration)
2323 (cons gnus-summary-buffer
2324 gnus-current-window-configuration))
2326 (cons (current-buffer)
2327 (current-window-configuration)))))
2330 (push method gnus-ephemeral-servers)
2331 (when (gnus-buffer-live-p gnus-group-buffer)
2332 (set-buffer gnus-group-buffer))
2333 (unless (gnus-check-server method)
2334 (error "Unable to contact server: %s" (gnus-status-message method)))
2336 (gnus-activate-group group 'scan)
2337 (unless (gnus-request-group group)
2338 (error "Couldn't request group: %s"
2339 (nnheader-get-report (car method)))))
2343 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup)
2344 (gnus-fetch-old-headers
2345 gnus-fetch-old-ephemeral-headers))
2346 (gnus-group-read-group (or number t) t group select-articles))
2351 (message "Quit reading the ephemeral group"))
2354 (defcustom gnus-gmane-group-download-format
2355 "http://download.gmane.org/%s/%s/%s"
2356 "URL for downloading mbox files.
2357 It must contain three \"%s\". They correspond to the group, the
2358 minimal and maximal article numbers, respectively."
2359 :group 'gnus-group-foreign
2360 :version "23.1" ;; No Gnus
2363 (autoload 'url-insert-file-contents "url-handlers")
2365 ;; - Add documentation, menu, key bindings, ...
2367 (defun gnus-read-ephemeral-gmane-group (group start &optional range)
2368 "Read articles from Gmane group GROUP as an ephemeral group.
2369 START is the first article. RANGE specifies how many articles
2370 are fetched. The articles are downloaded via HTTP using the URL
2371 specified by `gnus-gmane-group-download-format'."
2372 ;; See <http://gmane.org/export.php> for more information.
2375 (gnus-group-completing-read "Gmane group")
2376 (read-number "Start article number: ")
2377 (read-number "How many articles: ")))
2378 (unless range (setq range 500))
2380 (error "Invalid range: %s" range))
2381 (let ((tmpfile (mm-make-temp-file
2382 (format "%s.start-%s.range-%s." group start range)))
2383 (gnus-thread-sort-functions '(gnus-thread-sort-by-number)))
2384 (with-temp-file tmpfile
2385 (url-insert-file-contents
2386 (format gnus-gmane-group-download-format
2387 group start (+ start range)))
2388 (write-region (point-min) (point-max) tmpfile)
2389 (gnus-group-read-ephemeral-group
2390 (format "nndoc+ephemeral:%s.start-%s.range-%s" group start range)
2392 (nndoc-article-type mbox))))
2393 (delete-file tmpfile)))
2395 (defun gnus-read-ephemeral-gmane-group-url (url)
2396 "Create an ephemeral Gmane group from URL.
2398 Valid input formats include:
2399 \"http://thread.gmane.org/gmane.foo.bar/12300/focus=12399\",
2400 \"http://thread.gmane.org/gmane.foo.bar/12345/\",
2401 \"http://article.gmane.org/gmane.foo.bar/12345/\",
2402 \"http://news.gmane.org/group/gmane.foo.bar/thread=12345\""
2403 ;; - Feel free to add other useful Gmane URLs here! Maybe the URLs should
2405 ;; - The URLs should be added to `gnus-button-alist'. Probably we should
2406 ;; prompt the user to decide: "View via `browse-url' or in Gnus? "
2407 ;; (`gnus-read-ephemeral-gmane-group-url')
2409 (list (gnus-group-completing-read "Gmane URL")))
2410 (let (group start range)
2412 ;; URLs providing `group', `start' and `range':
2414 ;; http://thread.gmane.org/gmane.emacs.devel/86326/focus=86525
2415 "^http://thread\\.gmane\\.org/\\([^/]+\\)/\\([0-9]+\\)/focus=\\([0-9]+\\)$"
2417 (setq group (match-string 1 url)
2418 start (string-to-number (match-string 2 url))
2419 ;; Ensure that `range' is large enough to ensure focus article is
2421 range (- (string-to-number (match-string 3 url))
2423 ;; URLs providing `group' and `start':
2425 ;; http://article.gmane.org/gmane.comp.gnu.make.bugs/3584
2426 "^http://\\(?:thread\\|article\\|permalink\\)\\.gmane\\.org/\\([^/]+\\)/\\([0-9]+\\)"
2429 ;; Don't advertise these in the doc string yet:
2430 "^\\(?:nntp\\|news\\)://news\\.gmane\\.org/\\([^/]+\\)/\\([0-9]+\\)"
2433 ;; http://news.gmane.org/group/gmane.emacs.gnus.general/thread=65099/force_load=t
2434 "^http://news\\.gmane\\.org/group/\\([^/]+\\)/thread=\\([0-9]+\\)"
2436 (setq group (match-string 1 url)
2437 start (string-to-number (match-string 2 url))))
2439 (error "Can't parse URL %s" url)))
2440 (gnus-read-ephemeral-gmane-group group start range)))
2442 (defcustom gnus-bug-group-download-format-alist
2443 '((emacs . "http://debbugs.gnu.org/cgi/bugreport.cgi?bug=%s;mboxmaint=yes;mboxstat=yes")
2445 . "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%s&mbox=yes;mboxmaint=yes"))
2446 "Alist of symbols for bug trackers and the corresponding URL format string.
2447 The URL format string must contain a single \"%s\", specifying
2448 the bug number, and browsing the URL must return mbox output."
2449 :group 'gnus-group-foreign
2450 ;; Added mboxmaint=yes. This gets the version with the messages as
2451 ;; they went out, not as they came in.
2452 ;; Eg bug-gnu-emacs is replaced by ###@debbugs.
2454 :type '(repeat (cons (symbol) (string :tag "URL format string"))))
2456 (defun gnus-read-ephemeral-bug-group (ids mbox-url &optional window-conf)
2457 "Browse bug NUMBER as ephemeral group."
2458 (interactive (list (read-string "Enter bug number: "
2459 (thing-at-point 'word) nil)
2460 ;; FIXME: Add completing-read from
2461 ;; `gnus-emacs-bug-group-download-format' ...
2462 (cdr (assoc 'emacs gnus-bug-group-download-format-alist))))
2464 (setq ids (string-to-number ids)))
2466 (setq ids (list ids)))
2467 (let ((tmpfile (mm-make-temp-file "gnus-temp-group-")))
2468 (let ((coding-system-for-write 'binary)
2469 (coding-system-for-read 'binary))
2470 (with-temp-file tmpfile
2471 (mm-disable-multibyte)
2473 (url-insert-file-contents (format mbox-url id)))
2474 (goto-char (point-min))
2475 ;; Add the debbugs address so that we can respond to reports easily.
2476 (while (re-search-forward "^To: " nil t)
2478 (insert (format ", %s@%s" (car ids)
2479 (replace-regexp-in-string
2480 (replace-regexp-in-string mbox-url "^http://" "")
2482 (gnus-group-read-ephemeral-group
2483 (format "nndoc+ephemeral:bug#%s"
2484 (mapconcat 'number-to-string ids ","))
2486 (nndoc-article-type mbox))
2488 (delete-file tmpfile)))
2490 (defun gnus-read-ephemeral-debian-bug-group (number)
2491 "Browse Debian bug NUMBER as ephemeral group."
2492 (interactive (list (read-string "Enter bug number: "
2493 (thing-at-point 'word) nil)))
2494 (gnus-read-ephemeral-bug-group
2496 (cdr (assoc 'debian gnus-bug-group-download-format-alist))))
2498 (defvar debbugs-gnu-bug-number) ; debbugs-gnu
2500 (defun gnus-read-ephemeral-emacs-bug-group (ids &optional window-conf)
2501 "Browse Emacs bugs IDS as an ephemeral group."
2502 (interactive (list (string-to-number
2503 (read-string "Enter bug number: "
2504 (thing-at-point 'word) nil))))
2506 (setq ids (list ids)))
2507 (gnus-read-ephemeral-bug-group
2509 (cdr (assoc 'emacs gnus-bug-group-download-format-alist))
2511 (when (fboundp 'debbugs-gnu-summary-mode)
2512 (with-current-buffer (window-buffer (selected-window))
2513 (debbugs-gnu-summary-mode 1)
2514 (set (make-local-variable 'debbugs-gnu-bug-number) (car ids)))))
2516 (defun gnus-group-jump-to-group (group &optional prompt)
2517 "Jump to newsgroup GROUP.
2519 If PROMPT (the prefix) is a number, use the prompt specified in
2520 `gnus-group-jump-to-group-prompt'."
2522 (list (gnus-group-completing-read
2524 (if current-prefix-arg
2525 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt))
2526 (or (and (stringp gnus-group-jump-to-group-prompt)
2527 gnus-group-jump-to-group-prompt)
2528 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt))))
2529 (and (stringp p) p)))))))
2531 (when (equal group "")
2532 (error "Empty group name"))
2534 (unless (gnus-ephemeral-group-p group)
2535 ;; Either go to the line in the group buffer...
2536 (unless (gnus-group-goto-group group)
2537 ;; ... or insert the line.
2538 (gnus-group-update-group group)
2539 (gnus-group-goto-group group)))
2540 ;; Adjust cursor point.
2541 (gnus-group-position-point))
2543 (defun gnus-group-goto-group (group &optional far test-marked)
2544 "Goto to newsgroup GROUP.
2545 If FAR, it is likely that the group is not on the current line.
2546 If TEST-MARKED, the line must be marked."
2550 ;; It's quite likely that we are on the right line, so
2551 ;; we check the current line first.
2553 (eq (get-text-property (point) 'gnus-group)
2554 (gnus-intern-safe group gnus-active-hashtb))
2555 (or (not test-marked) (gnus-group-mark-line-p)))
2557 ;; Previous and next line are also likely, so we check them as well.
2561 (and (eq (get-text-property (point) 'gnus-group)
2562 (gnus-intern-safe group gnus-active-hashtb))
2563 (or (not test-marked) (gnus-group-mark-line-p)))))
2569 (and (eq (get-text-property (point) 'gnus-group)
2570 (gnus-intern-safe group gnus-active-hashtb))
2571 (or (not test-marked) (gnus-group-mark-line-p)))))
2575 (goto-char (point-min))
2577 (while (and (not found)
2582 (gnus-intern-safe group gnus-active-hashtb))))
2583 (if (gnus-group-mark-line-p)
2588 ;; Search through the entire buffer.
2591 (point-min) (point-max)
2592 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))))
2594 (defun gnus-group-next-group (n &optional silent)
2595 "Go to next N'th newsgroup.
2596 If N is negative, search backward instead.
2597 Returns the difference between N and the number of skips actually
2600 (gnus-group-next-unread-group n t nil silent))
2602 (defun gnus-group-next-unread-group (n &optional all level silent)
2603 "Go to next N'th unread newsgroup.
2604 If N is negative, search backward instead.
2605 If ALL is non-nil, choose any newsgroup, unread or not.
2606 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2607 such group can be found, the next group with a level higher than
2609 Returns the difference between N and the number of skips actually
2612 (let ((backward (< n 0))
2615 (gnus-group-search-forward
2616 backward (or (not gnus-group-goto-unread) all) level))
2620 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
2621 (if level " on this level or higher" "")))
2624 (defun gnus-group-prev-group (n)
2625 "Go to previous N'th newsgroup.
2626 Returns the difference between N and the number of skips actually
2629 (gnus-group-next-unread-group (- n) t))
2631 (defun gnus-group-prev-unread-group (n)
2632 "Go to previous N'th unread newsgroup.
2633 Returns the difference between N and the number of skips actually
2636 (gnus-group-next-unread-group (- n)))
2638 (defun gnus-group-next-unread-group-same-level (n)
2639 "Go to next N'th unread newsgroup on the same level.
2640 If N is negative, search backward instead.
2641 Returns the difference between N and the number of skips actually
2644 (gnus-group-next-unread-group n t (gnus-group-group-level))
2645 (gnus-group-position-point))
2647 (defun gnus-group-prev-unread-group-same-level (n)
2648 "Go to next N'th unread newsgroup on the same level.
2649 Returns the difference between N and the number of skips actually
2652 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
2653 (gnus-group-position-point))
2655 (defun gnus-group-best-unread-group (&optional exclude-group)
2656 "Go to the group with the highest level.
2657 If EXCLUDE-GROUP, do not go to that group."
2659 (goto-char (point-min))
2663 (setq unread (get-text-property (point) 'gnus-unread))
2664 (when (and (numberp unread) (> unread 0))
2665 (when (and (get-text-property (point) 'gnus-level)
2666 (< (get-text-property (point) 'gnus-level) best)
2667 (or (not exclude-group)
2668 (not (equal exclude-group (gnus-group-group-name)))))
2669 (setq best (get-text-property (point) 'gnus-level))
2670 (setq best-point (point))))
2673 (goto-char best-point))
2674 (gnus-group-position-point)
2675 (and best-point (gnus-group-group-name))))
2677 ;; Is there something like an after-point-motion-hook?
2678 ;; (inhibit-point-motion-hooks?). Is there a tool-bar-update function?
2680 ;; (defun gnus-group-menu-bar-update ()
2681 ;; (let* ((buf (list (with-current-buffer gnus-group-buffer
2682 ;; (current-buffer))))
2683 ;; (name (buffer-name (car buf))))
2685 ;; (if (> (length name) 27)
2686 ;; (concat (substring name 0 12)
2688 ;; (substring name -12))
2690 ;; (menu-bar-update-buffers-1 buf)))
2692 ;; (defun gnus-group-position-point ()
2693 ;; (gnus-goto-colon)
2694 ;; (gnus-group-menu-bar-update))
2696 (defun gnus-group-first-unread-group ()
2697 "Go to the first group with unread articles."
2700 (let ((opoint (point))
2702 (goto-char (point-min))
2703 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
2704 (and (numberp unread) ; Not a topic.
2705 (not (zerop unread))) ; Has unread articles.
2706 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2709 nil)) ; Not success.
2710 (gnus-group-position-point)))
2712 (defun gnus-group-enter-server-mode ()
2713 "Jump to the server buffer."
2715 (gnus-enter-server-buffer))
2717 (defun gnus-group-make-group-simple (&optional group)
2718 "Add a new newsgroup.
2719 The user will be prompted for GROUP."
2720 (interactive (list (gnus-group-completing-read)))
2721 (gnus-group-make-group (gnus-group-real-name group)
2722 (gnus-group-server group)
2725 (defun gnus-group-make-group (name &optional method address args encoded)
2726 "Add a new newsgroup.
2727 The user will be prompted for a NAME, for a select METHOD, and an
2728 ADDRESS. NAME should be a human-readable string (i.e., not be encoded
2729 even if it contains non-ASCII characters) unless ENCODED is non-nil.
2731 If the backend supports it, the group will also be created on the
2735 (gnus-read-group "Group name: ")
2736 (gnus-read-method "Select method for new group (use tab for completion)")))
2738 (when (stringp method)
2739 (setq method (or (gnus-server-to-method method) method)))
2741 (setq name (mm-encode-coding-string
2743 (gnus-group-name-charset method name))))
2744 (let* ((meth (gnus-method-simplify
2746 (not (gnus-server-equal method gnus-select-method)))
2747 (if address (list (intern method) address)
2749 (nname (if method (gnus-group-prefixed-name name meth) name))
2751 (when (gnus-group-entry nname)
2752 (error "Group %s already exists" (gnus-group-decoded-name nname)))
2753 ;; Subscribe to the new group.
2754 (gnus-group-change-level
2755 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
2756 gnus-level-default-subscribed gnus-level-killed
2757 (and (gnus-group-group-name)
2758 (gnus-group-entry (gnus-group-group-name)))
2761 (gnus-set-active nname (cons 1 0))
2762 (unless (gnus-ephemeral-group-p name)
2764 (concat "(gnus-group-set-info '"
2765 (gnus-prin1-to-string (cdr info)) ")")
2766 (concat "^(gnus-group-set-info '(\"" (regexp-quote name) "\"")))
2768 (gnus-group-insert-group-line-info nname)
2770 (gnus-group-position-point)
2772 ;; Load the back end and try to make the back end create
2773 ;; the group as well.
2774 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
2776 gnus-valid-select-methods)
2778 (gnus-check-server meth)
2779 (when (gnus-check-backend-function 'request-create-group nname)
2780 (unless (gnus-request-create-group nname nil args)
2781 (error "Could not create group on server: %s"
2782 (nnheader-get-report backend))))
2785 (defun gnus-group-delete-groups (&optional arg)
2786 "Delete the current group. Only meaningful with editable groups."
2788 (let ((n (length (gnus-group-process-prefix arg))))
2789 (when (gnus-yes-or-no-p
2791 "Delete this 1 group? "
2792 (format "Delete these %d groups? " n)))
2793 (gnus-group-iterate arg
2795 (gnus-group-delete-group group nil t))))))
2797 (defun gnus-group-delete-articles (group &optional oldp)
2798 "Delete all articles in the current group.
2799 If OLDP (the prefix), only delete articles that are \"old\",
2800 according to the expiry settings. Note that this will delete old
2801 not-expirable articles, too."
2802 (interactive (list (gnus-group-group-name)
2803 current-prefix-arg))
2804 (let ((articles (gnus-uncompress-range (gnus-active group))))
2805 (when (gnus-yes-or-no-p
2806 (format "Do you really want to delete these %d articles forever? "
2808 (gnus-request-expire-articles articles group
2809 (if current-prefix-arg
2813 (defun gnus-group-delete-group (group &optional force no-prompt)
2814 "Delete the current group. Only meaningful with editable groups.
2815 If FORCE (the prefix) is non-nil, all the articles in the group will
2816 be deleted. This is \"deleted\" as in \"removed forever from the face
2817 of the Earth\". There is no undo. The user will be prompted before
2819 Note that you also have to specify FORCE if you want the group to
2820 be removed from the server, even when it's empty."
2822 (list (gnus-group-group-name)
2823 current-prefix-arg))
2825 (error "No group to delete"))
2826 (unless (gnus-check-backend-function 'request-delete-group group)
2827 (error "This back end does not support group deletion"))
2829 (let ((group-decoded (gnus-group-decoded-name group)))
2830 (if (and (not no-prompt)
2831 (not (gnus-yes-or-no-p
2833 "Do you really want to delete %s%s? "
2834 group-decoded (if force " and all its contents" "")))))
2836 (gnus-message 6 "Deleting group %s..." group-decoded)
2837 (if (not (gnus-request-delete-group group force))
2838 (gnus-error 3 "Couldn't delete group %s" group-decoded)
2839 (gnus-message 6 "Deleting group %s...done" group-decoded)
2840 (gnus-group-goto-group group)
2841 (gnus-group-kill-group 1 t)
2842 (gnus-set-active group nil)
2844 (gnus-group-position-point)))
2846 (defun gnus-group-rename-group (group new-name)
2847 "Rename group from GROUP to NEW-NAME.
2848 When used interactively, GROUP is the group under point
2849 and NEW-NAME will be prompted for."
2851 (let ((group (gnus-group-group-name))
2853 (unless (gnus-check-backend-function 'request-rename-group group)
2854 (error "This back end does not support renaming groups"))
2855 (setq new-name (gnus-read-group
2857 (gnus-group-real-name (gnus-group-decoded-name group)))
2858 method (gnus-info-method (gnus-get-info group)))
2859 (list group (mm-encode-coding-string
2861 (gnus-group-name-charset
2863 (gnus-group-prefixed-name new-name method))))))
2865 (unless (gnus-check-backend-function 'request-rename-group group)
2866 (error "This back end does not support renaming groups"))
2868 (error "No group to rename"))
2869 (when (equal (gnus-group-real-name group) new-name)
2870 (error "Can't rename to the same name"))
2872 ;; We find the proper prefixed name.
2874 (if (gnus-group-native-p group)
2878 (gnus-group-prefixed-name
2879 (gnus-group-real-name new-name)
2880 (gnus-info-method (gnus-get-info group)))))
2882 (let ((decoded-group (gnus-group-decoded-name group))
2883 (decoded-new-name (gnus-group-decoded-name new-name)))
2884 (when (gnus-active new-name)
2885 (error "The group %s already exists" decoded-new-name))
2887 (gnus-message 6 "Renaming group %s to %s..."
2888 decoded-group decoded-new-name)
2891 (gnus-group-goto-group group)
2892 (not (when (< (gnus-group-group-level) gnus-level-zombie)
2893 (gnus-request-rename-group group new-name))))
2894 (gnus-error 3 "Couldn't rename group %s to %s"
2895 decoded-group decoded-new-name)
2896 ;; We rename the group internally by killing it...
2897 (gnus-group-kill-group)
2898 ;; ... changing its name ...
2899 (setcar (cdar gnus-list-of-killed-groups) new-name)
2900 ;; ... and then yanking it. Magic!
2901 (gnus-group-yank-group)
2902 (gnus-set-active new-name (gnus-active group))
2903 (gnus-message 6 "Renaming group %s to %s...done"
2904 decoded-group decoded-new-name)
2906 (setq gnus-killed-list (delete group gnus-killed-list))
2907 (gnus-set-active group nil)
2908 (gnus-dribble-touch)
2909 (gnus-group-position-point))))
2911 (defun gnus-group-edit-group (group &optional part)
2912 "Edit the group on the current line."
2913 (interactive (list (gnus-group-group-name)))
2914 (let ((part (or part 'info))
2917 (error "No group on current line"))
2918 (unless (setq info (gnus-get-info group))
2919 (error "Killed group; can't be edited"))
2921 (gnus-close-group group))
2923 ;; Find the proper form to edit.
2924 (cond ((eq part 'method)
2925 (or (gnus-info-method info) "native"))
2927 (gnus-info-params info))
2929 ;; The proper documentation.
2930 (gnus-format-message
2931 "Editing the %s for `%s'."
2933 ((eq part 'method) "select method")
2934 ((eq part 'params) "group parameters")
2936 (gnus-group-decoded-name group))
2938 (gnus-group-edit-group-done ',part ,group form)))
2941 (gnus-create-info-command
2944 "(gnus)Select Methods")
2946 "(gnus)Group Parameters")
2948 "(gnus)Group Info"))))))
2950 (defun gnus-group-edit-group-method (group)
2951 "Edit the select method of GROUP."
2952 (interactive (list (gnus-group-group-name)))
2953 (gnus-group-edit-group group 'method))
2955 (defun gnus-group-edit-group-parameters (group)
2956 "Edit the group parameters of GROUP."
2957 (interactive (list (gnus-group-group-name)))
2958 (gnus-group-edit-group group 'params))
2960 (defun gnus-group-edit-group-done (part group form)
2962 (let* ((method (cond ((eq part 'info) (nth 4 form))
2963 ((eq part 'method) form)
2965 (info (cond ((eq part 'info) form)
2966 ((eq part 'method) (gnus-get-info group))
2969 (if (or (not method)
2971 gnus-select-method method))
2972 (gnus-group-real-name (car info))
2973 (gnus-group-prefixed-name
2974 (gnus-group-real-name (car info)) method))
2976 (when (and new-group
2977 (not (equal new-group group)))
2978 (when (gnus-group-goto-group group)
2979 (gnus-group-kill-group 1))
2980 (gnus-activate-group new-group))
2982 (if (not (and info new-group))
2983 (gnus-group-set-info form (or new-group group) part)
2984 (setq info (gnus-copy-sequence info))
2985 (setcar info new-group)
2986 (unless (gnus-server-equal method "native")
2987 (unless (nthcdr 3 info)
2988 (nconc info (list nil nil)))
2989 (unless (nthcdr 4 info)
2990 (nconc info (list nil)))
2991 (gnus-info-set-method info method))
2992 (gnus-group-set-info info))
2993 (gnus-group-update-group (or new-group group))
2994 (gnus-group-position-point)))
2996 (defun gnus-group-make-useful-group (group method)
2997 "Create one of the groups described in `gnus-useful-groups'."
2999 (let ((entry (assoc (gnus-completing-read "Create group"
3000 (mapcar 'car gnus-useful-groups)
3002 gnus-useful-groups)))
3004 ;; Don't use `caddr' here since macros within the `interactive'
3005 ;; form won't be expanded.
3006 (car (cddr entry)))))
3007 (setq method (gnus-copy-sequence method))
3009 (while (setq entry (memq (assq 'eval method) method))
3010 (setcar entry (eval (cadar entry)))))
3011 (gnus-group-make-group group method))
3013 (defun gnus-group-make-help-group (&optional noerror)
3014 "Create the Gnus documentation group.
3015 Optional argument NOERROR modifies the behavior of this function when the
3016 group already exists:
3017 - if not given, and error is signaled,
3018 - if t, stay silent,
3019 - if anything else, just print a message."
3021 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
3022 (file (nnheader-find-etc-directory "gnus-tut.txt" t)))
3023 (if (gnus-group-entry name)
3024 (cond ((eq noerror nil)
3025 (error "Documentation group already exists"))
3030 (gnus-message 1 "Documentation group already exists")))
3033 (gnus-message 1 "Couldn't find doc group")
3034 (gnus-group-make-group
3035 (gnus-group-real-name name)
3036 (list 'nndoc "gnus-help"
3037 (list 'nndoc-address file)
3038 (list 'nndoc-article-type 'mbox))))
3040 (gnus-group-position-point))
3042 (defun gnus-group-make-doc-group (file type)
3043 "Create a group that uses a single file as the source.
3045 If called with a prefix argument, ask for the file type."
3047 (list (read-file-name "File name: ")
3048 (and current-prefix-arg 'ask)))
3049 (when (eq type 'ask)
3054 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
3056 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
3057 ((= char ?b) 'babyl)
3058 ((= char ?d) 'digest)
3059 ((= char ?f) 'forward)
3061 ((= char ?g) 'guess)
3062 (t (setq err (format "%c unknown. " char))
3065 (setq file (expand-file-name file))
3066 (let* ((name (gnus-generate-new-group-name
3067 (gnus-group-prefixed-name
3068 (file-name-nondirectory file) '(nndoc ""))))
3069 (method (list 'nndoc file
3070 (list 'nndoc-address file)
3071 (list 'nndoc-article-type (or type 'guess))))
3072 (coding (gnus-group-name-charset method name)))
3073 (setcar (cdr method) (mm-encode-coding-string file coding))
3074 (gnus-group-make-group
3075 (mm-encode-coding-string (gnus-group-real-name name) coding)
3078 (defvar nnweb-type-definition)
3079 (defvar gnus-group-web-type-history nil)
3080 (defvar gnus-group-web-search-history nil)
3081 (defun gnus-group-make-web-group (&optional solid)
3082 "Create an ephemeral nnweb group.
3083 If SOLID (the prefix), create a solid group."
3087 (if solid (gnus-read-group "Group name: ")
3088 (message-unique-id)))
3089 (default-type (or (car gnus-group-web-type-history)
3090 (symbol-name (caar nnweb-type-definition))))
3093 (gnus-completing-read
3094 "Search engine type"
3095 (mapcar (lambda (elem) (symbol-name (car elem)))
3096 nnweb-type-definition)
3097 t nil 'gnus-group-web-type-history)
3102 (cons (or (car gnus-group-web-search-history) "") 0)
3103 'gnus-group-web-search-history))
3105 `(nnweb ,group (nnweb-search ,search)
3106 (nnweb-type ,(intern type))
3107 (nnweb-ephemeral-p t))))
3110 (gnus-alist-pull 'nnweb-ephemeral-p method)
3111 (gnus-group-make-group group method))
3112 (gnus-group-read-ephemeral-group
3114 (cons (current-buffer)
3115 (if (derived-mode-p 'gnus-summary-mode) 'summary 'group))))))
3117 (defvar nnrss-group-alist)
3119 (defun nnrss-discover-feed (_arg))
3120 (defun nnrss-save-server-data (_arg)))
3121 (defun gnus-group-make-rss-group (&optional url)
3122 "Given a URL, discover if there is an RSS feed.
3123 If there is, use Gnus to create an nnrss group"
3127 (setq url (read-from-minibuffer "URL to Search for RSS: ")))
3128 (let ((feedinfo (nnrss-discover-feed url)))
3130 (let* ((title (gnus-newsgroup-savable-name
3131 (read-from-minibuffer "Title: "
3132 (gnus-newsgroup-savable-name
3136 (or (cdr (assoc 'title
3140 (desc (read-from-minibuffer "Description: "
3144 (or (cdr (assoc 'description
3148 (href (cdr (assoc 'href feedinfo)))
3149 (coding (gnus-group-name-charset '(nnrss "") title)))
3151 ;; Unify non-ASCII text.
3152 (setq title (mm-decode-coding-string
3153 (mm-encode-coding-string title coding)
3155 (gnus-group-make-group title '(nnrss ""))
3156 (push (list title href desc) nnrss-group-alist)
3157 (nnrss-save-server-data nil))
3158 (error "No feeds found for %s" url))))
3160 (defun gnus-group-make-directory-group (dir)
3161 "Create an nndir group.
3162 The user will be prompted for a directory. The contents of this
3163 directory will be used as a newsgroup. The directory should contain
3164 mail messages or news articles in files that have numeric names."
3166 (list (read-directory-name "Create group from directory: ")))
3167 (unless (file-exists-p dir)
3168 (error "No such directory"))
3169 (unless (file-directory-p dir)
3170 (error "Not a directory"))
3174 (while (or (not group) (gnus-group-entry group))
3176 (gnus-group-prefixed-name
3177 (expand-file-name ext dir)
3179 (setq ext (format "<%d>" (setq i (1+ i)))))
3180 (gnus-group-make-group
3181 (gnus-group-real-name group)
3182 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
3184 (defun gnus-group-add-to-virtual (n vgroup)
3185 "Add the current group to a virtual group."
3187 (list current-prefix-arg
3188 (gnus-group-completing-read "Add to virtual group"
3189 nil t "nnvirtual:")))
3190 (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
3191 (error "%s is not an nnvirtual group" vgroup))
3192 (gnus-close-group vgroup)
3193 (let* ((groups (gnus-group-process-prefix n))
3194 (method (gnus-info-method (gnus-get-info vgroup))))
3195 (setcar (cdr method)
3197 (nth 1 method) "\\|"
3200 (gnus-group-remove-mark s)
3201 (concat "\\(^" (regexp-quote s) "$\\)"))
3203 (gnus-group-position-point))
3205 (defun gnus-group-make-empty-virtual (group)
3206 "Create a new, fresh, empty virtual group."
3207 (interactive "sCreate new, empty virtual group: ")
3208 (let* ((method (list 'nnvirtual "^$"))
3209 (pgroup (gnus-group-prefixed-name group method)))
3210 ;; Check whether it exists already.
3211 (when (gnus-group-entry pgroup)
3212 (error "Group %s already exists" pgroup))
3213 ;; Subscribe the new group after the group on the current line.
3214 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
3215 (gnus-group-update-group pgroup)
3217 (gnus-group-position-point)))
3219 (defun gnus-group-enter-directory (dir)
3220 "Enter an ephemeral nneething group."
3221 (interactive "DDirectory to read: ")
3222 (let* ((method (list 'nneething dir '(nneething-read-only t)))
3223 (leaf (gnus-group-prefixed-name
3224 (file-name-nondirectory (directory-file-name dir))
3226 (name (gnus-generate-new-group-name leaf)))
3227 (unless (gnus-group-read-ephemeral-group
3229 (cons (current-buffer)
3230 (if (derived-mode-p 'gnus-summary-mode)
3232 (error "Couldn't enter %s" dir))))
3234 (defun gnus-group-expunge-group (group)
3235 "Expunge deleted articles in current nnimap GROUP."
3236 (interactive (list (gnus-group-group-name)))
3237 (let ((method (gnus-find-method-for-group group)))
3238 (if (not (gnus-check-backend-function
3239 'request-expunge-group (car method)))
3240 (error "%s does not support expunging" (car method))
3241 (gnus-request-expunge-group group method))))
3243 (autoload 'nnimap-acl-get "nnimap")
3244 (autoload 'nnimap-acl-edit "nnimap")
3246 (defun gnus-group-nnimap-edit-acl (group)
3247 "Edit the Access Control List of current nnimap GROUP."
3248 (interactive (list (gnus-group-group-name)))
3249 (let ((mailbox (gnus-group-real-name group)) method acl)
3251 (error "No group on current line"))
3252 (unless (gnus-get-info group)
3253 (error "Killed group; can't be edited"))
3254 (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap)
3255 (error "%s is not an nnimap group" group))
3256 (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
3257 (error "Server does not support ACL's"))
3258 (gnus-edit-form acl (gnus-format-message "\
3259 Editing the access control list for `%s'.
3261 An access control list is a list of (identifier . rights) elements.
3263 The identifier string specifies the corresponding user. The
3264 identifier \"anyone\" is reserved to refer to the universal identity.
3266 Rights is a string listing a (possibly empty) set of alphanumeric
3267 characters, each character listing a set of operations which is being
3268 controlled. Letters are reserved for \"standard\" rights, listed
3269 below. Digits are reserved for implementation or site defined rights.
3271 l - lookup (mailbox is visible to LIST/LSUB commands)
3272 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
3273 SEARCH, COPY from mailbox)
3274 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
3275 w - write (STORE flags other than \\SEEN and \\DELETED)
3276 i - insert (perform APPEND, COPY into mailbox)
3277 p - post (send mail to submission address for mailbox,
3278 not enforced by IMAP4 itself)
3279 c - create and delete mailbox (CREATE new sub-mailboxes in any
3280 implementation-defined hierarchy, RENAME or DELETE mailbox)
3281 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
3282 a - administer (perform SETACL)" group)
3285 ,mailbox ',method ',acl form)))))
3287 ;; Group sorting commands
3288 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3290 (defun gnus-group-sort-groups (func &optional reverse)
3291 "Sort the group buffer according to FUNC.
3292 When used interactively, the sorting function used will be
3293 determined by the `gnus-group-sort-function' variable.
3294 If REVERSE (the prefix), reverse the sorting order."
3295 (interactive (list gnus-group-sort-function current-prefix-arg))
3296 (funcall gnus-group-sort-alist-function
3297 (gnus-make-sort-function func) reverse)
3298 (gnus-group-unmark-all-groups)
3299 (gnus-group-list-groups)
3300 (gnus-dribble-touch))
3302 (defun gnus-group-sort-flat (func reverse)
3303 ;; We peel off the dummy group from the alist.
3305 (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group")
3306 (pop gnus-newsrc-alist))
3308 (setq gnus-newsrc-alist
3309 (sort gnus-newsrc-alist func))
3311 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
3312 ;; Regenerate the hash table.
3313 (gnus-make-hashtable-from-newsrc-alist)))
3315 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
3316 "Sort the group buffer alphabetically by group name.
3317 If REVERSE, sort in reverse order."
3319 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
3321 (defun gnus-group-sort-groups-by-real-name (&optional reverse)
3322 "Sort the group buffer alphabetically by real (unprefixed) group name.
3323 If REVERSE, sort in reverse order."
3325 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse))
3327 (defun gnus-group-sort-groups-by-unread (&optional reverse)
3328 "Sort the group buffer by number of unread articles.
3329 If REVERSE, sort in reverse order."
3331 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
3333 (defun gnus-group-sort-groups-by-level (&optional reverse)
3334 "Sort the group buffer by group level.
3335 If REVERSE, sort in reverse order."
3337 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
3339 (defun gnus-group-sort-groups-by-score (&optional reverse)
3340 "Sort the group buffer by group score.
3341 If REVERSE, sort in reverse order."
3343 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
3345 (defun gnus-group-sort-groups-by-rank (&optional reverse)
3346 "Sort the group buffer by group rank.
3347 If REVERSE, sort in reverse order."
3349 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
3351 (defun gnus-group-sort-groups-by-method (&optional reverse)
3352 "Sort the group buffer alphabetically by back end name.
3353 If REVERSE, sort in reverse order."
3355 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
3357 (defun gnus-group-sort-groups-by-server (&optional reverse)
3358 "Sort the group buffer alphabetically by server name.
3359 If REVERSE, sort in reverse order."
3361 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse))
3363 ;;; Selected group sorting.
3365 (defun gnus-group-sort-selected-groups (n func &optional reverse)
3366 "Sort the process/prefixed groups."
3367 (interactive (list current-prefix-arg gnus-group-sort-function))
3368 (let ((groups (gnus-group-process-prefix n)))
3369 (funcall gnus-group-sort-selected-function
3370 groups (gnus-make-sort-function func) reverse)
3371 (gnus-group-unmark-all-groups)
3372 (gnus-group-list-groups)
3373 (gnus-dribble-touch)))
3375 (defun gnus-group-sort-selected-flat (groups func reverse)
3376 (let (entries infos)
3377 ;; First find all the group entries for these groups.
3379 (push (nthcdr 2 (gnus-group-entry (pop groups)))
3381 ;; Then sort the infos.
3385 (lambda (entry) (car entry))
3386 (setq entries (nreverse entries)))
3389 (setq infos (nreverse infos)))
3390 ;; Go through all the infos and replace the old entries
3391 ;; with the new infos.
3393 (setcar (car entries) (pop infos))
3395 ;; Update the hashtable.
3396 (gnus-make-hashtable-from-newsrc-alist)))
3398 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse)
3399 "Sort the group buffer alphabetically by group name.
3400 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3401 sort in reverse order."
3402 (interactive (gnus-interactive "P\ny"))
3403 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse))
3405 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse)
3406 "Sort the group buffer alphabetically by real group name.
3407 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3408 sort in reverse order."
3409 (interactive (gnus-interactive "P\ny"))
3410 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-real-name reverse))
3412 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse)
3413 "Sort the group buffer by number of unread articles.
3414 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3415 sort in reverse order."
3416 (interactive (gnus-interactive "P\ny"))
3417 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse))
3419 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse)
3420 "Sort the group buffer by group level.
3421 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3422 sort in reverse order."
3423 (interactive (gnus-interactive "P\ny"))
3424 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse))
3426 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse)
3427 "Sort the group buffer by group score.
3428 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3429 sort in reverse order."
3430 (interactive (gnus-interactive "P\ny"))
3431 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse))
3433 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse)
3434 "Sort the group buffer by group rank.
3435 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3436 sort in reverse order."
3437 (interactive (gnus-interactive "P\ny"))
3438 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse))
3440 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse)
3441 "Sort the group buffer alphabetically by back end name.
3442 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3443 sort in reverse order."
3444 (interactive (gnus-interactive "P\ny"))
3445 (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse))
3447 ;;; Sorting predicates.
3449 (defun gnus-group-sort-by-alphabet (info1 info2)
3450 "Sort alphabetically."
3451 (string< (gnus-info-group info1) (gnus-info-group info2)))
3453 (defun gnus-group-sort-by-real-name (info1 info2)
3454 "Sort alphabetically on real (unprefixed) names."
3455 (string< (gnus-group-real-name (gnus-info-group info1))
3456 (gnus-group-real-name (gnus-info-group info2))))
3458 (defun gnus-group-sort-by-unread (info1 info2)
3459 "Sort by number of unread articles."
3460 (let ((n1 (gnus-group-unread (gnus-info-group info1)))
3461 (n2 (gnus-group-unread (gnus-info-group info2))))
3462 (< (or (and (numberp n1) n1) 0)
3463 (or (and (numberp n2) n2) 0))))
3465 (defun gnus-group-sort-by-level (info1 info2)
3467 (< (gnus-info-level info1) (gnus-info-level info2)))
3469 (defun gnus-group-sort-by-method (info1 info2)
3470 "Sort alphabetically by back end name."
3471 (string< (car (gnus-find-method-for-group
3472 (gnus-info-group info1) info1))
3473 (car (gnus-find-method-for-group
3474 (gnus-info-group info2) info2))))
3476 (defun gnus-group-sort-by-server (info1 info2)
3477 "Sort alphabetically by server name."
3478 (string< (gnus-method-to-full-server-name
3479 (gnus-find-method-for-group
3480 (gnus-info-group info1) info1))
3481 (gnus-method-to-full-server-name
3482 (gnus-find-method-for-group
3483 (gnus-info-group info2) info2))))
3485 (defun gnus-group-sort-by-score (info1 info2)
3486 "Sort by group score."
3487 (> (gnus-info-score info1) (gnus-info-score info2)))
3489 (defun gnus-group-sort-by-rank (info1 info2)
3490 "Sort by level and score."
3491 (let ((level1 (gnus-info-level info1))
3492 (level2 (gnus-info-level info2)))
3493 (or (< level1 level2)
3494 (and (= level1 level2)
3495 (> (gnus-info-score info1) (gnus-info-score info2))))))
3499 (defun gnus-group-clear-data (&optional arg)
3500 "Clear all marks and read ranges from the current group.
3501 Obeys the process/prefix convention."
3503 (when (gnus-y-or-n-p "Really clear data? ")
3504 (gnus-group-iterate arg
3507 (gnus-info-clear-data (setq info (gnus-get-info group)))
3508 (gnus-get-unread-articles-in-group info (gnus-active group) t)
3509 (when (gnus-group-goto-group group)
3510 (gnus-group-update-group-line)))))))
3512 (defun gnus-group-clear-data-on-native-groups ()
3513 "Clear all marks and read ranges from all native groups."
3515 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3516 (let ((alist (cdr gnus-newsrc-alist))
3518 (while (setq info (pop alist))
3519 (when (gnus-group-native-p (gnus-info-group info))
3520 (gnus-info-clear-data info)))
3521 (gnus-get-unread-articles)
3522 (gnus-dribble-touch)
3523 (when (gnus-y-or-n-p
3524 "Move the cache away to avoid problems in the future? ")
3525 (call-interactively 'gnus-cache-move-cache)))))
3527 (defun gnus-info-clear-data (info)
3528 "Clear all marks and read ranges from INFO."
3529 (let ((group (gnus-info-group info))
3531 (dolist (el (gnus-info-marks info))
3532 (push `(,(cdr el) add (,(car el))) action))
3533 (push `(,(gnus-info-read info) add (read)) action)
3536 (gnus-request-set-mark ,group ',action)
3537 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3538 (gnus-info-set-read ',info ',(gnus-info-read info))
3539 (when (gnus-group-goto-group ,group)
3540 (gnus-get-unread-articles-in-group ',info ',(gnus-active group) t)
3541 (gnus-group-update-group-line))))
3542 (setq action (mapcar (lambda (el) (list (nth 0 el) 'del (nth 2 el)))
3544 (gnus-request-set-mark group action)
3545 (gnus-info-set-read info nil)
3546 (when (gnus-info-marks info)
3547 (gnus-info-set-marks info nil))))
3549 ;; Group catching up.
3551 (defun gnus-group-catchup-current (&optional n all)
3552 "Mark all unread articles in the current newsgroup as read.
3553 If prefix argument N is numeric, the next N newsgroups will be
3554 caught up. If ALL is non-nil, marked articles will also be marked as
3555 read. Cross references (Xref: header) of articles are ignored.
3556 The number of newsgroups that this function was unable to catch
3559 (let ((groups (gnus-group-process-prefix n))
3562 (unless groups (error "No groups selected"))
3564 (or (not gnus-interactive-catchup) ;Without confirmation?
3569 "Do you really want to mark all articles in %s as read? "
3570 "Mark all unread articles in %s as read? ")
3571 (if (= (length groups) 1)
3572 (gnus-group-decoded-name (car groups))
3573 (format "these %d groups" (length groups)))))))
3575 (while (setq group (pop groups))
3576 (gnus-group-remove-mark group)
3577 ;; Virtual groups have to be given special treatment.
3578 (let ((method (gnus-find-method-for-group group)))
3579 (when (eq 'nnvirtual (car method))
3580 (nnvirtual-catchup-group
3581 (gnus-group-real-name group) (nth 1 method) all)))
3583 ((>= (gnus-group-level group) gnus-level-zombie)
3584 (gnus-message 2 "Dead groups can't be caught up"))
3586 (gnus-group-goto-group group)
3587 (gnus-group-catchup group all))
3588 (gnus-group-update-group-line))
3590 (setq ret (1+ ret)))))
3591 (gnus-group-next-unread-group 1)
3594 (defun gnus-group-catchup-current-all (&optional n)
3595 "Mark all articles in current newsgroup as read.
3596 Cross references (Xref: header) of articles are ignored."
3598 (gnus-group-catchup-current n 'all))
3600 (declare-function gnus-sequence-of-unread-articles "gnus-sum" (group))
3602 (defun gnus-group-catchup (group &optional all)
3603 "Mark all articles in GROUP as read.
3604 If ALL is non-nil, all articles are marked as read.
3605 The return value is the number of articles that were marked as read,
3606 or nil if no action could be taken."
3607 (let* ((entry (gnus-group-entry group))
3609 (marks (gnus-info-marks (nth 2 entry)))
3610 (unread (gnus-sequence-of-unread-articles group)))
3611 ;; Remove entries for this group.
3612 (nnmail-purge-split-history (gnus-group-real-name group))
3613 ;; Do the updating only if the newsgroup isn't killed.
3614 (if (not (numberp (car entry)))
3615 (gnus-message 1 "Can't catch up %s; non-active group" group)
3616 (gnus-update-read-articles group nil)
3618 ;; Nix out the lists of marks and dormants.
3619 (gnus-request-set-mark group (list (list (cdr (assq 'tick marks))
3621 (list (cdr (assq 'dormant marks))
3623 (setq unread (gnus-range-add (gnus-range-add
3624 unread (cdr (assq 'dormant marks)))
3625 (cdr (assq 'tick marks))))
3626 (gnus-add-marked-articles group 'tick nil nil 'force)
3627 (gnus-add-marked-articles group 'dormant nil nil 'force))
3628 ;; Do auto-expirable marks if that's required.
3629 (when (and (gnus-group-auto-expirable-p group)
3630 (not (gnus-group-read-only-p group)))
3633 (gnus-add-marked-articles group 'expire (list article))
3634 (gnus-request-set-mark group (list (list (list article)
3637 (let ((gnus-newsgroup-name group))
3638 (gnus-run-hooks 'gnus-group-catchup-group-hook))
3641 (defun gnus-group-expire-articles (&optional n)
3642 "Expire all expirable articles in the current newsgroup.
3643 Uses the process/prefix convention."
3645 (let ((groups (gnus-group-process-prefix n))
3648 (error "No groups to expire"))
3649 (while (setq group (pop groups))
3650 (gnus-group-remove-mark group)
3651 (gnus-group-expire-articles-1 group)
3652 (gnus-dribble-touch)
3653 (gnus-group-position-point))))
3655 (defun gnus-group-expire-articles-1 (group)
3656 (when (gnus-check-backend-function 'request-expire-articles group)
3657 (gnus-message 6 "Expiring articles in %s..."
3658 (gnus-group-decoded-name group))
3659 (let* ((info (gnus-get-info group))
3660 (expirable (if (gnus-group-total-expirable-p group)
3661 (cons nil (gnus-list-of-read-articles group))
3662 (assq 'expire (gnus-info-marks info))))
3664 (gnus-list-range-difference
3665 (gnus-uncompress-sequence (cdr expirable))
3666 (cdr (assq 'unexist (gnus-info-marks info)))))
3667 (expiry-wait (gnus-group-find-parameter group 'expiry-wait))
3668 (nnmail-expiry-target
3669 (or (gnus-group-find-parameter group 'expiry-target)
3670 nnmail-expiry-target)))
3672 (gnus-check-group group)
3675 (gnus-compress-sequence
3677 ;; We set the expiry variables to the group
3679 (let ((nnmail-expiry-wait-function nil)
3680 (nnmail-expiry-wait expiry-wait))
3681 (gnus-request-expire-articles articles-to-expire group))
3682 ;; Just expire using the normal expiry values.
3683 (gnus-request-expire-articles articles-to-expire group))))
3684 (gnus-close-group group))
3685 (gnus-message 6 "Expiring articles in %s...done"
3686 (gnus-group-decoded-name group))
3687 ;; Return the list of un-expired articles.
3690 (defun gnus-group-expire-all-groups ()
3691 "Expire all expirable articles in all newsgroups."
3694 (gnus-message 5 "Expiring...")
3695 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
3696 (cdr gnus-newsrc-alist))))
3697 (gnus-group-expire-articles nil)))
3698 (gnus-group-position-point)
3699 (gnus-message 5 "Expiring...done"))
3701 (defun gnus-group-set-current-level (n level)
3702 "Set the level of the next N groups to LEVEL."
3707 (unless (gnus-group-process-prefix current-prefix-arg)
3708 (error "No group on the current line"))
3710 (let ((s (read-string
3711 (format "Level (default %s): "
3712 (or (gnus-group-group-level)
3713 gnus-level-default-subscribed)))))
3714 (if (string-match "^\\s-*$" s)
3715 (int-to-string (or (gnus-group-group-level)
3716 gnus-level-default-subscribed))
3718 (unless (and (>= level 1) (<= level gnus-level-killed))
3719 (error "Invalid level: %d" level))
3720 (dolist (group (gnus-group-process-prefix n))
3721 (gnus-group-remove-mark group)
3722 (gnus-message 6 "Changed level of %s from %d to %d"
3723 (gnus-group-decoded-name group)
3724 (or (gnus-group-group-level) gnus-level-killed)
3726 (gnus-group-change-level
3727 group level (or (gnus-group-group-level) gnus-level-killed))
3728 (gnus-group-update-group-line))
3729 (gnus-group-position-point))
3731 (defun gnus-group-unsubscribe (&optional n)
3732 "Unsubscribe the current group."
3734 (gnus-group-unsubscribe-current-group n 'unsubscribe))
3736 (defun gnus-group-subscribe (&optional n)
3737 "Subscribe the current group."
3739 (gnus-group-unsubscribe-current-group n 'subscribe))
3741 (defun gnus-group-unsubscribe-current-group (&optional n do-sub)
3742 "Toggle subscription of the current group.
3743 If given numerical prefix, toggle the N next groups."
3745 (dolist (group (gnus-group-process-prefix n))
3746 (gnus-group-remove-mark group)
3747 (gnus-group-unsubscribe-group
3750 ((eq do-sub 'unsubscribe)
3751 gnus-level-default-unsubscribed)
3752 ((eq do-sub 'subscribe)
3753 gnus-level-default-subscribed)
3754 ((<= (gnus-group-group-level) gnus-level-subscribed)
3755 gnus-level-default-unsubscribed)
3757 gnus-level-default-subscribed))
3759 (gnus-group-update-group-line))
3760 (gnus-group-next-group 1))
3762 (defun gnus-group-unsubscribe-group (group &optional level silent)
3763 "Toggle subscription to GROUP.
3764 Killed newsgroups are subscribed. If SILENT, don't try to update the
3766 (interactive (list (gnus-group-completing-read
3767 nil nil (gnus-read-active-file-p))))
3768 (let ((newsrc (gnus-group-entry group)))
3770 ((string-match "\\`[ \t]*\\'" group)
3771 (error "Empty group name"))
3773 ;; Toggle subscription flag.
3774 (gnus-group-change-level
3775 newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc))
3776 gnus-level-subscribed)
3777 (1+ gnus-level-subscribed)
3778 gnus-level-default-subscribed)))
3780 (gnus-group-update-group group)))
3781 ((and (stringp group)
3782 (or (not (gnus-read-active-file-p))
3783 (gnus-active group)))
3784 ;; Add new newsgroup.
3785 (gnus-group-change-level
3787 (if level level gnus-level-default-subscribed)
3788 (or (and (member group gnus-zombie-list)
3791 (when (gnus-group-group-name)
3792 (gnus-group-entry (gnus-group-group-name))))
3794 (gnus-group-update-group group)))
3795 (t (error "No such newsgroup: %s" group)))
3796 (gnus-group-position-point)))
3798 (defun gnus-group-transpose-groups (n)
3799 "Move the current newsgroup up N places.
3800 If given a negative prefix, move down instead. The difference between
3801 N and the number of steps taken is returned."
3803 (unless (gnus-group-group-name)
3804 (error "No group on current line"))
3805 (gnus-group-kill-group 1)
3807 (forward-line (- n))
3808 (gnus-group-yank-group)
3809 (gnus-group-position-point)))
3811 (defun gnus-group-kill-all-zombies (&optional dummy)
3812 "Kill all zombie newsgroups.
3813 The optional DUMMY should always be nil."
3814 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3816 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3817 (setq gnus-zombie-list nil)
3818 (gnus-dribble-touch)
3819 (gnus-group-list-groups)))
3821 (defun gnus-group-kill-region (begin end)
3822 "Kill newsgroups in current region (excluding current point).
3823 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3836 (beginning-of-line) ;Important when LINES < 1
3837 (gnus-group-kill-group lines)))
3839 (defun gnus-group-kill-group (&optional n discard)
3840 "Kill the next N groups.
3841 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3842 However, only groups that were alive can be yanked; already killed
3843 groups or zombie groups can't be yanked.
3844 The return value is the name of the group that was killed, or a list
3847 (let ((buffer-read-only nil)
3848 (groups (gnus-group-process-prefix n))
3849 group entry level out)
3850 (if (< (length groups) 10)
3851 ;; This is faster when there are few groups.
3853 (push (setq group (pop groups)) out)
3854 (gnus-group-remove-mark group)
3855 (setq level (gnus-group-group-level))
3857 (when (and (not discard)
3858 (setq entry (gnus-group-entry group)))
3861 (gnus-group-goto-group ,(gnus-group-group-name))
3862 (gnus-group-yank-group)))
3863 (push (cons (car entry) (nth 2 entry))
3864 gnus-list-of-killed-groups))
3865 (gnus-group-change-level
3866 (if entry entry group) gnus-level-killed (if entry nil level))
3867 (when (numberp (gnus-group-unread group))
3868 (gnus-request-update-group-status group 'unsubscribe))
3869 (message "Killed group %s" (gnus-group-decoded-name group)))
3870 ;; If there are lots and lots of groups to be killed, we use
3871 ;; this thing instead.
3872 (dolist (group (nreverse groups))
3873 (gnus-group-remove-mark group)
3875 (push group gnus-killed-list)
3876 (setq gnus-newsrc-alist
3877 (delq (assoc group gnus-newsrc-alist)
3879 (when gnus-group-change-level-function
3880 (funcall gnus-group-change-level-function
3881 group gnus-level-killed 3))
3883 ((setq entry (gnus-group-entry group))
3884 (push (cons (car entry) (nth 2 entry))
3885 gnus-list-of-killed-groups)
3886 (setcdr (cdr entry) (cdddr entry)))
3887 ((member group gnus-zombie-list)
3888 (setq gnus-zombie-list (delete group gnus-zombie-list))))
3889 ;; There may be more than one instance displayed.
3890 (while (gnus-group-goto-group group)
3892 (when (numberp (gnus-group-unread group))
3893 (gnus-request-update-group-status group 'unsubscribe)))
3894 (gnus-make-hashtable-from-newsrc-alist))
3896 (gnus-group-position-point)
3897 (if (< (length out) 2) (car out) (nreverse out))))
3899 (defun gnus-group-yank-group (&optional arg)
3900 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3901 The numeric ARG specifies how many newsgroups are to be yanked. The
3902 name of the newsgroup yanked is returned, or (if several groups are
3903 yanked) a list of yanked groups is returned."
3905 (setq arg (or arg 1))
3906 (let (info group prev out)
3907 (while (>= (decf arg) 0)
3908 (when (not (setq info (pop gnus-list-of-killed-groups)))
3909 (error "No more newsgroups to yank"))
3910 (push (setq group (nth 1 info)) out)
3911 ;; Find which newsgroup to insert this one before - search
3912 ;; backward until something suitable is found. If there are no
3913 ;; other newsgroups in this buffer, just make this newsgroup the
3915 (setq prev (gnus-group-group-name))
3916 (gnus-group-change-level
3917 info (gnus-info-level (cdr info)) gnus-level-killed
3918 (and prev (gnus-group-entry prev))
3920 (gnus-group-insert-group-line-info group)
3921 (gnus-request-update-group-status group 'subscribe)
3923 `(when (gnus-group-goto-group ,group)
3924 (gnus-group-kill-group 1))))
3926 (gnus-group-position-point)
3927 (if (< (length out) 2) (car out) (nreverse out))))
3929 (defun gnus-group-kill-level (level)
3930 "Kill all groups that is on a certain LEVEL."
3931 (interactive "nKill all groups on level: ")
3933 ((= level gnus-level-zombie)
3934 (setq gnus-killed-list
3935 (nconc gnus-zombie-list gnus-killed-list))
3936 (setq gnus-zombie-list nil))
3937 ((and (< level gnus-level-zombie)
3939 (or gnus-expert-user
3942 "Do you really want to kill all groups on level %d? "
3944 (let* ((prev gnus-newsrc-alist)
3947 (if (= (gnus-info-level (car alist)) level)
3949 (push (gnus-info-group (car alist)) gnus-killed-list)
3950 (setcdr prev (cdr alist)))
3952 (setq alist (cdr alist)))
3953 (gnus-make-hashtable-from-newsrc-alist)
3954 (gnus-group-list-groups)))
3956 (error "Can't kill; invalid level: %d" level))))
3958 (defun gnus-group-list-all-groups (&optional arg)
3959 "List all newsgroups with level ARG or lower.
3960 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3961 unsubscribed groups."
3963 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
3965 ;; Redefine this to list ALL killed groups if prefix arg used.
3966 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3967 (defun gnus-group-list-killed (&optional arg)
3968 "List all killed newsgroups in the group buffer.
3969 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3970 entail asking the server for the groups."
3972 ;; Find all possible killed newsgroups if arg.
3974 (gnus-get-killed-groups))
3975 (if (not gnus-killed-list)
3976 (gnus-message 6 "No killed groups")
3977 (let (gnus-group-list-mode)
3978 (funcall gnus-group-prepare-function
3979 gnus-level-killed t gnus-level-killed))
3980 (goto-char (point-min)))
3981 (gnus-group-position-point))
3983 (defun gnus-group-list-zombies ()
3984 "List all zombie newsgroups in the group buffer."
3986 (if (not gnus-zombie-list)
3987 (gnus-message 6 "No zombie groups")
3988 (let (gnus-group-list-mode)
3989 (funcall gnus-group-prepare-function
3990 gnus-level-zombie t gnus-level-zombie))
3991 (goto-char (point-min)))
3992 (gnus-group-position-point))
3994 (defun gnus-group-list-active ()
3995 "List all groups that are available from the server(s)."
3997 ;; First we make sure that we have really read the active file.
3998 (unless (gnus-read-active-file-p)
3999 (let ((gnus-read-active-file t)
4000 (gnus-agent gnus-plugged)); If we're actually plugged, store the active file in the agent.
4001 (gnus-read-active-file)))
4002 ;; Find all groups and sort them.
4010 (push (symbol-name sym) list)))
4014 (buffer-read-only nil)
4018 (setq group (pop groups))
4019 (gnus-add-text-properties
4020 (point) (prog1 (1+ (point))
4022 (gnus-group-decoded-name group)
4024 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4026 'gnus-level (inline (gnus-group-level group)))))
4027 (goto-char (point-min))))
4029 (defun gnus-activate-all-groups (level)
4030 "Activate absolutely all groups."
4031 (interactive (list gnus-level-unsubscribed))
4032 (let ((gnus-activate-level level)
4033 (gnus-activate-foreign-newsgroups level))
4034 (gnus-group-get-new-news)))
4036 (defun gnus-group-get-new-news (&optional arg one-level)
4037 "Get newly arrived articles.
4038 If ARG is a number, it specifies which levels you are interested in
4039 re-scanning. If ARG is non-nil and not a number, this will force
4040 \"hard\" re-reading of the active files from all servers.
4041 If ONE-LEVEL is not nil, then re-scan only the specified level,
4042 otherwise all levels below ARG will be scanned too."
4045 (let ((gnus-inhibit-demon t)
4046 ;; Binding this variable will inhibit multiple fetchings
4047 ;; of the same mail source.
4048 (nnmail-fetched-sources (list t)))
4049 (gnus-run-hooks 'gnus-get-top-new-news-hook)
4050 (gnus-run-hooks 'gnus-get-new-news-hook)
4052 ;; Read any slave files.
4054 (gnus-master-read-slave-newsrc))
4056 (gnus-get-unread-articles (gnus-group-default-level arg t)
4059 ;; If the user wants it, we scan for new groups.
4060 (when (eq gnus-check-new-newsgroups 'always)
4061 (gnus-find-new-newsgroups))
4063 (gnus-check-reasonable-setup)
4064 (gnus-run-hooks 'gnus-after-getting-new-news-hook)
4065 (gnus-group-list-groups (and (numberp arg)
4066 (max (car gnus-group-list-mode) arg)))))
4068 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
4069 "Check for newly arrived news in the current group (and the N-1 next groups).
4070 The difference between N and the number of newsgroup checked is returned.
4071 If N is negative, this group and the N-1 previous groups will be checked.
4072 If DONT-SCAN is non-nil, scan non-activated groups as well."
4074 (let* ((groups (gnus-group-process-prefix n))
4075 (ret (if (numberp n) (- n (length groups)) 0))
4079 (gnus-inhibit-demon t)
4080 ;; Binding this variable will inhibit multiple fetchings
4081 ;; of the same mail source.
4082 (nnmail-fetched-sources (list t)))
4083 (gnus-run-hooks 'gnus-get-new-news-hook)
4084 (while (setq group (pop groups))
4085 (gnus-group-remove-mark group)
4086 ;; Bypass any previous denials from the server.
4087 (gnus-remove-denial (setq method (gnus-find-method-for-group group)))
4088 (if (or (and (not dont-scan)
4089 (gnus-request-group-scan group (gnus-get-info group)))
4090 (gnus-activate-group group (if dont-scan nil 'scan) nil method))
4091 (let ((info (gnus-get-info group))
4092 (active (gnus-active group)))
4094 (gnus-request-update-info info method))
4095 (gnus-get-unread-articles-in-group info active)
4096 (unless (gnus-virtual-group-p group)
4097 (gnus-close-group group))
4099 (gnus-agent-save-group-info
4100 method (gnus-group-real-name group) active))
4101 (gnus-group-update-group group nil t))
4102 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
4105 (when gnus-goto-next-group-when-activating
4106 (gnus-group-next-unread-group 1 t))
4107 (gnus-group-position-point)
4110 (defun gnus-group-describe-group (force &optional group)
4111 "Display a description of the current newsgroup."
4112 (interactive (list current-prefix-arg (gnus-group-group-name)))
4113 (let* ((method (gnus-find-method-for-group group))
4114 (mname (gnus-group-prefixed-name "" method))
4117 gnus-description-hashtb)
4118 (gnus-sethash mname nil gnus-description-hashtb))
4120 (error "No group name given"))
4121 (when (or (and gnus-description-hashtb
4122 ;; We check whether this group's method has been
4123 ;; queried for a description file.
4124 (gnus-gethash mname gnus-description-hashtb))
4125 (setq desc (gnus-group-get-description group))
4126 (gnus-read-descriptions-file method))
4127 (gnus-message 1 "%s"
4128 (or desc (gnus-gethash group gnus-description-hashtb)
4129 "No description available")))))
4131 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4132 (defun gnus-group-describe-all-groups (&optional force)
4133 "Pop up a buffer with descriptions of all newsgroups."
4136 (setq gnus-description-hashtb nil))
4137 (when (not (or gnus-description-hashtb
4138 (gnus-read-all-descriptions-files)))
4139 (error "Couldn't request descriptions file"))
4140 (let ((buffer-read-only nil)
4146 (let ((charset (gnus-group-name-charset nil (symbol-name group))))
4147 (insert (format " *: %-20s %s\n"
4148 (gnus-group-name-decode
4149 (symbol-name group) charset)
4150 (gnus-group-name-decode
4151 (symbol-value group) charset))))
4152 (gnus-add-text-properties
4153 b (1+ b) (list 'gnus-group group
4154 'gnus-unread t 'gnus-marked nil
4155 'gnus-level (1+ gnus-level-subscribed))))
4156 gnus-description-hashtb)
4157 (goto-char (point-min))
4158 (gnus-group-position-point)))
4160 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
4161 (defun gnus-group-apropos (regexp &optional search-description)
4162 "List all newsgroups that have names that match a regexp."
4163 (interactive "sGnus apropos (regexp): ")
4165 (obuf (current-buffer))
4167 ;; Go through all newsgroups that are known to Gnus.
4170 (and (symbol-name group)
4171 (string-match regexp (symbol-name group))
4172 (symbol-value group)
4173 (push (symbol-name group) groups)))
4175 ;; Also go through all descriptions that are known to Gnus.
4176 (when search-description
4179 (and (string-match regexp (symbol-value group))
4180 (push (symbol-name group) groups)))
4181 gnus-description-hashtb))
4183 (gnus-message 3 "No groups matched \"%s\"." regexp)
4184 ;; Print out all the groups.
4186 (pop-to-buffer "*Gnus Help*")
4187 (buffer-disable-undo)
4189 (setq groups (sort groups 'string<))
4191 ;; Groups may be entered twice into the list of groups.
4192 (when (not (string= (car groups) prev))
4193 (setq prev (car groups))
4194 (let ((charset (gnus-group-name-charset nil prev)))
4195 (insert (gnus-group-name-decode prev charset) "\n")
4196 (when (and gnus-description-hashtb
4197 (setq des (gnus-gethash (car groups)
4198 gnus-description-hashtb)))
4199 (insert " " (gnus-group-name-decode des charset) "\n"))))
4200 (setq groups (cdr groups)))
4201 (goto-char (point-min))))
4202 (pop-to-buffer obuf)))
4204 (defun gnus-group-description-apropos (regexp)
4205 "List all newsgroups that have names or descriptions that match REGEXP."
4206 (interactive "sGnus description apropos (regexp): ")
4207 (when (not (or gnus-description-hashtb
4208 (gnus-read-all-descriptions-files)))
4209 (error "Couldn't request descriptions file"))
4210 (gnus-group-apropos regexp t))
4212 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4213 (defun gnus-group-list-matching (level regexp &optional all lowest)
4214 "List all groups with unread articles that match REGEXP.
4215 If the prefix LEVEL is non-nil, it should be a number that says which
4216 level to cut off listing groups.
4217 If ALL, also list groups with no unread articles.
4218 If LOWEST, don't list groups with level lower than LOWEST.
4220 This command may read the active file."
4221 (interactive "P\nsList newsgroups matching: ")
4222 ;; First make sure active file has been read.
4224 (> (prefix-numeric-value level) gnus-level-killed))
4225 (gnus-get-killed-groups))
4226 (funcall gnus-group-prepare-function
4227 (or level gnus-level-subscribed) (and all t) (or lowest 1) regexp)
4228 (goto-char (point-min))
4229 (gnus-group-position-point))
4231 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4232 "List all groups that match REGEXP.
4233 If the prefix LEVEL is non-nil, it should be a number that says which
4234 level to cut off listing groups.
4235 If LOWEST, don't list groups with level lower than LOWEST."
4236 (interactive "P\nsList newsgroups matching: ")
4238 (setq level (prefix-numeric-value level)))
4239 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4241 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4242 (defun gnus-group-save-newsrc (&optional force)
4243 "Save the Gnus startup files.
4244 If FORCE, force saving whether it is necessary or not."
4246 (gnus-save-newsrc-file force))
4248 (defun gnus-group-restart (&optional arg)
4249 "Force Gnus to read the .newsrc file."
4251 (when (gnus-yes-or-no-p
4252 (format "Are you sure you want to restart Gnus? "))
4253 (gnus-save-newsrc-file)
4257 (defun gnus-group-read-init-file ()
4258 "Read the Gnus elisp init file."
4260 (gnus-read-init-file)
4261 (gnus-message 5 "Read %s" gnus-init-file))
4263 (defun gnus-group-check-bogus-groups (&optional silent)
4264 "Check bogus newsgroups.
4265 If given a prefix, don't ask for confirmation before removing a bogus
4268 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4269 (gnus-group-list-groups))
4271 (defun gnus-group-find-new-groups (&optional arg)
4272 "Search for new groups and add them.
4273 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
4274 With 1 C-u, use the `ask-server' method to query the server for new
4276 With 2 C-u's, use most complete method possible to query the server
4277 for new groups, and subscribe the new groups as zombies."
4279 (let ((new-groups (gnus-find-new-newsgroups (or arg 1)))
4281 (gnus-group-list-groups)
4282 (setq current-group (gnus-group-group-name))
4283 (dolist (group new-groups)
4284 (gnus-group-jump-to-group group))
4286 (gnus-group-jump-to-group current-group))))
4288 (defun gnus-group-edit-global-kill (&optional article group)
4289 "Edit the global kill file.
4290 If GROUP, edit that local kill file instead."
4292 (setq gnus-current-kill-article article)
4293 (gnus-kill-file-edit-file group)
4294 (gnus-message 6 "Editing a %s kill file (Type %s to exit)"
4295 (if group "local" "global")
4296 (substitute-command-keys "\\[gnus-kill-file-exit]")))
4298 (defun gnus-group-edit-local-kill (article group)
4299 "Edit a local kill file."
4300 (interactive (list nil (gnus-group-group-name)))
4301 (gnus-group-edit-global-kill article group))
4303 (defun gnus-group-force-update ()
4304 "Update `.newsrc' file."
4306 (gnus-save-newsrc-file))
4308 (defvar gnus-backlog-articles)
4310 (defun gnus-group-suspend ()
4311 "Suspend the current Gnus session.
4312 In fact, cleanup buffers except for group mode buffer.
4313 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4315 (gnus-run-hooks 'gnus-suspend-gnus-hook)
4316 (gnus-offer-save-summaries)
4317 ;; Kill Gnus buffers except for group mode buffer.
4318 (let ((group-buf (get-buffer gnus-group-buffer)))
4319 (dolist (buf (gnus-buffers))
4320 (unless (or (eq buf group-buf)
4321 (eq buf gnus-dribble-buffer)
4322 (with-current-buffer buf
4323 (derived-mode-p 'message-mode)))
4324 (gnus-kill-buffer buf)))
4325 (setq gnus-backlog-articles nil)
4326 (gnus-kill-gnus-frames)
4327 ;; Closing all the backends is useful (for instance) when when the
4328 ;; IP addresses have changed and you need to reconnect.
4329 (dolist (elem gnus-opened-servers)
4330 (gnus-close-server (car elem))
4331 (setcar (cdr elem) 'closed))
4333 (bury-buffer group-buf)
4334 (delete-windows-on group-buf t))))
4336 (defun gnus-group-clear-dribble ()
4337 "Clear all information from the dribble buffer."
4339 (gnus-dribble-clear)
4340 (gnus-message 7 "Cleared dribble buffer"))
4342 (defun gnus-group-exit ()
4343 "Quit reading news after updating .newsrc.eld and .newsrc.
4344 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4347 (or noninteractive ;For gnus-batch-kill
4348 (not gnus-interactive-exit) ;Without confirmation
4350 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4351 (gnus-run-hooks 'gnus-exit-gnus-hook)
4352 ;; Offer to save data from non-quitted summary buffers.
4353 (gnus-offer-save-summaries)
4354 ;; Save the newsrc file(s).
4355 (gnus-save-newsrc-file)
4357 (gnus-close-backends)
4358 ;; Reset everything.
4360 ;; Allow the user to do things after cleaning up.
4361 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4363 (defun gnus-group-quit ()
4364 "Quit reading news without updating .newsrc.eld or .newsrc.
4365 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4367 (when (or noninteractive ;For gnus-batch-kill
4368 (zerop (buffer-size))
4369 (not (gnus-server-opened gnus-select-method))
4371 (not gnus-current-startup-file)
4373 (format "Quit reading news without saving %s? "
4374 (file-name-nondirectory gnus-current-startup-file))))
4375 (gnus-run-hooks 'gnus-exit-gnus-hook)
4376 (gnus-configure-windows 'group t)
4377 (when (and (gnus-buffer-live-p gnus-dribble-buffer)
4378 (not (zerop (with-current-buffer gnus-dribble-buffer
4381 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4383 (gnus-close-backends)
4385 (gnus-kill-buffer gnus-group-buffer)
4386 ;; Allow the user to do things after cleaning up.
4387 (gnus-run-hooks 'gnus-after-exiting-gnus-hook)))
4389 (defun gnus-group-describe-briefly ()
4390 "Give a one line description of the group mode commands."
4392 (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")))
4394 (defun gnus-group-browse-foreign-server (method)
4395 "Browse a foreign news server.
4396 If called interactively, this function will ask for a select method
4397 (nntp, nnspool, etc.) and a server address (e.g., nntp.some.where).
4398 If not, METHOD should be a list where the first element is the method
4399 and the second element is the address."
4401 (list (let ((how (gnus-completing-read
4403 (mapcar 'car (append gnus-valid-select-methods
4405 t (cons "nntp" 0) 'gnus-method-history)))
4406 ;; We either got a back end name or a virtual server name.
4407 ;; If the first, we also need an address.
4408 (if (assoc how gnus-valid-select-methods)
4410 ;; Suggested by mapjph@bath.ac.uk.
4411 (gnus-completing-read
4413 ;; FIXME? gnus-secondary-servers is obsolete,
4414 ;; and it is not obvious that there is anything
4415 ;; sensible to use instead in this particular case.
4416 (if (boundp 'gnus-secondary-servers)
4417 gnus-secondary-servers
4418 (cdr gnus-select-method))))
4419 ;; We got a server name.
4421 (gnus-browse-foreign-server method))
4423 (defun gnus-group-set-info (info &optional method-only-group part)
4424 (when (or info part)
4425 (let* ((entry (gnus-group-entry
4426 (or method-only-group (gnus-info-group info))))
4428 (info (if method-only-group (nth 2 entry) info))
4430 (when method-only-group
4432 (error "Trying to change non-existent group %s" method-only-group))
4433 ;; We have received parts of the actual group info - either the
4434 ;; select method or the group parameters. We first check
4435 ;; whether we have to extend the info, and if so, do that.
4436 (let ((len (length info))
4437 (total (if (eq part 'method) 5 6)))
4439 (setcdr (nthcdr (1- len) info)
4440 (make-list (- total len) nil)))
4441 ;; Then we enter the new info.
4442 (setcar (nthcdr (1- total) info) part-info)))
4444 ;; This is a new group, so we just create it.
4445 (with-current-buffer gnus-group-buffer
4446 (setq method (gnus-info-method info))
4447 (when (gnus-server-equal method "native")
4449 (with-current-buffer gnus-group-buffer
4451 ;; It's a foreign group...
4452 (gnus-group-make-group
4453 (gnus-group-real-name (gnus-info-group info))
4454 (if (stringp method) method
4455 (prin1-to-string (car method)))
4457 (nth 1 (gnus-info-method info)))
4459 ;; It's a native group.
4460 (gnus-group-make-group (gnus-info-group info) nil nil nil t)))
4461 (gnus-message 6 "Note: New group created")
4463 (gnus-group-entry (gnus-group-prefixed-name
4464 (gnus-group-real-name (gnus-info-group info))
4465 (or (gnus-info-method info) gnus-select-method))))))
4466 ;; Whether it was a new group or not, we now have the entry, so we
4467 ;; can do the update.
4470 (setcar (nthcdr 2 entry) info)
4471 (when (and (not (eq (car entry) t))
4472 (gnus-active (gnus-info-group info)))
4473 (setcar entry (length
4474 (gnus-list-of-unread-articles (car info))))))
4475 (error "No such group: %s" (gnus-info-group info))))))
4477 ;; Ad-hoc function for inserting data from a different newsrc.eld
4478 ;; file. Use with caution, if at all.
4479 (defun gnus-import-other-newsrc-file (file)
4481 (insert-file-contents file)
4483 (while (ignore-errors
4484 (setq form (read (current-buffer))))
4485 (when (and (consp form)
4486 (eq (cadr form) 'gnus-newsrc-alist))
4487 (let ((infos (cadr (nth 2 form))))
4488 (dolist (info infos)
4489 (when (gnus-get-info (car info))
4490 (gnus-set-info (car info) info)))))))))
4492 (defun gnus-add-marked-articles (group type articles &optional info force)
4493 ;; Add ARTICLES of TYPE to the info of GROUP.
4494 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4495 ;; add, but replace marked articles of TYPE with ARTICLES.
4496 (let ((info (or info (gnus-get-info group)))
4499 (and (not (setq marked (nthcdr 3 info)))
4501 (setcdr (nthcdr 2 info)
4502 (list (list (cons type (gnus-compress-sequence
4504 (and (not (setq m (assq type (car marked))))
4507 (cons (cons type (gnus-compress-sequence articles t) )
4511 (setcar (nthcdr 3 info)
4512 (gnus-delete-alist type (car marked)))
4513 (setcdr m (gnus-compress-sequence articles t)))
4514 (setcdr m (gnus-compress-sequence
4515 (sort (nconc (gnus-uncompress-range (cdr m))
4516 (copy-sequence articles)) '<) t))))))
4518 (declare-function gnus-summary-add-mark "gnus-sum" (article type))
4520 (defun gnus-add-mark (group mark article)
4521 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4522 (let ((buffer (gnus-summary-buffer-name group)))
4523 (if (gnus-buffer-live-p buffer)
4524 (with-current-buffer (get-buffer buffer)
4525 (gnus-summary-add-mark article mark))
4526 (gnus-add-marked-articles group (cdr (assq mark gnus-article-mark-lists))
4530 ;;; Group timestamps
4533 (defun gnus-group-set-timestamp ()
4534 "Change the timestamp of the current group to the current time.
4535 This function can be used in hooks like `gnus-select-group-hook'
4536 or `gnus-group-catchup-group-hook'."
4537 (when gnus-newsgroup-name
4538 (let ((time (current-time)))
4539 (setcdr (cdr time) nil)
4540 (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
4542 (defsubst gnus-group-timestamp (group)
4543 "Return the timestamp for GROUP."
4544 (gnus-group-get-parameter group 'timestamp t))
4546 (defun gnus-group-timestamp-delta (group)
4547 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4548 (let* ((time (or (gnus-group-timestamp group)
4550 (delta (subtract-time (current-time) time)))
4551 (+ (* (nth 0 delta) 65536.0)
4554 (defun gnus-group-timestamp-string (group)
4555 "Return a string of the timestamp for GROUP."
4556 (let ((time (gnus-group-timestamp group)))
4559 (gnus-time-iso8601 time))))
4561 (defun gnus-group-list-cached (level &optional lowest)
4562 "List all groups with cached articles.
4563 If the prefix LEVEL is non-nil, it should be a number that says which
4564 level to cut off listing groups.
4565 If LOWEST, don't list groups with level lower than LOWEST.
4567 This command may read the active file."
4570 (setq level (prefix-numeric-value level)))
4571 (when (or (not level) (>= level gnus-level-zombie))
4573 (funcall gnus-group-prepare-function
4574 (or level gnus-level-subscribed)
4576 (let ((marks (gnus-info-marks info)))
4577 (assq 'cache marks)))
4580 (or (gnus-gethash group
4581 gnus-cache-active-hashtb)
4582 ;; Cache active file might use "."
4585 (mapconcat 'identity
4586 (split-string group ":")
4588 gnus-cache-active-hashtb))))
4589 (goto-char (point-min))
4590 (gnus-group-position-point))
4592 (defun gnus-group-list-dormant (level &optional lowest)
4593 "List all groups with dormant articles.
4594 If the prefix LEVEL is non-nil, it should be a number that says which
4595 level to cut off listing groups.
4596 If LOWEST, don't list groups with level lower than LOWEST.
4598 This command may read the active file."
4601 (setq level (prefix-numeric-value level)))
4602 (when (or (not level) (>= level gnus-level-zombie))
4604 (funcall gnus-group-prepare-function
4605 (or level gnus-level-subscribed)
4607 (let ((marks (gnus-info-marks info)))
4608 (assq 'dormant marks)))
4611 (goto-char (point-min))
4612 (gnus-group-position-point))
4614 (defun gnus-group-list-ticked (level &optional lowest)
4615 "List all groups with ticked articles.
4616 If the prefix LEVEL is non-nil, it should be a number that says which
4617 level to cut off listing groups.
4618 If LOWEST, don't list groups with level lower than LOWEST.
4620 This command may read the active file."
4623 (setq level (prefix-numeric-value level)))
4624 (when (or (not level) (>= level gnus-level-zombie))
4626 (funcall gnus-group-prepare-function
4627 (or level gnus-level-subscribed)
4629 (let ((marks (gnus-info-marks info)))
4630 (assq 'tick marks)))
4633 (goto-char (point-min))
4634 (gnus-group-position-point))
4636 (defun gnus-group-listed-groups ()
4637 "Return a list of listed groups."
4639 (goto-char (point-min))
4640 (while (setq point (text-property-not-all (point) (point-max)
4643 (push (symbol-name (get-text-property point 'gnus-group)) groups)
4647 (defun gnus-group-list-plus (&optional args)
4648 "List groups plus the current selection."
4650 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4651 (gnus-group-list-mode gnus-group-list-mode) ;; Save it.
4653 (push last-command-event unread-command-events)
4654 (push ?A unread-command-events)
4655 (let (gnus-pick-mode keys)
4656 (setq keys (read-key-sequence nil)
4657 func (lookup-key (current-local-map) keys)))
4661 (call-interactively func))))
4663 (defun gnus-group-list-flush (&optional args)
4664 "Flush groups from the current selection."
4666 (let ((gnus-group-list-option 'flush))
4667 (gnus-group-list-plus args)))
4669 (defun gnus-group-list-limit (&optional args)
4670 "List groups limited within the current selection.
4671 If you've limited the groups, you can further limit the selection
4672 with this command. If you've first limited to groups with
4673 dormant articles with `A ?', you can then further limit with
4674 `A / c', which will then limit to groups with cached articles, giving
4675 you the groups that have both dormant articles and cached articles."
4677 (let ((gnus-group-list-option 'limit))
4678 (gnus-group-list-plus args)))
4680 (declare-function gnus-mark-article-as-read "gnus-sum" (article &optional mark))
4681 (declare-function gnus-group-make-articles-read "gnus-sum" (group articles))
4683 (defun gnus-group-mark-article-read (group article)
4684 "Mark ARTICLE read."
4685 (let ((buffer (gnus-summary-buffer-name group))
4686 (mark gnus-read-mark)
4688 (if (get-buffer buffer)
4689 (with-current-buffer buffer
4690 (setq active gnus-newsgroup-active)
4691 (gnus-activate-group group)
4692 (when gnus-newsgroup-prepared
4693 (when (and gnus-newsgroup-auto-expire
4694 (memq mark gnus-auto-expirable-marks))
4695 (setq mark gnus-expirable-mark))
4696 (setq mark (gnus-request-update-mark
4697 group article mark))
4698 (gnus-request-set-mark
4699 group (list (list (list article) 'add '(read))))
4700 (gnus-mark-article-as-read article mark)
4701 (setq gnus-newsgroup-active (gnus-active group))
4703 (setq n (1+ (cdr active)))
4704 (while (<= n (cdr gnus-newsgroup-active))
4705 (unless (eq n article)
4706 (push n gnus-newsgroup-unselected))
4708 (setq gnus-newsgroup-unselected
4709 (sort gnus-newsgroup-unselected '<)))))
4710 (gnus-activate-group group)
4711 (gnus-group-make-articles-read group (list article))
4712 (when (and (gnus-group-auto-expirable-p group)
4713 (not (gnus-group-read-only-p group)))
4714 (gnus-add-marked-articles
4715 group 'expire (list article))))))
4719 ;;; Group compaction. -- dvl
4722 (defun gnus-group-compact-group (group)
4723 "Compact the current group.
4724 Compaction means removing gaps between article numbers. Hence, this
4725 operation is only meaningful for back ends using one file per article
4728 Note: currently only implemented in nnml."
4729 (interactive (list (gnus-group-group-name)))
4731 (error "No group to compact"))
4732 (unless (gnus-check-backend-function 'request-compact-group group)
4733 (error "This back end does not support group compaction"))
4734 (let ((group-decoded (gnus-group-decoded-name group)))
4736 Compacting group %s... (this may take a long time)"
4739 (if (not (gnus-request-compact-group group))
4740 (gnus-error 3 "Couldn't compact group %s" group-decoded)
4741 (gnus-message 6 "Compacting group %s...done" group-decoded)
4743 ;; Invalidate the "original article" buffer which might be out of date.
4744 ;; #### NOTE: Yes, this might be a bit rude, but since compaction
4745 ;; #### will not happen very often, I think this is acceptable.
4746 (let ((original (get-buffer gnus-original-article-buffer)))
4747 (and original (gnus-kill-buffer original)))
4748 ;; Update the group line to reflect new information (art number etc).
4749 (gnus-group-update-group-line))))
4751 (provide 'gnus-group)
4753 ;;; gnus-group.el ends here