1 ;;; gnus-group.el --- group mode commands for Gnus
3 ;; Copyright (C) 1996-2015 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
)
45 (let ((features (cons 'gnus-group features
)))
47 (unless (boundp 'gnus-cache-active-hashtb
)
48 (defvar gnus-cache-active-hashtb nil
)))
50 (autoload 'gnus-agent-total-fetched-for
"gnus-agent")
51 (autoload 'gnus-cache-total-fetched-for
"gnus-cache")
53 (autoload 'gnus-group-make-nnir-group
"nnir")
55 (defcustom gnus-no-groups-message
"No news is good news"
56 "*Message displayed by Gnus when no groups are available."
60 (defcustom gnus-keep-same-level nil
61 "*Non-nil means that the next newsgroup after the current will be on the same level.
62 When you type, for instance, `n' after reading the last article in the
63 current newsgroup, you will go to the next newsgroup. If this variable
64 is nil, the next newsgroup will be the next from the group
66 If this variable is non-nil, Gnus will either put you in the
67 next newsgroup with the same level, or, if no such newsgroup is
68 available, the next newsgroup with the lowest possible level higher
69 than the current level.
70 If this variable is `best', Gnus will make the next newsgroup the one
72 :group
'gnus-group-levels
73 :type
'(choice (const nil
)
75 (sexp :tag
"other" t
)))
77 (defcustom gnus-group-goto-unread t
78 "*If non-nil, movement commands will go to the next unread and subscribed group."
79 :link
'(custom-manual "(gnus)Group Maneuvering")
80 :group
'gnus-group-various
83 (defcustom gnus-goto-next-group-when-activating t
84 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group."
85 :link
'(custom-manual "(gnus)Scanning New Messages")
86 :group
'gnus-group-various
89 (defcustom gnus-permanently-visible-groups nil
90 "*Regexp to match groups that should always be listed in the group buffer.
91 This means that they will still be listed even when there are no
92 unread articles in the groups.
94 If nil, no groups are permanently visible."
95 :group
'gnus-group-listing
96 :type
'(choice regexp
(const nil
)))
98 (defcustom gnus-safe-html-newsgroups
"\\`nnrss[+:]"
99 "Groups in which links in html articles are considered all safe.
100 The value may be a regexp matching those groups, a list of group names,
101 or nil. This overrides `mm-w3m-safe-url-regexp' (which see). This is
102 effective only when emacs-w3m renders html articles, i.e., in the case
103 `mm-text-html-renderer' is set to `w3m'."
105 :group
'gnus-group-various
106 :type
'(choice regexp
107 (repeat :tag
"List of group names" (string :tag
"Group"))
110 (defcustom gnus-list-groups-with-ticked-articles t
111 "*If non-nil, list groups that have only ticked articles.
112 If nil, only list groups that have unread articles."
113 :group
'gnus-group-listing
116 (defcustom gnus-group-default-list-level gnus-level-subscribed
117 "Default listing level.
118 Ignored if `gnus-group-use-permanent-levels' is non-nil."
119 :group
'gnus-group-listing
120 :type
'(choice (integer :tag
"Level")
121 (function :tag
"Function returning level")))
123 (defcustom gnus-group-list-inactive-groups t
124 "*If non-nil, inactive groups will be listed."
125 :group
'gnus-group-listing
126 :group
'gnus-group-levels
129 (defcustom gnus-group-sort-function
'gnus-group-sort-by-alphabet
130 "*Function used for sorting the group buffer.
131 This function will be called with group info entries as the arguments
132 for the groups to be sorted. Pre-made functions include
133 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name',
134 `gnus-group-sort-by-unread', `gnus-group-sort-by-level',
135 `gnus-group-sort-by-score', `gnus-group-sort-by-method',
136 `gnus-group-sort-by-server', and `gnus-group-sort-by-rank'.
138 This variable can also be a list of sorting functions. In that case,
139 the most significant sort function should be the last function in the
141 :group
'gnus-group-listing
142 :link
'(custom-manual "(gnus)Sorting Groups")
143 :type
'(repeat :value-to-internal
(lambda (widget value
)
144 (if (listp value
) value
(list value
)))
145 :match
(lambda (widget value
)
147 (widget-editable-list-match widget value
)))
148 (choice (function-item gnus-group-sort-by-alphabet
)
149 (function-item gnus-group-sort-by-real-name
)
150 (function-item gnus-group-sort-by-unread
)
151 (function-item gnus-group-sort-by-level
)
152 (function-item gnus-group-sort-by-score
)
153 (function-item gnus-group-sort-by-method
)
154 (function-item gnus-group-sort-by-server
)
155 (function-item gnus-group-sort-by-rank
)
156 (function :tag
"other" nil
))))
158 (defcustom gnus-group-line-format
"%M\%S\%p\%P\%5y:%B%(%g%)\n"
159 "*Format of group lines.
160 It works along the same lines as a normal formatting string,
161 with some simple extensions.
163 %M Only marked articles (character, \"*\" or \" \")
164 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
165 %L Level of subscribedness (integer)
166 %N Number of unread articles (integer)
167 %I Number of dormant articles (integer)
168 %i Number of ticked and dormant (integer)
169 %T Number of ticked articles (integer)
170 %R Number of read articles (integer)
171 %U Number of unseen articles (integer)
172 %t Estimated total number of articles (integer)
173 %y Number of unread, unticked articles (integer)
174 %G Group name (string)
175 %g Qualified group name (string)
176 %c Short (collapsed) group name. See `gnus-group-uncollapsed-levels'.
177 %C Group comment (string)
178 %D Group description (string)
179 %s Select method (string)
180 %o Moderated group (char, \"m\")
181 %p Process mark (char)
182 %B Whether a summary buffer for the group is open (char, \"*\")
183 %O Moderated group (string, \"(m)\" or \"\")
184 %P Topic indentation (string)
185 %m Whether there is new(ish) mail in the group (char, \"%\")
186 %n Select from where (string)
187 %z A string that look like `<%s:%n>' if a foreign select method is used
188 %d The date the group was last entered.
189 %E Icon as defined by `gnus-group-icon-list'.
190 %F The disk space used by the articles fetched by both the cache and agent.
191 %u User defined specifier. The next character in the format string should
192 be a letter. Gnus will call the function gnus-user-format-function-X,
193 where X is the letter following %u. The function will be passed a
194 single dummy parameter as argument. The function should return a
195 string, which will be inserted into the buffer just like information
196 from any other group specifier.
198 Note that this format specification is not always respected. For
199 reasons of efficiency, when listing killed groups, this specification
200 is ignored altogether. If the spec is changed considerably, your
201 output may end up looking strange when listing both alive and killed
204 If you use %o or %O, reading the active file will be slower and quite
205 a bit of extra memory will be used. %D and %F will also worsen
206 performance. Also note that if you change the format specification to
207 include any of these specs, you must probably re-start Gnus to see
210 General format specifiers can also be used.
211 See Info node `(gnus)Formatting Variables'."
212 :link
'(custom-manual "(gnus)Formatting Variables")
213 :group
'gnus-group-visual
216 (defcustom gnus-group-mode-line-format
"Gnus: %%b {%M\%:%S}"
217 "*The format specification for the group mode line.
218 It works along the same lines as a normal formatting string,
219 with some simple extensions:
221 %S The native news server.
222 %M The native select method.
223 %: \":\" if %S isn't \"\"."
224 :group
'gnus-group-visual
227 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
228 (when (featurep 'xemacs
)
229 (add-hook 'gnus-group-mode-hook
'gnus-xmas-group-menu-add
)
230 (add-hook 'gnus-group-mode-hook
'gnus-xmas-setup-group-toolbar
))
232 (defcustom gnus-group-menu-hook nil
233 "Hook run after the creation of the group mode menu."
234 :group
'gnus-group-various
237 (defcustom gnus-group-catchup-group-hook nil
238 "Hook run when catching up a group from the group buffer."
239 :group
'gnus-group-various
240 :link
'(custom-manual "(gnus)Group Data")
243 (defcustom gnus-group-update-group-hook nil
244 "Hook called when updating group lines."
245 :group
'gnus-group-visual
248 (defcustom gnus-group-prepare-function
'gnus-group-prepare-flat
249 "*A function that is called to generate the group buffer.
250 The function is called with three arguments: The first is a number;
251 all group with a level less or equal to that number should be listed,
252 if the second is non-nil, empty groups should also be displayed. If
253 the third is non-nil, it is a number. No groups with a level lower
254 than this number should be displayed.
256 The only current function implemented is `gnus-group-prepare-flat'."
257 :group
'gnus-group-listing
260 (defcustom gnus-group-prepare-hook nil
261 "Hook called after the group buffer has been generated.
262 If you want to modify the group buffer, you can use this hook."
263 :group
'gnus-group-listing
266 (defcustom gnus-suspend-gnus-hook nil
267 "Hook called when suspending (not exiting) Gnus."
271 (defcustom gnus-exit-gnus-hook nil
272 "Hook called when exiting Gnus."
276 (defcustom gnus-after-exiting-gnus-hook nil
277 "Hook called after exiting Gnus."
281 (defcustom gnus-group-update-hook nil
282 "Hook called when a group line is changed."
283 :group
'gnus-group-visual
287 (defcustom gnus-useful-groups
288 '(("(ding) mailing list mirrored at gmane.org"
289 "gmane.emacs.gnus.general"
291 (nntp-address "news.gmane.org")))
294 (nntp "news.gnus.org"
295 (nntp-address "news.gnus.org")))
296 ("Local Gnus help group"
299 (nndoc-article-type mbox
)
300 (eval `(nndoc-address
301 ,(let ((file (nnheader-find-etc-directory
304 (error "Couldn't find doc group"))
306 "*Alist of useful group-server pairs."
307 :group
'gnus-group-listing
308 :type
'(repeat (list (string :tag
"Description")
310 (sexp :tag
"Method"))))
312 (defcustom gnus-group-highlight
314 ((and mailp
(= unread
0) (eq level
1)) .
315 gnus-group-mail-1-empty
)
316 ((and mailp
(eq level
1)) .
318 ((and mailp
(= unread
0) (eq level
2)) .
319 gnus-group-mail-2-empty
)
320 ((and mailp
(eq level
2)) .
322 ((and mailp
(= unread
0) (eq level
3)) .
323 gnus-group-mail-3-empty
)
324 ((and mailp
(eq level
3)) .
326 ((and mailp
(= unread
0)) .
327 gnus-group-mail-low-empty
)
331 ((and (= unread
0) (eq level
1)) .
332 gnus-group-news-1-empty
)
333 ((and (eq level
1)) .
335 ((and (= unread
0) (eq level
2)) .
336 gnus-group-news-2-empty
)
337 ((and (eq level
2)) .
339 ((and (= unread
0) (eq level
3)) .
340 gnus-group-news-3-empty
)
341 ((and (eq level
3)) .
343 ((and (= unread
0) (eq level
4)) .
344 gnus-group-news-4-empty
)
345 ((and (eq level
4)) .
347 ((and (= unread
0) (eq level
5)) .
348 gnus-group-news-5-empty
)
349 ((and (eq level
5)) .
351 ((and (= unread
0) (eq level
6)) .
352 gnus-group-news-6-empty
)
353 ((and (eq level
6)) .
355 ((and (= unread
0)) .
356 gnus-group-news-low-empty
)
358 gnus-group-news-low
))
359 "*Controls the highlighting of group buffer lines.
361 Below is a list of `Form'/`Face' pairs. When deciding how a
362 particular group line should be displayed, each form is
363 evaluated. The content of the face field after the first true form is
364 used. You can change how those group lines are displayed by
365 editing the face field.
367 It is also possible to change and add form fields, but currently that
368 requires an understanding of Lisp expressions. Hopefully this will
369 change in a future release. For now, you can use the following
370 variables in the Lisp expression:
372 group: The name of the group.
373 unread: The number of unread articles in the group.
374 method: The select method used.
375 mailp: Whether it's a mail group or not.
376 level: The level of the group.
377 score: The score of the group.
378 ticked: The number of ticked articles."
379 :group
'gnus-group-visual
380 :type
'(repeat (cons (sexp :tag
"Form") face
)))
381 (put 'gnus-group-highlight
'risky-local-variable t
)
383 (defcustom gnus-new-mail-mark ?%
384 "Mark used for groups with new mail."
385 :group
'gnus-group-visual
388 (defgroup gnus-group-icons nil
389 "Add Icons to your group buffer."
390 :group
'gnus-group-visual
)
392 (defcustom gnus-group-icon-list
394 "*Controls the insertion of icons into group buffer lines.
396 Below is a list of `Form'/`File' pairs. When deciding how a
397 particular group line should be displayed, each form is evaluated.
398 The icon from the file field after the first true form is used. You
399 can change how those group lines are displayed by editing the file
400 field. The File will either be found in the
401 `gnus-group-glyph-directory' or by designating absolute name of the
404 It is also possible to change and add form fields, but currently that
405 requires an understanding of Lisp expressions. Hopefully this will
406 change in a future release. For now, you can use the following
407 variables in the Lisp expression:
409 group: The name of the group.
410 unread: The number of unread articles in the group.
411 method: The select method used.
412 mailp: Whether it's a mail group or not.
413 level: The level of the group.
414 score: The score of the group.
415 ticked: The number of ticked articles."
416 :group
'gnus-group-icons
417 :type
'(repeat (cons (sexp :tag
"Form") file
)))
418 (put 'gnus-group-icon-list
'risky-local-variable t
)
420 (defcustom gnus-group-name-charset-method-alist nil
421 "Alist of method and the charset for group names.
424 (((nntp \"news.com.cn\") . cn-gb-2312))"
427 :type
'(repeat (cons (sexp :tag
"Method") (symbol :tag
"Charset"))))
429 (defcustom gnus-group-name-charset-group-alist
430 (if (or (and (fboundp 'find-coding-system
) (find-coding-system 'utf-8
))
431 (mm-coding-system-p 'utf-8
))
434 "Alist of group regexp and the charset for group names.
437 ((\"\\.com\\.cn:\" . cn-gb-2312))"
439 :type
'(repeat (cons (regexp :tag
"Group") (symbol :tag
"Charset"))))
441 (defcustom gnus-group-jump-to-group-prompt nil
442 "Default prompt for `gnus-group-jump-to-group'.
444 If non-nil, the value should be a string or an alist. If it is a string,
445 e.g. \"nnml:\", in which case `gnus-group-jump-to-group' offers \"Group:
446 nnml:\" in the minibuffer prompt.
448 If it is an alist, it must consist of \(NUMBER . PROMPT\) pairs, for example:
449 \((1 . \"\") (2 . \"nnfolder+archive:\")). The element with number 0 is
450 used when no prefix argument is given to `gnus-group-jump-to-group'."
452 :group
'gnus-group-various
453 :type
'(choice (string :tag
"Prompt string")
454 (const :tag
"Empty" nil
)
455 (repeat (cons (integer :tag
"Argument")
456 (string :tag
"Prompt string")))))
458 (defvar gnus-group-listing-limit
1000
459 "*A limit of the number of groups when listing.
460 If the number of groups is larger than the limit, list them in a
463 ;;; Internal variables
465 (defvar gnus-group-is-exiting-p nil
)
466 (defvar gnus-group-is-exiting-without-update-p nil
)
467 (defvar gnus-group-sort-alist-function
'gnus-group-sort-flat
468 "Function for sorting the group buffer.")
470 (defvar gnus-group-sort-selected-function
'gnus-group-sort-selected-flat
471 "Function for sorting the selected groups in the group buffer.")
473 (defvar gnus-group-indentation-function nil
)
474 (defvar gnus-goto-missing-group-function nil
)
475 (defvar gnus-group-update-group-function nil
)
476 (defvar gnus-group-goto-next-group-function nil
477 "Function to override finding the next group after listing groups.")
479 (defvar gnus-group-edit-buffer nil
)
481 (defvar gnus-tmp-news-method
)
482 (defvar gnus-tmp-colon
)
483 (defvar gnus-tmp-news-server
)
484 (defvar gnus-tmp-decoded-group
)
485 (defvar gnus-tmp-header
)
486 (defvar gnus-tmp-process-marked
)
487 (defvar gnus-tmp-summary-live
)
488 (defvar gnus-tmp-news-method-string
)
489 (defvar gnus-tmp-group-icon
)
490 (defvar gnus-tmp-moderated-string
)
491 (defvar gnus-tmp-newsgroup-description
)
492 (defvar gnus-tmp-comment
)
493 (defvar gnus-tmp-qualified-group
)
494 (defvar gnus-tmp-subscribed
)
495 (defvar gnus-tmp-number-of-read
)
496 (defvar gnus-inhibit-demon
)
497 (defvar gnus-pick-mode
)
498 (defvar gnus-tmp-marked-mark
)
499 (defvar gnus-tmp-number-of-unread
)
501 (defvar gnus-group-line-format-alist
502 `((?M gnus-tmp-marked-mark ?c
)
503 (?S gnus-tmp-subscribed ?c
)
504 (?L gnus-tmp-level ?d
)
505 (?N
(cond ((eq number t
) "*" )
509 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked
)))
510 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked
))))))
512 (?R gnus-tmp-number-of-read ?s
)
513 (?U
(if (gnus-active gnus-tmp-group
)
514 (gnus-number-of-unseen-articles-in-group gnus-tmp-group
)
517 (?t gnus-tmp-number-total ?d
)
518 (?y gnus-tmp-number-of-unread ?s
)
519 (?I
(gnus-range-length (cdr (assq 'dormant gnus-tmp-marked
))) ?d
)
520 (?T
(gnus-range-length (cdr (assq 'tick gnus-tmp-marked
))) ?d
)
521 (?i
(+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked
)))
522 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked
)))) ?d
)
523 (?g
(if (boundp 'gnus-tmp-decoded-group
)
524 gnus-tmp-decoded-group
527 (?G gnus-tmp-qualified-group ?s
)
528 (?c
(gnus-short-group-name (if (boundp 'gnus-tmp-decoded-group
)
529 gnus-tmp-decoded-group
532 (?C gnus-tmp-comment ?s
)
533 (?D gnus-tmp-newsgroup-description ?s
)
534 (?o gnus-tmp-moderated ?c
)
535 (?O gnus-tmp-moderated-string ?s
)
536 (?p gnus-tmp-process-marked ?c
)
537 (?s gnus-tmp-news-server ?s
)
538 (?n
,(if (featurep 'xemacs
)
539 '(symbol-name gnus-tmp-news-method
)
540 'gnus-tmp-news-method
)
542 (?P gnus-group-indentation ?s
)
543 (?E gnus-tmp-group-icon ?s
)
544 (?B gnus-tmp-summary-live ?c
)
545 (?z gnus-tmp-news-method-string ?s
)
546 (?m
(gnus-group-new-mail gnus-tmp-group
) ?c
)
547 (?d
(gnus-group-timestamp-string gnus-tmp-group
) ?s
)
548 (?u gnus-tmp-user-defined ?s
)
549 (?F
(gnus-total-fetched-for gnus-tmp-group
) ?s
)
552 (defvar gnus-group-mode-line-format-alist
553 `((?S gnus-tmp-news-server ?s
)
554 (?M gnus-tmp-news-method ?s
)
555 (?u gnus-tmp-user-defined ?s
)
556 (?
: gnus-tmp-colon ?s
)))
558 (defvar gnus-topic-topology nil
559 "The complete topic hierarchy.")
561 (defvar gnus-topic-alist nil
562 "The complete topic-group alist.")
564 (defvar gnus-group-marked nil
)
566 (defvar gnus-group-list-mode nil
)
569 (defvar gnus-group-listed-groups nil
)
570 (defvar gnus-group-list-option nil
)
576 (put 'gnus-group-mode
'mode-class
'special
)
578 (gnus-define-keys gnus-group-mode-map
579 " " gnus-group-read-group
580 "=" gnus-group-select-group
581 "\r" gnus-group-select-group
582 "\M-\r" gnus-group-quick-select-group
583 "\M- " gnus-group-visible-select-group
584 [(meta control return
)] gnus-group-select-group-ephemerally
585 "j" gnus-group-jump-to-group
586 "n" gnus-group-next-unread-group
587 "p" gnus-group-prev-unread-group
588 "\177" gnus-group-prev-unread-group
589 [delete] gnus-group-prev-unread-group
590 "N" gnus-group-next-group
591 "P" gnus-group-prev-group
592 "\M-n" gnus-group-next-unread-group-same-level
593 "\M-p" gnus-group-prev-unread-group-same-level
594 "," gnus-group-best-unread-group
595 "." gnus-group-first-unread-group
596 "u" gnus-group-unsubscribe-current-group
597 "U" gnus-group-unsubscribe-group
598 "c" gnus-group-catchup-current
599 "C" gnus-group-catchup-current-all
600 "\M-c" gnus-group-clear-data
601 "l" gnus-group-list-groups
602 "L" gnus-group-list-all-groups
605 "g" gnus-group-get-new-news
606 "\M-g" gnus-group-get-new-news-this-group
607 "R" gnus-group-restart
608 "r" gnus-group-read-init-file
609 "B" gnus-group-browse-foreign-server
610 "b" gnus-group-check-bogus-groups
611 "F" gnus-group-find-new-groups
612 "\C-c\C-d" gnus-group-describe-group
613 "\M-d" gnus-group-describe-all-groups
614 "\C-c\C-a" gnus-group-apropos
615 "\C-c\M-\C-a" gnus-group-description-apropos
616 "a" gnus-group-post-news
617 "\ek" gnus-group-edit-local-kill
618 "\eK" gnus-group-edit-global-kill
619 "\C-k" gnus-group-kill-group
620 "\C-y" gnus-group-yank-group
621 "\C-w" gnus-group-kill-region
622 "\C-x\C-t" gnus-group-transpose-groups
623 "\C-c\C-l" gnus-group-list-killed
624 "\C-c\C-x" gnus-group-expire-articles
625 "\C-c\M-\C-x" gnus-group-expire-all-groups
627 "s" gnus-group-save-newsrc
628 "z" gnus-group-suspend
631 "?" gnus-group-describe-briefly
632 "\C-c\C-i" gnus-info-find-node
633 "\M-e" gnus-group-edit-group-method
634 "^" gnus-group-enter-server-mode
635 gnus-mouse-2 gnus-mouse-pick-group
636 [follow-link] mouse-face
637 "<" beginning-of-buffer
640 "\C-c\C-s" gnus-group-sort-groups
642 "\C-c\M-g" gnus-activate-all-groups
643 "\M-&" gnus-group-universal-argument
644 "#" gnus-group-mark-group
645 "\M-#" gnus-group-unmark-group)
647 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
648 "m" gnus-group-mark-group
649 "u" gnus-group-unmark-group
650 "w" gnus-group-mark-region
651 "b" gnus-group-mark-buffer
652 "r" gnus-group-mark-regexp
653 "U" gnus-group-unmark-all-groups)
655 (gnus-define-keys (gnus-group-sieve-map "D" gnus-group-mode-map)
656 "u" gnus-sieve-update
657 "g" gnus-sieve-generate)
659 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
660 "d" gnus-group-make-directory-group
661 "h" gnus-group-make-help-group
662 "u" gnus-group-make-useful-group
663 "l" gnus-group-nnimap-edit-acl
664 "m" gnus-group-make-group
665 "E" gnus-group-edit-group
666 "e" gnus-group-edit-group-method
667 "p" gnus-group-edit-group-parameters
668 "v" gnus-group-add-to-virtual
669 "V" gnus-group-make-empty-virtual
670 "D" gnus-group-enter-directory
671 "f" gnus-group-make-doc-group
672 "w" gnus-group-make-web-group
673 "G" gnus-group-make-nnir-group
674 "M" gnus-group-read-ephemeral-group
675 "r" gnus-group-rename-group
676 "R" gnus-group-make-rss-group
677 "c" gnus-group-customize
678 "z" gnus-group-compact-group
679 "x" gnus-group-expunge-group
680 "\177" gnus-group-delete-group
681 [delete] gnus-group-delete-group
)
683 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map
)
684 "s" gnus-group-sort-groups
685 "a" gnus-group-sort-groups-by-alphabet
686 "u" gnus-group-sort-groups-by-unread
687 "l" gnus-group-sort-groups-by-level
688 "v" gnus-group-sort-groups-by-score
689 "r" gnus-group-sort-groups-by-rank
690 "m" gnus-group-sort-groups-by-method
691 "n" gnus-group-sort-groups-by-real-name
)
693 (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map
)
694 "s" gnus-group-sort-selected-groups
695 "a" gnus-group-sort-selected-groups-by-alphabet
696 "u" gnus-group-sort-selected-groups-by-unread
697 "l" gnus-group-sort-selected-groups-by-level
698 "v" gnus-group-sort-selected-groups-by-score
699 "r" gnus-group-sort-selected-groups-by-rank
700 "m" gnus-group-sort-selected-groups-by-method
701 "n" gnus-group-sort-selected-groups-by-real-name
)
703 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map
)
704 "k" gnus-group-list-killed
705 "z" gnus-group-list-zombies
706 "s" gnus-group-list-groups
707 "u" gnus-group-list-all-groups
708 "A" gnus-group-list-active
709 "a" gnus-group-apropos
710 "d" gnus-group-description-apropos
711 "m" gnus-group-list-matching
712 "M" gnus-group-list-all-matching
713 "l" gnus-group-list-level
714 "c" gnus-group-list-cached
715 "?" gnus-group-list-dormant
716 "!" gnus-group-list-ticked
)
718 (gnus-define-keys (gnus-group-list-limit-map "/" gnus-group-list-map
)
719 "k" gnus-group-list-limit
720 "z" gnus-group-list-limit
721 "s" gnus-group-list-limit
722 "u" gnus-group-list-limit
723 "A" gnus-group-list-limit
724 "m" gnus-group-list-limit
725 "M" gnus-group-list-limit
726 "l" gnus-group-list-limit
727 "c" gnus-group-list-limit
728 "?" gnus-group-list-limit
729 "!" gnus-group-list-limit
)
731 (gnus-define-keys (gnus-group-list-flush-map "f" gnus-group-list-map
)
732 "k" gnus-group-list-flush
733 "z" gnus-group-list-flush
734 "s" gnus-group-list-flush
735 "u" gnus-group-list-flush
736 "A" gnus-group-list-flush
737 "m" gnus-group-list-flush
738 "M" gnus-group-list-flush
739 "l" gnus-group-list-flush
740 "c" gnus-group-list-flush
741 "?" gnus-group-list-flush
742 "!" gnus-group-list-flush
)
744 (gnus-define-keys (gnus-group-list-plus-map "p" gnus-group-list-map
)
745 "k" gnus-group-list-plus
746 "z" gnus-group-list-plus
747 "s" gnus-group-list-plus
748 "u" gnus-group-list-plus
749 "A" gnus-group-list-plus
750 "m" gnus-group-list-plus
751 "M" gnus-group-list-plus
752 "l" gnus-group-list-plus
753 "c" gnus-group-list-plus
754 "?" gnus-group-list-plus
755 "!" gnus-group-list-plus
)
757 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map
)
758 "f" gnus-score-flush-cache
759 "e" gnus-score-edit-all-score
)
761 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map
)
762 "d" gnus-group-describe-group
765 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map
)
766 "l" gnus-group-set-current-level
767 "t" gnus-group-unsubscribe-current-group
768 "s" gnus-group-unsubscribe-group
769 "k" gnus-group-kill-group
770 "y" gnus-group-yank-group
771 "w" gnus-group-kill-region
772 "\C-k" gnus-group-kill-level
773 "z" gnus-group-kill-all-zombies
)
775 (defun gnus-topic-mode-p ()
776 "Return non-nil in `gnus-topic-mode'."
777 (and (boundp 'gnus-topic-mode
)
778 (symbol-value 'gnus-topic-mode
)))
780 (defun gnus-group-make-menu-bar ()
781 (unless (boundp 'gnus-group-reading-menu
)
784 gnus-group-reading-menu gnus-group-mode-map
""
786 ["Read" gnus-group-read-group
787 :included
(not (gnus-topic-mode-p))
788 :active
(gnus-group-group-name)]
789 ["Read " gnus-topic-read-group
790 :included
(gnus-topic-mode-p)]
791 ["Select" gnus-group-select-group
792 :included
(not (gnus-topic-mode-p))
793 :active
(gnus-group-group-name)]
794 ["Select " gnus-topic-select-group
795 :included
(gnus-topic-mode-p)]
796 ["See old articles" (gnus-group-select-group 'all
)
797 :keys
"C-u SPC" :active
(gnus-group-group-name)]
798 ["Catch up" gnus-group-catchup-current
799 :included
(not (gnus-topic-mode-p))
800 :active
(gnus-group-group-name)
801 ,@(if (featurep 'xemacs
) nil
802 '(:help
"Mark unread articles in the current group as read"))]
803 ["Catch up " gnus-topic-catchup-articles
804 :included
(gnus-topic-mode-p)
805 ,@(if (featurep 'xemacs
) nil
806 '(:help
"Mark unread articles in the current group or topic as read"))]
807 ["Catch up all articles" gnus-group-catchup-current-all
808 (gnus-group-group-name)]
809 ["Check for new articles" gnus-group-get-new-news-this-group
810 :included
(not (gnus-topic-mode-p))
811 :active
(gnus-group-group-name)
812 ,@(if (featurep 'xemacs
) nil
813 '(:help
"Check for new messages in current group"))]
814 ["Check for new articles " gnus-topic-get-new-news-this-topic
815 :included
(gnus-topic-mode-p)
816 ,@(if (featurep 'xemacs
) nil
817 '(:help
"Check for new messages in current group or topic"))]
818 ["Toggle subscription" gnus-group-unsubscribe-current-group
819 (gnus-group-group-name)]
820 ["Kill" gnus-group-kill-group
:active
(gnus-group-group-name)
821 ,@(if (featurep 'xemacs
) nil
822 '(:help
"Kill (remove) current group"))]
823 ["Yank" gnus-group-yank-group gnus-list-of-killed-groups
]
824 ["Describe" gnus-group-describe-group
:active
(gnus-group-group-name)
825 ,@(if (featurep 'xemacs
) nil
826 '(:help
"Display description of the current group"))]
827 ;; Actually one should check, if any of the marked groups gives t for
828 ;; (gnus-check-backend-function 'request-expire-articles ...)
829 ["Expire articles" gnus-group-expire-articles
830 :included
(not (gnus-topic-mode-p))
831 :active
(or (and (gnus-group-group-name)
832 (gnus-check-backend-function
833 'request-expire-articles
834 (gnus-group-group-name))) gnus-group-marked
)]
835 ["Expire articles " gnus-topic-expire-articles
836 :included
(gnus-topic-mode-p)]
837 ["Set group level..." gnus-group-set-current-level
838 (gnus-group-group-name)]
839 ["Select quick" gnus-group-quick-select-group
(gnus-group-group-name)]
840 ["Customize" gnus-group-customize
(gnus-group-group-name)]
841 ["Compact" gnus-group-compact-group
842 :active
(gnus-group-group-name)]
844 ["Parameters" gnus-group-edit-group-parameters
845 :included
(not (gnus-topic-mode-p))
846 :active
(gnus-group-group-name)]
847 ["Parameters " gnus-topic-edit-parameters
848 :included
(gnus-topic-mode-p)]
849 ["Select method" gnus-group-edit-group-method
850 (gnus-group-group-name)]
851 ["Info" gnus-group-edit-group
(gnus-group-group-name)]
852 ["Local kill file" gnus-group-edit-local-kill
(gnus-group-group-name)]
853 ["Global kill file" gnus-group-edit-global-kill t
])))
856 gnus-group-group-menu gnus-group-mode-map
""
859 ["List unread subscribed groups" gnus-group-list-groups t
]
860 ["List (un)subscribed groups" gnus-group-list-all-groups t
]
861 ["List killed groups" gnus-group-list-killed gnus-killed-list
]
862 ["List zombie groups" gnus-group-list-zombies gnus-zombie-list
]
863 ["List level..." gnus-group-list-level t
]
864 ["Describe all groups" gnus-group-describe-all-groups t
]
865 ["Group apropos..." gnus-group-apropos t
]
866 ["Group and description apropos..." gnus-group-description-apropos t
]
867 ["List groups matching..." gnus-group-list-matching t
]
868 ["List all groups matching..." gnus-group-list-all-matching t
]
869 ["List active file" gnus-group-list-active t
]
870 ["List groups with cached" gnus-group-list-cached t
]
871 ["List groups with dormant" gnus-group-list-dormant t
]
872 ["List groups with ticked" gnus-group-list-ticked t
])
874 ["Default sort" gnus-group-sort-groups t
]
875 ["Sort by method" gnus-group-sort-groups-by-method t
]
876 ["Sort by rank" gnus-group-sort-groups-by-rank t
]
877 ["Sort by score" gnus-group-sort-groups-by-score t
]
878 ["Sort by level" gnus-group-sort-groups-by-level t
]
879 ["Sort by unread" gnus-group-sort-groups-by-unread t
]
880 ["Sort by name" gnus-group-sort-groups-by-alphabet t
]
881 ["Sort by real name" gnus-group-sort-groups-by-real-name t
])
882 ("Sort process/prefixed"
883 ["Default sort" gnus-group-sort-selected-groups
884 (not (gnus-topic-mode-p))]
885 ["Sort by method" gnus-group-sort-selected-groups-by-method
886 (not (gnus-topic-mode-p))]
887 ["Sort by rank" gnus-group-sort-selected-groups-by-rank
888 (not (gnus-topic-mode-p))]
889 ["Sort by score" gnus-group-sort-selected-groups-by-score
890 (not (gnus-topic-mode-p))]
891 ["Sort by level" gnus-group-sort-selected-groups-by-level
892 (not (gnus-topic-mode-p))]
893 ["Sort by unread" gnus-group-sort-selected-groups-by-unread
894 (not (gnus-topic-mode-p))]
895 ["Sort by name" gnus-group-sort-selected-groups-by-alphabet
896 (not (gnus-topic-mode-p))]
897 ["Sort by real name" gnus-group-sort-selected-groups-by-real-name
898 (not (gnus-topic-mode-p))])
900 ["Mark group" gnus-group-mark-group
901 (and (gnus-group-group-name)
902 (not (memq (gnus-group-group-name) gnus-group-marked
)))]
903 ["Unmark group" gnus-group-unmark-group
904 (and (gnus-group-group-name)
905 (memq (gnus-group-group-name) gnus-group-marked
))]
906 ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked
]
907 ["Mark regexp..." gnus-group-mark-regexp t
]
908 ["Mark region" gnus-group-mark-region
:active
(gnus-mark-active-p)]
909 ["Mark buffer" gnus-group-mark-buffer t
]
910 ["Execute command" gnus-group-universal-argument
911 (or gnus-group-marked
(gnus-group-group-name))])
913 ["Subscribe to a group..." gnus-group-unsubscribe-group t
]
914 ["Kill all newsgroups in region" gnus-group-kill-region
915 :active
(gnus-mark-active-p)]
916 ["Kill all zombie groups" gnus-group-kill-all-zombies
918 ["Kill all groups on level..." gnus-group-kill-level t
])
920 ["Make a foreign group..." gnus-group-make-group t
]
921 ["Add a directory group..." gnus-group-make-directory-group t
]
922 ["Add the help group" gnus-group-make-help-group t
]
923 ["Make a doc group..." gnus-group-make-doc-group t
]
924 ["Make a web group..." gnus-group-make-web-group t
]
925 ["Make a search group..." gnus-group-make-nnir-group t
]
926 ["Make a virtual group..." gnus-group-make-empty-virtual t
]
927 ["Add a group to a virtual..." gnus-group-add-to-virtual t
]
928 ["Make an ephemeral group..." gnus-group-read-ephemeral-group t
]
929 ["Make an RSS group..." gnus-group-make-rss-group t
]
930 ["Rename group..." gnus-group-rename-group
931 (gnus-check-backend-function
932 'request-rename-group
(gnus-group-group-name))]
933 ["Delete group" gnus-group-delete-group
934 (gnus-check-backend-function
935 'request-delete-group
(gnus-group-group-name))])
937 ["Next" gnus-group-next-group t
]
938 ["Previous" gnus-group-prev-group t
]
939 ["Next unread" gnus-group-next-unread-group t
]
940 ["Previous unread" gnus-group-prev-unread-group t
]
941 ["Next unread same level" gnus-group-next-unread-group-same-level t
]
942 ["Previous unread same level"
943 gnus-group-prev-unread-group-same-level t
]
944 ["Jump to group..." gnus-group-jump-to-group t
]
945 ["First unread group" gnus-group-first-unread-group t
]
946 ["Best unread group" gnus-group-best-unread-group t
])
948 ["Generate" gnus-sieve-generate t
]
949 ["Generate and update" gnus-sieve-update t
])
950 ["Delete bogus groups" gnus-group-check-bogus-groups t
]
951 ["Find new newsgroups" gnus-group-find-new-groups t
]
952 ["Transpose" gnus-group-transpose-groups
953 (gnus-group-group-name)]
954 ["Read a directory as a group..." gnus-group-enter-directory t
]))
957 gnus-group-misc-menu gnus-group-mode-map
""
959 ["Send a mail" gnus-group-mail t
]
960 ["Send a message (mail or news)" gnus-group-post-news t
]
961 ["Create a local message" gnus-group-news t
]
962 ["Check for new news" gnus-group-get-new-news
963 ,@(if (featurep 'xemacs
) '(t)
964 '(:help
"Get newly arrived articles"))
966 ["Send queued messages" gnus-delay-send-queue
967 ,@(if (featurep 'xemacs
) '(t)
968 '(:help
"Send all messages that are scheduled to be sent now"))
970 ["Activate all groups" gnus-activate-all-groups t
]
971 ["Restart Gnus" gnus-group-restart t
]
972 ["Read init file" gnus-group-read-init-file t
]
973 ["Browse foreign server..." gnus-group-browse-foreign-server t
]
974 ["Enter server buffer" gnus-group-enter-server-mode t
]
975 ["Expire all expirable articles" gnus-group-expire-all-groups t
]
976 ["Gnus version" gnus-version t
]
977 ["Save .newsrc files" gnus-group-save-newsrc t
]
978 ["Suspend Gnus" gnus-group-suspend t
]
979 ["Clear dribble buffer" gnus-group-clear-dribble t
]
980 ["Read manual" gnus-info-find-node t
]
981 ["Flush score cache" gnus-score-flush-cache t
]
982 ["Toggle topics" gnus-topic-mode t
]
983 ["Send a bug report" gnus-bug t
]
984 ["Exit from Gnus" gnus-group-exit
985 ,@(if (featurep 'xemacs
) '(t)
986 '(:help
"Quit reading news"))]
987 ["Exit without saving" gnus-group-quit t
]))
989 (gnus-run-hooks 'gnus-group-menu-hook
)))
992 (defvar gnus-group-tool-bar-map nil
)
994 (defun gnus-group-tool-bar-update (&optional symbol value
)
995 "Update group buffer toolbar.
996 Setter function for custom variables."
998 (set-default symbol value
))
999 ;; (setq-default gnus-group-tool-bar-map nil)
1000 ;; (use-local-map gnus-group-mode-map)
1001 (when (gnus-alive-p)
1002 (with-current-buffer gnus-group-buffer
1003 (gnus-group-make-tool-bar t
))))
1005 (defcustom gnus-group-tool-bar
(if (eq gmm-tool-bar-style
'gnome
)
1006 'gnus-group-tool-bar-gnome
1007 'gnus-group-tool-bar-retro
)
1008 "Specifies the Gnus group tool bar.
1010 It can be either a list or a symbol referring to a list. See
1011 `gmm-tool-bar-from-list' for the format of the list. The
1012 default key map is `gnus-group-mode-map'.
1014 Pre-defined symbols include `gnus-group-tool-bar-gnome' and
1015 `gnus-group-tool-bar-retro'."
1016 :type
'(choice (const :tag
"GNOME style" gnus-group-tool-bar-gnome
)
1017 (const :tag
"Retro look" gnus-group-tool-bar-retro
)
1018 (repeat :tag
"User defined list" gmm-tool-bar-item
)
1020 :version
"23.1" ;; No Gnus
1021 :initialize
'custom-initialize-default
1022 :set
'gnus-group-tool-bar-update
1025 (defcustom gnus-group-tool-bar-gnome
1026 '((gnus-group-post-news "mail/compose")
1027 ;; Some useful agent icons? I don't use the agent so agent users should
1028 ;; suggest useful commands:
1029 (gnus-agent-toggle-plugged "unplugged" t
1030 :help
"Gnus is currently unplugged. Click to work online."
1031 :visible
(and gnus-agent
(not gnus-plugged
)))
1032 (gnus-agent-toggle-plugged "plugged" t
1033 :help
"Gnus is currently plugged. Click to work offline."
1034 :visible
(and gnus-agent gnus-plugged
))
1035 ;; FIXME: gnus-agent-toggle-plugged (in gnus-agent-group-make-menu-bar)
1036 ;; should have a better help text.
1037 (gnus-group-send-queue "mail/outbox" t
1038 :visible
(and gnus-agent gnus-plugged
)
1039 :help
"Send articles from the queue group")
1040 (gnus-group-get-new-news "mail/inbox" nil
1041 :visible
(or (not gnus-agent
)
1043 ;; FIXME: gnus-*-read-group should have a better help text.
1044 (gnus-topic-read-group "open" nil
1045 :visible
(and (boundp 'gnus-topic-mode
)
1047 (gnus-group-read-group "open" nil
1048 :visible
(not (and (boundp 'gnus-topic-mode
)
1050 ;; (gnus-group-find-new-groups "???" nil)
1051 (gnus-group-save-newsrc "save")
1052 (gnus-group-describe-group "describe")
1053 (gnus-group-unsubscribe-current-group "gnus/toggle-subscription")
1054 (gnus-group-prev-unread-group "left-arrow")
1055 (gnus-group-next-unread-group "right-arrow")
1056 (gnus-group-exit "exit")
1057 (gmm-customize-mode "preferences" t
:help
"Edit mode preferences")
1058 (gnus-info-find-node "help"))
1059 "List of functions for the group tool bar (GNOME style).
1061 See `gmm-tool-bar-from-list' for the format of the list."
1062 :type
'(repeat gmm-tool-bar-item
)
1063 :version
"23.1" ;; No Gnus
1064 :initialize
'custom-initialize-default
1065 :set
'gnus-group-tool-bar-update
1068 (defcustom gnus-group-tool-bar-retro
1069 '((gnus-group-get-new-news "gnus/get-news")
1070 (gnus-group-get-new-news-this-group "gnus/gnntg")
1071 (gnus-group-catchup-current "gnus/catchup")
1072 (gnus-group-describe-group "gnus/describe-group")
1073 (gnus-group-subscribe "gnus/subscribe" t
1074 :help
"Subscribe to the current group")
1075 (gnus-group-unsubscribe "gnus/unsubscribe" t
1076 :help
"Unsubscribe from the current group")
1077 (gnus-group-exit "gnus/exit-gnus" gnus-group-mode-map
))
1078 "List of functions for the group tool bar (retro look).
1080 See `gmm-tool-bar-from-list' for the format of the list."
1081 :type
'(repeat gmm-tool-bar-item
)
1082 :version
"23.1" ;; No Gnus
1083 :initialize
'custom-initialize-default
1084 :set
'gnus-group-tool-bar-update
1087 (defcustom gnus-group-tool-bar-zap-list t
1088 "List of icon items from the global tool bar.
1089 These items are not displayed in the Gnus group mode tool bar.
1091 See `gmm-tool-bar-from-list' for the format of the list."
1092 :type
'gmm-tool-bar-zap-list
1093 :version
"23.1" ;; No Gnus
1094 :initialize
'custom-initialize-default
1095 :set
'gnus-group-tool-bar-update
1098 (defvar image-load-path
)
1099 (defvar tool-bar-map
)
1101 (defun gnus-group-make-tool-bar (&optional force
)
1102 "Make a group mode tool bar from `gnus-group-tool-bar'.
1103 When FORCE, rebuild the tool bar."
1104 (when (and (not (featurep 'xemacs
))
1105 (boundp 'tool-bar-mode
)
1108 (or (not gnus-group-tool-bar-map
) force
))
1110 (gmm-image-load-path-for-library "gnus"
1111 "gnus/toggle-subscription.xpm"
1113 (image-load-path (cons (car load-path
)
1114 (when (boundp 'image-load-path
)
1116 (map (gmm-tool-bar-from-list gnus-group-tool-bar
1117 gnus-group-tool-bar-zap-list
1118 'gnus-group-mode-map
)))
1120 (set (make-local-variable 'tool-bar-map
) map
))))
1121 gnus-group-tool-bar-map
)
1123 (define-derived-mode gnus-group-mode fundamental-mode
"Group"
1124 "Major mode for reading news.
1126 All normal editing commands are switched off.
1127 \\<gnus-group-mode-map>
1128 The group buffer lists (some of) the groups available. For instance,
1129 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
1130 lists all zombie groups.
1132 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
1133 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
1135 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
1137 The following commands are available:
1139 \\{gnus-group-mode-map}"
1140 (when (gnus-visual-p 'group-menu
'menu
)
1141 (gnus-group-make-menu-bar)
1142 (gnus-group-make-tool-bar))
1143 (gnus-simplify-mode-line)
1144 (gnus-group-set-mode-line)
1145 (setq mode-line-process nil
)
1146 (buffer-disable-undo)
1147 (setq truncate-lines t
)
1148 (setq buffer-read-only t
1149 show-trailing-whitespace nil
)
1150 (gnus-set-default-directory)
1151 (gnus-update-format-specifications nil
'group
'group-mode
)
1152 (gnus-update-group-mark-positions)
1158 (defun gnus-update-group-mark-positions ()
1160 (let ((gnus-process-mark ?
\200)
1161 (gnus-group-update-hook nil
)
1162 (gnus-group-marked '("dummy.group"))
1163 (gnus-active-hashtb (make-vector 10 0)))
1164 (gnus-set-active "dummy.group" '(0 .
0))
1165 (gnus-set-work-buffer)
1166 (gnus-group-insert-group-line "dummy.group" 0 nil
0 nil
)
1167 (goto-char (point-min))
1168 (setq gnus-group-mark-positions
1169 (list (cons 'process
(and (search-forward
1170 (mm-string-to-multibyte "\200") nil t
)
1171 (- (point) (point-min) 1))))))))
1173 (defun gnus-mouse-pick-group (e)
1174 "Enter the group under the mouse pointer."
1177 (gnus-group-read-group nil
))
1179 (defun gnus-group-default-list-level ()
1180 "Return the real value for `gnus-group-default-list-level'."
1181 (if (functionp gnus-group-default-list-level
)
1182 (funcall gnus-group-default-list-level
)
1183 gnus-group-default-list-level
))
1185 ;; Look at LEVEL and find out what the level is really supposed to be.
1186 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
1187 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
1188 (defun gnus-group-default-level (&optional level number-or-nil
)
1190 (gnus-group-use-permanent-levels
1191 (or (setq gnus-group-use-permanent-levels
1192 (or level
(if (numberp gnus-group-use-permanent-levels
)
1193 gnus-group-use-permanent-levels
1194 (or (gnus-group-default-list-level)
1195 gnus-level-subscribed
))))
1196 (gnus-group-default-list-level) gnus-level-subscribed
))
1200 (or level
(gnus-group-default-list-level) gnus-level-subscribed
))))
1202 (defun gnus-group-setup-buffer ()
1203 (set-buffer (gnus-get-buffer-create gnus-group-buffer
))
1204 (unless (derived-mode-p 'gnus-group-mode
)
1207 (defun gnus-group-name-charset (method group
)
1209 (setq method
(gnus-find-method-for-group group
)))
1210 (when (stringp method
)
1211 (setq method
(gnus-server-to-method method
)))
1212 (if (eq (car method
) 'nnimap
)
1213 ;; IMAP groups should not be encoded, since they do the encoding
1214 ;; in utf7 in the protocol.
1216 (let ((item (or (assoc method gnus-group-name-charset-method-alist
)
1218 (assoc (list (car method
) (cadr method
))
1219 gnus-group-name-charset-method-alist
))))
1220 (alist gnus-group-name-charset-group-alist
)
1224 (while (setq item
(pop alist
))
1225 (if (string-match (car item
) group
)
1227 result
(cdr item
))))
1230 (defun gnus-group-name-decode (string charset
)
1231 ;; Fixme: Don't decode in unibyte mode.
1232 (if (and string charset
(featurep 'mule
))
1233 (mm-decode-coding-string string charset
)
1236 (defun gnus-group-decoded-name (string)
1237 (let ((charset (gnus-group-name-charset nil string
)))
1238 (gnus-group-name-decode string charset
)))
1240 (defun gnus-group-list-groups (&optional level unread lowest
)
1241 "List newsgroups with level LEVEL or lower that have unread articles.
1242 Default is all subscribed groups.
1243 If argument UNREAD is non-nil, groups with no unread articles are also
1246 Also see the `gnus-group-use-permanent-levels' variable."
1248 (list (if current-prefix-arg
1249 (prefix-numeric-value current-prefix-arg
)
1251 (gnus-group-default-level nil t
)
1252 (gnus-group-default-list-level)
1253 gnus-level-subscribed
))))
1255 (setq level
(car gnus-group-list-mode
)
1256 unread
(cdr gnus-group-list-mode
)))
1257 (setq level
(gnus-group-default-level level
))
1258 (gnus-group-setup-buffer)
1259 (gnus-update-format-specifications nil
'group
'group-mode
)
1260 (let ((case-fold-search nil
)
1261 (props (text-properties-at (point-at-bol)))
1262 (empty (= (point-min) (point-max)))
1263 (group (gnus-group-group-name))
1265 (set-buffer gnus-group-buffer
)
1266 (setq number
(funcall gnus-group-prepare-function level unread lowest
))
1267 (when (or (and (numberp number
)
1269 (zerop (buffer-size)))
1270 ;; No groups in the buffer.
1271 (gnus-message 5 "%s" gnus-no-groups-message
))
1272 ;; We have some groups displayed.
1273 (goto-char (point-max))
1274 (when (or (not gnus-group-goto-next-group-function
)
1275 (not (funcall gnus-group-goto-next-group-function
1279 (goto-char (point-min)))
1281 ;; Go to the first group with unread articles.
1282 (gnus-group-search-forward t
))
1284 ;; Find the right group to put point on. If the current group
1285 ;; has disappeared in the new listing, try to find the next
1286 ;; one. If no next one can be found, just leave point at the
1287 ;; first newsgroup in the buffer.
1288 (when (not (gnus-goto-char
1290 (point-min) (point-max)
1291 'gnus-group
(gnus-intern-safe
1292 group gnus-active-hashtb
))))
1293 (let ((newsrc (cdddr (gnus-group-entry group
))))
1295 (not (gnus-goto-char
1297 (point-min) (point-max) 'gnus-group
1299 (caar newsrc
) gnus-active-hashtb
)))))
1300 (setq newsrc
(cdr newsrc
)))
1302 (goto-char (point-max))
1303 (forward-line -
1)))))))
1304 ;; Adjust cursor point.
1305 (gnus-group-position-point)))
1307 (defun gnus-group-list-level (level &optional all
)
1308 "List groups on LEVEL.
1309 If ALL (the prefix), also list groups that have no unread articles."
1310 (interactive "nList groups on level: \nP")
1311 (gnus-group-list-groups level all level
))
1313 (defun gnus-group-prepare-logic (group test
)
1314 (or (and gnus-group-listed-groups
1315 (null gnus-group-list-option
)
1316 (member group gnus-group-listed-groups
))
1318 ((null gnus-group-listed-groups
) test
)
1319 ((null gnus-group-list-option
) test
)
1320 (t (and (member group gnus-group-listed-groups
)
1321 (if (eq gnus-group-list-option
'flush
)
1325 (defun gnus-group-prepare-flat (level &optional predicate lowest regexp
)
1326 "List all newsgroups with unread articles of level LEVEL or lower.
1327 If PREDICATE is a function, list groups that the function returns non-nil;
1328 if it is t, list groups that have no unread articles.
1329 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
1330 If REGEXP is a function, list dead groups that the function returns non-nil;
1331 if it is a string, only list groups matching REGEXP."
1332 (set-buffer gnus-group-buffer
)
1333 (let ((buffer-read-only nil
)
1334 (newsrc (cdr gnus-newsrc-alist
))
1335 (lowest (or lowest
1))
1336 (not-in-list (and gnus-group-listed-groups
1337 (copy-sequence gnus-group-listed-groups
)))
1338 info clevel unread group params
)
1340 (when (or (< lowest gnus-level-zombie
)
1341 gnus-group-listed-groups
)
1342 ;; List living groups.
1344 (setq info
(car newsrc
)
1345 group
(gnus-info-group info
)
1346 params
(gnus-info-params info
)
1348 unread
(gnus-group-unread group
))
1350 (setq not-in-list
(delete group not-in-list
)))
1351 (when (gnus-group-prepare-logic
1353 (and (or unread
; This group might be unchecked
1354 predicate
) ; Check if this group should be listed
1355 (or (not (stringp regexp
))
1356 (string-match regexp group
))
1357 (<= (setq clevel
(gnus-info-level info
)) level
)
1360 ((functionp predicate
)
1361 (funcall predicate info
))
1362 (predicate t
) ; We list all groups?
1365 (if (eq unread t
) ; Inactive?
1366 gnus-group-list-inactive-groups
1368 (and (numberp unread
) (> unread
0)))
1369 ; We list groups with unread articles
1370 (and gnus-list-groups-with-ticked-articles
1371 (cdr (assq 'tick
(gnus-info-marks info
))))
1372 ; And groups with ticked articles
1373 ;; Check for permanent visibility.
1374 (and gnus-permanently-visible-groups
1375 (string-match gnus-permanently-visible-groups
1377 (memq 'visible params
)
1378 (cdr (assq 'visible params
)))))))
1379 (gnus-group-insert-group-line
1380 group
(gnus-info-level info
)
1381 (gnus-info-marks info
) unread
(gnus-info-method info
)))))
1383 ;; List dead groups.
1384 (when (or gnus-group-listed-groups
1385 (and (>= level gnus-level-zombie
)
1386 (<= lowest gnus-level-zombie
)))
1387 (gnus-group-prepare-flat-list-dead
1388 (setq gnus-zombie-list
(sort gnus-zombie-list
'string
<))
1389 gnus-level-zombie ?Z
1392 (dolist (group gnus-zombie-list
)
1393 (setq not-in-list
(delete group not-in-list
))))
1394 (when (or gnus-group-listed-groups
1395 (and (>= level gnus-level-killed
) (<= lowest gnus-level-killed
)))
1396 (gnus-group-prepare-flat-list-dead
1399 (setq gnus-killed-list
(sort gnus-killed-list
'string
<)))
1400 gnus-level-killed ?K regexp
))
1402 (gnus-group-set-mode-line)
1403 (setq gnus-group-list-mode
(cons level predicate
))
1404 (gnus-run-hooks 'gnus-group-prepare-hook
)
1407 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp
)
1408 ;; List zombies and killed lists somewhat faster, which was
1409 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
1410 ;; this by ignoring the group format specification altogether.
1412 (if (> (length groups
) gnus-group-listing-limit
)
1414 (setq group
(pop groups
))
1415 (when (gnus-group-prepare-logic
1418 (and (stringp regexp
) (string-match regexp group
))
1419 (and (functionp regexp
) (funcall regexp group
))))
1420 (gnus-add-text-properties
1421 (point) (prog1 (1+ (point))
1422 (insert " " mark
" *: "
1423 (gnus-group-decoded-name group
)
1425 (list 'gnus-group
(gnus-intern-safe group gnus-active-hashtb
)
1427 'gnus-level level
))))
1429 (setq group
(pop groups
))
1430 (when (gnus-group-prepare-logic
1433 (and (stringp regexp
) (string-match regexp group
))
1434 (and (functionp regexp
) (funcall regexp group
))))
1435 (gnus-group-insert-group-line
1437 (let ((active (gnus-active group
)))
1439 (if (zerop (cdr active
))
1441 (- (1+ (cdr active
)) (car active
)))
1443 (gnus-method-simplify (gnus-find-method-for-group group
))))))))
1445 (defun gnus-group-update-group-line ()
1446 "Update the current line in the group buffer."
1447 (let* ((buffer-read-only nil
)
1448 (group (gnus-group-group-name))
1449 (entry (and group
(gnus-group-entry group
)))
1450 gnus-group-indentation
)
1453 (not (gnus-ephemeral-group-p group
))
1455 (concat "(gnus-group-set-info '"
1456 (gnus-prin1-to-string (nth 2 entry
))
1458 (concat "^(gnus-group-set-info '(\"" (regexp-quote group
) "\"")))
1459 (setq gnus-group-indentation
(gnus-group-group-indentation))
1461 (gnus-group-insert-group-line-info group
)
1463 (gnus-group-position-point))))
1465 (defun gnus-group-insert-group-line-info (group)
1466 "Insert GROUP on the current line."
1467 (let ((entry (gnus-group-entry group
))
1468 (gnus-group-indentation (gnus-group-group-indentation))
1472 ;; (Un)subscribed group.
1473 (setq info
(nth 2 entry
))
1474 (gnus-group-insert-group-line
1475 group
(gnus-info-level info
) (gnus-info-marks info
)
1476 (or (car entry
) t
) (gnus-info-method info
)))
1477 ;; This group is dead.
1478 (gnus-group-insert-group-line
1480 (if (member group gnus-zombie-list
) gnus-level-zombie gnus-level-killed
)
1482 (if (setq active
(gnus-active group
))
1483 (if (zerop (cdr active
))
1485 (- (1+ (cdr active
)) (car active
)))
1487 (gnus-method-simplify (gnus-find-method-for-group group
))))))
1489 (defun gnus-number-of-unseen-articles-in-group (group)
1490 (let* ((info (nth 2 (gnus-group-entry group
)))
1491 (marked (gnus-info-marks info
))
1492 (seen (cdr (assq 'seen marked
)))
1493 (active (gnus-active group
)))
1496 (length (gnus-uncompress-range
1497 (gnus-range-difference
1498 (gnus-range-difference (list active
) (gnus-info-read info
))
1501 ;; Moving through the Group buffer (in topic mode) e.g. with C-n doesn't
1502 ;; update the state (enabled/disabled) of the icon `gnus-group-describe-group'
1503 ;; automatically. After `C-l' the state is correct. See the following report
1505 ;; <http://thread.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de>:
1506 ;; From: Reiner Steib
1507 ;; Subject: tool bar icons not updated according to :active condition
1508 ;; Newsgroups: gmane.emacs.devel
1509 ;; Date: Mon, 23 Jan 2006 19:59:13 +0100
1510 ;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
1512 (defcustom gnus-group-update-tool-bar
1513 (and (not (featurep 'xemacs
))
1514 (boundp 'tool-bar-mode
)
1516 ;; Using `redraw-frame' (see `gnus-tool-bar-update') in Emacs might
1517 ;; be confusing, so maybe we shouldn't call it by default.
1518 (fboundp 'force-window-update
))
1519 "Force updating the group buffer tool bar."
1522 :initialize
'custom-initialize-default
1523 :set
(lambda (symbol value
)
1524 (set-default symbol value
)
1525 (when (gnus-alive-p)
1526 (with-current-buffer gnus-group-buffer
1527 ;; FIXME: Is there a better way to redraw the group buffer?
1528 (gnus-group-get-new-news 0))))
1531 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
1532 gnus-tmp-marked number
1534 "Insert a group line in the group buffer."
1535 (let* ((gnus-tmp-method
1536 (gnus-server-get-method gnus-tmp-group gnus-tmp-method
))
1537 (group-name-charset (gnus-group-name-charset gnus-tmp-method
1539 (gnus-tmp-active (gnus-active gnus-tmp-group
))
1540 (gnus-tmp-number-total
1542 (1+ (- (cdr gnus-tmp-active
) (car gnus-tmp-active
)))
1544 (gnus-tmp-number-of-unread
1545 (if (numberp number
) (int-to-string (max 0 number
))
1547 (gnus-tmp-number-of-read
1548 (if (numberp number
)
1549 (int-to-string (max 0 (- gnus-tmp-number-total number
)))
1551 (gnus-tmp-subscribed
1552 (cond ((<= gnus-tmp-level gnus-level-subscribed
) ?
)
1553 ((<= gnus-tmp-level gnus-level-unsubscribed
) ?U
)
1554 ((= gnus-tmp-level gnus-level-zombie
) ?Z
)
1556 (gnus-tmp-qualified-group
1557 (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group
)
1558 group-name-charset
))
1560 (or (gnus-group-get-parameter gnus-tmp-group
'comment t
)
1562 (gnus-tmp-newsgroup-description
1563 (if gnus-description-hashtb
1564 (or (gnus-group-name-decode
1565 (gnus-gethash gnus-tmp-group gnus-description-hashtb
)
1566 group-name-charset
) "")
1569 (if (and gnus-moderated-hashtb
1570 (gnus-gethash gnus-tmp-group gnus-moderated-hashtb
))
1572 (gnus-tmp-moderated-string
1573 (if (eq gnus-tmp-moderated ?m
) "(m)" ""))
1574 (gnus-tmp-group-icon (gnus-group-get-icon gnus-tmp-group
))
1575 (gnus-tmp-news-server (or (cadr gnus-tmp-method
) ""))
1576 (gnus-tmp-news-method (or (car gnus-tmp-method
) ""))
1577 (gnus-tmp-news-method-string
1579 (format "(%s:%s)" (car gnus-tmp-method
)
1580 (cadr gnus-tmp-method
)) ""))
1581 (gnus-tmp-marked-mark
1582 (if (and (numberp number
)
1584 (cdr (assq 'tick gnus-tmp-marked
)))
1586 (gnus-tmp-summary-live
1587 (if (and (not gnus-group-is-exiting-p
)
1588 (gnus-buffer-live-p (gnus-summary-buffer-name
1591 (gnus-tmp-process-marked
1592 (if (member gnus-tmp-group gnus-group-marked
)
1593 gnus-process-mark ?
))
1594 (buffer-read-only nil
)
1596 gnus-tmp-header
) ; passed as parameter to user-funcs.
1599 (gnus-add-text-properties
1603 (let ((gnus-tmp-decoded-group (gnus-group-name-decode
1604 gnus-tmp-group group-name-charset
)))
1605 (eval gnus-group-line-format-spec
)))
1606 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb
)
1607 gnus-unread
,(if (numberp number
)
1608 (string-to-number gnus-tmp-number-of-unread
)
1610 gnus-marked
,gnus-tmp-marked-mark
1611 gnus-indentation
,gnus-group-indentation
1612 gnus-level
,gnus-tmp-level
))
1614 (gnus-group--setup-tool-bar-update beg end
)
1616 (when (inline (gnus-visual-p 'group-highlight
'highlight
))
1617 (gnus-group-highlight-line gnus-tmp-group beg end
))
1618 (gnus-run-hooks 'gnus-group-update-hook
)
1621 (defun gnus-group--setup-tool-bar-update (beg end
)
1622 (when gnus-group-update-tool-bar
1623 (if (fboundp 'cursor-sensor-mode
)
1625 (unless (bound-and-true-p cursor-sensor-mode
)
1626 (cursor-sensor-mode 1))
1627 (gnus-put-text-property beg end
'cursor-sensor-functions
1628 '(gnus-tool-bar-update)))
1629 (gnus-put-text-property beg end
'point-entered
1630 #'gnus-tool-bar-update
)
1631 (gnus-put-text-property beg end
'point-left
1632 #'gnus-tool-bar-update
))))
1634 (defun gnus-group-update-eval-form (group list
)
1635 "Eval `car' of each element of LIST, and return the first that return t.
1636 Some value are bound so the form can use them."
1637 (defvar group-age
) (defvar ticked
) (defvar score
) (defvar level
)
1638 (defvar mailp
) (defvar total
) (defvar unread
)
1640 (let* ((entry (gnus-group-entry group
))
1641 (unread (if (numberp (car entry
)) (car entry
) 0))
1642 (active (gnus-active group
))
1643 (total (if active
(1+ (- (cdr active
) (car active
))) 0))
1644 (info (nth 2 entry
))
1645 (method (inline (gnus-server-get-method group
(gnus-info-method info
))))
1646 (marked (gnus-info-marks info
))
1647 (mailp (apply 'append
1650 (memq x
(assoc (symbol-name
1651 (car (or method gnus-select-method
)))
1652 gnus-valid-select-methods
)))
1653 '(mail post-mail
))))
1654 (level (or (gnus-info-level info
) gnus-level-killed
))
1655 (score (or (gnus-info-score info
) 0))
1656 (ticked (gnus-range-length (cdr (assq 'tick marked
))))
1657 (group-age (gnus-group-timestamp-delta group
)))
1658 ;; FIXME: http://thread.gmane.org/gmane.emacs.gnus.general/65451/focus=65465
1659 ;; ======================================================================
1660 ;; From: Richard Stallman
1661 ;; Subject: Re: Rewriting gnus-group-highlight-line (was: [...])
1662 ;; Cc: ding@gnus.org
1663 ;; Date: Sat, 27 Oct 2007 19:41:20 -0400
1664 ;; Message-ID: <E1IlvHM-0006TS-7t@fencepost.gnu.org>
1667 ;; The kludge is that the alist elements contain expressions that refer
1668 ;; to local variables with short names. Perhaps write your own tiny
1669 ;; evaluator that handles just `and', `or', and numeric comparisons
1670 ;; and just a few specific variables.
1671 ;; ======================================================================
1673 ;; Similar for other evaluated variables. Grep for risky-local-variable
1674 ;; to find them! -- rsteib
1676 ;; Eval the cars of the lists until we find a match.
1678 (not (eval (caar list
))))
1679 (setq list
(cdr list
)))
1682 (defun gnus-group-highlight-line (group beg end
)
1683 "Highlight the current line according to `gnus-group-highlight'.
1684 GROUP is current group, and the line to highlight starts at BEG
1686 (let ((face (cdar (gnus-group-update-eval-form
1688 gnus-group-highlight
))))
1689 (unless (eq face
(gnus-get-text-property-excluding-characters-with-faces beg
'face
))
1690 (let ((inhibit-read-only t
))
1691 (gnus-put-text-property-excluding-characters-with-faces
1693 (if (boundp face
) (symbol-value face
) face
)))
1694 (gnus-extent-start-open beg
))))
1696 (defun gnus-group-get-icon (group)
1697 "Return an icon for GROUP according to `gnus-group-icon-list'."
1698 (if gnus-group-icon-list
1700 (cdar (gnus-group-update-eval-form group gnus-group-icon-list
))))
1705 (gnus-create-image (expand-file-name image-path
))
1711 (defun gnus-group-refresh-group (group)
1712 (gnus-activate-group group
)
1713 (gnus-get-unread-articles-in-group (gnus-get-info group
)
1714 (gnus-active group
))
1715 (gnus-group-update-group group
))
1717 (defun gnus-group-update-group (group &optional visible-only
1719 "Update all lines where GROUP appear.
1720 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
1721 already. If INFO-UNCHANGED is non-nil, dribble buffer is not updated."
1722 (with-current-buffer gnus-group-buffer
1724 ;; The buffer may be narrowed.
1727 (let ((ident (gnus-intern-safe group gnus-active-hashtb
))
1729 found buffer-read-only
)
1730 (unless info-unchanged
1731 ;; Enter the current status into the dribble buffer.
1732 (let ((entry (gnus-group-entry group
)))
1734 (not (gnus-ephemeral-group-p group
)))
1736 (concat "(gnus-group-set-info '"
1737 (gnus-prin1-to-string (nth 2 entry
))
1739 (concat "^(gnus-group-set-info '(\""
1740 (regexp-quote group
) "\"")))))
1741 ;; Find all group instances. If topics are in use, each group
1742 ;; may be listed in more than once.
1743 (while (setq loc
(text-property-any
1744 loc
(point-max) 'gnus-group ident
))
1747 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1749 (gnus-group-insert-group-line-info group
)
1752 (gnus-run-hooks 'gnus-group-update-group-hook
)))
1753 (setq loc
(1+ loc
)))
1754 (unless (or found visible-only
)
1755 ;; No such line in the buffer, find out where it's supposed to
1756 ;; go, and insert it there (or at the end of the buffer).
1757 (if gnus-goto-missing-group-function
1758 (funcall gnus-goto-missing-group-function group
)
1759 (let ((entry (cddr (gnus-group-entry group
))))
1760 (while (and entry
(car entry
)
1764 (point-min) (point-max)
1765 'gnus-group
(gnus-intern-safe
1767 gnus-active-hashtb
)))))
1768 (setq entry
(cdr entry
)))
1769 (or entry
(goto-char (point-max)))))
1770 ;; Finally insert the line.
1771 (let ((gnus-group-indentation (gnus-group-group-indentation)))
1772 (gnus-group-insert-group-line-info group
)
1775 (gnus-run-hooks 'gnus-group-update-group-hook
))))
1776 (when gnus-group-update-group-function
1777 (funcall gnus-group-update-group-function group
))
1778 (gnus-group-set-mode-line))))))
1780 (defun gnus-group-set-mode-line ()
1781 "Update the mode line in the group buffer."
1782 (when (memq 'group gnus-updated-mode-lines
)
1783 ;; Yes, we want to keep this mode line updated.
1784 (with-current-buffer gnus-group-buffer
1785 (let* ((gformat (or gnus-group-mode-line-format-spec
1786 (gnus-set-format 'group-mode
)))
1787 (gnus-tmp-news-server (cadr gnus-select-method
))
1788 (gnus-tmp-news-method (car gnus-select-method
))
1789 (gnus-tmp-colon (if (equal gnus-tmp-news-server
"") "" ":"))
1791 gnus-tmp-header
;Dummy binding for user-defined formats
1792 ;; Get the resulting string.
1794 (and gnus-dribble-buffer
1795 (buffer-name gnus-dribble-buffer
)
1796 (buffer-modified-p gnus-dribble-buffer
)
1797 (with-current-buffer gnus-dribble-buffer
1798 (not (zerop (buffer-size))))))
1799 (mode-string (eval gformat
)))
1800 ;; Say whether the dribble buffer has been modified.
1801 (setq mode-line-modified
1802 (if modified
(car gnus-mode-line-modified
)
1803 (cdr gnus-mode-line-modified
)))
1804 ;; If the line is too long, we chop it off.
1805 (when (> (length mode-string
) max-len
)
1806 (setq mode-string
(substring mode-string
0 (- max-len
4))))
1808 (setq mode-line-buffer-identification
1809 (gnus-mode-line-buffer-identification
1810 (list mode-string
)))
1811 (set-buffer-modified-p modified
))))))
1813 (defun gnus-group-group-name ()
1814 "Get the name of the newsgroup on the current line."
1815 (let ((group (get-text-property (point-at-bol) 'gnus-group
)))
1817 (symbol-name group
))))
1819 (defun gnus-group-group-level ()
1820 "Get the level of the newsgroup on the current line."
1821 (get-text-property (point-at-bol) 'gnus-level
))
1823 (defun gnus-group-group-indentation ()
1824 "Get the indentation of the newsgroup on the current line."
1825 (or (get-text-property (point-at-bol) 'gnus-indentation
)
1826 (and gnus-group-indentation-function
1827 (funcall gnus-group-indentation-function
))
1830 (defun gnus-group-group-unread ()
1831 "Get the number of unread articles of the newsgroup on the current line."
1832 (get-text-property (point-at-bol) 'gnus-unread
))
1834 (defun gnus-group-new-mail (group)
1835 (if (nnmail-new-mail-p (gnus-group-real-name group
))
1839 (defun gnus-group-level (group)
1840 "Return the estimated level of GROUP."
1841 (or (gnus-info-level (gnus-get-info group
))
1842 (and (member group gnus-zombie-list
) gnus-level-zombie
)
1845 (defun gnus-group-search-forward (&optional backward all level first-too
)
1846 "Find the next newsgroup with unread articles.
1847 If BACKWARD is non-nil, find the previous newsgroup instead.
1848 If ALL is non-nil, just find any newsgroup.
1849 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
1851 If FIRST-TOO, the current line is also eligible as a target."
1852 (let ((way (if backward -
1 1))
1853 (low gnus-level-killed
)
1856 (if (and backward
(progn (beginning-of-line)) (bobp))
1865 (get-text-property (point) 'gnus-group
)
1869 (get-text-property (point) 'gnus-unread
)))
1870 (and (numberp unread
) (> unread
0)))
1871 (setq lev
(get-text-property (point)
1873 (<= lev gnus-level-subscribed
)))
1875 (and (setq lev
(get-text-property (point)
1884 (zerop (forward-line way
)))))
1886 (progn (gnus-group-position-point) t
)
1887 (goto-char (or pos beg
))
1890 (defun gnus-total-fetched-for (group)
1891 (let* ((size-in-cache (or (gnus-cache-total-fetched-for group
) 0))
1892 (size-in-agent (or (gnus-agent-total-fetched-for group
) 0))
1893 (size (+ size-in-cache size-in-agent
))
1894 (suffix '("B" "K" "M" "G"))
1897 (while (> size cutoff
)
1898 (setq size
(/ size scale
)
1899 suffix
(cdr suffix
)))
1900 (format "%5.1f%s" size
(car suffix
))))
1902 ;;; Gnus group mode commands
1906 (defun gnus-group-mark-line-p ()
1909 (forward-char (or (cdr (assq 'process gnus-group-mark-positions
)) 2))
1910 (eq (char-after) gnus-process-mark
)))
1912 (defun gnus-group-mark-group (n &optional unmark no-advance
)
1913 "Mark the current group."
1915 (let ((buffer-read-only nil
)
1919 (when (setq group
(gnus-group-group-name))
1920 ;; Go to the mark position.
1922 (forward-char (or (cdr (assq 'process gnus-group-mark-positions
)) 2))
1926 (setq gnus-group-marked
(delete group gnus-group-marked
))
1927 (insert-char ?
1 t
))
1928 (setq gnus-group-marked
1929 (cons group
(delete group gnus-group-marked
)))
1930 (insert-char gnus-process-mark
1 t
)))
1932 (gnus-group-next-group 1))
1934 (gnus-group-position-point)
1937 (defun gnus-group-unmark-group (n)
1938 "Remove the mark from the current group."
1940 (gnus-group-mark-group n
'unmark
)
1941 (gnus-group-position-point))
1943 (defun gnus-group-unmark-all-groups ()
1944 "Unmark all groups."
1947 (mapc 'gnus-group-remove-mark gnus-group-marked
))
1948 (gnus-group-position-point))
1950 (defun gnus-group-mark-region (unmark beg end
)
1951 "Mark all groups between point and mark.
1952 If UNMARK, remove the mark instead."
1953 (interactive "P\nr")
1954 (let ((num (count-lines beg end
)))
1957 (- num
(gnus-group-mark-group num unmark
)))))
1959 (defun gnus-group-mark-buffer (&optional unmark
)
1960 "Mark all groups in the buffer.
1961 If UNMARK, remove the mark instead."
1963 (gnus-group-mark-region unmark
(point-min) (point-max)))
1965 (defun gnus-group-mark-regexp (regexp)
1966 "Mark all groups that match some regexp."
1967 (interactive "sMark (regexp): ")
1968 (let ((alist (cdr gnus-newsrc-alist
))
1972 (when (string-match regexp
(setq group
(gnus-info-group (pop alist
))))
1973 (gnus-group-jump-to-group group
)
1974 (gnus-group-set-mark group
)))))
1975 (gnus-group-position-point))
1977 (defun gnus-group-remove-mark (group &optional test-marked
)
1978 "Remove the process mark from GROUP and move point there.
1979 Return nil if the group isn't displayed."
1980 (if (gnus-group-goto-group group nil test-marked
)
1982 (gnus-group-mark-group 1 'unmark t
)
1984 (setq gnus-group-marked
1985 (delete group gnus-group-marked
))
1988 (defun gnus-group-set-mark (group)
1989 "Set the process mark on GROUP."
1990 (if (gnus-group-goto-group group
)
1992 (gnus-group-mark-group 1 nil t
))
1993 (setq gnus-group-marked
(cons group
(delete group gnus-group-marked
)))))
1995 (defun gnus-group-universal-argument (arg &optional groups func
)
1996 "Perform any command on all groups according to the process/prefix convention."
1998 (if (eq (setq func
(or func
2001 (substitute-command-keys
2002 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
2004 (gnus-error 1 "Undefined key")
2005 (gnus-group-iterate arg
2007 (command-execute func
))))
2008 (gnus-group-position-point))
2010 (defun gnus-group-process-prefix (n)
2011 "Return a list of groups to work on.
2012 Take into consideration N (the prefix) and the list of marked groups."
2015 (setq n
(prefix-numeric-value n
))
2016 ;; There is a prefix, so we return a list of the N next
2018 (let ((way (if (< n
0) -
1 1))
2023 (if (setq group
(gnus-group-group-name))
2024 (push group groups
))
2026 (gnus-group-next-group way
)))
2028 ((and (gnus-region-active-p) (mark))
2029 ;; Work on the region between point and mark.
2030 (let ((max (max (point) (mark)))
2033 (goto-char (min (point) (mark)))
2036 (push (gnus-group-group-name) groups
)
2037 (zerop (gnus-group-next-group 1))
2039 (nreverse groups
))))
2041 ;; No prefix, but a list of marked articles.
2042 (reverse gnus-group-marked
))
2044 ;; Neither marked articles or a prefix, so we return the
2046 (let ((group (gnus-group-group-name)))
2047 (and group
(list group
))))))
2049 ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't
2050 ;;; imagine why I went through these contortions...
2052 (let ((function (make-symbol "gnus-group-iterate-function"))
2053 (window (make-symbol "gnus-group-iterate-window"))
2054 (groups (make-symbol "gnus-group-iterate-groups"))
2055 (group (make-symbol "gnus-group-iterate-group")))
2057 `(defun gnus-group-iterate (arg ,function
)
2058 "Iterate FUNCTION over all process/prefixed groups.
2059 FUNCTION will be called with the group name as the parameter
2060 and with point over the group in question."
2061 (let ((,groups
(gnus-group-process-prefix arg
))
2062 (,window
(selected-window))
2065 (setq ,group
(car ,groups
)
2066 ,groups
(cdr ,groups
))
2067 (select-window ,window
)
2068 (gnus-group-remove-mark ,group
)
2069 (save-selected-window
2071 (funcall ,function
,group
)))))))))
2073 (put 'gnus-group-iterate
'lisp-indent-function
1)
2075 ;; Selecting groups.
2077 (defun gnus-group-read-group (&optional all no-article group select-articles
)
2078 "Read news in this newsgroup.
2079 If the prefix argument ALL is non-nil, already read articles become
2082 If ALL is a positive number, fetch this number of the latest
2083 articles in the group. If ALL is a negative number, fetch this
2084 number of the earliest articles in the group.
2086 If the optional argument NO-ARTICLE is non-nil, no article will
2087 be auto-selected upon group entry. If GROUP is non-nil, fetch
2090 (let ((no-display (eq all
0))
2091 (group (or group
(gnus-group-group-name)))
2092 number active marked entry
)
2096 (error "No group on current line"))
2097 (setq marked
(gnus-info-marks
2098 (nth 2 (setq entry
(gnus-group-entry group
)))))
2099 ;; This group might be a dead group. In that case we have to get
2100 ;; the number of unread articles from `gnus-active-hashtb'.
2102 (cond ((numberp all
) all
)
2104 ((setq active
(gnus-active group
))
2105 (- (1+ (cdr active
)) (car active
)))))
2106 (gnus-summary-read-group
2107 group
(or all
(and (numberp number
)
2108 (zerop (+ number
(gnus-range-length
2109 (cdr (assq 'tick marked
)))
2111 (cdr (assq 'dormant marked
)))))))
2112 no-article nil no-display nil select-articles
)))
2114 (defun gnus-group-select-group (&optional all
)
2115 "Select this newsgroup.
2116 No article is selected automatically.
2117 If the group is opened, just switch the summary buffer.
2118 If ALL is non-nil, already read articles become readable.
2119 If ALL is a positive number, fetch this number of the latest
2120 articles in the group.
2121 If ALL is a negative number, fetch this number of the earliest
2122 articles in the group."
2124 (when (and (eobp) (not (gnus-group-group-name)))
2126 (gnus-group-read-group all t
))
2128 (defun gnus-group-quick-select-group (&optional all group
)
2129 "Select the GROUP \"quickly\".
2130 This means that no highlighting or scoring will be performed. If
2131 ALL (the prefix argument) is 0, don't even generate the summary
2132 buffer. If GROUP is nil, use current group.
2134 This might be useful if you want to toggle threading
2135 before entering the group."
2137 (require 'gnus-score
)
2139 gnus-score-find-score-files-function
2140 gnus-home-score-file
2141 gnus-apply-kill-hook
2142 gnus-summary-expunge-below
)
2143 (gnus-group-read-group all t group
)))
2145 (defun gnus-group-visible-select-group (&optional all
)
2146 "Select the current group without hiding any articles."
2148 (let ((gnus-inhibit-limiting t
))
2149 (gnus-group-read-group all t
)))
2151 (defun gnus-group-select-group-ephemerally ()
2152 "Select the current group without doing any processing whatsoever.
2153 You will actually be entered into a group that's a copy of
2154 the current group; no changes you make while in this group will
2157 (require 'gnus-score
)
2159 gnus-score-find-score-files-function gnus-apply-kill-hook
2160 gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates
2161 gnus-summary-mode-hook gnus-select-group-hook
2162 (group (gnus-group-group-name))
2163 (method (gnus-find-method-for-group group
)))
2164 (gnus-group-read-ephemeral-group
2165 (gnus-group-prefixed-name group method
) method
)))
2167 (defun gnus-group-name-at-point ()
2168 "Return a group name from around point if it exists, or nil."
2169 (if (derived-mode-p 'gnus-group-mode
)
2170 (let ((group (gnus-group-group-name)))
2172 (gnus-group-decoded-name group
)))
2173 (let ((regexp "[][\C-@-\t\v-*,/:-@\\^`{-\C-?]*\
2174 \\(nn[a-z]+\\(?:\\+[^][\C-@-*,/:-@\\^`{-\C-?]+\\)?:\
2175 \[^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)*\
2176 \\|[^][\C-@-*,./:-@\\^`{-\C-?]+\\(?:\\.[^][\C-@-*,./:-@\\^`{-\C-?]+\\)+\\)")
2178 (case-fold-search nil
))
2180 (if (or (and (not (or (eobp)
2181 (looking-at "[][\C-@-*,/;-@\\^`{-\C-?]")))
2183 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2185 (and (looking-at "[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*$")
2187 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2188 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2190 (string-match "\\`[][\C-@-\t\v-*,/;-@\\^`{-\C-?]*\\'"
2191 (buffer-substring (point-at-bol) (point))))
2192 (when (looking-at regexp
)
2194 (let (group distance
)
2195 (when (looking-at regexp
)
2196 (setq group
(match-string 1)
2197 distance
(- (match-beginning 1) (match-beginning 0))))
2198 (skip-chars-backward "][\C-@-\t\v-*,/;-@\\^`{-\C-?")
2199 (skip-chars-backward "^][\C-@-\t\v-*,/;-@\\^`{-\C-?"
2201 (if (looking-at regexp
)
2202 (if (and group
(<= distance
(- start
(match-end 0))))
2206 (goto-char start
)))))
2208 (defun gnus-group-completing-read (&optional prompt collection
2209 require-match initial-input hist
2211 "Read a group name with completion. Non-ASCII group names are allowed.
2212 The arguments are the same as `completing-read' except that COLLECTION
2213 and HIST default to `gnus-active-hashtb' and `gnus-group-history'
2214 respectively if they are omitted. Regards COLLECTION as a hash table
2215 if it is not a list."
2216 (or collection
(setq collection gnus-active-hashtb
))
2217 (let (choices group
)
2218 (if (listp collection
)
2219 (dolist (symbol collection
)
2220 (setq group
(symbol-name symbol
))
2221 (push (if (string-match "[^\000-\177]" group
)
2222 (gnus-group-decoded-name group
)
2225 (mapatoms (lambda (symbol)
2226 (setq group
(symbol-name symbol
))
2227 (push (if (string-match "[^\000-\177]" group
)
2228 (gnus-group-decoded-name group
)
2232 (setq group
(gnus-completing-read (or prompt
"Group") (nreverse choices
)
2233 require-match initial-input
2234 (or hist
'gnus-group-history
)
2236 (unless (if (listp collection
)
2237 (member group
(mapcar 'symbol-name collection
))
2238 (symbol-value (intern-soft group collection
)))
2240 (mm-encode-coding-string
2241 group
(gnus-group-name-charset nil group
))))
2242 (gnus-replace-in-string group
"\n" "")))
2245 (defun gnus-fetch-group (group &optional articles
)
2246 "Start Gnus if necessary and enter GROUP.
2247 If ARTICLES, display those articles.
2248 Returns whether the fetching was successful or not."
2249 (interactive (list (gnus-group-completing-read nil
2251 (gnus-group-name-at-point))))
2252 (unless (gnus-alive-p)
2254 (gnus-group-read-group (if articles nil t
) nil group articles
))
2257 (defun gnus-fetch-group-other-frame (group)
2258 "Pop up a frame and enter GROUP."
2260 (let ((window (get-buffer-window gnus-group-buffer
)))
2262 (select-frame (window-frame window
)))
2263 ((= (length (frame-list)) 1)
2264 (select-frame (make-frame)))
2267 (gnus-fetch-group group
))
2269 (defcustom gnus-large-ephemeral-newsgroup
200
2270 "The number of articles which indicates a large ephemeral newsgroup.
2271 Same as `gnus-large-newsgroup', but only used for ephemeral newsgroups.
2273 If the number of articles in a newsgroup is greater than this value,
2274 confirmation is required for selecting the newsgroup. If it is nil, no
2275 confirmation is required."
2277 :group
'gnus-group-select
2278 :type
'(choice (const :tag
"No limit" nil
)
2281 (defcustom gnus-fetch-old-ephemeral-headers nil
2282 "Same as `gnus-fetch-old-headers', but only used for ephemeral newsgroups."
2285 :type
'(choice (const :tag
"off" nil
)
2288 (sexp :menu-tag
"other" t
)))
2290 ;; Enter a group that is not in the group buffer. Non-nil is returned
2291 ;; if selection was successful.
2292 (defun gnus-group-read-ephemeral-group (group method
&optional activate
2293 quit-config request-only
2297 "Read GROUP from METHOD as an ephemeral group.
2298 If ACTIVATE, request the group first.
2299 If QUIT-CONFIG, use that Gnus window configuration name when
2300 exiting from the ephemeral group.
2301 If REQUEST-ONLY, don't actually read the group; just request it.
2302 If SELECT-ARTICLES, only select those articles.
2303 If PARAMETERS, use those as the group parameters.
2304 If NUMBER, fetch this number of articles.
2306 Return the name of the group if selection was successful."
2309 ;; (gnus-read-group "Group name: ")
2310 (gnus-group-completing-read)
2311 (gnus-read-method "From method")))
2312 (unless (gnus-alive-p)
2313 (nnheader-init-server-buffer)
2314 ;; Necessary because of funky inlining.
2315 (require 'gnus-cache
)
2316 (setq gnus-newsrc-hashtb
(gnus-make-hashtable)))
2317 ;; Transform the select method into a unique server.
2318 (when (stringp method
)
2319 (setq method
(gnus-server-to-method method
)))
2321 (intern (format "%s-address" (car method
)))))
2323 (if (assq address-slot
(cddr method
))
2324 `(,(car method
) ,(concat (cadr method
) "-ephemeral")
2326 `(,(car method
) ,(concat (cadr method
) "-ephemeral")
2327 (,address-slot
,(cadr method
))
2329 (let ((group (if (gnus-group-foreign-p group
) group
2330 (gnus-group-prefixed-name (gnus-group-real-name group
)
2332 (gnus-set-active group nil
)
2336 ,gnus-level-default-subscribed nil nil
,method
2342 ((assq gnus-current-window-configuration
2343 gnus-buffer-configuration
)
2344 (cons gnus-summary-buffer
2345 gnus-current-window-configuration
))
2347 (cons (current-buffer)
2348 (current-window-configuration)))))
2351 (push method gnus-ephemeral-servers
)
2352 (when (gnus-buffer-live-p gnus-group-buffer
)
2353 (set-buffer gnus-group-buffer
))
2354 (unless (gnus-check-server method
)
2355 (error "Unable to contact server: %s" (gnus-status-message method
)))
2357 (gnus-activate-group group
'scan
)
2358 (unless (gnus-request-group group
)
2359 (error "Couldn't request group: %s"
2360 (nnheader-get-report (car method
)))))
2364 (when (let ((gnus-large-newsgroup gnus-large-ephemeral-newsgroup
)
2365 (gnus-fetch-old-headers
2366 gnus-fetch-old-ephemeral-headers
))
2367 (gnus-group-read-group (or number t
) t group select-articles
))
2372 (message "Quit reading the ephemeral group"))
2375 (defcustom gnus-gmane-group-download-format
2376 "http://download.gmane.org/%s/%s/%s"
2377 "URL for downloading mbox files.
2378 It must contain three \"%s\". They correspond to the group, the
2379 minimal and maximal article numbers, respectively."
2380 :group
'gnus-group-foreign
2381 :version
"23.1" ;; No Gnus
2384 (autoload 'url-insert-file-contents
"url-handlers")
2386 ;; - Add documentation, menu, key bindings, ...
2388 (defun gnus-read-ephemeral-gmane-group (group start
&optional range
)
2389 "Read articles from Gmane group GROUP as an ephemeral group.
2390 START is the first article. RANGE specifies how many articles
2391 are fetched. The articles are downloaded via HTTP using the URL
2392 specified by `gnus-gmane-group-download-format'."
2393 ;; See <http://gmane.org/export.php> for more information.
2396 (gnus-group-completing-read "Gmane group")
2397 (read-number "Start article number: ")
2398 (read-number "How many articles: ")))
2399 (unless range
(setq range
500))
2401 (error "Invalid range: %s" range
))
2402 (let ((tmpfile (mm-make-temp-file
2403 (format "%s.start-%s.range-%s." group start range
)))
2404 (gnus-thread-sort-functions '(gnus-thread-sort-by-number)))
2405 (with-temp-file tmpfile
2406 (url-insert-file-contents
2407 (format gnus-gmane-group-download-format
2408 group start
(+ start range
)))
2409 (write-region (point-min) (point-max) tmpfile
)
2410 (gnus-group-read-ephemeral-group
2411 (format "nndoc+ephemeral:%s.start-%s.range-%s" group start range
)
2413 (nndoc-article-type mbox
))))
2414 (delete-file tmpfile
)))
2416 (defun gnus-read-ephemeral-gmane-group-url (url)
2417 "Create an ephemeral Gmane group from URL.
2419 Valid input formats include:
2420 \"http://thread.gmane.org/gmane.foo.bar/12300/focus=12399\",
2421 \"http://thread.gmane.org/gmane.foo.bar/12345/\",
2422 \"http://article.gmane.org/gmane.foo.bar/12345/\",
2423 \"http://news.gmane.org/group/gmane.foo.bar/thread=12345\""
2424 ;; - Feel free to add other useful Gmane URLs here! Maybe the URLs should
2426 ;; - The URLs should be added to `gnus-button-alist'. Probably we should
2427 ;; prompt the user to decide: "View via `browse-url' or in Gnus? "
2428 ;; (`gnus-read-ephemeral-gmane-group-url')
2430 (list (gnus-group-completing-read "Gmane URL")))
2431 (let (group start range
)
2433 ;; URLs providing `group', `start' and `range':
2435 ;; http://thread.gmane.org/gmane.emacs.devel/86326/focus=86525
2436 "^http://thread\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)/focus=\\([0-9]+\\)$"
2438 (setq group
(match-string 1 url
)
2439 start
(string-to-number (match-string 2 url
))
2440 ;; Ensure that `range' is large enough to ensure focus article is
2442 range
(- (string-to-number (match-string 3 url
))
2444 ;; URLs providing `group' and `start':
2446 ;; http://article.gmane.org/gmane.comp.gnu.make.bugs/3584
2447 "^http://\\(?:thread\\|article\\|permalink\\)\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)"
2450 ;; Don't advertise these in the doc string yet:
2451 "^\\(?:nntp\\|news\\)://news\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)"
2454 ;; http://news.gmane.org/group/gmane.emacs.gnus.general/thread=65099/force_load=t
2455 "^http://news\.gmane\.org/group/\\([^/]+\\)/thread=\\([0-9]+\\)"
2457 (setq group
(match-string 1 url
)
2458 start
(string-to-number (match-string 2 url
))))
2460 (error "Can't parse URL %s" url
)))
2461 (gnus-read-ephemeral-gmane-group group start range
)))
2463 (defcustom gnus-bug-group-download-format-alist
2464 '((emacs .
"http://debbugs.gnu.org/cgi/bugreport.cgi?bug=%s;mboxmaint=yes;mboxstat=yes")
2466 .
"http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%s&mbox=yes;mboxmaint=yes"))
2467 "Alist of symbols for bug trackers and the corresponding URL format string.
2468 The URL format string must contain a single \"%s\", specifying
2469 the bug number, and browsing the URL must return mbox output."
2470 :group
'gnus-group-foreign
2471 ;; Added mboxmaint=yes. This gets the version with the messages as
2472 ;; they went out, not as they came in.
2473 ;; Eg bug-gnu-emacs is replaced by ###@debbugs.
2475 :type
'(repeat (cons (symbol) (string :tag
"URL format string"))))
2477 (defun gnus-read-ephemeral-bug-group (ids mbox-url
&optional window-conf
)
2478 "Browse bug NUMBER as ephemeral group."
2479 (interactive (list (read-string "Enter bug number: "
2480 (thing-at-point 'word
) nil
)
2481 ;; FIXME: Add completing-read from
2482 ;; `gnus-emacs-bug-group-download-format' ...
2483 (cdr (assoc 'emacs gnus-bug-group-download-format-alist
))))
2485 (setq ids
(string-to-number ids
)))
2487 (setq ids
(list ids
)))
2488 (let ((tmpfile (mm-make-temp-file "gnus-temp-group-")))
2489 (let ((coding-system-for-write 'binary
)
2490 (coding-system-for-read 'binary
))
2491 (with-temp-file tmpfile
2492 (mm-disable-multibyte)
2494 (url-insert-file-contents (format mbox-url id
)))
2495 (goto-char (point-min))
2496 ;; Add the debbugs address so that we can respond to reports easily.
2497 (while (re-search-forward "^To: " nil t
)
2499 (insert (format ", %s@%s" (car ids
)
2500 (gnus-replace-in-string
2501 (gnus-replace-in-string mbox-url
"^http://" "")
2503 (gnus-group-read-ephemeral-group
2504 (format "nndoc+ephemeral:bug#%s"
2505 (mapconcat 'number-to-string ids
","))
2507 (nndoc-article-type mbox
))
2509 (delete-file tmpfile
)))
2511 (defun gnus-read-ephemeral-debian-bug-group (number)
2512 "Browse Debian bug NUMBER as ephemeral group."
2513 (interactive (list (read-string "Enter bug number: "
2514 (thing-at-point 'word
) nil
)))
2515 (gnus-read-ephemeral-bug-group
2517 (cdr (assoc 'debian gnus-bug-group-download-format-alist
))))
2519 (defvar debbugs-gnu-bug-number
) ; debbugs-gnu
2521 (defun gnus-read-ephemeral-emacs-bug-group (ids &optional window-conf
)
2522 "Browse Emacs bugs IDS as an ephemeral group."
2523 (interactive (list (string-to-number
2524 (read-string "Enter bug number: "
2525 (thing-at-point 'word
) nil
))))
2527 (setq ids
(list ids
)))
2528 (gnus-read-ephemeral-bug-group
2530 (cdr (assoc 'emacs gnus-bug-group-download-format-alist
))
2532 (when (fboundp 'debbugs-gnu-summary-mode
)
2533 (with-current-buffer (window-buffer (selected-window))
2534 (debbugs-gnu-summary-mode 1)
2535 (set (make-local-variable 'debbugs-gnu-bug-number
) (car ids
)))))
2537 (defun gnus-group-jump-to-group (group &optional prompt
)
2538 "Jump to newsgroup GROUP.
2540 If PROMPT (the prefix) is a number, use the prompt specified in
2541 `gnus-group-jump-to-group-prompt'."
2543 (list (gnus-group-completing-read
2545 (if current-prefix-arg
2546 (cdr (assq current-prefix-arg gnus-group-jump-to-group-prompt
))
2547 (or (and (stringp gnus-group-jump-to-group-prompt
)
2548 gnus-group-jump-to-group-prompt
)
2549 (let ((p (cdr (assq 0 gnus-group-jump-to-group-prompt
))))
2550 (and (stringp p
) p
)))))))
2552 (when (equal group
"")
2553 (error "Empty group name"))
2555 (unless (gnus-ephemeral-group-p group
)
2556 ;; Either go to the line in the group buffer...
2557 (unless (gnus-group-goto-group group
)
2558 ;; ... or insert the line.
2559 (gnus-group-update-group group
)
2560 (gnus-group-goto-group group
)))
2561 ;; Adjust cursor point.
2562 (gnus-group-position-point))
2564 (defun gnus-group-goto-group (group &optional far test-marked
)
2565 "Goto to newsgroup GROUP.
2566 If FAR, it is likely that the group is not on the current line.
2567 If TEST-MARKED, the line must be marked."
2571 ;; It's quite likely that we are on the right line, so
2572 ;; we check the current line first.
2574 (eq (get-text-property (point) 'gnus-group
)
2575 (gnus-intern-safe group gnus-active-hashtb
))
2576 (or (not test-marked
) (gnus-group-mark-line-p)))
2578 ;; Previous and next line are also likely, so we check them as well.
2582 (and (eq (get-text-property (point) 'gnus-group
)
2583 (gnus-intern-safe group gnus-active-hashtb
))
2584 (or (not test-marked
) (gnus-group-mark-line-p)))))
2590 (and (eq (get-text-property (point) 'gnus-group
)
2591 (gnus-intern-safe group gnus-active-hashtb
))
2592 (or (not test-marked
) (gnus-group-mark-line-p)))))
2596 (goto-char (point-min))
2598 (while (and (not found
)
2603 (gnus-intern-safe group gnus-active-hashtb
))))
2604 (if (gnus-group-mark-line-p)
2609 ;; Search through the entire buffer.
2612 (point-min) (point-max)
2613 'gnus-group
(gnus-intern-safe group gnus-active-hashtb
)))))))
2615 (defun gnus-group-next-group (n &optional silent
)
2616 "Go to next N'th newsgroup.
2617 If N is negative, search backward instead.
2618 Returns the difference between N and the number of skips actually
2621 (gnus-group-next-unread-group n t nil silent
))
2623 (defun gnus-group-next-unread-group (n &optional all level silent
)
2624 "Go to next N'th unread newsgroup.
2625 If N is negative, search backward instead.
2626 If ALL is non-nil, choose any newsgroup, unread or not.
2627 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2628 such group can be found, the next group with a level higher than
2630 Returns the difference between N and the number of skips actually
2633 (let ((backward (< n
0))
2636 (gnus-group-search-forward
2637 backward
(or (not gnus-group-goto-unread
) all
) level
))
2641 (gnus-message 7 "No more%s newsgroups%s" (if all
"" " unread")
2642 (if level
" on this level or higher" "")))
2645 (defun gnus-group-prev-group (n)
2646 "Go to previous N'th newsgroup.
2647 Returns the difference between N and the number of skips actually
2650 (gnus-group-next-unread-group (- n
) t
))
2652 (defun gnus-group-prev-unread-group (n)
2653 "Go to previous N'th unread newsgroup.
2654 Returns the difference between N and the number of skips actually
2657 (gnus-group-next-unread-group (- n
)))
2659 (defun gnus-group-next-unread-group-same-level (n)
2660 "Go to next N'th unread newsgroup on the same level.
2661 If N is negative, search backward instead.
2662 Returns the difference between N and the number of skips actually
2665 (gnus-group-next-unread-group n t
(gnus-group-group-level))
2666 (gnus-group-position-point))
2668 (defun gnus-group-prev-unread-group-same-level (n)
2669 "Go to next N'th unread newsgroup on the same level.
2670 Returns the difference between N and the number of skips actually
2673 (gnus-group-next-unread-group (- n
) t
(gnus-group-group-level))
2674 (gnus-group-position-point))
2676 (defun gnus-group-best-unread-group (&optional exclude-group
)
2677 "Go to the group with the highest level.
2678 If EXCLUDE-GROUP, do not go to that group."
2680 (goto-char (point-min))
2684 (setq unread
(get-text-property (point) 'gnus-unread
))
2685 (when (and (numberp unread
) (> unread
0))
2686 (when (and (get-text-property (point) 'gnus-level
)
2687 (< (get-text-property (point) 'gnus-level
) best
)
2688 (or (not exclude-group
)
2689 (not (equal exclude-group
(gnus-group-group-name)))))
2690 (setq best
(get-text-property (point) 'gnus-level
))
2691 (setq best-point
(point))))
2694 (goto-char best-point
))
2695 (gnus-group-position-point)
2696 (and best-point
(gnus-group-group-name))))
2698 ;; Is there something like an after-point-motion-hook?
2699 ;; (inhibit-point-motion-hooks?). Is there a tool-bar-update function?
2701 ;; (defun gnus-group-menu-bar-update ()
2702 ;; (let* ((buf (list (with-current-buffer gnus-group-buffer
2703 ;; (current-buffer))))
2704 ;; (name (buffer-name (car buf))))
2706 ;; (if (> (length name) 27)
2707 ;; (concat (substring name 0 12)
2709 ;; (substring name -12))
2711 ;; (menu-bar-update-buffers-1 buf)))
2713 ;; (defun gnus-group-position-point ()
2714 ;; (gnus-goto-colon)
2715 ;; (gnus-group-menu-bar-update))
2717 (defun gnus-group-first-unread-group ()
2718 "Go to the first group with unread articles."
2721 (let ((opoint (point))
2723 (goto-char (point-min))
2724 (if (or (eq (setq unread
(gnus-group-group-unread)) t
) ; Not active.
2725 (and (numberp unread
) ; Not a topic.
2726 (not (zerop unread
))) ; Has unread articles.
2727 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
2730 nil
)) ; Not success.
2731 (gnus-group-position-point)))
2733 (defun gnus-group-enter-server-mode ()
2734 "Jump to the server buffer."
2736 (gnus-enter-server-buffer))
2738 (defun gnus-group-make-group-simple (&optional group
)
2739 "Add a new newsgroup.
2740 The user will be prompted for GROUP."
2741 (interactive (list (gnus-group-completing-read)))
2742 (gnus-group-make-group (gnus-group-real-name group
)
2743 (gnus-group-server group
)
2746 (defun gnus-group-make-group (name &optional method address args encoded
)
2747 "Add a new newsgroup.
2748 The user will be prompted for a NAME, for a select METHOD, and an
2749 ADDRESS. NAME should be a human-readable string (i.e., not be encoded
2750 even if it contains non-ASCII characters) unless ENCODED is non-nil.
2752 If the backend supports it, the group will also be created on the
2756 (gnus-read-group "Group name: ")
2757 (gnus-read-method "Select method for new group (use tab for completion)")))
2759 (when (stringp method
)
2760 (setq method
(or (gnus-server-to-method method
) method
)))
2762 (setq name
(mm-encode-coding-string
2764 (gnus-group-name-charset method name
))))
2765 (let* ((meth (gnus-method-simplify
2767 (not (gnus-server-equal method gnus-select-method
)))
2768 (if address
(list (intern method
) address
)
2770 (nname (if method
(gnus-group-prefixed-name name meth
) name
))
2772 (when (gnus-group-entry nname
)
2773 (error "Group %s already exists" (gnus-group-decoded-name nname
)))
2774 ;; Subscribe to the new group.
2775 (gnus-group-change-level
2776 (setq info
(list t nname gnus-level-default-subscribed nil nil meth
))
2777 gnus-level-default-subscribed gnus-level-killed
2778 (and (gnus-group-group-name)
2779 (gnus-group-entry (gnus-group-group-name)))
2782 (gnus-set-active nname
(cons 1 0))
2783 (unless (gnus-ephemeral-group-p name
)
2785 (concat "(gnus-group-set-info '"
2786 (gnus-prin1-to-string (cdr info
)) ")")
2787 (concat "^(gnus-group-set-info '(\"" (regexp-quote name
) "\"")))
2789 (gnus-group-insert-group-line-info nname
)
2791 (gnus-group-position-point)
2793 ;; Load the back end and try to make the back end create
2794 ;; the group as well.
2795 (when (assoc (symbol-name (setq backend
(car (gnus-server-get-method
2797 gnus-valid-select-methods
)
2799 (gnus-check-server meth
)
2800 (when (gnus-check-backend-function 'request-create-group nname
)
2801 (unless (gnus-request-create-group nname nil args
)
2802 (error "Could not create group on server: %s"
2803 (nnheader-get-report backend
))))
2806 (defun gnus-group-delete-groups (&optional arg
)
2807 "Delete the current group. Only meaningful with editable groups."
2809 (let ((n (length (gnus-group-process-prefix arg
))))
2810 (when (gnus-yes-or-no-p
2812 "Delete this 1 group? "
2813 (format "Delete these %d groups? " n
)))
2814 (gnus-group-iterate arg
2816 (gnus-group-delete-group group nil t
))))))
2818 (defun gnus-group-delete-articles (group &optional oldp
)
2819 "Delete all articles in the current group.
2820 If OLDP (the prefix), only delete articles that are \"old\",
2821 according to the expiry settings. Note that this will delete old
2822 not-expirable articles, too."
2823 (interactive (list (gnus-group-group-name)
2824 current-prefix-arg
))
2825 (let ((articles (gnus-uncompress-range (gnus-active group
))))
2826 (when (gnus-yes-or-no-p
2827 (format "Do you really want to delete these %d articles forever? "
2829 (gnus-request-expire-articles articles group
2830 (if current-prefix-arg
2834 (defun gnus-group-delete-group (group &optional force no-prompt
)
2835 "Delete the current group. Only meaningful with editable groups.
2836 If FORCE (the prefix) is non-nil, all the articles in the group will
2837 be deleted. This is \"deleted\" as in \"removed forever from the face
2838 of the Earth\". There is no undo. The user will be prompted before
2840 Note that you also have to specify FORCE if you want the group to
2841 be removed from the server, even when it's empty."
2843 (list (gnus-group-group-name)
2844 current-prefix-arg
))
2846 (error "No group to delete"))
2847 (unless (gnus-check-backend-function 'request-delete-group group
)
2848 (error "This back end does not support group deletion"))
2850 (let ((group-decoded (gnus-group-decoded-name group
)))
2851 (if (and (not no-prompt
)
2852 (not (gnus-yes-or-no-p
2854 "Do you really want to delete %s%s? "
2855 group-decoded
(if force
" and all its contents" "")))))
2857 (gnus-message 6 "Deleting group %s..." group-decoded
)
2858 (if (not (gnus-request-delete-group group force
))
2859 (gnus-error 3 "Couldn't delete group %s" group-decoded
)
2860 (gnus-message 6 "Deleting group %s...done" group-decoded
)
2861 (gnus-group-goto-group group
)
2862 (gnus-group-kill-group 1 t
)
2863 (gnus-set-active group nil
)
2865 (gnus-group-position-point)))
2867 (defun gnus-group-rename-group (group new-name
)
2868 "Rename group from GROUP to NEW-NAME.
2869 When used interactively, GROUP is the group under point
2870 and NEW-NAME will be prompted for."
2872 (let ((group (gnus-group-group-name))
2874 (unless (gnus-check-backend-function 'request-rename-group group
)
2875 (error "This back end does not support renaming groups"))
2876 (setq new-name
(gnus-read-group
2878 (gnus-group-real-name (gnus-group-decoded-name group
)))
2879 method
(gnus-info-method (gnus-get-info group
)))
2880 (list group
(mm-encode-coding-string
2882 (gnus-group-name-charset
2884 (gnus-group-prefixed-name new-name method
))))))
2886 (unless (gnus-check-backend-function 'request-rename-group group
)
2887 (error "This back end does not support renaming groups"))
2889 (error "No group to rename"))
2890 (when (equal (gnus-group-real-name group
) new-name
)
2891 (error "Can't rename to the same name"))
2893 ;; We find the proper prefixed name.
2895 (if (gnus-group-native-p group
)
2899 (gnus-group-prefixed-name
2900 (gnus-group-real-name new-name
)
2901 (gnus-info-method (gnus-get-info group
)))))
2903 (let ((decoded-group (gnus-group-decoded-name group
))
2904 (decoded-new-name (gnus-group-decoded-name new-name
)))
2905 (when (gnus-active new-name
)
2906 (error "The group %s already exists" decoded-new-name
))
2908 (gnus-message 6 "Renaming group %s to %s..."
2909 decoded-group decoded-new-name
)
2912 (gnus-group-goto-group group
)
2913 (not (when (< (gnus-group-group-level) gnus-level-zombie
)
2914 (gnus-request-rename-group group new-name
))))
2915 (gnus-error 3 "Couldn't rename group %s to %s"
2916 decoded-group decoded-new-name
)
2917 ;; We rename the group internally by killing it...
2918 (gnus-group-kill-group)
2919 ;; ... changing its name ...
2920 (setcar (cdar gnus-list-of-killed-groups
) new-name
)
2921 ;; ... and then yanking it. Magic!
2922 (gnus-group-yank-group)
2923 (gnus-set-active new-name
(gnus-active group
))
2924 (gnus-message 6 "Renaming group %s to %s...done"
2925 decoded-group decoded-new-name
)
2927 (setq gnus-killed-list
(delete group gnus-killed-list
))
2928 (gnus-set-active group nil
)
2929 (gnus-dribble-touch)
2930 (gnus-group-position-point))))
2932 (defun gnus-group-edit-group (group &optional part
)
2933 "Edit the group on the current line."
2934 (interactive (list (gnus-group-group-name)))
2935 (let ((part (or part
'info
))
2938 (error "No group on current line"))
2939 (unless (setq info
(gnus-get-info group
))
2940 (error "Killed group; can't be edited"))
2942 (gnus-close-group group
))
2944 ;; Find the proper form to edit.
2945 (cond ((eq part
'method
)
2946 (or (gnus-info-method info
) "native"))
2948 (gnus-info-params info
))
2950 ;; The proper documentation.
2952 "Editing the %s for `%s'."
2954 ((eq part
'method
) "select method")
2955 ((eq part
'params
) "group parameters")
2957 (gnus-group-decoded-name group
))
2959 (gnus-group-edit-group-done ',part
,group form
)))
2962 (gnus-create-info-command
2965 "(gnus)Select Methods")
2967 "(gnus)Group Parameters")
2969 "(gnus)Group Info"))))))
2971 (defun gnus-group-edit-group-method (group)
2972 "Edit the select method of GROUP."
2973 (interactive (list (gnus-group-group-name)))
2974 (gnus-group-edit-group group
'method
))
2976 (defun gnus-group-edit-group-parameters (group)
2977 "Edit the group parameters of GROUP."
2978 (interactive (list (gnus-group-group-name)))
2979 (gnus-group-edit-group group
'params
))
2981 (defun gnus-group-edit-group-done (part group form
)
2983 (let* ((method (cond ((eq part
'info
) (nth 4 form
))
2984 ((eq part
'method
) form
)
2986 (info (cond ((eq part
'info
) form
)
2987 ((eq part
'method
) (gnus-get-info group
))
2990 (if (or (not method
)
2992 gnus-select-method method
))
2993 (gnus-group-real-name (car info
))
2994 (gnus-group-prefixed-name
2995 (gnus-group-real-name (car info
)) method
))
2997 (when (and new-group
2998 (not (equal new-group group
)))
2999 (when (gnus-group-goto-group group
)
3000 (gnus-group-kill-group 1))
3001 (gnus-activate-group new-group
))
3003 (if (not (and info new-group
))
3004 (gnus-group-set-info form
(or new-group group
) part
)
3005 (setq info
(gnus-copy-sequence info
))
3006 (setcar info new-group
)
3007 (unless (gnus-server-equal method
"native")
3008 (unless (nthcdr 3 info
)
3009 (nconc info
(list nil nil
)))
3010 (unless (nthcdr 4 info
)
3011 (nconc info
(list nil
)))
3012 (gnus-info-set-method info method
))
3013 (gnus-group-set-info info
))
3014 (gnus-group-update-group (or new-group group
))
3015 (gnus-group-position-point)))
3017 (defun gnus-group-make-useful-group (group method
)
3018 "Create one of the groups described in `gnus-useful-groups'."
3020 (let ((entry (assoc (gnus-completing-read "Create group"
3021 (mapcar 'car gnus-useful-groups
)
3023 gnus-useful-groups
)))
3025 ;; Don't use `caddr' here since macros within the `interactive'
3026 ;; form won't be expanded.
3027 (car (cddr entry
)))))
3028 (setq method
(gnus-copy-sequence method
))
3030 (while (setq entry
(memq (assq 'eval method
) method
))
3031 (setcar entry
(eval (cadar entry
)))))
3032 (gnus-group-make-group group method
))
3034 (defun gnus-group-make-help-group (&optional noerror
)
3035 "Create the Gnus documentation group.
3036 Optional argument NOERROR modifies the behavior of this function when the
3037 group already exists:
3038 - if not given, and error is signaled,
3039 - if t, stay silent,
3040 - if anything else, just print a message."
3042 (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
3043 (file (nnheader-find-etc-directory "gnus-tut.txt" t
)))
3044 (if (gnus-group-entry name
)
3045 (cond ((eq noerror nil
)
3046 (error "Documentation group already exists"))
3051 (gnus-message 1 "Documentation group already exists")))
3054 (gnus-message 1 "Couldn't find doc group")
3055 (gnus-group-make-group
3056 (gnus-group-real-name name
)
3057 (list 'nndoc
"gnus-help"
3058 (list 'nndoc-address file
)
3059 (list 'nndoc-article-type
'mbox
))))
3061 (gnus-group-position-point))
3063 (defun gnus-group-make-doc-group (file type
)
3064 "Create a group that uses a single file as the source.
3066 If called with a prefix argument, ask for the file type."
3068 (list (read-file-name "File name: ")
3069 (and current-prefix-arg
'ask
)))
3070 (when (eq type
'ask
)
3075 "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [m, b, d, f, a, g]: "
3077 (setq found
(cond ((= (setq char
(read-char)) ?m
) 'mbox
)
3078 ((= char ?b
) 'babyl
)
3079 ((= char ?d
) 'digest
)
3080 ((= char ?f
) 'forward
)
3082 ((= char ?g
) 'guess
)
3083 (t (setq err
(format "%c unknown. " char
))
3086 (setq file
(expand-file-name file
))
3087 (let* ((name (gnus-generate-new-group-name
3088 (gnus-group-prefixed-name
3089 (file-name-nondirectory file
) '(nndoc ""))))
3090 (method (list 'nndoc file
3091 (list 'nndoc-address file
)
3092 (list 'nndoc-article-type
(or type
'guess
))))
3093 (coding (gnus-group-name-charset method name
)))
3094 (setcar (cdr method
) (mm-encode-coding-string file coding
))
3095 (gnus-group-make-group
3096 (mm-encode-coding-string (gnus-group-real-name name
) coding
)
3099 (defvar nnweb-type-definition
)
3100 (defvar gnus-group-web-type-history nil
)
3101 (defvar gnus-group-web-search-history nil
)
3102 (defun gnus-group-make-web-group (&optional solid
)
3103 "Create an ephemeral nnweb group.
3104 If SOLID (the prefix), create a solid group."
3108 (if solid
(gnus-read-group "Group name: ")
3109 (message-unique-id)))
3110 (default-type (or (car gnus-group-web-type-history
)
3111 (symbol-name (caar nnweb-type-definition
))))
3114 (gnus-completing-read
3115 "Search engine type"
3116 (mapcar (lambda (elem) (symbol-name (car elem
)))
3117 nnweb-type-definition
)
3118 t nil
'gnus-group-web-type-history
)
3123 (cons (or (car gnus-group-web-search-history
) "") 0)
3124 'gnus-group-web-search-history
))
3126 `(nnweb ,group
(nnweb-search ,search
)
3127 (nnweb-type ,(intern type
))
3128 (nnweb-ephemeral-p t
))))
3131 (gnus-alist-pull 'nnweb-ephemeral-p method
)
3132 (gnus-group-make-group group method
))
3133 (gnus-group-read-ephemeral-group
3135 (cons (current-buffer)
3136 (if (derived-mode-p 'gnus-summary-mode
) 'summary
'group
))))))
3138 (defvar nnrss-group-alist
)
3140 (defun nnrss-discover-feed (_arg))
3141 (defun nnrss-save-server-data (_arg)))
3142 (defun gnus-group-make-rss-group (&optional url
)
3143 "Given a URL, discover if there is an RSS feed.
3144 If there is, use Gnus to create an nnrss group"
3148 (setq url
(read-from-minibuffer "URL to Search for RSS: ")))
3149 (let ((feedinfo (nnrss-discover-feed url
)))
3151 (let* ((title (gnus-newsgroup-savable-name
3152 (read-from-minibuffer "Title: "
3153 (gnus-newsgroup-savable-name
3157 (or (cdr (assoc 'title
3161 (desc (read-from-minibuffer "Description: "
3165 (or (cdr (assoc 'description
3169 (href (cdr (assoc 'href feedinfo
)))
3170 (coding (gnus-group-name-charset '(nnrss "") title
)))
3172 ;; Unify non-ASCII text.
3173 (setq title
(mm-decode-coding-string
3174 (mm-encode-coding-string title coding
)
3176 (gnus-group-make-group title
'(nnrss ""))
3177 (push (list title href desc
) nnrss-group-alist
)
3178 (nnrss-save-server-data nil
))
3179 (error "No feeds found for %s" url
))))
3181 (defun gnus-group-make-directory-group (dir)
3182 "Create an nndir group.
3183 The user will be prompted for a directory. The contents of this
3184 directory will be used as a newsgroup. The directory should contain
3185 mail messages or news articles in files that have numeric names."
3187 (list (read-directory-name "Create group from directory: ")))
3188 (unless (file-exists-p dir
)
3189 (error "No such directory"))
3190 (unless (file-directory-p dir
)
3191 (error "Not a directory"))
3195 (while (or (not group
) (gnus-group-entry group
))
3197 (gnus-group-prefixed-name
3198 (expand-file-name ext dir
)
3200 (setq ext
(format "<%d>" (setq i
(1+ i
)))))
3201 (gnus-group-make-group
3202 (gnus-group-real-name group
)
3203 (list 'nndir
(gnus-group-real-name group
) (list 'nndir-directory dir
)))))
3205 (defun gnus-group-add-to-virtual (n vgroup
)
3206 "Add the current group to a virtual group."
3208 (list current-prefix-arg
3209 (gnus-group-completing-read "Add to virtual group"
3210 nil t
"nnvirtual:")))
3211 (unless (eq (car (gnus-find-method-for-group vgroup
)) 'nnvirtual
)
3212 (error "%s is not an nnvirtual group" vgroup
))
3213 (gnus-close-group vgroup
)
3214 (let* ((groups (gnus-group-process-prefix n
))
3215 (method (gnus-info-method (gnus-get-info vgroup
))))
3216 (setcar (cdr method
)
3218 (nth 1 method
) "\\|"
3221 (gnus-group-remove-mark s
)
3222 (concat "\\(^" (regexp-quote s
) "$\\)"))
3224 (gnus-group-position-point))
3226 (defun gnus-group-make-empty-virtual (group)
3227 "Create a new, fresh, empty virtual group."
3228 (interactive "sCreate new, empty virtual group: ")
3229 (let* ((method (list 'nnvirtual
"^$"))
3230 (pgroup (gnus-group-prefixed-name group method
)))
3231 ;; Check whether it exists already.
3232 (when (gnus-group-entry pgroup
)
3233 (error "Group %s already exists" pgroup
))
3234 ;; Subscribe the new group after the group on the current line.
3235 (gnus-subscribe-group pgroup
(gnus-group-group-name) method
)
3236 (gnus-group-update-group pgroup
)
3238 (gnus-group-position-point)))
3240 (defun gnus-group-enter-directory (dir)
3241 "Enter an ephemeral nneething group."
3242 (interactive "DDirectory to read: ")
3243 (let* ((method (list 'nneething dir
'(nneething-read-only t
)))
3244 (leaf (gnus-group-prefixed-name
3245 (file-name-nondirectory (directory-file-name dir
))
3247 (name (gnus-generate-new-group-name leaf
)))
3248 (unless (gnus-group-read-ephemeral-group
3250 (cons (current-buffer)
3251 (if (derived-mode-p 'gnus-summary-mode
)
3253 (error "Couldn't enter %s" dir
))))
3255 (defun gnus-group-expunge-group (group)
3256 "Expunge deleted articles in current nnimap GROUP."
3257 (interactive (list (gnus-group-group-name)))
3258 (let ((method (gnus-find-method-for-group group
)))
3259 (if (not (gnus-check-backend-function
3260 'request-expunge-group
(car method
)))
3261 (error "%s does not support expunging" (car method
))
3262 (gnus-request-expunge-group group method
))))
3264 (autoload 'nnimap-acl-get
"nnimap")
3265 (autoload 'nnimap-acl-edit
"nnimap")
3267 (defun gnus-group-nnimap-edit-acl (group)
3268 "Edit the Access Control List of current nnimap GROUP."
3269 (interactive (list (gnus-group-group-name)))
3270 (let ((mailbox (gnus-group-real-name group
)) method acl
)
3272 (error "No group on current line"))
3273 (unless (gnus-get-info group
)
3274 (error "Killed group; can't be edited"))
3275 (unless (eq (car (setq method
(gnus-find-method-for-group group
))) 'nnimap
)
3276 (error "%s is not an nnimap group" group
))
3277 (unless (setq acl
(nnimap-acl-get mailbox
(cadr method
)))
3278 (error "Server does not support ACL's"))
3279 (gnus-edit-form acl
(format "Editing the access control list for `%s'.
3281 An access control list is a list of (identifier . rights) elements.
3283 The identifier string specifies the corresponding user. The
3284 identifier \"anyone\" is reserved to refer to the universal identity.
3286 Rights is a string listing a (possibly empty) set of alphanumeric
3287 characters, each character listing a set of operations which is being
3288 controlled. Letters are reserved for \"standard\" rights, listed
3289 below. Digits are reserved for implementation or site defined rights.
3291 l - lookup (mailbox is visible to LIST/LSUB commands)
3292 r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL,
3293 SEARCH, COPY from mailbox)
3294 s - keep seen/unseen information across sessions (STORE \\SEEN flag)
3295 w - write (STORE flags other than \\SEEN and \\DELETED)
3296 i - insert (perform APPEND, COPY into mailbox)
3297 p - post (send mail to submission address for mailbox,
3298 not enforced by IMAP4 itself)
3299 c - create and delete mailbox (CREATE new sub-mailboxes in any
3300 implementation-defined hierarchy, RENAME or DELETE mailbox)
3301 d - delete messages (STORE \\DELETED flag, perform EXPUNGE)
3302 a - administer (perform SETACL)" group
)
3305 ,mailbox
',method
',acl form
)))))
3307 ;; Group sorting commands
3308 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3310 (defun gnus-group-sort-groups (func &optional reverse
)
3311 "Sort the group buffer according to FUNC.
3312 When used interactively, the sorting function used will be
3313 determined by the `gnus-group-sort-function' variable.
3314 If REVERSE (the prefix), reverse the sorting order."
3315 (interactive (list gnus-group-sort-function current-prefix-arg
))
3316 (funcall gnus-group-sort-alist-function
3317 (gnus-make-sort-function func
) reverse
)
3318 (gnus-group-unmark-all-groups)
3319 (gnus-group-list-groups)
3320 (gnus-dribble-touch))
3322 (defun gnus-group-sort-flat (func reverse
)
3323 ;; We peel off the dummy group from the alist.
3325 (when (equal (gnus-info-group (car gnus-newsrc-alist
)) "dummy.group")
3326 (pop gnus-newsrc-alist
))
3328 (setq gnus-newsrc-alist
3329 (sort gnus-newsrc-alist func
))
3331 (setq gnus-newsrc-alist
(nreverse gnus-newsrc-alist
)))
3332 ;; Regenerate the hash table.
3333 (gnus-make-hashtable-from-newsrc-alist)))
3335 (defun gnus-group-sort-groups-by-alphabet (&optional reverse
)
3336 "Sort the group buffer alphabetically by group name.
3337 If REVERSE, sort in reverse order."
3339 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse
))
3341 (defun gnus-group-sort-groups-by-real-name (&optional reverse
)
3342 "Sort the group buffer alphabetically by real (unprefixed) group name.
3343 If REVERSE, sort in reverse order."
3345 (gnus-group-sort-groups 'gnus-group-sort-by-real-name reverse
))
3347 (defun gnus-group-sort-groups-by-unread (&optional reverse
)
3348 "Sort the group buffer by number of unread articles.
3349 If REVERSE, sort in reverse order."
3351 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse
))
3353 (defun gnus-group-sort-groups-by-level (&optional reverse
)
3354 "Sort the group buffer by group level.
3355 If REVERSE, sort in reverse order."
3357 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse
))
3359 (defun gnus-group-sort-groups-by-score (&optional reverse
)
3360 "Sort the group buffer by group score.
3361 If REVERSE, sort in reverse order."
3363 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse
))
3365 (defun gnus-group-sort-groups-by-rank (&optional reverse
)
3366 "Sort the group buffer by group rank.
3367 If REVERSE, sort in reverse order."
3369 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse
))
3371 (defun gnus-group-sort-groups-by-method (&optional reverse
)
3372 "Sort the group buffer alphabetically by back end name.
3373 If REVERSE, sort in reverse order."
3375 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse
))
3377 (defun gnus-group-sort-groups-by-server (&optional reverse
)
3378 "Sort the group buffer alphabetically by server name.
3379 If REVERSE, sort in reverse order."
3381 (gnus-group-sort-groups 'gnus-group-sort-by-server reverse
))
3383 ;;; Selected group sorting.
3385 (defun gnus-group-sort-selected-groups (n func
&optional reverse
)
3386 "Sort the process/prefixed groups."
3387 (interactive (list current-prefix-arg gnus-group-sort-function
))
3388 (let ((groups (gnus-group-process-prefix n
)))
3389 (funcall gnus-group-sort-selected-function
3390 groups
(gnus-make-sort-function func
) reverse
)
3391 (gnus-group-unmark-all-groups)
3392 (gnus-group-list-groups)
3393 (gnus-dribble-touch)))
3395 (defun gnus-group-sort-selected-flat (groups func reverse
)
3396 (let (entries infos
)
3397 ;; First find all the group entries for these groups.
3399 (push (nthcdr 2 (gnus-group-entry (pop groups
)))
3401 ;; Then sort the infos.
3405 (lambda (entry) (car entry
))
3406 (setq entries
(nreverse entries
)))
3409 (setq infos
(nreverse infos
)))
3410 ;; Go through all the infos and replace the old entries
3411 ;; with the new infos.
3413 (setcar (car entries
) (pop infos
))
3415 ;; Update the hashtable.
3416 (gnus-make-hashtable-from-newsrc-alist)))
3418 (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse
)
3419 "Sort the group buffer alphabetically by group name.
3420 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3421 sort in reverse order."
3422 (interactive (gnus-interactive "P\ny"))
3423 (gnus-group-sort-selected-groups n
'gnus-group-sort-by-alphabet reverse
))
3425 (defun gnus-group-sort-selected-groups-by-real-name (&optional n reverse
)
3426 "Sort the group buffer alphabetically by real group name.
3427 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3428 sort in reverse order."
3429 (interactive (gnus-interactive "P\ny"))
3430 (gnus-group-sort-selected-groups n
'gnus-group-sort-by-real-name reverse
))
3432 (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse
)
3433 "Sort the group buffer by number of unread articles.
3434 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3435 sort in reverse order."
3436 (interactive (gnus-interactive "P\ny"))
3437 (gnus-group-sort-selected-groups n
'gnus-group-sort-by-unread reverse
))
3439 (defun gnus-group-sort-selected-groups-by-level (&optional n reverse
)
3440 "Sort the group buffer by group level.
3441 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3442 sort in reverse order."
3443 (interactive (gnus-interactive "P\ny"))
3444 (gnus-group-sort-selected-groups n
'gnus-group-sort-by-level reverse
))
3446 (defun gnus-group-sort-selected-groups-by-score (&optional n reverse
)
3447 "Sort the group buffer by group score.
3448 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3449 sort in reverse order."
3450 (interactive (gnus-interactive "P\ny"))
3451 (gnus-group-sort-selected-groups n
'gnus-group-sort-by-score reverse
))
3453 (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse
)
3454 "Sort the group buffer by group rank.
3455 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3456 sort in reverse order."
3457 (interactive (gnus-interactive "P\ny"))
3458 (gnus-group-sort-selected-groups n
'gnus-group-sort-by-rank reverse
))
3460 (defun gnus-group-sort-selected-groups-by-method (&optional n reverse
)
3461 "Sort the group buffer alphabetically by back end name.
3462 Obeys the process/prefix convention. If REVERSE (the symbolic prefix),
3463 sort in reverse order."
3464 (interactive (gnus-interactive "P\ny"))
3465 (gnus-group-sort-selected-groups n
'gnus-group-sort-by-method reverse
))
3467 ;;; Sorting predicates.
3469 (defun gnus-group-sort-by-alphabet (info1 info2
)
3470 "Sort alphabetically."
3471 (string< (gnus-info-group info1
) (gnus-info-group info2
)))
3473 (defun gnus-group-sort-by-real-name (info1 info2
)
3474 "Sort alphabetically on real (unprefixed) names."
3475 (string< (gnus-group-real-name (gnus-info-group info1
))
3476 (gnus-group-real-name (gnus-info-group info2
))))
3478 (defun gnus-group-sort-by-unread (info1 info2
)
3479 "Sort by number of unread articles."
3480 (let ((n1 (gnus-group-unread (gnus-info-group info1
)))
3481 (n2 (gnus-group-unread (gnus-info-group info2
))))
3482 (< (or (and (numberp n1
) n1
) 0)
3483 (or (and (numberp n2
) n2
) 0))))
3485 (defun gnus-group-sort-by-level (info1 info2
)
3487 (< (gnus-info-level info1
) (gnus-info-level info2
)))
3489 (defun gnus-group-sort-by-method (info1 info2
)
3490 "Sort alphabetically by back end name."
3491 (string< (car (gnus-find-method-for-group
3492 (gnus-info-group info1
) info1
))
3493 (car (gnus-find-method-for-group
3494 (gnus-info-group info2
) info2
))))
3496 (defun gnus-group-sort-by-server (info1 info2
)
3497 "Sort alphabetically by server name."
3498 (string< (gnus-method-to-full-server-name
3499 (gnus-find-method-for-group
3500 (gnus-info-group info1
) info1
))
3501 (gnus-method-to-full-server-name
3502 (gnus-find-method-for-group
3503 (gnus-info-group info2
) info2
))))
3505 (defun gnus-group-sort-by-score (info1 info2
)
3506 "Sort by group score."
3507 (> (gnus-info-score info1
) (gnus-info-score info2
)))
3509 (defun gnus-group-sort-by-rank (info1 info2
)
3510 "Sort by level and score."
3511 (let ((level1 (gnus-info-level info1
))
3512 (level2 (gnus-info-level info2
)))
3513 (or (< level1 level2
)
3514 (and (= level1 level2
)
3515 (> (gnus-info-score info1
) (gnus-info-score info2
))))))
3519 (defun gnus-group-clear-data (&optional arg
)
3520 "Clear all marks and read ranges from the current group.
3521 Obeys the process/prefix convention."
3523 (when (gnus-y-or-n-p "Really clear data? ")
3524 (gnus-group-iterate arg
3527 (gnus-info-clear-data (setq info
(gnus-get-info group
)))
3528 (gnus-get-unread-articles-in-group info
(gnus-active group
) t
)
3529 (when (gnus-group-goto-group group
)
3530 (gnus-group-update-group-line)))))))
3532 (defun gnus-group-clear-data-on-native-groups ()
3533 "Clear all marks and read ranges from all native groups."
3535 (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ")
3536 (let ((alist (cdr gnus-newsrc-alist
))
3538 (while (setq info
(pop alist
))
3539 (when (gnus-group-native-p (gnus-info-group info
))
3540 (gnus-info-clear-data info
)))
3541 (gnus-get-unread-articles)
3542 (gnus-dribble-touch)
3543 (when (gnus-y-or-n-p
3544 "Move the cache away to avoid problems in the future? ")
3545 (call-interactively 'gnus-cache-move-cache
)))))
3547 (defun gnus-info-clear-data (info)
3548 "Clear all marks and read ranges from INFO."
3549 (let ((group (gnus-info-group info
))
3551 (dolist (el (gnus-info-marks info
))
3552 (push `(,(cdr el
) add
(,(car el
))) action
))
3553 (push `(,(gnus-info-read info
) add
(read)) action
)
3556 (gnus-request-set-mark ,group
',action
)
3557 (gnus-info-set-marks ',info
',(gnus-info-marks info
) t
)
3558 (gnus-info-set-read ',info
',(gnus-info-read info
))
3559 (when (gnus-group-goto-group ,group
)
3560 (gnus-get-unread-articles-in-group ',info
',(gnus-active group
) t
)
3561 (gnus-group-update-group-line))))
3562 (setq action
(mapcar (lambda (el) (list (nth 0 el
) 'del
(nth 2 el
)))
3564 (gnus-request-set-mark group action
)
3565 (gnus-info-set-read info nil
)
3566 (when (gnus-info-marks info
)
3567 (gnus-info-set-marks info nil
))))
3569 ;; Group catching up.
3571 (defun gnus-group-catchup-current (&optional n all
)
3572 "Mark all unread articles in the current newsgroup as read.
3573 If prefix argument N is numeric, the next N newsgroups will be
3574 caught up. If ALL is non-nil, marked articles will also be marked as
3575 read. Cross references (Xref: header) of articles are ignored.
3576 The number of newsgroups that this function was unable to catch
3579 (let ((groups (gnus-group-process-prefix n
))
3582 (unless groups
(error "No groups selected"))
3584 (or (not gnus-interactive-catchup
) ;Without confirmation?
3589 "Do you really want to mark all articles in %s as read? "
3590 "Mark all unread articles in %s as read? ")
3591 (if (= (length groups
) 1)
3592 (gnus-group-decoded-name (car groups
))
3593 (format "these %d groups" (length groups
)))))))
3595 (while (setq group
(pop groups
))
3596 (gnus-group-remove-mark group
)
3597 ;; Virtual groups have to be given special treatment.
3598 (let ((method (gnus-find-method-for-group group
)))
3599 (when (eq 'nnvirtual
(car method
))
3600 (nnvirtual-catchup-group
3601 (gnus-group-real-name group
) (nth 1 method
) all
)))
3603 ((>= (gnus-group-level group
) gnus-level-zombie
)
3604 (gnus-message 2 "Dead groups can't be caught up"))
3606 (gnus-group-goto-group group
)
3607 (gnus-group-catchup group all
))
3608 (gnus-group-update-group-line))
3610 (setq ret
(1+ ret
)))))
3611 (gnus-group-next-unread-group 1)
3614 (defun gnus-group-catchup-current-all (&optional n
)
3615 "Mark all articles in current newsgroup as read.
3616 Cross references (Xref: header) of articles are ignored."
3618 (gnus-group-catchup-current n
'all
))
3620 (declare-function gnus-sequence-of-unread-articles
"gnus-sum" (group))
3622 (defun gnus-group-catchup (group &optional all
)
3623 "Mark all articles in GROUP as read.
3624 If ALL is non-nil, all articles are marked as read.
3625 The return value is the number of articles that were marked as read,
3626 or nil if no action could be taken."
3627 (let* ((entry (gnus-group-entry group
))
3629 (marks (gnus-info-marks (nth 2 entry
)))
3630 (unread (gnus-sequence-of-unread-articles group
)))
3631 ;; Remove entries for this group.
3632 (nnmail-purge-split-history (gnus-group-real-name group
))
3633 ;; Do the updating only if the newsgroup isn't killed.
3634 (if (not (numberp (car entry
)))
3635 (gnus-message 1 "Can't catch up %s; non-active group" group
)
3636 (gnus-update-read-articles group nil
)
3638 ;; Nix out the lists of marks and dormants.
3639 (gnus-request-set-mark group
(list (list (cdr (assq 'tick marks
))
3641 (list (cdr (assq 'dormant marks
))
3643 (setq unread
(gnus-range-add (gnus-range-add
3644 unread
(cdr (assq 'dormant marks
)))
3645 (cdr (assq 'tick marks
))))
3646 (gnus-add-marked-articles group
'tick nil nil
'force
)
3647 (gnus-add-marked-articles group
'dormant nil nil
'force
))
3648 ;; Do auto-expirable marks if that's required.
3649 (when (and (gnus-group-auto-expirable-p group
)
3650 (not (gnus-group-read-only-p group
)))
3653 (gnus-add-marked-articles group
'expire
(list article
))
3654 (gnus-request-set-mark group
(list (list (list article
)
3657 (let ((gnus-newsgroup-name group
))
3658 (gnus-run-hooks 'gnus-group-catchup-group-hook
))
3661 (defun gnus-group-expire-articles (&optional n
)
3662 "Expire all expirable articles in the current newsgroup.
3663 Uses the process/prefix convention."
3665 (let ((groups (gnus-group-process-prefix n
))
3668 (error "No groups to expire"))
3669 (while (setq group
(pop groups
))
3670 (gnus-group-remove-mark group
)
3671 (gnus-group-expire-articles-1 group
)
3672 (gnus-dribble-touch)
3673 (gnus-group-position-point))))
3675 (defun gnus-group-expire-articles-1 (group)
3676 (when (gnus-check-backend-function 'request-expire-articles group
)
3677 (gnus-message 6 "Expiring articles in %s..."
3678 (gnus-group-decoded-name group
))
3679 (let* ((info (gnus-get-info group
))
3680 (expirable (if (gnus-group-total-expirable-p group
)
3681 (cons nil
(gnus-list-of-read-articles group
))
3682 (assq 'expire
(gnus-info-marks info
))))
3684 (gnus-list-range-difference
3685 (gnus-uncompress-sequence (cdr expirable
))
3686 (cdr (assq 'unexist
(gnus-info-marks info
)))))
3687 (expiry-wait (gnus-group-find-parameter group
'expiry-wait
))
3688 (nnmail-expiry-target
3689 (or (gnus-group-find-parameter group
'expiry-target
)
3690 nnmail-expiry-target
)))
3692 (gnus-check-group group
)
3695 (gnus-compress-sequence
3697 ;; We set the expiry variables to the group
3699 (let ((nnmail-expiry-wait-function nil
)
3700 (nnmail-expiry-wait expiry-wait
))
3701 (gnus-request-expire-articles articles-to-expire group
))
3702 ;; Just expire using the normal expiry values.
3703 (gnus-request-expire-articles articles-to-expire group
))))
3704 (gnus-close-group group
))
3705 (gnus-message 6 "Expiring articles in %s...done"
3706 (gnus-group-decoded-name group
))
3707 ;; Return the list of un-expired articles.
3710 (defun gnus-group-expire-all-groups ()
3711 "Expire all expirable articles in all newsgroups."
3714 (gnus-message 5 "Expiring...")
3715 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info
))
3716 (cdr gnus-newsrc-alist
))))
3717 (gnus-group-expire-articles nil
)))
3718 (gnus-group-position-point)
3719 (gnus-message 5 "Expiring...done"))
3721 (defun gnus-group-set-current-level (n level
)
3722 "Set the level of the next N groups to LEVEL."
3727 (unless (gnus-group-process-prefix current-prefix-arg
)
3728 (error "No group on the current line"))
3730 (let ((s (read-string
3731 (format "Level (default %s): "
3732 (or (gnus-group-group-level)
3733 gnus-level-default-subscribed
)))))
3734 (if (string-match "^\\s-*$" s
)
3735 (int-to-string (or (gnus-group-group-level)
3736 gnus-level-default-subscribed
))
3738 (unless (and (>= level
1) (<= level gnus-level-killed
))
3739 (error "Invalid level: %d" level
))
3740 (dolist (group (gnus-group-process-prefix n
))
3741 (gnus-group-remove-mark group
)
3742 (gnus-message 6 "Changed level of %s from %d to %d"
3743 (gnus-group-decoded-name group
)
3744 (or (gnus-group-group-level) gnus-level-killed
)
3746 (gnus-group-change-level
3747 group level
(or (gnus-group-group-level) gnus-level-killed
))
3748 (gnus-group-update-group-line))
3749 (gnus-group-position-point))
3751 (defun gnus-group-unsubscribe (&optional n
)
3752 "Unsubscribe the current group."
3754 (gnus-group-unsubscribe-current-group n
'unsubscribe
))
3756 (defun gnus-group-subscribe (&optional n
)
3757 "Subscribe the current group."
3759 (gnus-group-unsubscribe-current-group n
'subscribe
))
3761 (defun gnus-group-unsubscribe-current-group (&optional n do-sub
)
3762 "Toggle subscription of the current group.
3763 If given numerical prefix, toggle the N next groups."
3765 (dolist (group (gnus-group-process-prefix n
))
3766 (gnus-group-remove-mark group
)
3767 (gnus-group-unsubscribe-group
3770 ((eq do-sub
'unsubscribe
)
3771 gnus-level-default-unsubscribed
)
3772 ((eq do-sub
'subscribe
)
3773 gnus-level-default-subscribed
)
3774 ((<= (gnus-group-group-level) gnus-level-subscribed
)
3775 gnus-level-default-unsubscribed
)
3777 gnus-level-default-subscribed
))
3779 (gnus-group-update-group-line))
3780 (gnus-group-next-group 1))
3782 (defun gnus-group-unsubscribe-group (group &optional level silent
)
3783 "Toggle subscription to GROUP.
3784 Killed newsgroups are subscribed. If SILENT, don't try to update the
3786 (interactive (list (gnus-group-completing-read
3787 nil nil
(gnus-read-active-file-p))))
3788 (let ((newsrc (gnus-group-entry group
)))
3790 ((string-match "\\`[ \t]*\\'" group
)
3791 (error "Empty group name"))
3793 ;; Toggle subscription flag.
3794 (gnus-group-change-level
3795 newsrc
(if level level
(if (<= (gnus-info-level (nth 2 newsrc
))
3796 gnus-level-subscribed
)
3797 (1+ gnus-level-subscribed
)
3798 gnus-level-default-subscribed
)))
3800 (gnus-group-update-group group
)))
3801 ((and (stringp group
)
3802 (or (not (gnus-read-active-file-p))
3803 (gnus-active group
)))
3804 ;; Add new newsgroup.
3805 (gnus-group-change-level
3807 (if level level gnus-level-default-subscribed
)
3808 (or (and (member group gnus-zombie-list
)
3811 (when (gnus-group-group-name)
3812 (gnus-group-entry (gnus-group-group-name))))
3814 (gnus-group-update-group group
)))
3815 (t (error "No such newsgroup: %s" group
)))
3816 (gnus-group-position-point)))
3818 (defun gnus-group-transpose-groups (n)
3819 "Move the current newsgroup up N places.
3820 If given a negative prefix, move down instead. The difference between
3821 N and the number of steps taken is returned."
3823 (unless (gnus-group-group-name)
3824 (error "No group on current line"))
3825 (gnus-group-kill-group 1)
3827 (forward-line (- n
))
3828 (gnus-group-yank-group)
3829 (gnus-group-position-point)))
3831 (defun gnus-group-kill-all-zombies (&optional dummy
)
3832 "Kill all zombie newsgroups.
3833 The optional DUMMY should always be nil."
3834 (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? "))))
3836 (setq gnus-killed-list
(nconc gnus-zombie-list gnus-killed-list
))
3837 (setq gnus-zombie-list nil
)
3838 (gnus-dribble-touch)
3839 (gnus-group-list-groups)))
3841 (defun gnus-group-kill-region (begin end
)
3842 "Kill newsgroups in current region (excluding current point).
3843 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3856 (beginning-of-line) ;Important when LINES < 1
3857 (gnus-group-kill-group lines
)))
3859 (defun gnus-group-kill-group (&optional n discard
)
3860 "Kill the next N groups.
3861 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3862 However, only groups that were alive can be yanked; already killed
3863 groups or zombie groups can't be yanked.
3864 The return value is the name of the group that was killed, or a list
3867 (let ((buffer-read-only nil
)
3868 (groups (gnus-group-process-prefix n
))
3869 group entry level out
)
3870 (if (< (length groups
) 10)
3871 ;; This is faster when there are few groups.
3873 (push (setq group
(pop groups
)) out
)
3874 (gnus-group-remove-mark group
)
3875 (setq level
(gnus-group-group-level))
3877 (when (and (not discard
)
3878 (setq entry
(gnus-group-entry group
)))
3881 (gnus-group-goto-group ,(gnus-group-group-name))
3882 (gnus-group-yank-group)))
3883 (push (cons (car entry
) (nth 2 entry
))
3884 gnus-list-of-killed-groups
))
3885 (gnus-group-change-level
3886 (if entry entry group
) gnus-level-killed
(if entry nil level
))
3887 (when (numberp (gnus-group-unread group
))
3888 (gnus-request-update-group-status group
'unsubscribe
))
3889 (message "Killed group %s" (gnus-group-decoded-name group
)))
3890 ;; If there are lots and lots of groups to be killed, we use
3891 ;; this thing instead.
3892 (dolist (group (nreverse groups
))
3893 (gnus-group-remove-mark group
)
3895 (push group gnus-killed-list
)
3896 (setq gnus-newsrc-alist
3897 (delq (assoc group gnus-newsrc-alist
)
3899 (when gnus-group-change-level-function
3900 (funcall gnus-group-change-level-function
3901 group gnus-level-killed
3))
3903 ((setq entry
(gnus-group-entry group
))
3904 (push (cons (car entry
) (nth 2 entry
))
3905 gnus-list-of-killed-groups
)
3906 (setcdr (cdr entry
) (cdddr entry
)))
3907 ((member group gnus-zombie-list
)
3908 (setq gnus-zombie-list
(delete group gnus-zombie-list
))))
3909 ;; There may be more than one instance displayed.
3910 (while (gnus-group-goto-group group
)
3912 (when (numberp (gnus-group-unread group
))
3913 (gnus-request-update-group-status group
'unsubscribe
)))
3914 (gnus-make-hashtable-from-newsrc-alist))
3916 (gnus-group-position-point)
3917 (if (< (length out
) 2) (car out
) (nreverse out
))))
3919 (defun gnus-group-yank-group (&optional arg
)
3920 "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup.
3921 The numeric ARG specifies how many newsgroups are to be yanked. The
3922 name of the newsgroup yanked is returned, or (if several groups are
3923 yanked) a list of yanked groups is returned."
3925 (setq arg
(or arg
1))
3926 (let (info group prev out
)
3927 (while (>= (decf arg
) 0)
3928 (when (not (setq info
(pop gnus-list-of-killed-groups
)))
3929 (error "No more newsgroups to yank"))
3930 (push (setq group
(nth 1 info
)) out
)
3931 ;; Find which newsgroup to insert this one before - search
3932 ;; backward until something suitable is found. If there are no
3933 ;; other newsgroups in this buffer, just make this newsgroup the
3935 (setq prev
(gnus-group-group-name))
3936 (gnus-group-change-level
3937 info
(gnus-info-level (cdr info
)) gnus-level-killed
3938 (and prev
(gnus-group-entry prev
))
3940 (gnus-group-insert-group-line-info group
)
3941 (gnus-request-update-group-status group
'subscribe
)
3943 `(when (gnus-group-goto-group ,group
)
3944 (gnus-group-kill-group 1))))
3946 (gnus-group-position-point)
3947 (if (< (length out
) 2) (car out
) (nreverse out
))))
3949 (defun gnus-group-kill-level (level)
3950 "Kill all groups that is on a certain LEVEL."
3951 (interactive "nKill all groups on level: ")
3953 ((= level gnus-level-zombie
)
3954 (setq gnus-killed-list
3955 (nconc gnus-zombie-list gnus-killed-list
))
3956 (setq gnus-zombie-list nil
))
3957 ((and (< level gnus-level-zombie
)
3959 (or gnus-expert-user
3962 "Do you really want to kill all groups on level %d? "
3964 (let* ((prev gnus-newsrc-alist
)
3967 (if (= (gnus-info-level (car alist
)) level
)
3969 (push (gnus-info-group (car alist
)) gnus-killed-list
)
3970 (setcdr prev
(cdr alist
)))
3972 (setq alist
(cdr alist
)))
3973 (gnus-make-hashtable-from-newsrc-alist)
3974 (gnus-group-list-groups)))
3976 (error "Can't kill; invalid level: %d" level
))))
3978 (defun gnus-group-list-all-groups (&optional arg
)
3979 "List all newsgroups with level ARG or lower.
3980 Default is `gnus-level-unsubscribed', which lists all subscribed and most
3981 unsubscribed groups."
3983 (gnus-group-list-groups (or arg gnus-level-unsubscribed
) t
))
3985 ;; Redefine this to list ALL killed groups if prefix arg used.
3986 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
3987 (defun gnus-group-list-killed (&optional arg
)
3988 "List all killed newsgroups in the group buffer.
3989 If ARG is non-nil, list ALL killed groups known to Gnus. This may
3990 entail asking the server for the groups."
3992 ;; Find all possible killed newsgroups if arg.
3994 (gnus-get-killed-groups))
3995 (if (not gnus-killed-list
)
3996 (gnus-message 6 "No killed groups")
3997 (let (gnus-group-list-mode)
3998 (funcall gnus-group-prepare-function
3999 gnus-level-killed t gnus-level-killed
))
4000 (goto-char (point-min)))
4001 (gnus-group-position-point))
4003 (defun gnus-group-list-zombies ()
4004 "List all zombie newsgroups in the group buffer."
4006 (if (not gnus-zombie-list
)
4007 (gnus-message 6 "No zombie groups")
4008 (let (gnus-group-list-mode)
4009 (funcall gnus-group-prepare-function
4010 gnus-level-zombie t gnus-level-zombie
))
4011 (goto-char (point-min)))
4012 (gnus-group-position-point))
4014 (defun gnus-group-list-active ()
4015 "List all groups that are available from the server(s)."
4017 ;; First we make sure that we have really read the active file.
4018 (unless (gnus-read-active-file-p)
4019 (let ((gnus-read-active-file t
)
4020 (gnus-agent gnus-plugged
)); If we're actually plugged, store the active file in the agent.
4021 (gnus-read-active-file)))
4022 ;; Find all groups and sort them.
4030 (push (symbol-name sym
) list
)))
4034 (buffer-read-only nil
)
4038 (setq group
(pop groups
))
4039 (gnus-add-text-properties
4040 (point) (prog1 (1+ (point))
4042 (gnus-group-decoded-name group
)
4044 (list 'gnus-group
(gnus-intern-safe group gnus-active-hashtb
)
4046 'gnus-level
(inline (gnus-group-level group
)))))
4047 (goto-char (point-min))))
4049 (defun gnus-activate-all-groups (level)
4050 "Activate absolutely all groups."
4051 (interactive (list gnus-level-unsubscribed
))
4052 (let ((gnus-activate-level level
)
4053 (gnus-activate-foreign-newsgroups level
))
4054 (gnus-group-get-new-news)))
4056 (defun gnus-group-get-new-news (&optional arg one-level
)
4057 "Get newly arrived articles.
4058 If ARG is a number, it specifies which levels you are interested in
4059 re-scanning. If ARG is non-nil and not a number, this will force
4060 \"hard\" re-reading of the active files from all servers.
4061 If ONE-LEVEL is not nil, then re-scan only the specified level,
4062 otherwise all levels below ARG will be scanned too."
4065 (let ((gnus-inhibit-demon t
)
4066 ;; Binding this variable will inhibit multiple fetchings
4067 ;; of the same mail source.
4068 (nnmail-fetched-sources (list t
)))
4069 (gnus-run-hooks 'gnus-get-top-new-news-hook
)
4070 (gnus-run-hooks 'gnus-get-new-news-hook
)
4072 ;; Read any slave files.
4074 (gnus-master-read-slave-newsrc))
4076 (gnus-get-unread-articles (gnus-group-default-level arg t
)
4079 ;; If the user wants it, we scan for new groups.
4080 (when (eq gnus-check-new-newsgroups
'always
)
4081 (gnus-find-new-newsgroups))
4083 (gnus-check-reasonable-setup)
4084 (gnus-run-hooks 'gnus-after-getting-new-news-hook
)
4085 (gnus-group-list-groups (and (numberp arg
)
4086 (max (car gnus-group-list-mode
) arg
)))))
4088 (defun gnus-group-get-new-news-this-group (&optional n dont-scan
)
4089 "Check for newly arrived news in the current group (and the N-1 next groups).
4090 The difference between N and the number of newsgroup checked is returned.
4091 If N is negative, this group and the N-1 previous groups will be checked.
4092 If DONT-SCAN is non-nil, scan non-activated groups as well."
4094 (let* ((groups (gnus-group-process-prefix n
))
4095 (ret (if (numberp n
) (- n
(length groups
)) 0))
4099 (gnus-inhibit-demon t
)
4100 ;; Binding this variable will inhibit multiple fetchings
4101 ;; of the same mail source.
4102 (nnmail-fetched-sources (list t
)))
4103 (gnus-run-hooks 'gnus-get-new-news-hook
)
4104 (while (setq group
(pop groups
))
4105 (gnus-group-remove-mark group
)
4106 ;; Bypass any previous denials from the server.
4107 (gnus-remove-denial (setq method
(gnus-find-method-for-group group
)))
4108 (if (or (and (not dont-scan
)
4109 (gnus-request-group-scan group
(gnus-get-info group
)))
4110 (gnus-activate-group group
(if dont-scan nil
'scan
) nil method
))
4111 (let ((info (gnus-get-info group
))
4112 (active (gnus-active group
)))
4114 (gnus-request-update-info info method
))
4115 (gnus-get-unread-articles-in-group info active
)
4116 (unless (gnus-virtual-group-p group
)
4117 (gnus-close-group group
))
4119 (gnus-agent-save-group-info
4120 method
(gnus-group-real-name group
) active
))
4121 (gnus-group-update-group group nil t
))
4122 (gnus-error 3 "%s error: %s" group
(gnus-status-message group
))))
4125 (when gnus-goto-next-group-when-activating
4126 (gnus-group-next-unread-group 1 t
))
4127 (gnus-group-position-point)
4130 (defun gnus-group-describe-group (force &optional group
)
4131 "Display a description of the current newsgroup."
4132 (interactive (list current-prefix-arg
(gnus-group-group-name)))
4133 (let* ((method (gnus-find-method-for-group group
))
4134 (mname (gnus-group-prefixed-name "" method
))
4137 gnus-description-hashtb
)
4138 (gnus-sethash mname nil gnus-description-hashtb
))
4140 (error "No group name given"))
4141 (when (or (and gnus-description-hashtb
4142 ;; We check whether this group's method has been
4143 ;; queried for a description file.
4144 (gnus-gethash mname gnus-description-hashtb
))
4145 (setq desc
(gnus-group-get-description group
))
4146 (gnus-read-descriptions-file method
))
4147 (gnus-message 1 "%s"
4148 (or desc
(gnus-gethash group gnus-description-hashtb
)
4149 "No description available")))))
4151 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4152 (defun gnus-group-describe-all-groups (&optional force
)
4153 "Pop up a buffer with descriptions of all newsgroups."
4156 (setq gnus-description-hashtb nil
))
4157 (when (not (or gnus-description-hashtb
4158 (gnus-read-all-descriptions-files)))
4159 (error "Couldn't request descriptions file"))
4160 (let ((buffer-read-only nil
)
4166 (let ((charset (gnus-group-name-charset nil
(symbol-name group
))))
4167 (insert (format " *: %-20s %s\n"
4168 (gnus-group-name-decode
4169 (symbol-name group
) charset
)
4170 (gnus-group-name-decode
4171 (symbol-value group
) charset
))))
4172 (gnus-add-text-properties
4173 b
(1+ b
) (list 'gnus-group group
4174 'gnus-unread t
'gnus-marked nil
4175 'gnus-level
(1+ gnus-level-subscribed
))))
4176 gnus-description-hashtb
)
4177 (goto-char (point-min))
4178 (gnus-group-position-point)))
4180 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
4181 (defun gnus-group-apropos (regexp &optional search-description
)
4182 "List all newsgroups that have names that match a regexp."
4183 (interactive "sGnus apropos (regexp): ")
4185 (obuf (current-buffer))
4187 ;; Go through all newsgroups that are known to Gnus.
4190 (and (symbol-name group
)
4191 (string-match regexp
(symbol-name group
))
4192 (symbol-value group
)
4193 (push (symbol-name group
) groups
)))
4195 ;; Also go through all descriptions that are known to Gnus.
4196 (when search-description
4199 (and (string-match regexp
(symbol-value group
))
4200 (push (symbol-name group
) groups
)))
4201 gnus-description-hashtb
))
4203 (gnus-message 3 "No groups matched \"%s\"." regexp
)
4204 ;; Print out all the groups.
4206 (pop-to-buffer "*Gnus Help*")
4207 (buffer-disable-undo)
4209 (setq groups
(sort groups
'string
<))
4211 ;; Groups may be entered twice into the list of groups.
4212 (when (not (string= (car groups
) prev
))
4213 (setq prev
(car groups
))
4214 (let ((charset (gnus-group-name-charset nil prev
)))
4215 (insert (gnus-group-name-decode prev charset
) "\n")
4216 (when (and gnus-description-hashtb
4217 (setq des
(gnus-gethash (car groups
)
4218 gnus-description-hashtb
)))
4219 (insert " " (gnus-group-name-decode des charset
) "\n"))))
4220 (setq groups
(cdr groups
)))
4221 (goto-char (point-min))))
4222 (pop-to-buffer obuf
)))
4224 (defun gnus-group-description-apropos (regexp)
4225 "List all newsgroups that have names or descriptions that match REGEXP."
4226 (interactive "sGnus description apropos (regexp): ")
4227 (when (not (or gnus-description-hashtb
4228 (gnus-read-all-descriptions-files)))
4229 (error "Couldn't request descriptions file"))
4230 (gnus-group-apropos regexp t
))
4232 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4233 (defun gnus-group-list-matching (level regexp
&optional all lowest
)
4234 "List all groups with unread articles that match REGEXP.
4235 If the prefix LEVEL is non-nil, it should be a number that says which
4236 level to cut off listing groups.
4237 If ALL, also list groups with no unread articles.
4238 If LOWEST, don't list groups with level lower than LOWEST.
4240 This command may read the active file."
4241 (interactive "P\nsList newsgroups matching: ")
4242 ;; First make sure active file has been read.
4244 (> (prefix-numeric-value level
) gnus-level-killed
))
4245 (gnus-get-killed-groups))
4246 (funcall gnus-group-prepare-function
4247 (or level gnus-level-subscribed
) (and all t
) (or lowest
1) regexp
)
4248 (goto-char (point-min))
4249 (gnus-group-position-point))
4251 (defun gnus-group-list-all-matching (level regexp
&optional lowest
)
4252 "List all groups that match REGEXP.
4253 If the prefix LEVEL is non-nil, it should be a number that says which
4254 level to cut off listing groups.
4255 If LOWEST, don't list groups with level lower than LOWEST."
4256 (interactive "P\nsList newsgroups matching: ")
4258 (setq level
(prefix-numeric-value level
)))
4259 (gnus-group-list-matching (or level gnus-level-killed
) regexp t lowest
))
4261 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4262 (defun gnus-group-save-newsrc (&optional force
)
4263 "Save the Gnus startup files.
4264 If FORCE, force saving whether it is necessary or not."
4266 (gnus-save-newsrc-file force
))
4268 (defun gnus-group-restart (&optional arg
)
4269 "Force Gnus to read the .newsrc file."
4271 (when (gnus-yes-or-no-p
4272 (format "Are you sure you want to restart Gnus? "))
4273 (gnus-save-newsrc-file)
4277 (defun gnus-group-read-init-file ()
4278 "Read the Gnus elisp init file."
4280 (gnus-read-init-file)
4281 (gnus-message 5 "Read %s" gnus-init-file
))
4283 (defun gnus-group-check-bogus-groups (&optional silent
)
4284 "Check bogus newsgroups.
4285 If given a prefix, don't ask for confirmation before removing a bogus
4288 (gnus-check-bogus-newsgroups (and (not silent
) (not gnus-expert-user
)))
4289 (gnus-group-list-groups))
4291 (defun gnus-group-find-new-groups (&optional arg
)
4292 "Search for new groups and add them.
4293 Each new group will be treated with `gnus-subscribe-newsgroup-method'.
4294 With 1 C-u, use the `ask-server' method to query the server for new
4296 With 2 C-u's, use most complete method possible to query the server
4297 for new groups, and subscribe the new groups as zombies."
4299 (let ((new-groups (gnus-find-new-newsgroups (or arg
1)))
4301 (gnus-group-list-groups)
4302 (setq current-group
(gnus-group-group-name))
4303 (dolist (group new-groups
)
4304 (gnus-group-jump-to-group group
))
4306 (gnus-group-jump-to-group current-group
))))
4308 (defun gnus-group-edit-global-kill (&optional article group
)
4309 "Edit the global kill file.
4310 If GROUP, edit that local kill file instead."
4312 (setq gnus-current-kill-article article
)
4313 (gnus-kill-file-edit-file group
)
4314 (gnus-message 6 "Editing a %s kill file (Type %s to exit)"
4315 (if group
"local" "global")
4316 (substitute-command-keys "\\[gnus-kill-file-exit]")))
4318 (defun gnus-group-edit-local-kill (article group
)
4319 "Edit a local kill file."
4320 (interactive (list nil
(gnus-group-group-name)))
4321 (gnus-group-edit-global-kill article group
))
4323 (defun gnus-group-force-update ()
4324 "Update `.newsrc' file."
4326 (gnus-save-newsrc-file))
4328 (defvar gnus-backlog-articles
)
4330 (defun gnus-group-suspend ()
4331 "Suspend the current Gnus session.
4332 In fact, cleanup buffers except for group mode buffer.
4333 The hook `gnus-suspend-gnus-hook' is called before actually suspending."
4335 (gnus-run-hooks 'gnus-suspend-gnus-hook
)
4336 (gnus-offer-save-summaries)
4337 ;; Kill Gnus buffers except for group mode buffer.
4338 (let ((group-buf (get-buffer gnus-group-buffer
)))
4339 (dolist (buf (gnus-buffers))
4340 (unless (or (eq buf group-buf
)
4341 (eq buf gnus-dribble-buffer
)
4342 (with-current-buffer buf
4343 (derived-mode-p 'message-mode
)))
4344 (gnus-kill-buffer buf
)))
4345 (setq gnus-backlog-articles nil
)
4346 (gnus-kill-gnus-frames)
4347 ;; Closing all the backends is useful (for instance) when when the
4348 ;; IP addresses have changed and you need to reconnect.
4349 (dolist (elem gnus-opened-servers
)
4350 (gnus-close-server (car elem
))
4351 (setcar (cdr elem
) 'closed
))
4353 (bury-buffer group-buf
)
4354 (delete-windows-on group-buf t
))))
4356 (defun gnus-group-clear-dribble ()
4357 "Clear all information from the dribble buffer."
4359 (gnus-dribble-clear)
4360 (gnus-message 7 "Cleared dribble buffer"))
4362 (defun gnus-group-exit ()
4363 "Quit reading news after updating .newsrc.eld and .newsrc.
4364 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4367 (or noninteractive
;For gnus-batch-kill
4368 (not gnus-interactive-exit
) ;Without confirmation
4370 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4371 (gnus-run-hooks 'gnus-exit-gnus-hook
)
4372 ;; Offer to save data from non-quitted summary buffers.
4373 (gnus-offer-save-summaries)
4374 ;; Save the newsrc file(s).
4375 (gnus-save-newsrc-file)
4377 (gnus-close-backends)
4378 ;; Reset everything.
4380 ;; Allow the user to do things after cleaning up.
4381 (gnus-run-hooks 'gnus-after-exiting-gnus-hook
)))
4383 (defun gnus-group-quit ()
4384 "Quit reading news without updating .newsrc.eld or .newsrc.
4385 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4387 (when (or noninteractive
;For gnus-batch-kill
4388 (zerop (buffer-size))
4389 (not (gnus-server-opened gnus-select-method
))
4391 (not gnus-current-startup-file
)
4393 (format "Quit reading news without saving %s? "
4394 (file-name-nondirectory gnus-current-startup-file
))))
4395 (gnus-run-hooks 'gnus-exit-gnus-hook
)
4396 (gnus-configure-windows 'group t
)
4397 (when (and (gnus-buffer-live-p gnus-dribble-buffer
)
4398 (not (zerop (with-current-buffer gnus-dribble-buffer
4401 ";;; Gnus was exited on purpose without saving the .newsrc files."))
4403 (gnus-close-backends)
4405 (gnus-kill-buffer gnus-group-buffer
)
4406 ;; Allow the user to do things after cleaning up.
4407 (gnus-run-hooks 'gnus-after-exiting-gnus-hook
)))
4409 (defun gnus-group-describe-briefly ()
4410 "Give a one line description of the group mode commands."
4412 (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")))
4414 (defun gnus-group-browse-foreign-server (method)
4415 "Browse a foreign news server.
4416 If called interactively, this function will ask for a select method
4417 (nntp, nnspool, etc.) and a server address (e.g., nntp.some.where).
4418 If not, METHOD should be a list where the first element is the method
4419 and the second element is the address."
4421 (list (let ((how (gnus-completing-read
4423 (mapcar 'car
(append gnus-valid-select-methods
4425 t
(cons "nntp" 0) 'gnus-method-history
)))
4426 ;; We either got a back end name or a virtual server name.
4427 ;; If the first, we also need an address.
4428 (if (assoc how gnus-valid-select-methods
)
4430 ;; Suggested by mapjph@bath.ac.uk.
4431 (gnus-completing-read
4433 ;; FIXME? gnus-secondary-servers is obsolete,
4434 ;; and it is not obvious that there is anything
4435 ;; sensible to use instead in this particular case.
4436 (if (boundp 'gnus-secondary-servers
)
4437 gnus-secondary-servers
4438 (cdr gnus-select-method
))))
4439 ;; We got a server name.
4441 (gnus-browse-foreign-server method
))
4443 (defun gnus-group-set-info (info &optional method-only-group part
)
4444 (when (or info part
)
4445 (let* ((entry (gnus-group-entry
4446 (or method-only-group
(gnus-info-group info
))))
4448 (info (if method-only-group
(nth 2 entry
) info
))
4450 (when method-only-group
4452 (error "Trying to change non-existent group %s" method-only-group
))
4453 ;; We have received parts of the actual group info - either the
4454 ;; select method or the group parameters. We first check
4455 ;; whether we have to extend the info, and if so, do that.
4456 (let ((len (length info
))
4457 (total (if (eq part
'method
) 5 6)))
4459 (setcdr (nthcdr (1- len
) info
)
4460 (make-list (- total len
) nil
)))
4461 ;; Then we enter the new info.
4462 (setcar (nthcdr (1- total
) info
) part-info
)))
4464 ;; This is a new group, so we just create it.
4465 (with-current-buffer gnus-group-buffer
4466 (setq method
(gnus-info-method info
))
4467 (when (gnus-server-equal method
"native")
4469 (with-current-buffer gnus-group-buffer
4471 ;; It's a foreign group...
4472 (gnus-group-make-group
4473 (gnus-group-real-name (gnus-info-group info
))
4474 (if (stringp method
) method
4475 (prin1-to-string (car method
)))
4477 (nth 1 (gnus-info-method info
)))
4479 ;; It's a native group.
4480 (gnus-group-make-group (gnus-info-group info
) nil nil nil t
)))
4481 (gnus-message 6 "Note: New group created")
4483 (gnus-group-entry (gnus-group-prefixed-name
4484 (gnus-group-real-name (gnus-info-group info
))
4485 (or (gnus-info-method info
) gnus-select-method
))))))
4486 ;; Whether it was a new group or not, we now have the entry, so we
4487 ;; can do the update.
4490 (setcar (nthcdr 2 entry
) info
)
4491 (when (and (not (eq (car entry
) t
))
4492 (gnus-active (gnus-info-group info
)))
4493 (setcar entry
(length
4494 (gnus-list-of-unread-articles (car info
))))))
4495 (error "No such group: %s" (gnus-info-group info
))))))
4497 ;; Ad-hoc function for inserting data from a different newsrc.eld
4498 ;; file. Use with caution, if at all.
4499 (defun gnus-import-other-newsrc-file (file)
4501 (insert-file-contents file
)
4503 (while (ignore-errors
4504 (setq form
(read (current-buffer))))
4505 (when (and (consp form
)
4506 (eq (cadr form
) 'gnus-newsrc-alist
))
4507 (let ((infos (cadr (nth 2 form
))))
4508 (dolist (info infos
)
4509 (when (gnus-get-info (car info
))
4510 (gnus-set-info (car info
) info
)))))))))
4512 (defun gnus-add-marked-articles (group type articles
&optional info force
)
4513 ;; Add ARTICLES of TYPE to the info of GROUP.
4514 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
4515 ;; add, but replace marked articles of TYPE with ARTICLES.
4516 (let ((info (or info
(gnus-get-info group
)))
4519 (and (not (setq marked
(nthcdr 3 info
)))
4521 (setcdr (nthcdr 2 info
)
4522 (list (list (cons type
(gnus-compress-sequence
4524 (and (not (setq m
(assq type
(car marked
))))
4527 (cons (cons type
(gnus-compress-sequence articles t
) )
4531 (setcar (nthcdr 3 info
)
4532 (gnus-delete-alist type
(car marked
)))
4533 (setcdr m
(gnus-compress-sequence articles t
)))
4534 (setcdr m
(gnus-compress-sequence
4535 (sort (nconc (gnus-uncompress-range (cdr m
))
4536 (copy-sequence articles
)) '<) t
))))))
4538 (declare-function gnus-summary-add-mark
"gnus-sum" (article type
))
4540 (defun gnus-add-mark (group mark article
)
4541 "Mark ARTICLE in GROUP with MARK, whether the group is displayed or not."
4542 (let ((buffer (gnus-summary-buffer-name group
)))
4543 (if (gnus-buffer-live-p buffer
)
4544 (with-current-buffer (get-buffer buffer
)
4545 (gnus-summary-add-mark article mark
))
4546 (gnus-add-marked-articles group
(cdr (assq mark gnus-article-mark-lists
))
4550 ;;; Group timestamps
4553 (defun gnus-group-set-timestamp ()
4554 "Change the timestamp of the current group to the current time.
4555 This function can be used in hooks like `gnus-select-group-hook'
4556 or `gnus-group-catchup-group-hook'."
4557 (when gnus-newsgroup-name
4558 (let ((time (current-time)))
4559 (setcdr (cdr time
) nil
)
4560 (gnus-group-set-parameter gnus-newsgroup-name
'timestamp time
))))
4562 (defsubst gnus-group-timestamp
(group)
4563 "Return the timestamp for GROUP."
4564 (gnus-group-get-parameter group
'timestamp t
))
4566 (defun gnus-group-timestamp-delta (group)
4567 "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
4568 (let* ((time (or (gnus-group-timestamp group
)
4570 (delta (subtract-time (current-time) time
)))
4571 (+ (* (nth 0 delta
) 65536.0)
4574 (defun gnus-group-timestamp-string (group)
4575 "Return a string of the timestamp for GROUP."
4576 (let ((time (gnus-group-timestamp group
)))
4579 (gnus-time-iso8601 time
))))
4581 (defun gnus-group-list-cached (level &optional lowest
)
4582 "List all groups with cached articles.
4583 If the prefix LEVEL is non-nil, it should be a number that says which
4584 level to cut off listing groups.
4585 If LOWEST, don't list groups with level lower than LOWEST.
4587 This command may read the active file."
4590 (setq level
(prefix-numeric-value level
)))
4591 (when (or (not level
) (>= level gnus-level-zombie
))
4593 (funcall gnus-group-prepare-function
4594 (or level gnus-level-subscribed
)
4596 (let ((marks (gnus-info-marks info
)))
4597 (assq 'cache marks
)))
4600 (or (gnus-gethash group
4601 gnus-cache-active-hashtb
)
4602 ;; Cache active file might use "."
4605 (mapconcat 'identity
4606 (split-string group
":")
4608 gnus-cache-active-hashtb
))))
4609 (goto-char (point-min))
4610 (gnus-group-position-point))
4612 (defun gnus-group-list-dormant (level &optional lowest
)
4613 "List all groups with dormant articles.
4614 If the prefix LEVEL is non-nil, it should be a number that says which
4615 level to cut off listing groups.
4616 If LOWEST, don't list groups with level lower than LOWEST.
4618 This command may read the active file."
4621 (setq level
(prefix-numeric-value level
)))
4622 (when (or (not level
) (>= level gnus-level-zombie
))
4624 (funcall gnus-group-prepare-function
4625 (or level gnus-level-subscribed
)
4627 (let ((marks (gnus-info-marks info
)))
4628 (assq 'dormant marks
)))
4631 (goto-char (point-min))
4632 (gnus-group-position-point))
4634 (defun gnus-group-list-ticked (level &optional lowest
)
4635 "List all groups with ticked articles.
4636 If the prefix LEVEL is non-nil, it should be a number that says which
4637 level to cut off listing groups.
4638 If LOWEST, don't list groups with level lower than LOWEST.
4640 This command may read the active file."
4643 (setq level
(prefix-numeric-value level
)))
4644 (when (or (not level
) (>= level gnus-level-zombie
))
4646 (funcall gnus-group-prepare-function
4647 (or level gnus-level-subscribed
)
4649 (let ((marks (gnus-info-marks info
)))
4650 (assq 'tick marks
)))
4653 (goto-char (point-min))
4654 (gnus-group-position-point))
4656 (defun gnus-group-listed-groups ()
4657 "Return a list of listed groups."
4659 (goto-char (point-min))
4660 (while (setq point
(text-property-not-all (point) (point-max)
4663 (push (symbol-name (get-text-property point
'gnus-group
)) groups
)
4667 (defun gnus-group-list-plus (&optional args
)
4668 "List groups plus the current selection."
4670 (let ((gnus-group-listed-groups (gnus-group-listed-groups))
4671 (gnus-group-list-mode gnus-group-list-mode
) ;; Save it.
4673 (push last-command-event unread-command-events
)
4674 (if (featurep 'xemacs
)
4675 (push (make-event 'key-press
'(key ?A
)) unread-command-events
)
4676 (push ?A unread-command-events
))
4677 (let (gnus-pick-mode keys
)
4678 (setq keys
(if (featurep 'xemacs
)
4679 (events-to-keys (read-key-sequence nil
))
4680 (read-key-sequence nil
)))
4681 (setq func
(lookup-key (current-local-map) keys
)))
4685 (call-interactively func
))))
4687 (defun gnus-group-list-flush (&optional args
)
4688 "Flush groups from the current selection."
4690 (let ((gnus-group-list-option 'flush
))
4691 (gnus-group-list-plus args
)))
4693 (defun gnus-group-list-limit (&optional args
)
4694 "List groups limited within the current selection.
4695 If you've limited the groups, you can further limit the selection
4696 with this command. If you've first limited to groups with
4697 dormant articles with `A ?', you can then further limit with
4698 `A / c', which will then limit to groups with cached articles, giving
4699 you the groups that have both dormant articles and cached articles."
4701 (let ((gnus-group-list-option 'limit
))
4702 (gnus-group-list-plus args
)))
4704 (declare-function gnus-mark-article-as-read
"gnus-sum" (article &optional mark
))
4705 (declare-function gnus-group-make-articles-read
"gnus-sum" (group articles
))
4707 (defun gnus-group-mark-article-read (group article
)
4708 "Mark ARTICLE read."
4709 (let ((buffer (gnus-summary-buffer-name group
))
4710 (mark gnus-read-mark
)
4712 (if (get-buffer buffer
)
4713 (with-current-buffer buffer
4714 (setq active gnus-newsgroup-active
)
4715 (gnus-activate-group group
)
4716 (when gnus-newsgroup-prepared
4717 (when (and gnus-newsgroup-auto-expire
4718 (memq mark gnus-auto-expirable-marks
))
4719 (setq mark gnus-expirable-mark
))
4720 (setq mark
(gnus-request-update-mark
4721 group article mark
))
4722 (gnus-request-set-mark
4723 group
(list (list (list article
) 'add
'(read))))
4724 (gnus-mark-article-as-read article mark
)
4725 (setq gnus-newsgroup-active
(gnus-active group
))
4727 (setq n
(1+ (cdr active
)))
4728 (while (<= n
(cdr gnus-newsgroup-active
))
4729 (unless (eq n article
)
4730 (push n gnus-newsgroup-unselected
))
4732 (setq gnus-newsgroup-unselected
4733 (sort gnus-newsgroup-unselected
'<)))))
4734 (gnus-activate-group group
)
4735 (gnus-group-make-articles-read group
(list article
))
4736 (when (and (gnus-group-auto-expirable-p group
)
4737 (not (gnus-group-read-only-p group
)))
4738 (gnus-add-marked-articles
4739 group
'expire
(list article
))))))
4743 ;;; Group compaction. -- dvl
4746 (defun gnus-group-compact-group (group)
4747 "Compact the current group.
4748 Compaction means removing gaps between article numbers. Hence, this
4749 operation is only meaningful for back ends using one file per article
4752 Note: currently only implemented in nnml."
4753 (interactive (list (gnus-group-group-name)))
4755 (error "No group to compact"))
4756 (unless (gnus-check-backend-function 'request-compact-group group
)
4757 (error "This back end does not support group compaction"))
4758 (let ((group-decoded (gnus-group-decoded-name group
)))
4760 Compacting group %s... (this may take a long time)"
4763 (if (not (gnus-request-compact-group group
))
4764 (gnus-error 3 "Couldn't compact group %s" group-decoded
)
4765 (gnus-message 6 "Compacting group %s...done" group-decoded
)
4767 ;; Invalidate the "original article" buffer which might be out of date.
4768 ;; #### NOTE: Yes, this might be a bit rude, but since compaction
4769 ;; #### will not happen very often, I think this is acceptable.
4770 (let ((original (get-buffer gnus-original-article-buffer
)))
4771 (and original
(gnus-kill-buffer original
)))
4772 ;; Update the group line to reflect new information (art number etc).
4773 (gnus-group-update-group-line))))
4775 (provide 'gnus-group
)
4777 ;;; gnus-group.el ends here