Commit | Line | Data |
---|---|---|
eec82323 | 1 | ;;; gnus-group.el --- group mode commands for Gnus |
16409b0b GM |
2 | ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 |
3 | ;; Free Software Foundation, Inc. | |
eec82323 | 4 | |
6748645f | 5 | ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
eec82323 LMI |
6 | ;; Keywords: news |
7 | ||
8 | ;; This file is part of GNU Emacs. | |
9 | ||
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 2, or (at your option) | |
13 | ;; any later version. | |
14 | ||
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. | |
19 | ||
20 | ;; You should have received a copy of the GNU General Public License | |
21 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 | ;; Boston, MA 02111-1307, USA. | |
24 | ||
25 | ;;; Commentary: | |
26 | ||
27 | ;;; Code: | |
28 | ||
5ab7173c RS |
29 | (eval-when-compile (require 'cl)) |
30 | ||
eec82323 LMI |
31 | (require 'gnus) |
32 | (require 'gnus-start) | |
33 | (require 'nnmail) | |
34 | (require 'gnus-spec) | |
35 | (require 'gnus-int) | |
36 | (require 'gnus-range) | |
37 | (require 'gnus-win) | |
38 | (require 'gnus-undo) | |
16409b0b | 39 | (require 'time-date) |
eec82323 LMI |
40 | |
41 | (defcustom gnus-group-archive-directory | |
6748645f | 42 | "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/" |
eec82323 LMI |
43 | "*The address of the (ding) archives." |
44 | :group 'gnus-group-foreign | |
45 | :type 'directory) | |
46 | ||
47 | (defcustom gnus-group-recent-archive-directory | |
6748645f | 48 | "*ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/" |
eec82323 LMI |
49 | "*The address of the most recent (ding) articles." |
50 | :group 'gnus-group-foreign | |
51 | :type 'directory) | |
52 | ||
16409b0b | 53 | (defcustom gnus-no-groups-message "No gnus is bad news" |
eec82323 LMI |
54 | "*Message displayed by Gnus when no groups are available." |
55 | :group 'gnus-start | |
56 | :type 'string) | |
57 | ||
58 | (defcustom gnus-keep-same-level nil | |
59 | "*Non-nil means that the next newsgroup after the current will be on the same level. | |
60 | When you type, for instance, `n' after reading the last article in the | |
61 | current newsgroup, you will go to the next newsgroup. If this variable | |
62 | is nil, the next newsgroup will be the next from the group | |
63 | buffer. | |
64 | If this variable is non-nil, Gnus will either put you in the | |
65 | next newsgroup with the same level, or, if no such newsgroup is | |
66 | available, the next newsgroup with the lowest possible level higher | |
67 | than the current level. | |
68 | If this variable is `best', Gnus will make the next newsgroup the one | |
69 | with the best level." | |
70 | :group 'gnus-group-levels | |
71 | :type '(choice (const nil) | |
72 | (const best) | |
73 | (sexp :tag "other" t))) | |
74 | ||
75 | (defcustom gnus-group-goto-unread t | |
76 | "*If non-nil, movement commands will go to the next unread and subscribed group." | |
77 | :link '(custom-manual "(gnus)Group Maneuvering") | |
78 | :group 'gnus-group-various | |
79 | :type 'boolean) | |
80 | ||
81 | (defcustom gnus-goto-next-group-when-activating t | |
82 | "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group." | |
83 | :link '(custom-manual "(gnus)Scanning New Messages") | |
84 | :group 'gnus-group-various | |
85 | :type 'boolean) | |
86 | ||
87 | (defcustom gnus-permanently-visible-groups nil | |
88 | "*Regexp to match groups that should always be listed in the group buffer. | |
a8151ef7 LMI |
89 | This means that they will still be listed even when there are no |
90 | unread articles in the groups. | |
91 | ||
92 | If nil, no groups are permanently visible." | |
eec82323 | 93 | :group 'gnus-group-listing |
eb284ea1 | 94 | :type '(choice regexp (const nil))) |
eec82323 LMI |
95 | |
96 | (defcustom gnus-list-groups-with-ticked-articles t | |
97 | "*If non-nil, list groups that have only ticked articles. | |
98 | If nil, only list groups that have unread articles." | |
99 | :group 'gnus-group-listing | |
100 | :type 'boolean) | |
101 | ||
102 | (defcustom gnus-group-default-list-level gnus-level-subscribed | |
103 | "*Default listing level. | |
104 | Ignored if `gnus-group-use-permanent-levels' is non-nil." | |
105 | :group 'gnus-group-listing | |
106 | :type 'integer) | |
107 | ||
108 | (defcustom gnus-group-list-inactive-groups t | |
109 | "*If non-nil, inactive groups will be listed." | |
110 | :group 'gnus-group-listing | |
111 | :group 'gnus-group-levels | |
112 | :type 'boolean) | |
113 | ||
114 | (defcustom gnus-group-sort-function 'gnus-group-sort-by-alphabet | |
115 | "*Function used for sorting the group buffer. | |
116 | This function will be called with group info entries as the arguments | |
117 | for the groups to be sorted. Pre-made functions include | |
118 | `gnus-group-sort-by-alphabet', `gnus-group-sort-by-real-name', | |
119 | `gnus-group-sort-by-unread', `gnus-group-sort-by-level', | |
120 | `gnus-group-sort-by-score', `gnus-group-sort-by-method', and | |
121 | `gnus-group-sort-by-rank'. | |
122 | ||
123 | This variable can also be a list of sorting functions. In that case, | |
124 | the most significant sort function should be the last function in the | |
125 | list." | |
126 | :group 'gnus-group-listing | |
127 | :link '(custom-manual "(gnus)Sorting Groups") | |
128 | :type '(radio (function-item gnus-group-sort-by-alphabet) | |
129 | (function-item gnus-group-sort-by-real-name) | |
130 | (function-item gnus-group-sort-by-unread) | |
131 | (function-item gnus-group-sort-by-level) | |
132 | (function-item gnus-group-sort-by-score) | |
133 | (function-item gnus-group-sort-by-method) | |
134 | (function-item gnus-group-sort-by-rank) | |
135 | (function :tag "other" nil))) | |
136 | ||
137 | (defcustom gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n" | |
138 | "*Format of group lines. | |
139 | It works along the same lines as a normal formatting string, | |
140 | with some simple extensions. | |
141 | ||
142 | %M Only marked articles (character, \"*\" or \" \") | |
143 | %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \") | |
144 | %L Level of subscribedness (integer) | |
145 | %N Number of unread articles (integer) | |
146 | %I Number of dormant articles (integer) | |
147 | %i Number of ticked and dormant (integer) | |
148 | %T Number of ticked articles (integer) | |
149 | %R Number of read articles (integer) | |
150 | %t Estimated total number of articles (integer) | |
151 | %y Number of unread, unticked articles (integer) | |
152 | %G Group name (string) | |
153 | %g Qualified group name (string) | |
154 | %D Group description (string) | |
155 | %s Select method (string) | |
156 | %o Moderated group (char, \"m\") | |
157 | %p Process mark (char) | |
158 | %O Moderated group (string, \"(m)\" or \"\") | |
159 | %P Topic indentation (string) | |
160 | %m Whether there is new(ish) mail in the group (char, \"%\") | |
161 | %l Whether there are GroupLens predictions for this group (string) | |
162 | %n Select from where (string) | |
163 | %z A string that look like `<%s:%n>' if a foreign select method is used | |
164 | %d The date the group was last entered. | |
16409b0b | 165 | %E Icon as defined by `gnus-group-icon-list'. |
eec82323 LMI |
166 | %u User defined specifier. The next character in the format string should |
167 | be a letter. Gnus will call the function gnus-user-format-function-X, | |
168 | where X is the letter following %u. The function will be passed the | |
169 | current header as argument. The function should return a string, which | |
170 | will be inserted into the buffer just like information from any other | |
171 | group specifier. | |
172 | ||
173 | Text between %( and %) will be highlighted with `gnus-mouse-face' when | |
174 | the mouse point move inside the area. There can only be one such area. | |
175 | ||
176 | Note that this format specification is not always respected. For | |
177 | reasons of efficiency, when listing killed groups, this specification | |
178 | is ignored altogether. If the spec is changed considerably, your | |
179 | output may end up looking strange when listing both alive and killed | |
180 | groups. | |
181 | ||
182 | If you use %o or %O, reading the active file will be slower and quite | |
183 | a bit of extra memory will be used. %D will also worsen performance. | |
184 | Also note that if you change the format specification to include any | |
185 | of these specs, you must probably re-start Gnus to see them go into | |
186 | effect." | |
187 | :group 'gnus-group-visual | |
188 | :type 'string) | |
189 | ||
190 | (defcustom gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}" | |
191 | "*The format specification for the group mode line. | |
192 | It works along the same lines as a normal formatting string, | |
193 | with some simple extensions: | |
194 | ||
195 | %S The native news server. | |
196 | %M The native select method. | |
197 | %: \":\" if %S isn't \"\"." | |
198 | :group 'gnus-group-visual | |
199 | :type 'string) | |
200 | ||
201 | (defcustom gnus-group-mode-hook nil | |
202 | "Hook for Gnus group mode." | |
203 | :group 'gnus-group-various | |
204 | :options '(gnus-topic-mode) | |
205 | :type 'hook) | |
206 | ||
207 | (defcustom gnus-group-menu-hook nil | |
208 | "Hook run after the creation of the group mode menu." | |
209 | :group 'gnus-group-various | |
210 | :type 'hook) | |
211 | ||
212 | (defcustom gnus-group-catchup-group-hook nil | |
213 | "Hook run when catching up a group from the group buffer." | |
214 | :group 'gnus-group-various | |
215 | :link '(custom-manual "(gnus)Group Data") | |
216 | :type 'hook) | |
217 | ||
218 | (defcustom gnus-group-update-group-hook nil | |
219 | "Hook called when updating group lines." | |
220 | :group 'gnus-group-visual | |
221 | :type 'hook) | |
222 | ||
223 | (defcustom gnus-group-prepare-function 'gnus-group-prepare-flat | |
224 | "*A function that is called to generate the group buffer. | |
225 | The function is called with three arguments: The first is a number; | |
226 | all group with a level less or equal to that number should be listed, | |
227 | if the second is non-nil, empty groups should also be displayed. If | |
228 | the third is non-nil, it is a number. No groups with a level lower | |
229 | than this number should be displayed. | |
230 | ||
231 | The only current function implemented is `gnus-group-prepare-flat'." | |
232 | :group 'gnus-group-listing | |
233 | :type 'function) | |
234 | ||
235 | (defcustom gnus-group-prepare-hook nil | |
236 | "Hook called after the group buffer has been generated. | |
237 | If you want to modify the group buffer, you can use this hook." | |
238 | :group 'gnus-group-listing | |
239 | :type 'hook) | |
240 | ||
241 | (defcustom gnus-suspend-gnus-hook nil | |
242 | "Hook called when suspending (not exiting) Gnus." | |
243 | :group 'gnus-exit | |
244 | :type 'hook) | |
245 | ||
246 | (defcustom gnus-exit-gnus-hook nil | |
247 | "Hook called when exiting Gnus." | |
248 | :group 'gnus-exit | |
249 | :type 'hook) | |
250 | ||
251 | (defcustom gnus-after-exiting-gnus-hook nil | |
252 | "Hook called after exiting Gnus." | |
253 | :group 'gnus-exit | |
254 | :type 'hook) | |
255 | ||
256 | (defcustom gnus-group-update-hook '(gnus-group-highlight-line) | |
257 | "Hook called when a group line is changed. | |
258 | The hook will not be called if `gnus-visual' is nil. | |
259 | ||
260 | The default function `gnus-group-highlight-line' will | |
261 | highlight the line according to the `gnus-group-highlight' | |
262 | variable." | |
263 | :group 'gnus-group-visual | |
264 | :type 'hook) | |
265 | ||
266 | (defcustom gnus-useful-groups | |
6748645f | 267 | '(("(ding) mailing list mirrored at sunsite.auc.dk" |
eec82323 LMI |
268 | "emacs.ding" |
269 | (nntp "sunsite.auc.dk" | |
6748645f LMI |
270 | (nntp-address "sunsite.auc.dk"))) |
271 | ("gnus-bug archive" | |
272 | "gnus-bug" | |
273 | (nndir "/ftp@ftp.ifi.uio.no:/pub/emacs/gnus/gnus-bug/")) | |
eec82323 LMI |
274 | ("Gnus help group" |
275 | "gnus-help" | |
276 | (nndoc "gnus-help" | |
277 | (nndoc-article-type mbox) | |
278 | (eval `(nndoc-address | |
279 | ,(let ((file (nnheader-find-etc-directory | |
280 | "gnus-tut.txt" t))) | |
281 | (unless file | |
282 | (error "Couldn't find doc group")) | |
283 | file)))))) | |
6748645f | 284 | "*Alist of useful group-server pairs." |
eec82323 LMI |
285 | :group 'gnus-group-listing |
286 | :type '(repeat (list (string :tag "Description") | |
287 | (string :tag "Name") | |
288 | (sexp :tag "Method")))) | |
289 | ||
290 | (defcustom gnus-group-highlight | |
291 | '(;; News. | |
292 | ((and (= unread 0) (not mailp) (eq level 1)) . | |
293 | gnus-group-news-1-empty-face) | |
294 | ((and (not mailp) (eq level 1)) . | |
295 | gnus-group-news-1-face) | |
296 | ((and (= unread 0) (not mailp) (eq level 2)) . | |
297 | gnus-group-news-2-empty-face) | |
298 | ((and (not mailp) (eq level 2)) . | |
299 | gnus-group-news-2-face) | |
300 | ((and (= unread 0) (not mailp) (eq level 3)) . | |
301 | gnus-group-news-3-empty-face) | |
302 | ((and (not mailp) (eq level 3)) . | |
303 | gnus-group-news-3-face) | |
16409b0b GM |
304 | ((and (= unread 0) (not mailp) (eq level 4)) . |
305 | gnus-group-news-4-empty-face) | |
306 | ((and (not mailp) (eq level 4)) . | |
307 | gnus-group-news-4-face) | |
308 | ((and (= unread 0) (not mailp) (eq level 5)) . | |
309 | gnus-group-news-5-empty-face) | |
310 | ((and (not mailp) (eq level 5)) . | |
311 | gnus-group-news-5-face) | |
312 | ((and (= unread 0) (not mailp) (eq level 6)) . | |
313 | gnus-group-news-6-empty-face) | |
314 | ((and (not mailp) (eq level 6)) . | |
315 | gnus-group-news-6-face) | |
eec82323 LMI |
316 | ((and (= unread 0) (not mailp)) . |
317 | gnus-group-news-low-empty-face) | |
318 | ((and (not mailp)) . | |
319 | gnus-group-news-low-face) | |
320 | ;; Mail. | |
321 | ((and (= unread 0) (eq level 1)) . | |
322 | gnus-group-mail-1-empty-face) | |
323 | ((eq level 1) . | |
324 | gnus-group-mail-1-face) | |
325 | ((and (= unread 0) (eq level 2)) . | |
326 | gnus-group-mail-2-empty-face) | |
327 | ((eq level 2) . | |
328 | gnus-group-mail-2-face) | |
329 | ((and (= unread 0) (eq level 3)) . | |
330 | gnus-group-mail-3-empty-face) | |
331 | ((eq level 3) . | |
332 | gnus-group-mail-3-face) | |
333 | ((= unread 0) . | |
334 | gnus-group-mail-low-empty-face) | |
335 | (t . | |
16409b0b | 336 | gnus-group-mail-low-face)) |
6748645f | 337 | "*Controls the highlighting of group buffer lines. |
eec82323 LMI |
338 | |
339 | Below is a list of `Form'/`Face' pairs. When deciding how a a | |
340 | particular group line should be displayed, each form is | |
341 | evaluated. The content of the face field after the first true form is | |
342 | used. You can change how those group lines are displayed by | |
343 | editing the face field. | |
344 | ||
345 | It is also possible to change and add form fields, but currently that | |
346 | requires an understanding of Lisp expressions. Hopefully this will | |
347 | change in a future release. For now, you can use the following | |
348 | variables in the Lisp expression: | |
349 | ||
350 | group: The name of the group. | |
351 | unread: The number of unread articles in the group. | |
352 | method: The select method used. | |
353 | mailp: Whether it's a mail group or not. | |
354 | level: The level of the group. | |
355 | score: The score of the group. | |
356 | ticked: The number of ticked articles." | |
357 | :group 'gnus-group-visual | |
358 | :type '(repeat (cons (sexp :tag "Form") face))) | |
359 | ||
360 | (defcustom gnus-new-mail-mark ?% | |
361 | "Mark used for groups with new mail." | |
362 | :group 'gnus-group-visual | |
363 | :type 'character) | |
364 | ||
16409b0b GM |
365 | (defgroup gnus-group-icons nil |
366 | "Add Icons to your group buffer. " | |
367 | :group 'gnus-group-visual) | |
368 | ||
369 | (defcustom gnus-group-icon-list | |
370 | nil | |
371 | "*Controls the insertion of icons into group buffer lines. | |
372 | ||
373 | Below is a list of `Form'/`File' pairs. When deciding how a | |
374 | particular group line should be displayed, each form is evaluated. | |
375 | The icon from the file field after the first true form is used. You | |
376 | can change how those group lines are displayed by editing the file | |
377 | field. The File will either be found in the | |
35ef97a5 | 378 | `gnus-group-glyph-directory' or by designating absolute name of the |
16409b0b GM |
379 | file. |
380 | ||
381 | It is also possible to change and add form fields, but currently that | |
382 | requires an understanding of Lisp expressions. Hopefully this will | |
383 | change in a future release. For now, you can use the following | |
384 | variables in the Lisp expression: | |
385 | ||
386 | group: The name of the group. | |
387 | unread: The number of unread articles in the group. | |
388 | method: The select method used. | |
389 | mailp: Whether it's a mail group or not. | |
390 | newsp: Whether it's a news group or not | |
391 | level: The level of the group. | |
392 | score: The score of the group. | |
393 | ticked: The number of ticked articles." | |
394 | :group 'gnus-group-icons | |
395 | :type '(repeat (cons (sexp :tag "Form") file))) | |
396 | ||
397 | (defcustom gnus-group-name-charset-method-alist nil | |
398 | "*Alist of method and the charset for group names. | |
399 | ||
400 | For example: | |
401 | (((nntp \"news.com.cn\") . cn-gb-2312)) | |
402 | " | |
5002cc5c | 403 | :version "21.1" |
16409b0b GM |
404 | :group 'gnus-charset |
405 | :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset")))) | |
406 | ||
407 | (defcustom gnus-group-name-charset-group-alist nil | |
408 | "*Alist of group regexp and the charset for group names. | |
409 | ||
410 | For example: | |
411 | ((\"\\.com\\.cn:\" . cn-gb-2312)) | |
412 | " | |
413 | :group 'gnus-charset | |
414 | :type '(repeat (cons (regexp :tag "Group") (symbol :tag "Charset")))) | |
415 | ||
eec82323 LMI |
416 | ;;; Internal variables |
417 | ||
418 | (defvar gnus-group-sort-alist-function 'gnus-group-sort-flat | |
419 | "Function for sorting the group buffer.") | |
420 | ||
421 | (defvar gnus-group-sort-selected-function 'gnus-group-sort-selected-flat | |
422 | "Function for sorting the selected groups in the group buffer.") | |
423 | ||
424 | (defvar gnus-group-indentation-function nil) | |
425 | (defvar gnus-goto-missing-group-function nil) | |
426 | (defvar gnus-group-update-group-function nil) | |
427 | (defvar gnus-group-goto-next-group-function nil | |
428 | "Function to override finding the next group after listing groups.") | |
429 | ||
430 | (defvar gnus-group-edit-buffer nil) | |
431 | ||
432 | (defvar gnus-group-line-format-alist | |
433 | `((?M gnus-tmp-marked-mark ?c) | |
434 | (?S gnus-tmp-subscribed ?c) | |
435 | (?L gnus-tmp-level ?d) | |
436 | (?N (cond ((eq number t) "*" ) | |
437 | ((numberp number) | |
438 | (int-to-string | |
439 | (+ number | |
440 | (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) | |
441 | (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))))) | |
442 | (t number)) ?s) | |
443 | (?R gnus-tmp-number-of-read ?s) | |
444 | (?t gnus-tmp-number-total ?d) | |
445 | (?y gnus-tmp-number-of-unread ?s) | |
446 | (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d) | |
447 | (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d) | |
448 | (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) | |
449 | (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d) | |
450 | (?g gnus-tmp-group ?s) | |
451 | (?G gnus-tmp-qualified-group ?s) | |
452 | (?c (gnus-short-group-name gnus-tmp-group) ?s) | |
453 | (?D gnus-tmp-newsgroup-description ?s) | |
454 | (?o gnus-tmp-moderated ?c) | |
455 | (?O gnus-tmp-moderated-string ?s) | |
456 | (?p gnus-tmp-process-marked ?c) | |
457 | (?s gnus-tmp-news-server ?s) | |
458 | (?n gnus-tmp-news-method ?s) | |
459 | (?P gnus-group-indentation ?s) | |
16409b0b | 460 | (?E gnus-tmp-group-icon ?s) |
eec82323 LMI |
461 | (?l gnus-tmp-grouplens ?s) |
462 | (?z gnus-tmp-news-method-string ?s) | |
463 | (?m (gnus-group-new-mail gnus-tmp-group) ?c) | |
464 | (?d (gnus-group-timestamp-string gnus-tmp-group) ?s) | |
465 | (?u gnus-tmp-user-defined ?s))) | |
466 | ||
467 | (defvar gnus-group-mode-line-format-alist | |
468 | `((?S gnus-tmp-news-server ?s) | |
469 | (?M gnus-tmp-news-method ?s) | |
470 | (?u gnus-tmp-user-defined ?s) | |
471 | (?: gnus-tmp-colon ?s))) | |
472 | ||
473 | (defvar gnus-topic-topology nil | |
474 | "The complete topic hierarchy.") | |
475 | ||
476 | (defvar gnus-topic-alist nil | |
477 | "The complete topic-group alist.") | |
478 | ||
479 | (defvar gnus-group-marked nil) | |
480 | ||
481 | (defvar gnus-group-list-mode nil) | |
482 | ||
16409b0b GM |
483 | |
484 | (defvar gnus-group-icon-cache nil) | |
485 | ||
eec82323 LMI |
486 | ;;; |
487 | ;;; Gnus group mode | |
488 | ;;; | |
489 | ||
490 | (put 'gnus-group-mode 'mode-class 'special) | |
491 | ||
492 | (when t | |
493 | (gnus-define-keys gnus-group-mode-map | |
494 | " " gnus-group-read-group | |
495 | "=" gnus-group-select-group | |
496 | "\r" gnus-group-select-group | |
497 | "\M-\r" gnus-group-quick-select-group | |
16409b0b | 498 | "\M- " gnus-group-visible-select-group |
eec82323 LMI |
499 | [(meta control return)] gnus-group-select-group-ephemerally |
500 | "j" gnus-group-jump-to-group | |
501 | "n" gnus-group-next-unread-group | |
502 | "p" gnus-group-prev-unread-group | |
503 | "\177" gnus-group-prev-unread-group | |
504 | [delete] gnus-group-prev-unread-group | |
6748645f | 505 | [backspace] gnus-group-prev-unread-group |
eec82323 LMI |
506 | "N" gnus-group-next-group |
507 | "P" gnus-group-prev-group | |
508 | "\M-n" gnus-group-next-unread-group-same-level | |
509 | "\M-p" gnus-group-prev-unread-group-same-level | |
510 | "," gnus-group-best-unread-group | |
511 | "." gnus-group-first-unread-group | |
512 | "u" gnus-group-unsubscribe-current-group | |
513 | "U" gnus-group-unsubscribe-group | |
514 | "c" gnus-group-catchup-current | |
515 | "C" gnus-group-catchup-current-all | |
516 | "\M-c" gnus-group-clear-data | |
517 | "l" gnus-group-list-groups | |
518 | "L" gnus-group-list-all-groups | |
519 | "m" gnus-group-mail | |
520 | "g" gnus-group-get-new-news | |
521 | "\M-g" gnus-group-get-new-news-this-group | |
522 | "R" gnus-group-restart | |
523 | "r" gnus-group-read-init-file | |
524 | "B" gnus-group-browse-foreign-server | |
525 | "b" gnus-group-check-bogus-groups | |
a8151ef7 | 526 | "F" gnus-group-find-new-groups |
eec82323 LMI |
527 | "\C-c\C-d" gnus-group-describe-group |
528 | "\M-d" gnus-group-describe-all-groups | |
529 | "\C-c\C-a" gnus-group-apropos | |
530 | "\C-c\M-\C-a" gnus-group-description-apropos | |
531 | "a" gnus-group-post-news | |
532 | "\ek" gnus-group-edit-local-kill | |
533 | "\eK" gnus-group-edit-global-kill | |
534 | "\C-k" gnus-group-kill-group | |
535 | "\C-y" gnus-group-yank-group | |
536 | "\C-w" gnus-group-kill-region | |
537 | "\C-x\C-t" gnus-group-transpose-groups | |
538 | "\C-c\C-l" gnus-group-list-killed | |
539 | "\C-c\C-x" gnus-group-expire-articles | |
540 | "\C-c\M-\C-x" gnus-group-expire-all-groups | |
541 | "V" gnus-version | |
542 | "s" gnus-group-save-newsrc | |
543 | "z" gnus-group-suspend | |
544 | "q" gnus-group-exit | |
545 | "Q" gnus-group-quit | |
546 | "?" gnus-group-describe-briefly | |
547 | "\C-c\C-i" gnus-info-find-node | |
548 | "\M-e" gnus-group-edit-group-method | |
549 | "^" gnus-group-enter-server-mode | |
550 | gnus-mouse-2 gnus-mouse-pick-group | |
551 | "<" beginning-of-buffer | |
552 | ">" end-of-buffer | |
553 | "\C-c\C-b" gnus-bug | |
554 | "\C-c\C-s" gnus-group-sort-groups | |
555 | "t" gnus-topic-mode | |
556 | "\C-c\M-g" gnus-activate-all-groups | |
557 | "\M-&" gnus-group-universal-argument | |
558 | "#" gnus-group-mark-group | |
559 | "\M-#" gnus-group-unmark-group) | |
560 | ||
561 | (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map) | |
562 | "m" gnus-group-mark-group | |
563 | "u" gnus-group-unmark-group | |
564 | "w" gnus-group-mark-region | |
a8151ef7 | 565 | "b" gnus-group-mark-buffer |
eec82323 LMI |
566 | "r" gnus-group-mark-regexp |
567 | "U" gnus-group-unmark-all-groups) | |
568 | ||
569 | (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map) | |
570 | "d" gnus-group-make-directory-group | |
571 | "h" gnus-group-make-help-group | |
572 | "u" gnus-group-make-useful-group | |
573 | "a" gnus-group-make-archive-group | |
574 | "k" gnus-group-make-kiboze-group | |
16409b0b | 575 | "l" gnus-group-nnimap-edit-acl |
eec82323 LMI |
576 | "m" gnus-group-make-group |
577 | "E" gnus-group-edit-group | |
578 | "e" gnus-group-edit-group-method | |
579 | "p" gnus-group-edit-group-parameters | |
580 | "v" gnus-group-add-to-virtual | |
581 | "V" gnus-group-make-empty-virtual | |
582 | "D" gnus-group-enter-directory | |
583 | "f" gnus-group-make-doc-group | |
584 | "w" gnus-group-make-web-group | |
585 | "r" gnus-group-rename-group | |
586 | "c" gnus-group-customize | |
16409b0b | 587 | "x" gnus-group-nnimap-expunge |
eec82323 LMI |
588 | "\177" gnus-group-delete-group |
589 | [delete] gnus-group-delete-group) | |
590 | ||
591 | (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map) | |
592 | "b" gnus-group-brew-soup | |
593 | "w" gnus-soup-save-areas | |
594 | "s" gnus-soup-send-replies | |
595 | "p" gnus-soup-pack-packet | |
596 | "r" nnsoup-pack-replies) | |
597 | ||
598 | (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map) | |
599 | "s" gnus-group-sort-groups | |
600 | "a" gnus-group-sort-groups-by-alphabet | |
601 | "u" gnus-group-sort-groups-by-unread | |
602 | "l" gnus-group-sort-groups-by-level | |
603 | "v" gnus-group-sort-groups-by-score | |
604 | "r" gnus-group-sort-groups-by-rank | |
605 | "m" gnus-group-sort-groups-by-method) | |
606 | ||
607 | (gnus-define-keys (gnus-group-sort-selected-map "P" gnus-group-group-map) | |
608 | "s" gnus-group-sort-selected-groups | |
609 | "a" gnus-group-sort-selected-groups-by-alphabet | |
610 | "u" gnus-group-sort-selected-groups-by-unread | |
611 | "l" gnus-group-sort-selected-groups-by-level | |
612 | "v" gnus-group-sort-selected-groups-by-score | |
613 | "r" gnus-group-sort-selected-groups-by-rank | |
614 | "m" gnus-group-sort-selected-groups-by-method) | |
615 | ||
616 | (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map) | |
617 | "k" gnus-group-list-killed | |
618 | "z" gnus-group-list-zombies | |
619 | "s" gnus-group-list-groups | |
620 | "u" gnus-group-list-all-groups | |
621 | "A" gnus-group-list-active | |
622 | "a" gnus-group-apropos | |
623 | "d" gnus-group-description-apropos | |
624 | "m" gnus-group-list-matching | |
625 | "M" gnus-group-list-all-matching | |
16409b0b GM |
626 | "l" gnus-group-list-level |
627 | "c" gnus-group-list-cached | |
628 | "?" gnus-group-list-dormant) | |
eec82323 LMI |
629 | |
630 | (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map) | |
631 | "f" gnus-score-flush-cache) | |
632 | ||
633 | (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map) | |
634 | "d" gnus-group-describe-group | |
635 | "f" gnus-group-fetch-faq | |
636 | "v" gnus-version) | |
637 | ||
638 | (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map) | |
639 | "l" gnus-group-set-current-level | |
640 | "t" gnus-group-unsubscribe-current-group | |
641 | "s" gnus-group-unsubscribe-group | |
642 | "k" gnus-group-kill-group | |
643 | "y" gnus-group-yank-group | |
644 | "w" gnus-group-kill-region | |
645 | "\C-k" gnus-group-kill-level | |
646 | "z" gnus-group-kill-all-zombies)) | |
647 | ||
648 | (defun gnus-group-make-menu-bar () | |
649 | (gnus-turn-off-edit-menu 'group) | |
650 | (unless (boundp 'gnus-group-reading-menu) | |
651 | ||
652 | (easy-menu-define | |
653 | gnus-group-reading-menu gnus-group-mode-map "" | |
654 | '("Group" | |
655 | ["Read" gnus-group-read-group (gnus-group-group-name)] | |
656 | ["Select" gnus-group-select-group (gnus-group-group-name)] | |
657 | ["See old articles" (gnus-group-select-group 'all) | |
658 | :keys "C-u SPC" :active (gnus-group-group-name)] | |
84b9b23e DL |
659 | ["Catch up" gnus-group-catchup-current :active (gnus-group-group-name) |
660 | :help "Mark unread articles in the current group as read"] | |
eec82323 LMI |
661 | ["Catch up all articles" gnus-group-catchup-current-all |
662 | (gnus-group-group-name)] | |
663 | ["Check for new articles" gnus-group-get-new-news-this-group | |
84b9b23e DL |
664 | :active (gnus-group-group-name) |
665 | :help "Check for new messages in current group"] | |
eec82323 LMI |
666 | ["Toggle subscription" gnus-group-unsubscribe-current-group |
667 | (gnus-group-group-name)] | |
84b9b23e DL |
668 | ["Kill" gnus-group-kill-group :active (gnus-group-group-name) |
669 | :help "Kill (remove) current group"] | |
eec82323 | 670 | ["Yank" gnus-group-yank-group gnus-list-of-killed-groups] |
84b9b23e DL |
671 | ["Describe" gnus-group-describe-group :active (gnus-group-group-name) |
672 | :help "Display description of the current group"] | |
eec82323 LMI |
673 | ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)] |
674 | ;; Actually one should check, if any of the marked groups gives t for | |
675 | ;; (gnus-check-backend-function 'request-expire-articles ...) | |
676 | ["Expire articles" gnus-group-expire-articles | |
677 | (or (and (gnus-group-group-name) | |
678 | (gnus-check-backend-function | |
679 | 'request-expire-articles | |
680 | (gnus-group-group-name))) gnus-group-marked)] | |
681 | ["Set group level" gnus-group-set-current-level | |
682 | (gnus-group-group-name)] | |
683 | ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)] | |
684 | ["Customize" gnus-group-customize (gnus-group-group-name)] | |
685 | ("Edit" | |
686 | ["Parameters" gnus-group-edit-group-parameters | |
687 | (gnus-group-group-name)] | |
688 | ["Select method" gnus-group-edit-group-method | |
689 | (gnus-group-group-name)] | |
690 | ["Info" gnus-group-edit-group (gnus-group-group-name)] | |
691 | ["Local kill file" gnus-group-edit-local-kill (gnus-group-group-name)] | |
a8151ef7 | 692 | ["Global kill file" gnus-group-edit-global-kill t]))) |
eec82323 LMI |
693 | |
694 | (easy-menu-define | |
695 | gnus-group-group-menu gnus-group-mode-map "" | |
696 | '("Groups" | |
697 | ("Listing" | |
698 | ["List unread subscribed groups" gnus-group-list-groups t] | |
699 | ["List (un)subscribed groups" gnus-group-list-all-groups t] | |
700 | ["List killed groups" gnus-group-list-killed gnus-killed-list] | |
701 | ["List zombie groups" gnus-group-list-zombies gnus-zombie-list] | |
702 | ["List level..." gnus-group-list-level t] | |
703 | ["Describe all groups" gnus-group-describe-all-groups t] | |
704 | ["Group apropos..." gnus-group-apropos t] | |
705 | ["Group and description apropos..." gnus-group-description-apropos t] | |
706 | ["List groups matching..." gnus-group-list-matching t] | |
707 | ["List all groups matching..." gnus-group-list-all-matching t] | |
16409b0b GM |
708 | ["List active file" gnus-group-list-active t] |
709 | ["List groups with cached" gnus-group-list-cached t] | |
710 | ["List groups with dormant" gnus-group-list-dormant t]) | |
eec82323 LMI |
711 | ("Sort" |
712 | ["Default sort" gnus-group-sort-groups t] | |
713 | ["Sort by method" gnus-group-sort-groups-by-method t] | |
714 | ["Sort by rank" gnus-group-sort-groups-by-rank t] | |
715 | ["Sort by score" gnus-group-sort-groups-by-score t] | |
716 | ["Sort by level" gnus-group-sort-groups-by-level t] | |
717 | ["Sort by unread" gnus-group-sort-groups-by-unread t] | |
718 | ["Sort by name" gnus-group-sort-groups-by-alphabet t]) | |
719 | ("Sort process/prefixed" | |
720 | ["Default sort" gnus-group-sort-selected-groups | |
721 | (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))] | |
722 | ["Sort by method" gnus-group-sort-selected-groups-by-method | |
723 | (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))] | |
724 | ["Sort by rank" gnus-group-sort-selected-groups-by-rank | |
725 | (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))] | |
726 | ["Sort by score" gnus-group-sort-selected-groups-by-score | |
727 | (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))] | |
728 | ["Sort by level" gnus-group-sort-selected-groups-by-level | |
729 | (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))] | |
730 | ["Sort by unread" gnus-group-sort-selected-groups-by-unread | |
731 | (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))] | |
732 | ["Sort by name" gnus-group-sort-selected-groups-by-alphabet | |
733 | (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]) | |
734 | ("Mark" | |
735 | ["Mark group" gnus-group-mark-group | |
736 | (and (gnus-group-group-name) | |
737 | (not (memq (gnus-group-group-name) gnus-group-marked)))] | |
738 | ["Unmark group" gnus-group-unmark-group | |
739 | (and (gnus-group-group-name) | |
740 | (memq (gnus-group-group-name) gnus-group-marked))] | |
741 | ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked] | |
742 | ["Mark regexp..." gnus-group-mark-regexp t] | |
743 | ["Mark region" gnus-group-mark-region t] | |
744 | ["Mark buffer" gnus-group-mark-buffer t] | |
745 | ["Execute command" gnus-group-universal-argument | |
746 | (or gnus-group-marked (gnus-group-group-name))]) | |
747 | ("Subscribe" | |
748 | ["Subscribe to a group" gnus-group-unsubscribe-group t] | |
749 | ["Kill all newsgroups in region" gnus-group-kill-region t] | |
750 | ["Kill all zombie groups" gnus-group-kill-all-zombies | |
751 | gnus-zombie-list] | |
752 | ["Kill all groups on level..." gnus-group-kill-level t]) | |
753 | ("Foreign groups" | |
754 | ["Make a foreign group" gnus-group-make-group t] | |
755 | ["Add a directory group" gnus-group-make-directory-group t] | |
756 | ["Add the help group" gnus-group-make-help-group t] | |
757 | ["Add the archive group" gnus-group-make-archive-group t] | |
758 | ["Make a doc group" gnus-group-make-doc-group t] | |
759 | ["Make a web group" gnus-group-make-web-group t] | |
760 | ["Make a kiboze group" gnus-group-make-kiboze-group t] | |
761 | ["Make a virtual group" gnus-group-make-empty-virtual t] | |
762 | ["Add a group to a virtual" gnus-group-add-to-virtual t] | |
763 | ["Rename group" gnus-group-rename-group | |
764 | (gnus-check-backend-function | |
765 | 'request-rename-group (gnus-group-group-name))] | |
766 | ["Delete group" gnus-group-delete-group | |
767 | (gnus-check-backend-function | |
768 | 'request-delete-group (gnus-group-group-name))]) | |
769 | ("Move" | |
770 | ["Next" gnus-group-next-group t] | |
771 | ["Previous" gnus-group-prev-group t] | |
772 | ["Next unread" gnus-group-next-unread-group t] | |
773 | ["Previous unread" gnus-group-prev-unread-group t] | |
774 | ["Next unread same level" gnus-group-next-unread-group-same-level t] | |
775 | ["Previous unread same level" | |
776 | gnus-group-prev-unread-group-same-level t] | |
777 | ["Jump to group" gnus-group-jump-to-group t] | |
778 | ["First unread group" gnus-group-first-unread-group t] | |
779 | ["Best unread group" gnus-group-best-unread-group t]) | |
780 | ["Delete bogus groups" gnus-group-check-bogus-groups t] | |
a8151ef7 | 781 | ["Find new newsgroups" gnus-group-find-new-groups t] |
eec82323 LMI |
782 | ["Transpose" gnus-group-transpose-groups |
783 | (gnus-group-group-name)] | |
a8151ef7 | 784 | ["Read a directory as a group..." gnus-group-enter-directory t])) |
eec82323 LMI |
785 | |
786 | (easy-menu-define | |
787 | gnus-group-misc-menu gnus-group-mode-map "" | |
788 | '("Misc" | |
789 | ("SOUP" | |
790 | ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)] | |
791 | ["Send replies" gnus-soup-send-replies | |
792 | (fboundp 'gnus-soup-pack-packet)] | |
793 | ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)] | |
794 | ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)] | |
6748645f | 795 | ["Brew SOUP" gnus-group-brew-soup (fboundp 'gnus-soup-pack-packet)]) |
eec82323 LMI |
796 | ["Send a mail" gnus-group-mail t] |
797 | ["Post an article..." gnus-group-post-news t] | |
84b9b23e DL |
798 | ["Check for new news" gnus-group-get-new-news |
799 | :help "Get newly arrived articles"] | |
eec82323 LMI |
800 | ["Activate all groups" gnus-activate-all-groups t] |
801 | ["Restart Gnus" gnus-group-restart t] | |
802 | ["Read init file" gnus-group-read-init-file t] | |
803 | ["Browse foreign server" gnus-group-browse-foreign-server t] | |
804 | ["Enter server buffer" gnus-group-enter-server-mode t] | |
805 | ["Expire all expirable articles" gnus-group-expire-all-groups t] | |
806 | ["Generate any kiboze groups" nnkiboze-generate-groups t] | |
807 | ["Gnus version" gnus-version t] | |
808 | ["Save .newsrc files" gnus-group-save-newsrc t] | |
809 | ["Suspend Gnus" gnus-group-suspend t] | |
810 | ["Clear dribble buffer" gnus-group-clear-dribble t] | |
811 | ["Read manual" gnus-info-find-node t] | |
812 | ["Flush score cache" gnus-score-flush-cache t] | |
813 | ["Toggle topics" gnus-topic-mode t] | |
6748645f | 814 | ["Send a bug report" gnus-bug t] |
84b9b23e DL |
815 | ["Exit from Gnus" gnus-group-exit |
816 | :help "Quit reading news"] | |
a8151ef7 | 817 | ["Exit without saving" gnus-group-quit t])) |
eec82323 | 818 | |
6748645f | 819 | (gnus-run-hooks 'gnus-group-menu-hook))) |
eec82323 | 820 | |
619a6b30 DL |
821 | (defvar gnus-group-toolbar-map nil) |
822 | ||
9a0026a6 | 823 | ;; Emacs 21 tool bar. Should be no-op otherwise. |
84b9b23e | 824 | (defun gnus-group-make-tool-bar () |
a1506d29 | 825 | (if (and |
b1f236d8 SZ |
826 | (condition-case nil (require 'tool-bar) (error nil)) |
827 | (fboundp 'tool-bar-add-item-from-menu) | |
828 | (default-value 'tool-bar-mode) | |
829 | (not gnus-group-toolbar-map)) | |
619a6b30 DL |
830 | (setq gnus-group-toolbar-map |
831 | (let ((tool-bar-map (make-sparse-keymap))) | |
832 | (tool-bar-add-item-from-menu | |
833 | 'gnus-group-get-new-news "get-news" gnus-group-mode-map) | |
834 | (tool-bar-add-item-from-menu | |
835 | 'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map) | |
836 | (tool-bar-add-item-from-menu | |
837 | 'gnus-group-catchup-current "catchup" gnus-group-mode-map) | |
838 | (tool-bar-add-item-from-menu | |
839 | 'gnus-group-describe-group "describe-group" gnus-group-mode-map) | |
840 | (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe | |
841 | :help "Subscribe to the current group") | |
842 | (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe | |
843 | 'unsubscribe | |
844 | :help "Unsubscribe from the current group") | |
845 | (tool-bar-add-item-from-menu | |
846 | 'gnus-group-exit "exit-gnus" gnus-group-mode-map) | |
678986c9 GM |
847 | tool-bar-map))) |
848 | (if gnus-group-toolbar-map | |
849 | (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map))) | |
84b9b23e | 850 | |
eec82323 LMI |
851 | (defun gnus-group-mode () |
852 | "Major mode for reading news. | |
853 | ||
854 | All normal editing commands are switched off. | |
855 | \\<gnus-group-mode-map> | |
856 | The group buffer lists (some of) the groups available. For instance, | |
857 | `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]' | |
858 | lists all zombie groups. | |
859 | ||
860 | Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe | |
861 | to a group not displayed, type `\\[gnus-group-unsubscribe-group]'. | |
862 | ||
863 | For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]'). | |
864 | ||
865 | The following commands are available: | |
866 | ||
867 | \\{gnus-group-mode-map}" | |
868 | (interactive) | |
619a6b30 | 869 | (kill-all-local-variables) |
eec82323 | 870 | (when (gnus-visual-p 'group-menu 'menu) |
84b9b23e DL |
871 | (gnus-group-make-menu-bar) |
872 | (gnus-group-make-tool-bar)) | |
eec82323 LMI |
873 | (gnus-simplify-mode-line) |
874 | (setq major-mode 'gnus-group-mode) | |
875 | (setq mode-name "Group") | |
876 | (gnus-group-set-mode-line) | |
877 | (setq mode-line-process nil) | |
878 | (use-local-map gnus-group-mode-map) | |
16409b0b | 879 | (buffer-disable-undo) |
eec82323 LMI |
880 | (setq truncate-lines t) |
881 | (setq buffer-read-only t) | |
882 | (gnus-set-default-directory) | |
883 | (gnus-update-format-specifications nil 'group 'group-mode) | |
884 | (gnus-update-group-mark-positions) | |
eec82323 LMI |
885 | (when gnus-use-undo |
886 | (gnus-undo-mode 1)) | |
6748645f LMI |
887 | (when gnus-slave |
888 | (gnus-slave-mode)) | |
889 | (gnus-run-hooks 'gnus-group-mode-hook)) | |
eec82323 LMI |
890 | |
891 | (defun gnus-update-group-mark-positions () | |
892 | (save-excursion | |
6748645f | 893 | (let ((gnus-process-mark ?\200) |
eec82323 | 894 | (gnus-group-marked '("dummy.group")) |
6748645f LMI |
895 | (gnus-active-hashtb (make-vector 10 0)) |
896 | (topic "")) | |
eec82323 LMI |
897 | (gnus-set-active "dummy.group" '(0 . 0)) |
898 | (gnus-set-work-buffer) | |
899 | (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil) | |
900 | (goto-char (point-min)) | |
901 | (setq gnus-group-mark-positions | |
902 | (list (cons 'process (and (search-forward "\200" nil t) | |
903 | (- (point) 2)))))))) | |
904 | ||
eec82323 LMI |
905 | (defun gnus-mouse-pick-group (e) |
906 | "Enter the group under the mouse pointer." | |
907 | (interactive "e") | |
908 | (mouse-set-point e) | |
909 | (gnus-group-read-group nil)) | |
910 | ||
911 | ;; Look at LEVEL and find out what the level is really supposed to be. | |
912 | ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens | |
913 | ;; will depend on whether `gnus-group-use-permanent-levels' is used. | |
914 | (defun gnus-group-default-level (&optional level number-or-nil) | |
915 | (cond | |
916 | (gnus-group-use-permanent-levels | |
917 | (or (setq gnus-group-use-permanent-levels | |
918 | (or level (if (numberp gnus-group-use-permanent-levels) | |
919 | gnus-group-use-permanent-levels | |
920 | (or gnus-group-default-list-level | |
921 | gnus-level-subscribed)))) | |
922 | gnus-group-default-list-level gnus-level-subscribed)) | |
923 | (number-or-nil | |
924 | level) | |
925 | (t | |
926 | (or level gnus-group-default-list-level gnus-level-subscribed)))) | |
927 | ||
928 | (defun gnus-group-setup-buffer () | |
6748645f | 929 | (set-buffer (gnus-get-buffer-create gnus-group-buffer)) |
eec82323 | 930 | (unless (eq major-mode 'gnus-group-mode) |
eec82323 LMI |
931 | (gnus-group-mode) |
932 | (when gnus-carpal | |
933 | (gnus-carpal-setup-buffer 'group)))) | |
934 | ||
16409b0b GM |
935 | (defsubst gnus-group-name-charset (method group) |
936 | (if (null method) | |
937 | (setq method (gnus-find-method-for-group group))) | |
938 | (let ((item (assoc method gnus-group-name-charset-method-alist)) | |
939 | (alist gnus-group-name-charset-group-alist) | |
940 | result) | |
a1506d29 | 941 | (if item |
16409b0b GM |
942 | (cdr item) |
943 | (while (setq item (pop alist)) | |
944 | (if (string-match (car item) group) | |
945 | (setq alist nil | |
946 | result (cdr item)))) | |
947 | result))) | |
948 | ||
949 | (defsubst gnus-group-name-decode (string charset) | |
950 | (if (and string charset (featurep 'mule)) | |
951 | (mm-decode-coding-string string charset) | |
952 | string)) | |
953 | ||
954 | (defun gnus-group-decoded-name (string) | |
955 | (let ((charset (gnus-group-name-charset nil string))) | |
956 | (gnus-group-name-decode string charset))) | |
957 | ||
eec82323 LMI |
958 | (defun gnus-group-list-groups (&optional level unread lowest) |
959 | "List newsgroups with level LEVEL or lower that have unread articles. | |
960 | Default is all subscribed groups. | |
961 | If argument UNREAD is non-nil, groups with no unread articles are also | |
962 | listed. | |
963 | ||
964 | Also see the `gnus-group-use-permanent-levels' variable." | |
965 | (interactive | |
966 | (list (if current-prefix-arg | |
967 | (prefix-numeric-value current-prefix-arg) | |
968 | (or | |
969 | (gnus-group-default-level nil t) | |
970 | gnus-group-default-list-level | |
971 | gnus-level-subscribed)))) | |
eec82323 LMI |
972 | (unless level |
973 | (setq level (car gnus-group-list-mode) | |
974 | unread (cdr gnus-group-list-mode))) | |
975 | (setq level (gnus-group-default-level level)) | |
976 | (gnus-group-setup-buffer) | |
977 | (gnus-update-format-specifications nil 'group 'group-mode) | |
978 | (let ((case-fold-search nil) | |
979 | (props (text-properties-at (gnus-point-at-bol))) | |
980 | (empty (= (point-min) (point-max))) | |
981 | (group (gnus-group-group-name)) | |
982 | number) | |
983 | (set-buffer gnus-group-buffer) | |
984 | (setq number (funcall gnus-group-prepare-function level unread lowest)) | |
985 | (when (or (and (numberp number) | |
986 | (zerop number)) | |
987 | (zerop (buffer-size))) | |
988 | ;; No groups in the buffer. | |
989 | (gnus-message 5 gnus-no-groups-message)) | |
990 | ;; We have some groups displayed. | |
991 | (goto-char (point-max)) | |
992 | (when (or (not gnus-group-goto-next-group-function) | |
993 | (not (funcall gnus-group-goto-next-group-function | |
994 | group props))) | |
995 | (cond | |
996 | (empty | |
997 | (goto-char (point-min))) | |
998 | ((not group) | |
999 | ;; Go to the first group with unread articles. | |
1000 | (gnus-group-search-forward t)) | |
1001 | (t | |
1002 | ;; Find the right group to put point on. If the current group | |
1003 | ;; has disappeared in the new listing, try to find the next | |
1004 | ;; one. If no next one can be found, just leave point at the | |
1005 | ;; first newsgroup in the buffer. | |
1006 | (when (not (gnus-goto-char | |
1007 | (text-property-any | |
1008 | (point-min) (point-max) | |
1009 | 'gnus-group (gnus-intern-safe | |
1010 | group gnus-active-hashtb)))) | |
1011 | (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb)))) | |
1012 | (while (and newsrc | |
1013 | (not (gnus-goto-char | |
1014 | (text-property-any | |
1015 | (point-min) (point-max) 'gnus-group | |
1016 | (gnus-intern-safe | |
1017 | (caar newsrc) gnus-active-hashtb))))) | |
1018 | (setq newsrc (cdr newsrc))) | |
1019 | (unless newsrc | |
1020 | (goto-char (point-max)) | |
1021 | (forward-line -1))))))) | |
1022 | ;; Adjust cursor point. | |
1023 | (gnus-group-position-point))) | |
1024 | ||
1025 | (defun gnus-group-list-level (level &optional all) | |
1026 | "List groups on LEVEL. | |
1027 | If ALL (the prefix), also list groups that have no unread articles." | |
1028 | (interactive "nList groups on level: \nP") | |
1029 | (gnus-group-list-groups level all level)) | |
1030 | ||
1031 | (defun gnus-group-prepare-flat (level &optional all lowest regexp) | |
1032 | "List all newsgroups with unread articles of level LEVEL or lower. | |
1033 | If ALL is non-nil, list groups that have no unread articles. | |
1034 | If LOWEST is non-nil, list all newsgroups of level LOWEST or higher. | |
1035 | If REGEXP, only list groups matching REGEXP." | |
1036 | (set-buffer gnus-group-buffer) | |
1037 | (let ((buffer-read-only nil) | |
1038 | (newsrc (cdr gnus-newsrc-alist)) | |
1039 | (lowest (or lowest 1)) | |
1040 | info clevel unread group params) | |
1041 | (erase-buffer) | |
1042 | (when (< lowest gnus-level-zombie) | |
1043 | ;; List living groups. | |
1044 | (while newsrc | |
1045 | (setq info (car newsrc) | |
1046 | group (gnus-info-group info) | |
1047 | params (gnus-info-params info) | |
1048 | newsrc (cdr newsrc) | |
1049 | unread (car (gnus-gethash group gnus-newsrc-hashtb))) | |
16409b0b | 1050 | (and unread ; This group might be unchecked |
eec82323 LMI |
1051 | (or (not regexp) |
1052 | (string-match regexp group)) | |
1053 | (<= (setq clevel (gnus-info-level info)) level) | |
1054 | (>= clevel lowest) | |
1055 | (or all ; We list all groups? | |
1056 | (if (eq unread t) ; Unactivated? | |
1057 | gnus-group-list-inactive-groups ; We list unactivated | |
1058 | (> unread 0)) ; We list groups with unread articles | |
1059 | (and gnus-list-groups-with-ticked-articles | |
1060 | (cdr (assq 'tick (gnus-info-marks info)))) | |
1061 | ; And groups with tickeds | |
1062 | ;; Check for permanent visibility. | |
1063 | (and gnus-permanently-visible-groups | |
1064 | (string-match gnus-permanently-visible-groups | |
1065 | group)) | |
1066 | (memq 'visible params) | |
1067 | (cdr (assq 'visible params))) | |
1068 | (gnus-group-insert-group-line | |
1069 | group (gnus-info-level info) | |
1070 | (gnus-info-marks info) unread (gnus-info-method info))))) | |
1071 | ||
1072 | ;; List dead groups. | |
1073 | (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie) | |
1074 | (gnus-group-prepare-flat-list-dead | |
1075 | (setq gnus-zombie-list (sort gnus-zombie-list 'string<)) | |
1076 | gnus-level-zombie ?Z | |
1077 | regexp)) | |
1078 | (and (>= level gnus-level-killed) (<= lowest gnus-level-killed) | |
1079 | (gnus-group-prepare-flat-list-dead | |
1080 | (setq gnus-killed-list (sort gnus-killed-list 'string<)) | |
1081 | gnus-level-killed ?K regexp)) | |
1082 | ||
1083 | (gnus-group-set-mode-line) | |
1084 | (setq gnus-group-list-mode (cons level all)) | |
6748645f | 1085 | (gnus-run-hooks 'gnus-group-prepare-hook) |
eec82323 LMI |
1086 | t)) |
1087 | ||
1088 | (defun gnus-group-prepare-flat-list-dead (groups level mark regexp) | |
1089 | ;; List zombies and killed lists somewhat faster, which was | |
1090 | ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does | |
1091 | ;; this by ignoring the group format specification altogether. | |
1092 | (let (group) | |
1093 | (if regexp | |
1094 | ;; This loop is used when listing groups that match some | |
1095 | ;; regexp. | |
1096 | (while groups | |
1097 | (setq group (pop groups)) | |
1098 | (when (string-match regexp group) | |
1099 | (gnus-add-text-properties | |
1100 | (point) (prog1 (1+ (point)) | |
16409b0b | 1101 | (insert " " mark " *: " |
a1506d29 | 1102 | (gnus-group-name-decode group |
16409b0b | 1103 | (gnus-group-name-charset |
a1506d29 | 1104 | nil group)) |
16409b0b | 1105 | "\n")) |
eec82323 LMI |
1106 | (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb) |
1107 | 'gnus-unread t | |
1108 | 'gnus-level level)))) | |
1109 | ;; This loop is used when listing all groups. | |
1110 | (while groups | |
16409b0b | 1111 | (setq group (pop groups)) |
eec82323 LMI |
1112 | (gnus-add-text-properties |
1113 | (point) (prog1 (1+ (point)) | |
1114 | (insert " " mark " *: " | |
a1506d29 | 1115 | (gnus-group-name-decode group |
16409b0b | 1116 | (gnus-group-name-charset |
a1506d29 | 1117 | nil group)) |
16409b0b | 1118 | "\n")) |
eec82323 LMI |
1119 | (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb) |
1120 | 'gnus-unread t | |
1121 | 'gnus-level level)))))) | |
1122 | ||
1123 | (defun gnus-group-update-group-line () | |
1124 | "Update the current line in the group buffer." | |
1125 | (let* ((buffer-read-only nil) | |
1126 | (group (gnus-group-group-name)) | |
1127 | (entry (and group (gnus-gethash group gnus-newsrc-hashtb))) | |
1128 | gnus-group-indentation) | |
1129 | (when group | |
1130 | (and entry | |
1131 | (not (gnus-ephemeral-group-p group)) | |
1132 | (gnus-dribble-enter | |
1133 | (concat "(gnus-group-set-info '" | |
1134 | (gnus-prin1-to-string (nth 2 entry)) | |
1135 | ")"))) | |
1136 | (setq gnus-group-indentation (gnus-group-group-indentation)) | |
1137 | (gnus-delete-line) | |
1138 | (gnus-group-insert-group-line-info group) | |
1139 | (forward-line -1) | |
1140 | (gnus-group-position-point)))) | |
1141 | ||
1142 | (defun gnus-group-insert-group-line-info (group) | |
1143 | "Insert GROUP on the current line." | |
1144 | (let ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
1145 | (gnus-group-indentation (gnus-group-group-indentation)) | |
1146 | active info) | |
1147 | (if entry | |
1148 | (progn | |
1149 | ;; (Un)subscribed group. | |
1150 | (setq info (nth 2 entry)) | |
1151 | (gnus-group-insert-group-line | |
1152 | group (gnus-info-level info) (gnus-info-marks info) | |
1153 | (or (car entry) t) (gnus-info-method info))) | |
1154 | ;; This group is dead. | |
1155 | (gnus-group-insert-group-line | |
1156 | group | |
1157 | (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed) | |
1158 | nil | |
1159 | (if (setq active (gnus-active group)) | |
1160 | (if (zerop (cdr active)) | |
1161 | 0 | |
1162 | (- (1+ (cdr active)) (car active))) | |
1163 | nil) | |
1164 | nil)))) | |
1165 | ||
1166 | (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level | |
1167 | gnus-tmp-marked number | |
1168 | gnus-tmp-method) | |
1169 | "Insert a group line in the group buffer." | |
16409b0b | 1170 | (let* ((gnus-tmp-method |
a1506d29 | 1171 | (gnus-server-get-method gnus-tmp-group gnus-tmp-method)) |
16409b0b GM |
1172 | (group-name-charset (gnus-group-name-charset gnus-tmp-method |
1173 | gnus-tmp-group)) | |
1174 | (gnus-tmp-active (gnus-active gnus-tmp-group)) | |
eec82323 LMI |
1175 | (gnus-tmp-number-total |
1176 | (if gnus-tmp-active | |
1177 | (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active))) | |
1178 | 0)) | |
1179 | (gnus-tmp-number-of-unread | |
1180 | (if (numberp number) (int-to-string (max 0 number)) | |
1181 | "*")) | |
1182 | (gnus-tmp-number-of-read | |
1183 | (if (numberp number) | |
1184 | (int-to-string (max 0 (- gnus-tmp-number-total number))) | |
1185 | "*")) | |
1186 | (gnus-tmp-subscribed | |
1187 | (cond ((<= gnus-tmp-level gnus-level-subscribed) ? ) | |
1188 | ((<= gnus-tmp-level gnus-level-unsubscribed) ?U) | |
1189 | ((= gnus-tmp-level gnus-level-zombie) ?Z) | |
1190 | (t ?K))) | |
a1506d29 | 1191 | (gnus-tmp-qualified-group |
16409b0b GM |
1192 | (gnus-group-name-decode (gnus-group-real-name gnus-tmp-group) |
1193 | group-name-charset)) | |
eec82323 LMI |
1194 | (gnus-tmp-newsgroup-description |
1195 | (if gnus-description-hashtb | |
16409b0b | 1196 | (or (gnus-group-name-decode |
a1506d29 | 1197 | (gnus-gethash gnus-tmp-group gnus-description-hashtb) |
16409b0b | 1198 | group-name-charset) "") |
eec82323 LMI |
1199 | "")) |
1200 | (gnus-tmp-moderated | |
1201 | (if (and gnus-moderated-hashtb | |
1202 | (gnus-gethash gnus-tmp-group gnus-moderated-hashtb)) | |
1203 | ?m ? )) | |
1204 | (gnus-tmp-moderated-string | |
1205 | (if (eq gnus-tmp-moderated ?m) "(m)" "")) | |
16409b0b | 1206 | (gnus-tmp-group-icon "==&&==") |
eec82323 LMI |
1207 | (gnus-tmp-news-server (or (cadr gnus-tmp-method) "")) |
1208 | (gnus-tmp-news-method (or (car gnus-tmp-method) "")) | |
1209 | (gnus-tmp-news-method-string | |
1210 | (if gnus-tmp-method | |
1211 | (format "(%s:%s)" (car gnus-tmp-method) | |
1212 | (cadr gnus-tmp-method)) "")) | |
1213 | (gnus-tmp-marked-mark | |
1214 | (if (and (numberp number) | |
1215 | (zerop number) | |
1216 | (cdr (assq 'tick gnus-tmp-marked))) | |
1217 | ?* ? )) | |
1218 | (gnus-tmp-process-marked | |
1219 | (if (member gnus-tmp-group gnus-group-marked) | |
1220 | gnus-process-mark ? )) | |
1221 | (gnus-tmp-grouplens | |
1222 | (or (and gnus-use-grouplens | |
1223 | (bbb-grouplens-group-p gnus-tmp-group)) | |
1224 | "")) | |
1225 | (buffer-read-only nil) | |
1226 | header gnus-tmp-header) ; passed as parameter to user-funcs. | |
1227 | (beginning-of-line) | |
1228 | (gnus-add-text-properties | |
1229 | (point) | |
1230 | (prog1 (1+ (point)) | |
1231 | ;; Insert the text. | |
1232 | (eval gnus-group-line-format-spec)) | |
1233 | `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb) | |
1234 | gnus-unread ,(if (numberp number) | |
1235 | (string-to-int gnus-tmp-number-of-unread) | |
1236 | t) | |
1237 | gnus-marked ,gnus-tmp-marked-mark | |
1238 | gnus-indentation ,gnus-group-indentation | |
1239 | gnus-level ,gnus-tmp-level)) | |
16409b0b | 1240 | (forward-line -1) |
eec82323 | 1241 | (when (inline (gnus-visual-p 'group-highlight 'highlight)) |
16409b0b GM |
1242 | (gnus-run-hooks 'gnus-group-update-hook)) |
1243 | (forward-line) | |
eec82323 LMI |
1244 | ;; Allow XEmacs to remove front-sticky text properties. |
1245 | (gnus-group-remove-excess-properties))) | |
1246 | ||
1247 | (defun gnus-group-highlight-line () | |
1248 | "Highlight the current line according to `gnus-group-highlight'." | |
1249 | (let* ((list gnus-group-highlight) | |
1250 | (p (point)) | |
1251 | (end (progn (end-of-line) (point))) | |
1252 | ;; now find out where the line starts and leave point there. | |
1253 | (beg (progn (beginning-of-line) (point))) | |
1254 | (group (gnus-group-group-name)) | |
1255 | (entry (gnus-group-entry group)) | |
1256 | (unread (if (numberp (car entry)) (car entry) 0)) | |
1257 | (active (gnus-active group)) | |
1258 | (total (if active (1+ (- (cdr active) (car active))) 0)) | |
1259 | (info (nth 2 entry)) | |
1260 | (method (gnus-server-get-method group (gnus-info-method info))) | |
1261 | (marked (gnus-info-marks info)) | |
1262 | (mailp (memq 'mail (assoc (symbol-name | |
1263 | (car (or method gnus-select-method))) | |
1264 | gnus-valid-select-methods))) | |
6748645f | 1265 | (level (or (gnus-info-level info) gnus-level-killed)) |
eec82323 LMI |
1266 | (score (or (gnus-info-score info) 0)) |
1267 | (ticked (gnus-range-length (cdr (assq 'tick marked)))) | |
1268 | (group-age (gnus-group-timestamp-delta group)) | |
1269 | (inhibit-read-only t)) | |
1270 | ;; Eval the cars of the lists until we find a match. | |
1271 | (while (and list | |
1272 | (not (eval (caar list)))) | |
1273 | (setq list (cdr list))) | |
1274 | (let ((face (cdar list))) | |
1275 | (unless (eq face (get-text-property beg 'face)) | |
6748645f | 1276 | (gnus-put-text-property-excluding-characters-with-faces |
eec82323 LMI |
1277 | beg end 'face |
1278 | (setq face (if (boundp face) (symbol-value face) face))) | |
1279 | (gnus-extent-start-open beg))) | |
1280 | (goto-char p))) | |
1281 | ||
1282 | (defun gnus-group-update-group (group &optional visible-only) | |
1283 | "Update all lines where GROUP appear. | |
1284 | If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't | |
1285 | already." | |
1286 | ;; Can't use `save-excursion' here, so we do it manually. | |
1287 | (let ((buf (current-buffer)) | |
1288 | mark) | |
1289 | (set-buffer gnus-group-buffer) | |
1290 | (setq mark (point-marker)) | |
1291 | ;; The buffer may be narrowed. | |
1292 | (save-restriction | |
1293 | (widen) | |
1294 | (let ((ident (gnus-intern-safe group gnus-active-hashtb)) | |
1295 | (loc (point-min)) | |
1296 | found buffer-read-only) | |
1297 | ;; Enter the current status into the dribble buffer. | |
1298 | (let ((entry (gnus-gethash group gnus-newsrc-hashtb))) | |
6748645f LMI |
1299 | (when (and entry |
1300 | (not (gnus-ephemeral-group-p group))) | |
eec82323 LMI |
1301 | (gnus-dribble-enter |
1302 | (concat "(gnus-group-set-info '" | |
1303 | (gnus-prin1-to-string (nth 2 entry)) | |
1304 | ")")))) | |
1305 | ;; Find all group instances. If topics are in use, each group | |
1306 | ;; may be listed in more than once. | |
1307 | (while (setq loc (text-property-any | |
1308 | loc (point-max) 'gnus-group ident)) | |
1309 | (setq found t) | |
1310 | (goto-char loc) | |
1311 | (let ((gnus-group-indentation (gnus-group-group-indentation))) | |
1312 | (gnus-delete-line) | |
1313 | (gnus-group-insert-group-line-info group) | |
1314 | (save-excursion | |
1315 | (forward-line -1) | |
6748645f | 1316 | (gnus-run-hooks 'gnus-group-update-group-hook))) |
eec82323 LMI |
1317 | (setq loc (1+ loc))) |
1318 | (unless (or found visible-only) | |
1319 | ;; No such line in the buffer, find out where it's supposed to | |
1320 | ;; go, and insert it there (or at the end of the buffer). | |
1321 | (if gnus-goto-missing-group-function | |
1322 | (funcall gnus-goto-missing-group-function group) | |
1323 | (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb)))) | |
1324 | (while (and entry (car entry) | |
1325 | (not | |
1326 | (gnus-goto-char | |
1327 | (text-property-any | |
1328 | (point-min) (point-max) | |
1329 | 'gnus-group (gnus-intern-safe | |
1330 | (caar entry) gnus-active-hashtb))))) | |
1331 | (setq entry (cdr entry))) | |
1332 | (or entry (goto-char (point-max))))) | |
1333 | ;; Finally insert the line. | |
1334 | (let ((gnus-group-indentation (gnus-group-group-indentation))) | |
1335 | (gnus-group-insert-group-line-info group) | |
1336 | (save-excursion | |
1337 | (forward-line -1) | |
6748645f | 1338 | (gnus-run-hooks 'gnus-group-update-group-hook)))) |
eec82323 LMI |
1339 | (when gnus-group-update-group-function |
1340 | (funcall gnus-group-update-group-function group)) | |
1341 | (gnus-group-set-mode-line))) | |
1342 | (goto-char mark) | |
1343 | (set-marker mark nil) | |
1344 | (set-buffer buf))) | |
1345 | ||
1346 | (defun gnus-group-set-mode-line () | |
1347 | "Update the mode line in the group buffer." | |
1348 | (when (memq 'group gnus-updated-mode-lines) | |
1349 | ;; Yes, we want to keep this mode line updated. | |
1350 | (save-excursion | |
1351 | (set-buffer gnus-group-buffer) | |
1352 | (let* ((gformat (or gnus-group-mode-line-format-spec | |
6748645f | 1353 | (gnus-set-format 'group-mode))) |
eec82323 LMI |
1354 | (gnus-tmp-news-server (cadr gnus-select-method)) |
1355 | (gnus-tmp-news-method (car gnus-select-method)) | |
1356 | (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":")) | |
1357 | (max-len 60) | |
1358 | gnus-tmp-header ;Dummy binding for user-defined formats | |
1359 | ;; Get the resulting string. | |
1360 | (modified | |
1361 | (and gnus-dribble-buffer | |
1362 | (buffer-name gnus-dribble-buffer) | |
1363 | (buffer-modified-p gnus-dribble-buffer) | |
1364 | (save-excursion | |
1365 | (set-buffer gnus-dribble-buffer) | |
1366 | (not (zerop (buffer-size)))))) | |
1367 | (mode-string (eval gformat))) | |
1368 | ;; Say whether the dribble buffer has been modified. | |
a8151ef7 LMI |
1369 | (setq mode-line-modified |
1370 | (if modified (car gnus-mode-line-modified) | |
1371 | (cdr gnus-mode-line-modified))) | |
eec82323 LMI |
1372 | ;; If the line is too long, we chop it off. |
1373 | (when (> (length mode-string) max-len) | |
1374 | (setq mode-string (substring mode-string 0 (- max-len 4)))) | |
1375 | (prog1 | |
1376 | (setq mode-line-buffer-identification | |
1377 | (gnus-mode-line-buffer-identification | |
1378 | (list mode-string))) | |
1379 | (set-buffer-modified-p modified)))))) | |
1380 | ||
1381 | (defun gnus-group-group-name () | |
1382 | "Get the name of the newsgroup on the current line." | |
1383 | (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group))) | |
6748645f LMI |
1384 | (when group |
1385 | (symbol-name group)))) | |
eec82323 LMI |
1386 | |
1387 | (defun gnus-group-group-level () | |
1388 | "Get the level of the newsgroup on the current line." | |
1389 | (get-text-property (gnus-point-at-bol) 'gnus-level)) | |
1390 | ||
1391 | (defun gnus-group-group-indentation () | |
1392 | "Get the indentation of the newsgroup on the current line." | |
1393 | (or (get-text-property (gnus-point-at-bol) 'gnus-indentation) | |
1394 | (and gnus-group-indentation-function | |
1395 | (funcall gnus-group-indentation-function)) | |
1396 | "")) | |
1397 | ||
1398 | (defun gnus-group-group-unread () | |
1399 | "Get the number of unread articles of the newsgroup on the current line." | |
1400 | (get-text-property (gnus-point-at-bol) 'gnus-unread)) | |
1401 | ||
1402 | (defun gnus-group-new-mail (group) | |
1403 | (if (nnmail-new-mail-p (gnus-group-real-name group)) | |
1404 | gnus-new-mail-mark | |
1405 | ? )) | |
1406 | ||
1407 | (defun gnus-group-level (group) | |
1408 | "Return the estimated level of GROUP." | |
1409 | (or (gnus-info-level (gnus-get-info group)) | |
6748645f LMI |
1410 | (and (member group gnus-zombie-list) gnus-level-zombie) |
1411 | gnus-level-killed)) | |
eec82323 LMI |
1412 | |
1413 | (defun gnus-group-search-forward (&optional backward all level first-too) | |
1414 | "Find the next newsgroup with unread articles. | |
1415 | If BACKWARD is non-nil, find the previous newsgroup instead. | |
1416 | If ALL is non-nil, just find any newsgroup. | |
1417 | If LEVEL is non-nil, find group with level LEVEL, or higher if no such | |
1418 | group exists. | |
1419 | If FIRST-TOO, the current line is also eligible as a target." | |
1420 | (let ((way (if backward -1 1)) | |
1421 | (low gnus-level-killed) | |
1422 | (beg (point)) | |
1423 | pos found lev) | |
1424 | (if (and backward (progn (beginning-of-line)) (bobp)) | |
1425 | nil | |
1426 | (unless first-too | |
1427 | (forward-line way)) | |
1428 | (while (and | |
1429 | (not (eobp)) | |
1430 | (not (setq | |
1431 | found | |
a8151ef7 LMI |
1432 | (and |
1433 | (get-text-property (point) 'gnus-group) | |
1434 | (or all | |
1435 | (and | |
1436 | (let ((unread | |
1437 | (get-text-property (point) 'gnus-unread))) | |
1438 | (and (numberp unread) (> unread 0))) | |
1439 | (setq lev (get-text-property (point) | |
1440 | 'gnus-level)) | |
1441 | (<= lev gnus-level-subscribed))) | |
1442 | (or (not level) | |
1443 | (and (setq lev (get-text-property (point) | |
eec82323 | 1444 | 'gnus-level)) |
a8151ef7 LMI |
1445 | (or (= lev level) |
1446 | (and (< lev low) | |
1447 | (< level lev) | |
1448 | (progn | |
1449 | (setq low lev) | |
1450 | (setq pos (point)) | |
1451 | nil)))))))) | |
eec82323 LMI |
1452 | (zerop (forward-line way))))) |
1453 | (if found | |
1454 | (progn (gnus-group-position-point) t) | |
1455 | (goto-char (or pos beg)) | |
1456 | (and pos t)))) | |
1457 | ||
1458 | ;;; Gnus group mode commands | |
1459 | ||
1460 | ;; Group marking. | |
1461 | ||
16409b0b GM |
1462 | (defun gnus-group-mark-line-p () |
1463 | (save-excursion | |
1464 | (beginning-of-line) | |
1465 | (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2)) | |
1466 | (eq (char-after) gnus-process-mark))) | |
1467 | ||
eec82323 LMI |
1468 | (defun gnus-group-mark-group (n &optional unmark no-advance) |
1469 | "Mark the current group." | |
1470 | (interactive "p") | |
1471 | (let ((buffer-read-only nil) | |
1472 | group) | |
1473 | (while (and (> n 0) | |
1474 | (not (eobp))) | |
1475 | (when (setq group (gnus-group-group-name)) | |
1476 | ;; Go to the mark position. | |
1477 | (beginning-of-line) | |
1478 | (forward-char (or (cdr (assq 'process gnus-group-mark-positions)) 2)) | |
1479 | (subst-char-in-region | |
16409b0b | 1480 | (point) (1+ (point)) (char-after) |
eec82323 LMI |
1481 | (if unmark |
1482 | (progn | |
1483 | (setq gnus-group-marked (delete group gnus-group-marked)) | |
1484 | ? ) | |
1485 | (setq gnus-group-marked | |
1486 | (cons group (delete group gnus-group-marked))) | |
1487 | gnus-process-mark))) | |
1488 | (unless no-advance | |
1489 | (gnus-group-next-group 1)) | |
1490 | (decf n)) | |
1491 | (gnus-summary-position-point) | |
1492 | n)) | |
1493 | ||
1494 | (defun gnus-group-unmark-group (n) | |
1495 | "Remove the mark from the current group." | |
1496 | (interactive "p") | |
1497 | (gnus-group-mark-group n 'unmark) | |
1498 | (gnus-group-position-point)) | |
1499 | ||
1500 | (defun gnus-group-unmark-all-groups () | |
1501 | "Unmark all groups." | |
1502 | (interactive) | |
1503 | (let ((groups gnus-group-marked)) | |
1504 | (save-excursion | |
1505 | (while groups | |
1506 | (gnus-group-remove-mark (pop groups))))) | |
1507 | (gnus-group-position-point)) | |
1508 | ||
1509 | (defun gnus-group-mark-region (unmark beg end) | |
1510 | "Mark all groups between point and mark. | |
1511 | If UNMARK, remove the mark instead." | |
1512 | (interactive "P\nr") | |
1513 | (let ((num (count-lines beg end))) | |
1514 | (save-excursion | |
1515 | (goto-char beg) | |
1516 | (- num (gnus-group-mark-group num unmark))))) | |
1517 | ||
1518 | (defun gnus-group-mark-buffer (&optional unmark) | |
1519 | "Mark all groups in the buffer. | |
1520 | If UNMARK, remove the mark instead." | |
1521 | (interactive "P") | |
1522 | (gnus-group-mark-region unmark (point-min) (point-max))) | |
1523 | ||
1524 | (defun gnus-group-mark-regexp (regexp) | |
1525 | "Mark all groups that match some regexp." | |
1526 | (interactive "sMark (regexp): ") | |
1527 | (let ((alist (cdr gnus-newsrc-alist)) | |
1528 | group) | |
1529 | (while alist | |
1530 | (when (string-match regexp (setq group (gnus-info-group (pop alist)))) | |
1531 | (gnus-group-set-mark group)))) | |
1532 | (gnus-group-position-point)) | |
1533 | ||
16409b0b | 1534 | (defun gnus-group-remove-mark (group &optional test-marked) |
eec82323 LMI |
1535 | "Remove the process mark from GROUP and move point there. |
1536 | Return nil if the group isn't displayed." | |
16409b0b | 1537 | (if (gnus-group-goto-group group nil test-marked) |
eec82323 LMI |
1538 | (save-excursion |
1539 | (gnus-group-mark-group 1 'unmark t) | |
1540 | t) | |
1541 | (setq gnus-group-marked | |
1542 | (delete group gnus-group-marked)) | |
1543 | nil)) | |
1544 | ||
1545 | (defun gnus-group-set-mark (group) | |
1546 | "Set the process mark on GROUP." | |
1547 | (if (gnus-group-goto-group group) | |
1548 | (save-excursion | |
1549 | (gnus-group-mark-group 1 nil t)) | |
1550 | (setq gnus-group-marked (cons group (delete group gnus-group-marked))))) | |
1551 | ||
1552 | (defun gnus-group-universal-argument (arg &optional groups func) | |
1553 | "Perform any command on all groups according to the process/prefix convention." | |
1554 | (interactive "P") | |
1555 | (if (eq (setq func (or func | |
1556 | (key-binding | |
1557 | (read-key-sequence | |
1558 | (substitute-command-keys | |
1559 | "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]"))))) | |
1560 | 'undefined) | |
1561 | (gnus-error 1 "Undefined key") | |
1562 | (gnus-group-iterate arg | |
1563 | (lambda (group) | |
1564 | (command-execute func)))) | |
1565 | (gnus-group-position-point)) | |
1566 | ||
1567 | (defun gnus-group-process-prefix (n) | |
1568 | "Return a list of groups to work on. | |
1569 | Take into consideration N (the prefix) and the list of marked groups." | |
1570 | (cond | |
1571 | (n | |
1572 | (setq n (prefix-numeric-value n)) | |
1573 | ;; There is a prefix, so we return a list of the N next | |
1574 | ;; groups. | |
1575 | (let ((way (if (< n 0) -1 1)) | |
1576 | (n (abs n)) | |
1577 | group groups) | |
1578 | (save-excursion | |
6748645f LMI |
1579 | (while (> n 0) |
1580 | (if (setq group (gnus-group-group-name)) | |
1581 | (push group groups)) | |
eec82323 LMI |
1582 | (setq n (1- n)) |
1583 | (gnus-group-next-group way))) | |
1584 | (nreverse groups))) | |
1585 | ((gnus-region-active-p) | |
1586 | ;; Work on the region between point and mark. | |
1587 | (let ((max (max (point) (mark))) | |
1588 | groups) | |
1589 | (save-excursion | |
1590 | (goto-char (min (point) (mark))) | |
1591 | (while | |
1592 | (and | |
1593 | (push (gnus-group-group-name) groups) | |
1594 | (zerop (gnus-group-next-group 1)) | |
1595 | (< (point) max))) | |
1596 | (nreverse groups)))) | |
1597 | (gnus-group-marked | |
1598 | ;; No prefix, but a list of marked articles. | |
1599 | (reverse gnus-group-marked)) | |
1600 | (t | |
1601 | ;; Neither marked articles or a prefix, so we return the | |
1602 | ;; current group. | |
1603 | (let ((group (gnus-group-group-name))) | |
1604 | (and group (list group)))))) | |
1605 | ||
6748645f LMI |
1606 | ;;; !!!Surely gnus-group-iterate should be a macro instead? I can't |
1607 | ;;; imagine why I went through these contortions... | |
1608 | (eval-and-compile | |
1609 | (let ((function (make-symbol "gnus-group-iterate-function")) | |
1610 | (window (make-symbol "gnus-group-iterate-window")) | |
1611 | (groups (make-symbol "gnus-group-iterate-groups")) | |
1612 | (group (make-symbol "gnus-group-iterate-group"))) | |
1613 | (eval | |
1614 | `(defun gnus-group-iterate (arg ,function) | |
1615 | "Iterate FUNCTION over all process/prefixed groups. | |
16409b0b | 1616 | FUNCTION will be called with the group name as the parameter |
eec82323 | 1617 | and with point over the group in question." |
6748645f LMI |
1618 | (let ((,groups (gnus-group-process-prefix arg)) |
1619 | (,window (selected-window)) | |
1620 | ,group) | |
16409b0b GM |
1621 | (while ,groups |
1622 | (setq ,group (car ,groups) | |
1623 | ,groups (cdr ,groups)) | |
6748645f LMI |
1624 | (select-window ,window) |
1625 | (gnus-group-remove-mark ,group) | |
1626 | (save-selected-window | |
1627 | (save-excursion | |
1628 | (funcall ,function ,group))))))))) | |
eec82323 LMI |
1629 | |
1630 | (put 'gnus-group-iterate 'lisp-indent-function 1) | |
1631 | ||
1632 | ;; Selecting groups. | |
1633 | ||
6748645f | 1634 | (defun gnus-group-read-group (&optional all no-article group select-articles) |
eec82323 LMI |
1635 | "Read news in this newsgroup. |
1636 | If the prefix argument ALL is non-nil, already read articles become | |
1637 | readable. IF ALL is a number, fetch this number of articles. If the | |
1638 | optional argument NO-ARTICLE is non-nil, no article will be | |
1639 | auto-selected upon group entry. If GROUP is non-nil, fetch that | |
1640 | group." | |
1641 | (interactive "P") | |
1642 | (let ((no-display (eq all 0)) | |
1643 | (group (or group (gnus-group-group-name))) | |
1644 | number active marked entry) | |
1645 | (when (eq all 0) | |
1646 | (setq all nil)) | |
1647 | (unless group | |
1648 | (error "No group on current line")) | |
1649 | (setq marked (gnus-info-marks | |
1650 | (nth 2 (setq entry (gnus-gethash | |
1651 | group gnus-newsrc-hashtb))))) | |
1652 | ;; This group might be a dead group. In that case we have to get | |
1653 | ;; the number of unread articles from `gnus-active-hashtb'. | |
1654 | (setq number | |
1655 | (cond ((numberp all) all) | |
1656 | (entry (car entry)) | |
1657 | ((setq active (gnus-active group)) | |
1658 | (- (1+ (cdr active)) (car active))))) | |
1659 | (gnus-summary-read-group | |
1660 | group (or all (and (numberp number) | |
1661 | (zerop (+ number (gnus-range-length | |
1662 | (cdr (assq 'tick marked))) | |
1663 | (gnus-range-length | |
1664 | (cdr (assq 'dormant marked))))))) | |
6748645f | 1665 | no-article nil no-display nil select-articles))) |
eec82323 LMI |
1666 | |
1667 | (defun gnus-group-select-group (&optional all) | |
1668 | "Select this newsgroup. | |
1669 | No article is selected automatically. | |
1670 | If ALL is non-nil, already read articles become readable. | |
1671 | If ALL is a number, fetch this number of articles." | |
1672 | (interactive "P") | |
1673 | (gnus-group-read-group all t)) | |
1674 | ||
1675 | (defun gnus-group-quick-select-group (&optional all) | |
1676 | "Select the current group \"quickly\". | |
1677 | This means that no highlighting or scoring will be performed. | |
1678 | If ALL (the prefix argument) is 0, don't even generate the summary | |
6748645f LMI |
1679 | buffer. |
1680 | ||
1681 | This might be useful if you want to toggle threading | |
1682 | before entering the group." | |
eec82323 LMI |
1683 | (interactive "P") |
1684 | (require 'gnus-score) | |
1685 | (let (gnus-visual | |
1686 | gnus-score-find-score-files-function | |
1687 | gnus-home-score-file | |
1688 | gnus-apply-kill-hook | |
1689 | gnus-summary-expunge-below) | |
1690 | (gnus-group-read-group all t))) | |
1691 | ||
1692 | (defun gnus-group-visible-select-group (&optional all) | |
1693 | "Select the current group without hiding any articles." | |
1694 | (interactive "P") | |
1695 | (let ((gnus-inhibit-limiting t)) | |
1696 | (gnus-group-read-group all t))) | |
1697 | ||
1698 | (defun gnus-group-select-group-ephemerally () | |
1699 | "Select the current group without doing any processing whatsoever. | |
1700 | You will actually be entered into a group that's a copy of | |
1701 | the current group; no changes you make while in this group will | |
1702 | be permanent." | |
1703 | (interactive) | |
1704 | (require 'gnus-score) | |
1705 | (let* (gnus-visual | |
1706 | gnus-score-find-score-files-function gnus-apply-kill-hook | |
1707 | gnus-summary-expunge-below gnus-show-threads gnus-suppress-duplicates | |
1708 | gnus-summary-mode-hook gnus-select-group-hook | |
1709 | (group (gnus-group-group-name)) | |
1710 | (method (gnus-find-method-for-group group))) | |
eec82323 LMI |
1711 | (gnus-group-read-ephemeral-group |
1712 | (gnus-group-prefixed-name group method) method))) | |
1713 | ||
1714 | ;;;###autoload | |
1715 | (defun gnus-fetch-group (group) | |
1716 | "Start Gnus if necessary and enter GROUP. | |
1717 | Returns whether the fetching was successful or not." | |
16409b0b | 1718 | (interactive (list (completing-read "Group name: " gnus-active-hashtb))) |
eec82323 | 1719 | (unless (get-buffer gnus-group-buffer) |
6748645f | 1720 | (gnus-no-server)) |
eec82323 LMI |
1721 | (gnus-group-read-group nil nil group)) |
1722 | ||
6748645f LMI |
1723 | ;;;###autoload |
1724 | (defun gnus-fetch-group-other-frame (group) | |
1725 | "Pop up a frame and enter GROUP." | |
1726 | (interactive "P") | |
1727 | (let ((window (get-buffer-window gnus-group-buffer))) | |
1728 | (cond (window | |
1729 | (select-frame (window-frame window))) | |
1730 | ((= (length (frame-list)) 1) | |
1731 | (select-frame (make-frame))) | |
1732 | (t | |
1733 | (other-frame 1)))) | |
1734 | (gnus-fetch-group group)) | |
1735 | ||
eec82323 LMI |
1736 | (defvar gnus-ephemeral-group-server 0) |
1737 | ||
1738 | ;; Enter a group that is not in the group buffer. Non-nil is returned | |
1739 | ;; if selection was successful. | |
1740 | (defun gnus-group-read-ephemeral-group (group method &optional activate | |
6748645f LMI |
1741 | quit-config request-only |
1742 | select-articles) | |
eec82323 LMI |
1743 | "Read GROUP from METHOD as an ephemeral group. |
1744 | If ACTIVATE, request the group first. | |
1745 | If QUIT-CONFIG, use that window configuration when exiting from the | |
1746 | ephemeral group. | |
1747 | If REQUEST-ONLY, don't actually read the group; just request it. | |
6748645f | 1748 | If SELECT-ARTICLES, only select those articles. |
eec82323 | 1749 | |
16409b0b | 1750 | Return the name of the group if selection was successful." |
eec82323 | 1751 | ;; Transform the select method into a unique server. |
6748645f LMI |
1752 | (when (stringp method) |
1753 | (setq method (gnus-server-to-method method))) | |
1754 | (setq method | |
1755 | `(,(car method) ,(concat (cadr method) "-ephemeral") | |
1756 | (,(intern (format "%s-address" (car method))) ,(cadr method)) | |
1757 | ,@(cddr method))) | |
eec82323 LMI |
1758 | (let ((group (if (gnus-group-foreign-p group) group |
1759 | (gnus-group-prefixed-name group method)))) | |
1760 | (gnus-sethash | |
1761 | group | |
1762 | `(-1 nil (,group | |
1763 | ,gnus-level-default-subscribed nil nil ,method | |
1764 | ((quit-config . | |
1765 | ,(if quit-config quit-config | |
1766 | (cons gnus-summary-buffer | |
1767 | gnus-current-window-configuration)))))) | |
1768 | gnus-newsrc-hashtb) | |
6748645f | 1769 | (push method gnus-ephemeral-servers) |
eec82323 LMI |
1770 | (set-buffer gnus-group-buffer) |
1771 | (unless (gnus-check-server method) | |
1772 | (error "Unable to contact server: %s" (gnus-status-message method))) | |
1773 | (when activate | |
1774 | (gnus-activate-group group 'scan) | |
1775 | (unless (gnus-request-group group) | |
1776 | (error "Couldn't request group: %s" | |
1777 | (nnheader-get-report (car method))))) | |
1778 | (if request-only | |
1779 | group | |
1780 | (condition-case () | |
6748645f | 1781 | (when (gnus-group-read-group t t group select-articles) |
eec82323 LMI |
1782 | group) |
1783 | ;;(error nil) | |
2491844d DL |
1784 | (quit |
1785 | (message "Quit reading the ephemeral group") | |
1786 | nil))))) | |
eec82323 LMI |
1787 | |
1788 | (defun gnus-group-jump-to-group (group) | |
1789 | "Jump to newsgroup GROUP." | |
1790 | (interactive | |
1791 | (list (completing-read | |
1792 | "Group: " gnus-active-hashtb nil | |
1793 | (gnus-read-active-file-p) | |
1794 | nil | |
1795 | 'gnus-group-history))) | |
1796 | ||
1797 | (when (equal group "") | |
1798 | (error "Empty group name")) | |
1799 | ||
1800 | (unless (gnus-ephemeral-group-p group) | |
1801 | ;; Either go to the line in the group buffer... | |
1802 | (unless (gnus-group-goto-group group) | |
1803 | ;; ... or insert the line. | |
1804 | (gnus-group-update-group group) | |
1805 | (gnus-group-goto-group group))) | |
1806 | ;; Adjust cursor point. | |
1807 | (gnus-group-position-point)) | |
1808 | ||
16409b0b | 1809 | (defun gnus-group-goto-group (group &optional far test-marked) |
eec82323 | 1810 | "Goto to newsgroup GROUP. |
16409b0b GM |
1811 | If FAR, it is likely that the group is not on the current line. |
1812 | If TEST-MARKED, the line must be marked." | |
eec82323 | 1813 | (when group |
16409b0b GM |
1814 | (beginning-of-line) |
1815 | (cond | |
1816 | ;; It's quite likely that we are on the right line, so | |
1817 | ;; we check the current line first. | |
1818 | ((and (not far) | |
1819 | (eq (get-text-property (point) 'gnus-group) | |
1820 | (gnus-intern-safe group gnus-active-hashtb)) | |
1821 | (or (not test-marked) (gnus-group-mark-line-p))) | |
1822 | (point)) | |
1823 | ;; Previous and next line are also likely, so we check them as well. | |
1824 | ((and (not far) | |
1825 | (save-excursion | |
1826 | (forward-line -1) | |
1827 | (and (eq (get-text-property (point) 'gnus-group) | |
1828 | (gnus-intern-safe group gnus-active-hashtb)) | |
1829 | (or (not test-marked) (gnus-group-mark-line-p))))) | |
1830 | (forward-line -1) | |
1831 | (point)) | |
1832 | ((and (not far) | |
1833 | (save-excursion | |
1834 | (forward-line 1) | |
1835 | (and (eq (get-text-property (point) 'gnus-group) | |
1836 | (gnus-intern-safe group gnus-active-hashtb)) | |
1837 | (or (not test-marked) (gnus-group-mark-line-p))))) | |
1838 | (forward-line 1) | |
1839 | (point)) | |
1840 | (test-marked | |
1841 | (goto-char (point-min)) | |
1842 | (let (found) | |
a1506d29 | 1843 | (while (and (not found) |
16409b0b GM |
1844 | (gnus-goto-char |
1845 | (text-property-any | |
1846 | (point) (point-max) | |
a1506d29 | 1847 | 'gnus-group |
16409b0b GM |
1848 | (gnus-intern-safe group gnus-active-hashtb)))) |
1849 | (if (gnus-group-mark-line-p) | |
1850 | (setq found t) | |
1851 | (forward-line 1))) | |
1852 | found)) | |
1853 | (t | |
1854 | ;; Search through the entire buffer. | |
1855 | (gnus-goto-char | |
1856 | (text-property-any | |
1857 | (point-min) (point-max) | |
1858 | 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))))) | |
eec82323 LMI |
1859 | |
1860 | (defun gnus-group-next-group (n &optional silent) | |
1861 | "Go to next N'th newsgroup. | |
1862 | If N is negative, search backward instead. | |
1863 | Returns the difference between N and the number of skips actually | |
1864 | done." | |
1865 | (interactive "p") | |
1866 | (gnus-group-next-unread-group n t nil silent)) | |
1867 | ||
1868 | (defun gnus-group-next-unread-group (n &optional all level silent) | |
1869 | "Go to next N'th unread newsgroup. | |
1870 | If N is negative, search backward instead. | |
1871 | If ALL is non-nil, choose any newsgroup, unread or not. | |
1872 | If LEVEL is non-nil, choose the next group with level LEVEL, or, if no | |
1873 | such group can be found, the next group with a level higher than | |
1874 | LEVEL. | |
1875 | Returns the difference between N and the number of skips actually | |
1876 | made." | |
1877 | (interactive "p") | |
1878 | (let ((backward (< n 0)) | |
1879 | (n (abs n))) | |
1880 | (while (and (> n 0) | |
1881 | (gnus-group-search-forward | |
1882 | backward (or (not gnus-group-goto-unread) all) level)) | |
1883 | (setq n (1- n))) | |
1884 | (when (and (/= 0 n) | |
1885 | (not silent)) | |
1886 | (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread") | |
1887 | (if level " on this level or higher" ""))) | |
1888 | n)) | |
1889 | ||
1890 | (defun gnus-group-prev-group (n) | |
1891 | "Go to previous N'th newsgroup. | |
1892 | Returns the difference between N and the number of skips actually | |
1893 | done." | |
1894 | (interactive "p") | |
1895 | (gnus-group-next-unread-group (- n) t)) | |
1896 | ||
1897 | (defun gnus-group-prev-unread-group (n) | |
1898 | "Go to previous N'th unread newsgroup. | |
1899 | Returns the difference between N and the number of skips actually | |
1900 | done." | |
1901 | (interactive "p") | |
1902 | (gnus-group-next-unread-group (- n))) | |
1903 | ||
1904 | (defun gnus-group-next-unread-group-same-level (n) | |
1905 | "Go to next N'th unread newsgroup on the same level. | |
1906 | If N is negative, search backward instead. | |
1907 | Returns the difference between N and the number of skips actually | |
1908 | done." | |
1909 | (interactive "p") | |
1910 | (gnus-group-next-unread-group n t (gnus-group-group-level)) | |
1911 | (gnus-group-position-point)) | |
1912 | ||
1913 | (defun gnus-group-prev-unread-group-same-level (n) | |
1914 | "Go to next N'th unread newsgroup on the same level. | |
1915 | Returns the difference between N and the number of skips actually | |
1916 | done." | |
1917 | (interactive "p") | |
1918 | (gnus-group-next-unread-group (- n) t (gnus-group-group-level)) | |
1919 | (gnus-group-position-point)) | |
1920 | ||
1921 | (defun gnus-group-best-unread-group (&optional exclude-group) | |
1922 | "Go to the group with the highest level. | |
1923 | If EXCLUDE-GROUP, do not go to that group." | |
1924 | (interactive) | |
1925 | (goto-char (point-min)) | |
1926 | (let ((best 100000) | |
1927 | unread best-point) | |
1928 | (while (not (eobp)) | |
1929 | (setq unread (get-text-property (point) 'gnus-unread)) | |
1930 | (when (and (numberp unread) (> unread 0)) | |
1931 | (when (and (get-text-property (point) 'gnus-level) | |
1932 | (< (get-text-property (point) 'gnus-level) best) | |
1933 | (or (not exclude-group) | |
1934 | (not (equal exclude-group (gnus-group-group-name))))) | |
1935 | (setq best (get-text-property (point) 'gnus-level)) | |
1936 | (setq best-point (point)))) | |
1937 | (forward-line 1)) | |
1938 | (when best-point | |
1939 | (goto-char best-point)) | |
1940 | (gnus-summary-position-point) | |
1941 | (and best-point (gnus-group-group-name)))) | |
1942 | ||
1943 | (defun gnus-group-first-unread-group () | |
1944 | "Go to the first group with unread articles." | |
1945 | (interactive) | |
1946 | (prog1 | |
1947 | (let ((opoint (point)) | |
1948 | unread) | |
1949 | (goto-char (point-min)) | |
1950 | (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active. | |
1951 | (and (numberp unread) ; Not a topic. | |
1952 | (not (zerop unread))) ; Has unread articles. | |
1953 | (zerop (gnus-group-next-unread-group 1))) ; Next unread group. | |
1954 | (point) ; Success. | |
1955 | (goto-char opoint) | |
1956 | nil)) ; Not success. | |
1957 | (gnus-group-position-point))) | |
1958 | ||
1959 | (defun gnus-group-enter-server-mode () | |
1960 | "Jump to the server buffer." | |
1961 | (interactive) | |
1962 | (gnus-enter-server-buffer)) | |
1963 | ||
1964 | (defun gnus-group-make-group (name &optional method address args) | |
1965 | "Add a new newsgroup. | |
1966 | The user will be prompted for a NAME, for a select METHOD, and an | |
1967 | ADDRESS." | |
1968 | (interactive | |
1969 | (list | |
1970 | (gnus-read-group "Group name: ") | |
1971 | (gnus-read-method "From method: "))) | |
1972 | ||
6748645f | 1973 | (when (stringp method) |
16409b0b GM |
1974 | (setq method (or (gnus-server-to-method method) method))) |
1975 | (let* ((meth (gnus-method-simplify | |
1976 | (when (and method | |
1977 | (not (gnus-server-equal method gnus-select-method))) | |
1978 | (if address (list (intern method) address) | |
1979 | method)))) | |
eec82323 LMI |
1980 | (nname (if method (gnus-group-prefixed-name name meth) name)) |
1981 | backend info) | |
1982 | (when (gnus-gethash nname gnus-newsrc-hashtb) | |
1983 | (error "Group %s already exists" nname)) | |
1984 | ;; Subscribe to the new group. | |
1985 | (gnus-group-change-level | |
1986 | (setq info (list t nname gnus-level-default-subscribed nil nil meth)) | |
1987 | gnus-level-default-subscribed gnus-level-killed | |
1988 | (and (gnus-group-group-name) | |
1989 | (gnus-gethash (gnus-group-group-name) | |
1990 | gnus-newsrc-hashtb)) | |
1991 | t) | |
1992 | ;; Make it active. | |
1993 | (gnus-set-active nname (cons 1 0)) | |
1994 | (unless (gnus-ephemeral-group-p name) | |
1995 | (gnus-dribble-enter | |
1996 | (concat "(gnus-group-set-info '" | |
1997 | (gnus-prin1-to-string (cdr info)) ")"))) | |
1998 | ;; Insert the line. | |
1999 | (gnus-group-insert-group-line-info nname) | |
2000 | (forward-line -1) | |
2001 | (gnus-group-position-point) | |
2002 | ||
2003 | ;; Load the backend and try to make the backend create | |
2004 | ;; the group as well. | |
2005 | (when (assoc (symbol-name (setq backend (car (gnus-server-get-method | |
2006 | nil meth)))) | |
2007 | gnus-valid-select-methods) | |
2008 | (require backend)) | |
2009 | (gnus-check-server meth) | |
2010 | (when (gnus-check-backend-function 'request-create-group nname) | |
2011 | (gnus-request-create-group nname nil args)) | |
2012 | t)) | |
2013 | ||
16409b0b GM |
2014 | (defun gnus-group-delete-groups (&optional arg) |
2015 | "Delete the current group. Only meaningful with editable groups." | |
2016 | (interactive "P") | |
2017 | (let ((n (length (gnus-group-process-prefix arg)))) | |
2018 | (when (gnus-yes-or-no-p | |
2019 | (if (= n 1) | |
2020 | "Delete this 1 group? " | |
2021 | (format "Delete these %d groups? " n))) | |
2022 | (gnus-group-iterate arg | |
2023 | (lambda (group) | |
2024 | (gnus-group-delete-group group nil t)))))) | |
2025 | ||
2026 | (defun gnus-group-delete-group (group &optional force no-prompt) | |
2027 | "Delete the current group. Only meaningful with editable groups. | |
eec82323 LMI |
2028 | If FORCE (the prefix) is non-nil, all the articles in the group will |
2029 | be deleted. This is \"deleted\" as in \"removed forever from the face | |
2030 | of the Earth\". There is no undo. The user will be prompted before | |
2031 | doing the deletion." | |
2032 | (interactive | |
2033 | (list (gnus-group-group-name) | |
2034 | current-prefix-arg)) | |
2035 | (unless group | |
2036 | (error "No group to rename")) | |
2037 | (unless (gnus-check-backend-function 'request-delete-group group) | |
2038 | (error "This backend does not support group deletion")) | |
2039 | (prog1 | |
16409b0b GM |
2040 | (if (and (not no-prompt) |
2041 | (not (gnus-yes-or-no-p | |
2042 | (format | |
2043 | "Do you really want to delete %s%s? " | |
2044 | group (if force " and all its contents" ""))))) | |
eec82323 LMI |
2045 | () ; Whew! |
2046 | (gnus-message 6 "Deleting group %s..." group) | |
2047 | (if (not (gnus-request-delete-group group force)) | |
2048 | (gnus-error 3 "Couldn't delete group %s" group) | |
2049 | (gnus-message 6 "Deleting group %s...done" group) | |
2050 | (gnus-group-goto-group group) | |
2051 | (gnus-group-kill-group 1 t) | |
2052 | (gnus-sethash group nil gnus-active-hashtb) | |
2053 | t)) | |
2054 | (gnus-group-position-point))) | |
2055 | ||
2056 | (defun gnus-group-rename-group (group new-name) | |
2057 | "Rename group from GROUP to NEW-NAME. | |
2058 | When used interactively, GROUP is the group under point | |
2059 | and NEW-NAME will be prompted for." | |
2060 | (interactive | |
2061 | (list | |
2062 | (gnus-group-group-name) | |
2063 | (progn | |
2064 | (unless (gnus-check-backend-function | |
2065 | 'request-rename-group (gnus-group-group-name)) | |
2066 | (error "This backend does not support renaming groups")) | |
2067 | (gnus-read-group "Rename group to: " | |
2068 | (gnus-group-real-name (gnus-group-group-name)))))) | |
2069 | ||
2070 | (unless (gnus-check-backend-function 'request-rename-group group) | |
2071 | (error "This backend does not support renaming groups")) | |
2072 | (unless group | |
2073 | (error "No group to rename")) | |
2074 | (when (equal (gnus-group-real-name group) new-name) | |
2075 | (error "Can't rename to the same name")) | |
2076 | ||
2077 | ;; We find the proper prefixed name. | |
2078 | (setq new-name | |
2079 | (if (gnus-group-native-p group) | |
2080 | ;; Native group. | |
2081 | new-name | |
2082 | ;; Foreign group. | |
2083 | (gnus-group-prefixed-name | |
2084 | (gnus-group-real-name new-name) | |
2085 | (gnus-info-method (gnus-get-info group))))) | |
2086 | ||
2087 | (gnus-message 6 "Renaming group %s to %s..." group new-name) | |
2088 | (prog1 | |
8b93df01 DL |
2089 | (if (progn |
2090 | (gnus-group-goto-group group) | |
2091 | (not (when (< (gnus-group-group-level) gnus-level-zombie) | |
2092 | (gnus-request-rename-group group new-name)))) | |
eec82323 LMI |
2093 | (gnus-error 3 "Couldn't rename group %s to %s" group new-name) |
2094 | ;; We rename the group internally by killing it... | |
eec82323 LMI |
2095 | (gnus-group-kill-group) |
2096 | ;; ... changing its name ... | |
2097 | (setcar (cdar gnus-list-of-killed-groups) new-name) | |
2098 | ;; ... and then yanking it. Magic! | |
2099 | (gnus-group-yank-group) | |
2100 | (gnus-set-active new-name (gnus-active group)) | |
2101 | (gnus-message 6 "Renaming group %s to %s...done" group new-name) | |
2102 | new-name) | |
6748645f LMI |
2103 | (setq gnus-killed-list (delete group gnus-killed-list)) |
2104 | (gnus-set-active group nil) | |
2105 | (gnus-dribble-touch) | |
eec82323 LMI |
2106 | (gnus-group-position-point))) |
2107 | ||
2108 | (defun gnus-group-edit-group (group &optional part) | |
2109 | "Edit the group on the current line." | |
2110 | (interactive (list (gnus-group-group-name))) | |
2111 | (let ((part (or part 'info)) | |
2112 | info) | |
2113 | (unless group | |
2114 | (error "No group on current line")) | |
2115 | (unless (setq info (gnus-get-info group)) | |
2116 | (error "Killed group; can't be edited")) | |
2117 | (ignore-errors | |
2118 | (gnus-close-group group)) | |
2119 | (gnus-edit-form | |
2120 | ;; Find the proper form to edit. | |
2121 | (cond ((eq part 'method) | |
2122 | (or (gnus-info-method info) "native")) | |
2123 | ((eq part 'params) | |
2124 | (gnus-info-params info)) | |
2125 | (t info)) | |
2126 | ;; The proper documentation. | |
2127 | (format | |
2128 | "Editing the %s for `%s'." | |
2129 | (cond | |
2130 | ((eq part 'method) "select method") | |
2131 | ((eq part 'params) "group parameters") | |
2132 | (t "group info")) | |
16409b0b | 2133 | (gnus-group-decoded-name group)) |
eec82323 LMI |
2134 | `(lambda (form) |
2135 | (gnus-group-edit-group-done ',part ,group form))))) | |
2136 | ||
2137 | (defun gnus-group-edit-group-method (group) | |
2138 | "Edit the select method of GROUP." | |
2139 | (interactive (list (gnus-group-group-name))) | |
2140 | (gnus-group-edit-group group 'method)) | |
2141 | ||
2142 | (defun gnus-group-edit-group-parameters (group) | |
2143 | "Edit the group parameters of GROUP." | |
2144 | (interactive (list (gnus-group-group-name))) | |
2145 | (gnus-group-edit-group group 'params)) | |
2146 | ||
2147 | (defun gnus-group-edit-group-done (part group form) | |
2148 | "Update variables." | |
2149 | (let* ((method (cond ((eq part 'info) (nth 4 form)) | |
2150 | ((eq part 'method) form) | |
2151 | (t nil))) | |
2152 | (info (cond ((eq part 'info) form) | |
2153 | ((eq part 'method) (gnus-get-info group)) | |
2154 | (t nil))) | |
2155 | (new-group (if info | |
2156 | (if (or (not method) | |
2157 | (gnus-server-equal | |
2158 | gnus-select-method method)) | |
2159 | (gnus-group-real-name (car info)) | |
2160 | (gnus-group-prefixed-name | |
2161 | (gnus-group-real-name (car info)) method)) | |
2162 | nil))) | |
2163 | (when (and new-group | |
2164 | (not (equal new-group group))) | |
2165 | (when (gnus-group-goto-group group) | |
2166 | (gnus-group-kill-group 1)) | |
2167 | (gnus-activate-group new-group)) | |
2168 | ;; Set the info. | |
2169 | (if (not (and info new-group)) | |
2170 | (gnus-group-set-info form (or new-group group) part) | |
2171 | (setq info (gnus-copy-sequence info)) | |
2172 | (setcar info new-group) | |
2173 | (unless (gnus-server-equal method "native") | |
2174 | (unless (nthcdr 3 info) | |
2175 | (nconc info (list nil nil))) | |
2176 | (unless (nthcdr 4 info) | |
2177 | (nconc info (list nil))) | |
2178 | (gnus-info-set-method info method)) | |
2179 | (gnus-group-set-info info)) | |
2180 | (gnus-group-update-group (or new-group group)) | |
2181 | (gnus-group-position-point))) | |
2182 | ||
2183 | (defun gnus-group-make-useful-group (group method) | |
6748645f | 2184 | "Create one of the groups described in `gnus-useful-groups'." |
eec82323 LMI |
2185 | (interactive |
2186 | (let ((entry (assoc (completing-read "Create group: " gnus-useful-groups | |
2187 | nil t) | |
2188 | gnus-useful-groups))) | |
a8151ef7 | 2189 | (list (cadr entry) (caddr entry)))) |
eec82323 LMI |
2190 | (setq method (gnus-copy-sequence method)) |
2191 | (let (entry) | |
2192 | (while (setq entry (memq (assq 'eval method) method)) | |
2193 | (setcar entry (eval (cadar entry))))) | |
2194 | (gnus-group-make-group group method)) | |
2195 | ||
2196 | (defun gnus-group-make-help-group () | |
2197 | "Create the Gnus documentation group." | |
2198 | (interactive) | |
2199 | (let ((name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help"))) | |
6748645f | 2200 | (file (nnheader-find-etc-directory "gnus-tut.txt" t))) |
eec82323 LMI |
2201 | (when (gnus-gethash name gnus-newsrc-hashtb) |
2202 | (error "Documentation group already exists")) | |
2203 | (if (not file) | |
2204 | (gnus-message 1 "Couldn't find doc group") | |
2205 | (gnus-group-make-group | |
2206 | (gnus-group-real-name name) | |
2207 | (list 'nndoc "gnus-help" | |
2208 | (list 'nndoc-address file) | |
2209 | (list 'nndoc-article-type 'mbox))))) | |
2210 | (gnus-group-position-point)) | |
2211 | ||
2212 | (defun gnus-group-make-doc-group (file type) | |
2213 | "Create a group that uses a single file as the source." | |
2214 | (interactive | |
2215 | (list (read-file-name "File name: ") | |
2216 | (and current-prefix-arg 'ask))) | |
2217 | (when (eq type 'ask) | |
2218 | (let ((err "") | |
2219 | char found) | |
2220 | (while (not found) | |
2221 | (message | |
2222 | "%sFile type (mbox, babyl, digest, forward, mmdf, guess) [mbdfag]: " | |
2223 | err) | |
2224 | (setq found (cond ((= (setq char (read-char)) ?m) 'mbox) | |
2225 | ((= char ?b) 'babyl) | |
2226 | ((= char ?d) 'digest) | |
2227 | ((= char ?f) 'forward) | |
2228 | ((= char ?a) 'mmfd) | |
16409b0b | 2229 | ((= char ?g) 'guess) |
eec82323 LMI |
2230 | (t (setq err (format "%c unknown. " char)) |
2231 | nil)))) | |
2232 | (setq type found))) | |
2233 | (let* ((file (expand-file-name file)) | |
2234 | (name (gnus-generate-new-group-name | |
2235 | (gnus-group-prefixed-name | |
2236 | (file-name-nondirectory file) '(nndoc ""))))) | |
2237 | (gnus-group-make-group | |
2238 | (gnus-group-real-name name) | |
2239 | (list 'nndoc file | |
2240 | (list 'nndoc-address file) | |
2241 | (list 'nndoc-article-type (or type 'guess)))))) | |
2242 | ||
2243 | (defvar nnweb-type-definition) | |
2244 | (defvar gnus-group-web-type-history nil) | |
2245 | (defvar gnus-group-web-search-history nil) | |
2246 | (defun gnus-group-make-web-group (&optional solid) | |
2247 | "Create an ephemeral nnweb group. | |
2248 | If SOLID (the prefix), create a solid group." | |
2249 | (interactive "P") | |
2250 | (require 'nnweb) | |
2251 | (let* ((group | |
2252 | (if solid (gnus-read-group "Group name: ") | |
2253 | (message-unique-id))) | |
a8151ef7 LMI |
2254 | (default-type (or (car gnus-group-web-type-history) |
2255 | (symbol-name (caar nnweb-type-definition)))) | |
eec82323 | 2256 | (type |
a8151ef7 LMI |
2257 | (gnus-string-or |
2258 | (completing-read | |
2259 | (format "Search engine type (default %s): " default-type) | |
2260 | (mapcar (lambda (elem) (list (symbol-name (car elem)))) | |
2261 | nnweb-type-definition) | |
2262 | nil t nil 'gnus-group-web-type-history) | |
2263 | default-type)) | |
eec82323 LMI |
2264 | (search |
2265 | (read-string | |
2266 | "Search string: " | |
2267 | (cons (or (car gnus-group-web-search-history) "") 0) | |
2268 | 'gnus-group-web-search-history)) | |
2269 | (method | |
2270 | `(nnweb ,group (nnweb-search ,search) | |
2271 | (nnweb-type ,(intern type)) | |
2272 | (nnweb-ephemeral-p t)))) | |
2273 | (if solid | |
2274 | (gnus-group-make-group group "nnweb" "" `(,(intern type) ,search)) | |
2275 | (gnus-group-read-ephemeral-group | |
2276 | group method t | |
2277 | (cons (current-buffer) | |
2278 | (if (eq major-mode 'gnus-summary-mode) 'summary 'group)))))) | |
2279 | ||
16409b0b GM |
2280 | (defvar nnwarchive-type-definition) |
2281 | (defvar gnus-group-warchive-type-history nil) | |
2282 | (defvar gnus-group-warchive-login-history nil) | |
2283 | (defvar gnus-group-warchive-address-history nil) | |
2284 | ||
2285 | (defun gnus-group-make-warchive-group () | |
2286 | "Create a nnwarchive group." | |
2287 | (interactive) | |
2288 | (require 'nnwarchive) | |
2289 | (let* ((group (gnus-read-group "Group name: ")) | |
2290 | (default-type (or (car gnus-group-warchive-type-history) | |
2291 | (symbol-name (caar nnwarchive-type-definition)))) | |
2292 | (type | |
2293 | (gnus-string-or | |
2294 | (completing-read | |
2295 | (format "Warchive type (default %s): " default-type) | |
2296 | (mapcar (lambda (elem) (list (symbol-name (car elem)))) | |
2297 | nnwarchive-type-definition) | |
2298 | nil t nil 'gnus-group-warchive-type-history) | |
2299 | default-type)) | |
2300 | (address (read-string "Warchive address: " | |
2301 | nil 'gnus-group-warchive-address-history)) | |
2302 | (default-login (or (car gnus-group-warchive-login-history) | |
2303 | user-mail-address)) | |
2304 | (login | |
2305 | (gnus-string-or | |
2306 | (read-string | |
2307 | (format "Warchive login (default %s): " user-mail-address) | |
2308 | default-login 'gnus-group-warchive-login-history) | |
2309 | user-mail-address)) | |
2310 | (method | |
a1506d29 | 2311 | `(nnwarchive ,address |
16409b0b GM |
2312 | (nnwarchive-type ,(intern type)) |
2313 | (nnwarchive-login ,login)))) | |
2314 | (gnus-group-make-group group method))) | |
2315 | ||
eec82323 LMI |
2316 | (defun gnus-group-make-archive-group (&optional all) |
2317 | "Create the (ding) Gnus archive group of the most recent articles. | |
2318 | Given a prefix, create a full group." | |
2319 | (interactive "P") | |
2320 | (let ((group (gnus-group-prefixed-name | |
2321 | (if all "ding.archives" "ding.recent") '(nndir "")))) | |
2322 | (when (gnus-gethash group gnus-newsrc-hashtb) | |
2323 | (error "Archive group already exists")) | |
2324 | (gnus-group-make-group | |
2325 | (gnus-group-real-name group) | |
2326 | (list 'nndir (if all "hpc" "edu") | |
2327 | (list 'nndir-directory | |
2328 | (if all gnus-group-archive-directory | |
2329 | gnus-group-recent-archive-directory)))) | |
2330 | (gnus-group-add-parameter group (cons 'to-address "ding@gnus.org")))) | |
2331 | ||
2332 | (defun gnus-group-make-directory-group (dir) | |
2333 | "Create an nndir group. | |
2334 | The user will be prompted for a directory. The contents of this | |
2335 | directory will be used as a newsgroup. The directory should contain | |
2336 | mail messages or news articles in files that have numeric names." | |
2337 | (interactive | |
2338 | (list (read-file-name "Create group from directory: "))) | |
2339 | (unless (file-exists-p dir) | |
2340 | (error "No such directory")) | |
2341 | (unless (file-directory-p dir) | |
2342 | (error "Not a directory")) | |
2343 | (let ((ext "") | |
2344 | (i 0) | |
2345 | group) | |
2346 | (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb)) | |
2347 | (setq group | |
2348 | (gnus-group-prefixed-name | |
c6e7b580 | 2349 | (expand-file-name ext dir) |
eec82323 LMI |
2350 | '(nndir ""))) |
2351 | (setq ext (format "<%d>" (setq i (1+ i))))) | |
2352 | (gnus-group-make-group | |
2353 | (gnus-group-real-name group) | |
2354 | (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir))))) | |
2355 | ||
5002cc5c | 2356 | (eval-when-compile (defvar nnkiboze-score-file)) |
eec82323 LMI |
2357 | (defun gnus-group-make-kiboze-group (group address scores) |
2358 | "Create an nnkiboze group. | |
2359 | The user will be prompted for a name, a regexp to match groups, and | |
2360 | score file entries for articles to include in the group." | |
2361 | (interactive | |
2362 | (list | |
2363 | (read-string "nnkiboze group name: ") | |
2364 | (read-string "Source groups (regexp): ") | |
2365 | (let ((headers (mapcar (lambda (group) (list group)) | |
2366 | '("subject" "from" "number" "date" "message-id" | |
2367 | "references" "chars" "lines" "xref" | |
2368 | "followup" "all" "body" "head"))) | |
2369 | scores header regexp regexps) | |
2370 | (while (not (equal "" (setq header (completing-read | |
2371 | "Match on header: " headers nil t)))) | |
2372 | (setq regexps nil) | |
2373 | (while (not (equal "" (setq regexp (read-string | |
2491844d | 2374 | (format "Match on %s (regexp): " |
eec82323 LMI |
2375 | header))))) |
2376 | (push (list regexp nil nil 'r) regexps)) | |
2377 | (push (cons header regexps) scores)) | |
2378 | scores))) | |
2379 | (gnus-group-make-group group "nnkiboze" address) | |
2491844d DL |
2380 | (let* ((nnkiboze-current-group group) |
2381 | (score-file (car (nnkiboze-score-file ""))) | |
8b93df01 DL |
2382 | (score-dir (file-name-directory score-file))) |
2383 | (unless (file-exists-p score-dir) | |
2384 | (make-directory score-dir)) | |
2385 | (with-temp-file score-file | |
2386 | (let (emacs-lisp-mode-hook) | |
2387 | (pp scores (current-buffer)))))) | |
eec82323 LMI |
2388 | |
2389 | (defun gnus-group-add-to-virtual (n vgroup) | |
2390 | "Add the current group to a virtual group." | |
2391 | (interactive | |
2392 | (list current-prefix-arg | |
2393 | (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t | |
2394 | "nnvirtual:"))) | |
2395 | (unless (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual) | |
2396 | (error "%s is not an nnvirtual group" vgroup)) | |
2397 | (gnus-close-group vgroup) | |
2398 | (let* ((groups (gnus-group-process-prefix n)) | |
2399 | (method (gnus-info-method (gnus-get-info vgroup)))) | |
2400 | (setcar (cdr method) | |
2401 | (concat | |
2402 | (nth 1 method) "\\|" | |
2403 | (mapconcat | |
2404 | (lambda (s) | |
2405 | (gnus-group-remove-mark s) | |
2406 | (concat "\\(^" (regexp-quote s) "$\\)")) | |
2407 | groups "\\|")))) | |
2408 | (gnus-group-position-point)) | |
2409 | ||
2410 | (defun gnus-group-make-empty-virtual (group) | |
2411 | "Create a new, fresh, empty virtual group." | |
2412 | (interactive "sCreate new, empty virtual group: ") | |
2413 | (let* ((method (list 'nnvirtual "^$")) | |
2414 | (pgroup (gnus-group-prefixed-name group method))) | |
2415 | ;; Check whether it exists already. | |
2416 | (when (gnus-gethash pgroup gnus-newsrc-hashtb) | |
a8151ef7 | 2417 | (error "Group %s already exists" pgroup)) |
eec82323 LMI |
2418 | ;; Subscribe the new group after the group on the current line. |
2419 | (gnus-subscribe-group pgroup (gnus-group-group-name) method) | |
2420 | (gnus-group-update-group pgroup) | |
2421 | (forward-line -1) | |
2422 | (gnus-group-position-point))) | |
2423 | ||
2424 | (defun gnus-group-enter-directory (dir) | |
2425 | "Enter an ephemeral nneething group." | |
2426 | (interactive "DDirectory to read: ") | |
2427 | (let* ((method (list 'nneething dir '(nneething-read-only t))) | |
2428 | (leaf (gnus-group-prefixed-name | |
2429 | (file-name-nondirectory (directory-file-name dir)) | |
2430 | method)) | |
2431 | (name (gnus-generate-new-group-name leaf))) | |
2432 | (unless (gnus-group-read-ephemeral-group | |
2433 | name method t | |
2434 | (cons (current-buffer) | |
2435 | (if (eq major-mode 'gnus-summary-mode) | |
2436 | 'summary 'group))) | |
2437 | (error "Couldn't enter %s" dir)))) | |
2438 | ||
16409b0b GM |
2439 | (eval-and-compile |
2440 | (autoload 'nnimap-expunge "nnimap") | |
2441 | (autoload 'nnimap-acl-get "nnimap") | |
2442 | (autoload 'nnimap-acl-edit "nnimap")) | |
2443 | ||
2444 | (defun gnus-group-nnimap-expunge (group) | |
2445 | "Expunge deleted articles in current nnimap GROUP." | |
2446 | (interactive (list (gnus-group-group-name))) | |
2447 | (let ((mailbox (gnus-group-real-name group)) method) | |
2448 | (unless group | |
2449 | (error "No group on current line")) | |
2450 | (unless (gnus-get-info group) | |
2451 | (error "Killed group; can't be edited")) | |
2452 | (unless (eq 'nnimap (car (setq method (gnus-find-method-for-group group)))) | |
2453 | (error "%s is not an nnimap group" group)) | |
2454 | (nnimap-expunge mailbox (cadr method)))) | |
2455 | ||
2456 | (defun gnus-group-nnimap-edit-acl (group) | |
2457 | "Edit the Access Control List of current nnimap GROUP." | |
2458 | (interactive (list (gnus-group-group-name))) | |
2459 | (let ((mailbox (gnus-group-real-name group)) method acl) | |
2460 | (unless group | |
2461 | (error "No group on current line")) | |
2462 | (unless (gnus-get-info group) | |
2463 | (error "Killed group; can't be edited")) | |
2464 | (unless (eq (car (setq method (gnus-find-method-for-group group))) 'nnimap) | |
2465 | (error "%s is not an nnimap group" group)) | |
2491844d DL |
2466 | (unless (setq acl (nnimap-acl-get mailbox (cadr method))) |
2467 | (error "Server does not support ACL's")) | |
2468 | (gnus-edit-form acl (format "Editing the access control list for `%s'. | |
16409b0b GM |
2469 | |
2470 | An access control list is a list of (identifier . rights) elements. | |
2471 | ||
2472 | The identifier string specifies the corresponding user. The | |
2473 | identifier \"anyone\" is reserved to refer to the universal identity. | |
2474 | ||
2475 | Rights is a string listing a (possibly empty) set of alphanumeric | |
2476 | characters, each character listing a set of operations which is being | |
2477 | controlled. Letters are reserved for ``standard'' rights, listed | |
2478 | below. Digits are reserved for implementation or site defined rights. | |
2479 | ||
2480 | l - lookup (mailbox is visible to LIST/LSUB commands) | |
2481 | r - read (SELECT the mailbox, perform CHECK, FETCH, PARTIAL, | |
2482 | SEARCH, COPY from mailbox) | |
2483 | s - keep seen/unseen information across sessions (STORE \\SEEN flag) | |
2484 | w - write (STORE flags other than \\SEEN and \\DELETED) | |
2485 | i - insert (perform APPEND, COPY into mailbox) | |
2486 | p - post (send mail to submission address for mailbox, | |
2487 | not enforced by IMAP4 itself) | |
2488 | c - create and delete mailbox (CREATE new sub-mailboxes in any | |
2489 | implementation-defined hierarchy, RENAME or DELETE mailbox) | |
2490 | d - delete messages (STORE \\DELETED flag, perform EXPUNGE) | |
2491 | a - administer (perform SETACL)" group) | |
2492 | `(lambda (form) | |
2493 | (nnimap-acl-edit | |
2494 | ,mailbox ',method ',acl form))))) | |
2495 | ||
eec82323 LMI |
2496 | ;; Group sorting commands |
2497 | ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>. | |
2498 | ||
2499 | (defun gnus-group-sort-groups (func &optional reverse) | |
2500 | "Sort the group buffer according to FUNC. | |
2501 | When used interactively, the sorting function used will be | |
2502 | determined by the `gnus-group-sort-function' variable. | |
2503 | If REVERSE (the prefix), reverse the sorting order." | |
2504 | (interactive (list gnus-group-sort-function current-prefix-arg)) | |
2505 | (funcall gnus-group-sort-alist-function | |
2506 | (gnus-make-sort-function func) reverse) | |
2507 | (gnus-group-list-groups) | |
2508 | (gnus-dribble-touch)) | |
2509 | ||
2510 | (defun gnus-group-sort-flat (func reverse) | |
2511 | ;; We peel off the dummy group from the alist. | |
2512 | (when func | |
2513 | (when (equal (gnus-info-group (car gnus-newsrc-alist)) "dummy.group") | |
2514 | (pop gnus-newsrc-alist)) | |
2515 | ;; Do the sorting. | |
2516 | (setq gnus-newsrc-alist | |
2517 | (sort gnus-newsrc-alist func)) | |
2518 | (when reverse | |
2519 | (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))) | |
2520 | ;; Regenerate the hash table. | |
2521 | (gnus-make-hashtable-from-newsrc-alist))) | |
2522 | ||
2523 | (defun gnus-group-sort-groups-by-alphabet (&optional reverse) | |
2524 | "Sort the group buffer alphabetically by group name. | |
2525 | If REVERSE, sort in reverse order." | |
2526 | (interactive "P") | |
2527 | (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse)) | |
2528 | ||
2529 | (defun gnus-group-sort-groups-by-unread (&optional reverse) | |
2530 | "Sort the group buffer by number of unread articles. | |
2531 | If REVERSE, sort in reverse order." | |
2532 | (interactive "P") | |
2533 | (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse)) | |
2534 | ||
2535 | (defun gnus-group-sort-groups-by-level (&optional reverse) | |
2536 | "Sort the group buffer by group level. | |
2537 | If REVERSE, sort in reverse order." | |
2538 | (interactive "P") | |
2539 | (gnus-group-sort-groups 'gnus-group-sort-by-level reverse)) | |
2540 | ||
2541 | (defun gnus-group-sort-groups-by-score (&optional reverse) | |
2542 | "Sort the group buffer by group score. | |
2543 | If REVERSE, sort in reverse order." | |
2544 | (interactive "P") | |
2545 | (gnus-group-sort-groups 'gnus-group-sort-by-score reverse)) | |
2546 | ||
2547 | (defun gnus-group-sort-groups-by-rank (&optional reverse) | |
2548 | "Sort the group buffer by group rank. | |
2549 | If REVERSE, sort in reverse order." | |
2550 | (interactive "P") | |
2551 | (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse)) | |
2552 | ||
2553 | (defun gnus-group-sort-groups-by-method (&optional reverse) | |
2554 | "Sort the group buffer alphabetically by backend name. | |
2555 | If REVERSE, sort in reverse order." | |
2556 | (interactive "P") | |
2557 | (gnus-group-sort-groups 'gnus-group-sort-by-method reverse)) | |
2558 | ||
2559 | ;;; Selected group sorting. | |
2560 | ||
2561 | (defun gnus-group-sort-selected-groups (n func &optional reverse) | |
2562 | "Sort the process/prefixed groups." | |
2563 | (interactive (list current-prefix-arg gnus-group-sort-function)) | |
2564 | (let ((groups (gnus-group-process-prefix n))) | |
2565 | (funcall gnus-group-sort-selected-function | |
2566 | groups (gnus-make-sort-function func) reverse) | |
2567 | (gnus-group-list-groups))) | |
2568 | ||
2569 | (defun gnus-group-sort-selected-flat (groups func reverse) | |
2570 | (let (entries infos) | |
2571 | ;; First find all the group entries for these groups. | |
2572 | (while groups | |
2573 | (push (nthcdr 2 (gnus-gethash (pop groups) gnus-newsrc-hashtb)) | |
2574 | entries)) | |
2575 | ;; Then sort the infos. | |
2576 | (setq infos | |
2577 | (sort | |
2578 | (mapcar | |
2579 | (lambda (entry) (car entry)) | |
2580 | (setq entries (nreverse entries))) | |
2581 | func)) | |
2582 | (when reverse | |
2583 | (setq infos (nreverse infos))) | |
2584 | ;; Go through all the infos and replace the old entries | |
2585 | ;; with the new infos. | |
2586 | (while infos | |
16409b0b | 2587 | (setcar (car entries) (pop infos)) |
eec82323 LMI |
2588 | (pop entries)) |
2589 | ;; Update the hashtable. | |
2590 | (gnus-make-hashtable-from-newsrc-alist))) | |
2591 | ||
16409b0b | 2592 | (defun gnus-group-sort-selected-groups-by-alphabet (&optional n reverse) |
eec82323 | 2593 | "Sort the group buffer alphabetically by group name. |
16409b0b GM |
2594 | Obeys the process/prefix convention. If REVERSE (the symbolic prefix), |
2595 | sort in reverse order." | |
2596 | (interactive (gnus-interactive "P\ny")) | |
2597 | (gnus-group-sort-selected-groups n 'gnus-group-sort-by-alphabet reverse)) | |
eec82323 | 2598 | |
16409b0b | 2599 | (defun gnus-group-sort-selected-groups-by-unread (&optional n reverse) |
eec82323 | 2600 | "Sort the group buffer by number of unread articles. |
16409b0b GM |
2601 | Obeys the process/prefix convention. If REVERSE (the symbolic prefix), |
2602 | sort in reverse order." | |
2603 | (interactive (gnus-interactive "P\ny")) | |
2604 | (gnus-group-sort-selected-groups n 'gnus-group-sort-by-unread reverse)) | |
eec82323 | 2605 | |
16409b0b | 2606 | (defun gnus-group-sort-selected-groups-by-level (&optional n reverse) |
eec82323 | 2607 | "Sort the group buffer by group level. |
16409b0b GM |
2608 | Obeys the process/prefix convention. If REVERSE (the symbolic prefix), |
2609 | sort in reverse order." | |
2610 | (interactive (gnus-interactive "P\ny")) | |
2611 | (gnus-group-sort-selected-groups n 'gnus-group-sort-by-level reverse)) | |
eec82323 | 2612 | |
16409b0b | 2613 | (defun gnus-group-sort-selected-groups-by-score (&optional n reverse) |
eec82323 | 2614 | "Sort the group buffer by group score. |
16409b0b GM |
2615 | Obeys the process/prefix convention. If REVERSE (the symbolic prefix), |
2616 | sort in reverse order." | |
2617 | (interactive (gnus-interactive "P\ny")) | |
2618 | (gnus-group-sort-selected-groups n 'gnus-group-sort-by-score reverse)) | |
eec82323 | 2619 | |
16409b0b | 2620 | (defun gnus-group-sort-selected-groups-by-rank (&optional n reverse) |
eec82323 | 2621 | "Sort the group buffer by group rank. |
16409b0b GM |
2622 | Obeys the process/prefix convention. If REVERSE (the symbolic prefix), |
2623 | sort in reverse order." | |
2624 | (interactive (gnus-interactive "P\ny")) | |
2625 | (gnus-group-sort-selected-groups n 'gnus-group-sort-by-rank reverse)) | |
eec82323 | 2626 | |
16409b0b | 2627 | (defun gnus-group-sort-selected-groups-by-method (&optional n reverse) |
eec82323 | 2628 | "Sort the group buffer alphabetically by backend name. |
16409b0b GM |
2629 | Obeys the process/prefix convention. If REVERSE (the symbolic prefix), |
2630 | sort in reverse order." | |
2631 | (interactive (gnus-interactive "P\ny")) | |
2632 | (gnus-group-sort-selected-groups n 'gnus-group-sort-by-method reverse)) | |
eec82323 LMI |
2633 | |
2634 | ;;; Sorting predicates. | |
2635 | ||
2636 | (defun gnus-group-sort-by-alphabet (info1 info2) | |
2637 | "Sort alphabetically." | |
2638 | (string< (gnus-info-group info1) (gnus-info-group info2))) | |
2639 | ||
2640 | (defun gnus-group-sort-by-real-name (info1 info2) | |
2641 | "Sort alphabetically on real (unprefixed) names." | |
2642 | (string< (gnus-group-real-name (gnus-info-group info1)) | |
2643 | (gnus-group-real-name (gnus-info-group info2)))) | |
2644 | ||
2645 | (defun gnus-group-sort-by-unread (info1 info2) | |
2646 | "Sort by number of unread articles." | |
2647 | (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb))) | |
2648 | (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb)))) | |
2649 | (< (or (and (numberp n1) n1) 0) | |
2650 | (or (and (numberp n2) n2) 0)))) | |
2651 | ||
2652 | (defun gnus-group-sort-by-level (info1 info2) | |
2653 | "Sort by level." | |
2654 | (< (gnus-info-level info1) (gnus-info-level info2))) | |
2655 | ||
2656 | (defun gnus-group-sort-by-method (info1 info2) | |
2657 | "Sort alphabetically by backend name." | |
2658 | (string< (symbol-name (car (gnus-find-method-for-group | |
2659 | (gnus-info-group info1) info1))) | |
2660 | (symbol-name (car (gnus-find-method-for-group | |
2661 | (gnus-info-group info2) info2))))) | |
2662 | ||
2663 | (defun gnus-group-sort-by-score (info1 info2) | |
2664 | "Sort by group score." | |
2665 | (< (gnus-info-score info1) (gnus-info-score info2))) | |
2666 | ||
2667 | (defun gnus-group-sort-by-rank (info1 info2) | |
2668 | "Sort by level and score." | |
2669 | (let ((level1 (gnus-info-level info1)) | |
2670 | (level2 (gnus-info-level info2))) | |
2671 | (or (< level1 level2) | |
2672 | (and (= level1 level2) | |
2673 | (> (gnus-info-score info1) (gnus-info-score info2)))))) | |
2674 | ||
2675 | ;;; Clearing data | |
2676 | ||
2677 | (defun gnus-group-clear-data (&optional arg) | |
2678 | "Clear all marks and read ranges from the current group." | |
2679 | (interactive "P") | |
2680 | (gnus-group-iterate arg | |
2681 | (lambda (group) | |
2682 | (let (info) | |
2683 | (gnus-info-clear-data (setq info (gnus-get-info group))) | |
2684 | (gnus-get-unread-articles-in-group info (gnus-active group) t) | |
2685 | (when (gnus-group-goto-group group) | |
2686 | (gnus-group-update-group-line)))))) | |
2687 | ||
2688 | (defun gnus-group-clear-data-on-native-groups () | |
2689 | "Clear all marks and read ranges from all native groups." | |
2690 | (interactive) | |
2691 | (when (gnus-yes-or-no-p "Really clear all data from almost all groups? ") | |
2692 | (let ((alist (cdr gnus-newsrc-alist)) | |
2693 | info) | |
2694 | (while (setq info (pop alist)) | |
2695 | (when (gnus-group-native-p (gnus-info-group info)) | |
2696 | (gnus-info-clear-data info))) | |
2697 | (gnus-get-unread-articles) | |
6748645f | 2698 | (gnus-dribble-touch) |
eec82323 LMI |
2699 | (when (gnus-y-or-n-p |
2700 | "Move the cache away to avoid problems in the future? ") | |
2701 | (call-interactively 'gnus-cache-move-cache))))) | |
2702 | ||
2703 | (defun gnus-info-clear-data (info) | |
2704 | "Clear all marks and read ranges from INFO." | |
2705 | (let ((group (gnus-info-group info))) | |
2706 | (gnus-undo-register | |
2707 | `(progn | |
2708 | (gnus-info-set-marks ',info ',(gnus-info-marks info) t) | |
2709 | (gnus-info-set-read ',info ',(gnus-info-read info)) | |
2710 | (when (gnus-group-goto-group ,group) | |
2711 | (gnus-group-update-group-line)))) | |
2712 | (gnus-info-set-read info nil) | |
2713 | (when (gnus-info-marks info) | |
2714 | (gnus-info-set-marks info nil)))) | |
2715 | ||
2716 | ;; Group catching up. | |
2717 | ||
2718 | (defun gnus-group-catchup-current (&optional n all) | |
16409b0b | 2719 | "Mark all unread articles in the current newsgroup as read. |
6748645f | 2720 | If prefix argument N is numeric, the next N newsgroups will be |
eec82323 LMI |
2721 | caught up. If ALL is non-nil, marked articles will also be marked as |
2722 | read. Cross references (Xref: header) of articles are ignored. | |
6748645f LMI |
2723 | The number of newsgroups that this function was unable to catch |
2724 | up is returned." | |
eec82323 | 2725 | (interactive "P") |
eec82323 | 2726 | (let ((groups (gnus-group-process-prefix n)) |
16409b0b GM |
2727 | (ret 0) |
2728 | group) | |
6748645f | 2729 | (unless groups (error "No groups selected")) |
eec82323 LMI |
2730 | (if (not |
2731 | (or (not gnus-interactive-catchup) ;Without confirmation? | |
2732 | gnus-expert-user | |
2733 | (gnus-y-or-n-p | |
2734 | (format | |
2735 | (if all | |
2736 | "Do you really want to mark all articles in %s as read? " | |
2737 | "Mark all unread articles in %s as read? ") | |
2738 | (if (= (length groups) 1) | |
2739 | (car groups) | |
2740 | (format "these %d groups" (length groups))))))) | |
2741 | n | |
16409b0b GM |
2742 | (while (setq group (pop groups)) |
2743 | (gnus-group-remove-mark group) | |
eec82323 | 2744 | ;; Virtual groups have to be given special treatment. |
16409b0b | 2745 | (let ((method (gnus-find-method-for-group group))) |
eec82323 LMI |
2746 | (when (eq 'nnvirtual (car method)) |
2747 | (nnvirtual-catchup-group | |
16409b0b GM |
2748 | (gnus-group-real-name group) (nth 1 method) all))) |
2749 | (if (>= (gnus-group-level group) gnus-level-zombie) | |
eec82323 LMI |
2750 | (gnus-message 2 "Dead groups can't be caught up") |
2751 | (if (prog1 | |
16409b0b GM |
2752 | (gnus-group-goto-group group) |
2753 | (gnus-group-catchup group all)) | |
eec82323 | 2754 | (gnus-group-update-group-line) |
16409b0b | 2755 | (setq ret (1+ ret))))) |
eec82323 LMI |
2756 | (gnus-group-next-unread-group 1) |
2757 | ret))) | |
2758 | ||
2759 | (defun gnus-group-catchup-current-all (&optional n) | |
2760 | "Mark all articles in current newsgroup as read. | |
2761 | Cross references (Xref: header) of articles are ignored." | |
2762 | (interactive "P") | |
2763 | (gnus-group-catchup-current n 'all)) | |
2764 | ||
2765 | (defun gnus-group-catchup (group &optional all) | |
2766 | "Mark all articles in GROUP as read. | |
2767 | If ALL is non-nil, all articles are marked as read. | |
2768 | The return value is the number of articles that were marked as read, | |
2769 | or nil if no action could be taken." | |
2770 | (let* ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
2771 | (num (car entry))) | |
16409b0b GM |
2772 | ;; Remove entries for this group. |
2773 | (nnmail-purge-split-history (gnus-group-real-name group)) | |
eec82323 LMI |
2774 | ;; Do the updating only if the newsgroup isn't killed. |
2775 | (if (not (numberp (car entry))) | |
2776 | (gnus-message 1 "Can't catch up %s; non-active group" group) | |
2777 | ;; Do auto-expirable marks if that's required. | |
2778 | (when (gnus-group-auto-expirable-p group) | |
2779 | (gnus-add-marked-articles | |
2780 | group 'expire (gnus-list-of-unread-articles group)) | |
2781 | (when all | |
2782 | (let ((marks (nth 3 (nth 2 entry)))) | |
2783 | (gnus-add-marked-articles | |
2784 | group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))) | |
2785 | (gnus-add-marked-articles | |
2786 | group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))))) | |
2787 | (when entry | |
2788 | (gnus-update-read-articles group nil) | |
2789 | ;; Also nix out the lists of marks and dormants. | |
2790 | (when all | |
2791 | (gnus-add-marked-articles group 'tick nil nil 'force) | |
2792 | (gnus-add-marked-articles group 'dormant nil nil 'force)) | |
2793 | (let ((gnus-newsgroup-name group)) | |
6748645f | 2794 | (gnus-run-hooks 'gnus-group-catchup-group-hook)) |
eec82323 LMI |
2795 | num)))) |
2796 | ||
2797 | (defun gnus-group-expire-articles (&optional n) | |
2798 | "Expire all expirable articles in the current newsgroup." | |
2799 | (interactive "P") | |
2800 | (let ((groups (gnus-group-process-prefix n)) | |
2801 | group) | |
2802 | (unless groups | |
2803 | (error "No groups to expire")) | |
2804 | (while (setq group (pop groups)) | |
2805 | (gnus-group-remove-mark group) | |
16409b0b | 2806 | (gnus-group-expire-articles-1 group) |
eec82323 LMI |
2807 | (gnus-dribble-touch) |
2808 | (gnus-group-position-point)))) | |
2809 | ||
16409b0b GM |
2810 | (defun gnus-group-expire-articles-1 (group) |
2811 | (when (gnus-check-backend-function 'request-expire-articles group) | |
2812 | (gnus-message 6 "Expiring articles in %s..." group) | |
2813 | (let* ((info (gnus-get-info group)) | |
2814 | (expirable (if (gnus-group-total-expirable-p group) | |
2815 | (cons nil (gnus-list-of-read-articles group)) | |
2816 | (assq 'expire (gnus-info-marks info)))) | |
2817 | (expiry-wait (gnus-group-find-parameter group 'expiry-wait)) | |
2818 | (nnmail-expiry-target | |
2819 | (or (gnus-group-find-parameter group 'expiry-target) | |
2820 | nnmail-expiry-target))) | |
2821 | (when expirable | |
2822 | (gnus-check-group group) | |
2823 | (setcdr | |
2824 | expirable | |
2825 | (gnus-compress-sequence | |
2826 | (if expiry-wait | |
2827 | ;; We set the expiry variables to the group | |
2828 | ;; parameter. | |
2829 | (let ((nnmail-expiry-wait-function nil) | |
2830 | (nnmail-expiry-wait expiry-wait)) | |
2831 | (gnus-request-expire-articles | |
2832 | (gnus-uncompress-sequence (cdr expirable)) group)) | |
2833 | ;; Just expire using the normal expiry values. | |
2834 | (gnus-request-expire-articles | |
2835 | (gnus-uncompress-sequence (cdr expirable)) group)))) | |
2836 | (gnus-close-group group)) | |
2837 | (gnus-message 6 "Expiring articles in %s...done" group) | |
2838 | ;; Return the list of un-expired articles. | |
2839 | (cdr expirable)))) | |
2840 | ||
eec82323 LMI |
2841 | (defun gnus-group-expire-all-groups () |
2842 | "Expire all expirable articles in all newsgroups." | |
2843 | (interactive) | |
2844 | (save-excursion | |
2845 | (gnus-message 5 "Expiring...") | |
2846 | (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info)) | |
2847 | (cdr gnus-newsrc-alist)))) | |
2848 | (gnus-group-expire-articles nil))) | |
2849 | (gnus-group-position-point) | |
2850 | (gnus-message 5 "Expiring...done")) | |
2851 | ||
2852 | (defun gnus-group-set-current-level (n level) | |
2853 | "Set the level of the next N groups to LEVEL." | |
2854 | (interactive | |
2855 | (list | |
2856 | current-prefix-arg | |
2857 | (string-to-int | |
2858 | (let ((s (read-string | |
2859 | (format "Level (default %s): " | |
2860 | (or (gnus-group-group-level) | |
2861 | gnus-level-default-subscribed))))) | |
2862 | (if (string-match "^\\s-*$" s) | |
2863 | (int-to-string (or (gnus-group-group-level) | |
2864 | gnus-level-default-subscribed)) | |
2865 | s))))) | |
2866 | (unless (and (>= level 1) (<= level gnus-level-killed)) | |
16409b0b | 2867 | (error "Invalid level: %d" level)) |
eec82323 LMI |
2868 | (let ((groups (gnus-group-process-prefix n)) |
2869 | group) | |
2870 | (while (setq group (pop groups)) | |
2871 | (gnus-group-remove-mark group) | |
2872 | (gnus-message 6 "Changed level of %s from %d to %d" | |
2873 | group (or (gnus-group-group-level) gnus-level-killed) | |
2874 | level) | |
2875 | (gnus-group-change-level | |
2876 | group level (or (gnus-group-group-level) gnus-level-killed)) | |
2877 | (gnus-group-update-group-line))) | |
2878 | (gnus-group-position-point)) | |
2879 | ||
2880 | (defun gnus-group-unsubscribe (&optional n) | |
2881 | "Unsubscribe the current group." | |
2882 | (interactive "P") | |
2883 | (gnus-group-unsubscribe-current-group n 'unsubscribe)) | |
2884 | ||
2885 | (defun gnus-group-subscribe (&optional n) | |
2886 | "Subscribe the current group." | |
2887 | (interactive "P") | |
2888 | (gnus-group-unsubscribe-current-group n 'subscribe)) | |
2889 | ||
2890 | (defun gnus-group-unsubscribe-current-group (&optional n do-sub) | |
2891 | "Toggle subscription of the current group. | |
2892 | If given numerical prefix, toggle the N next groups." | |
2893 | (interactive "P") | |
2894 | (let ((groups (gnus-group-process-prefix n)) | |
2895 | group) | |
2896 | (while groups | |
2897 | (setq group (car groups) | |
2898 | groups (cdr groups)) | |
2899 | (gnus-group-remove-mark group) | |
2900 | (gnus-group-unsubscribe-group | |
2901 | group | |
2902 | (cond | |
2903 | ((eq do-sub 'unsubscribe) | |
2904 | gnus-level-default-unsubscribed) | |
2905 | ((eq do-sub 'subscribe) | |
2906 | gnus-level-default-subscribed) | |
2907 | ((<= (gnus-group-group-level) gnus-level-subscribed) | |
2908 | gnus-level-default-unsubscribed) | |
2909 | (t | |
2910 | gnus-level-default-subscribed)) | |
2911 | t) | |
2912 | (gnus-group-update-group-line)) | |
2913 | (gnus-group-next-group 1))) | |
2914 | ||
2915 | (defun gnus-group-unsubscribe-group (group &optional level silent) | |
2916 | "Toggle subscription to GROUP. | |
2917 | Killed newsgroups are subscribed. If SILENT, don't try to update the | |
2918 | group line." | |
2919 | (interactive | |
2920 | (list (completing-read | |
2921 | "Group: " gnus-active-hashtb nil | |
2922 | (gnus-read-active-file-p) | |
2923 | nil | |
2924 | 'gnus-group-history))) | |
2925 | (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb))) | |
2926 | (cond | |
6748645f | 2927 | ((string-match "^[ \t]*$" group) |
eec82323 LMI |
2928 | (error "Empty group name")) |
2929 | (newsrc | |
2930 | ;; Toggle subscription flag. | |
2931 | (gnus-group-change-level | |
2932 | newsrc (if level level (if (<= (gnus-info-level (nth 2 newsrc)) | |
2933 | gnus-level-subscribed) | |
2934 | (1+ gnus-level-subscribed) | |
2935 | gnus-level-default-subscribed))) | |
2936 | (unless silent | |
2937 | (gnus-group-update-group group))) | |
2938 | ((and (stringp group) | |
2939 | (or (not (gnus-read-active-file-p)) | |
2940 | (gnus-active group))) | |
2941 | ;; Add new newsgroup. | |
2942 | (gnus-group-change-level | |
2943 | group | |
2944 | (if level level gnus-level-default-subscribed) | |
2945 | (or (and (member group gnus-zombie-list) | |
2946 | gnus-level-zombie) | |
2947 | gnus-level-killed) | |
2948 | (when (gnus-group-group-name) | |
2949 | (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb))) | |
2950 | (unless silent | |
2951 | (gnus-group-update-group group))) | |
2952 | (t (error "No such newsgroup: %s" group))) | |
2953 | (gnus-group-position-point))) | |
2954 | ||
2955 | (defun gnus-group-transpose-groups (n) | |
2956 | "Move the current newsgroup up N places. | |
2957 | If given a negative prefix, move down instead. The difference between | |
2958 | N and the number of steps taken is returned." | |
2959 | (interactive "p") | |
2960 | (unless (gnus-group-group-name) | |
2961 | (error "No group on current line")) | |
2962 | (gnus-group-kill-group 1) | |
2963 | (prog1 | |
2964 | (forward-line (- n)) | |
2965 | (gnus-group-yank-group) | |
2966 | (gnus-group-position-point))) | |
2967 | ||
16409b0b GM |
2968 | (defun gnus-group-kill-all-zombies (&optional dummy) |
2969 | "Kill all zombie newsgroups. | |
2970 | The optional DUMMY should always be nil." | |
2971 | (interactive (list (not (gnus-yes-or-no-p "Really kill all zombies? ")))) | |
2972 | (unless dummy | |
2973 | (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list)) | |
2974 | (setq gnus-zombie-list nil) | |
2975 | (gnus-dribble-touch) | |
2976 | (gnus-group-list-groups))) | |
eec82323 LMI |
2977 | |
2978 | (defun gnus-group-kill-region (begin end) | |
2979 | "Kill newsgroups in current region (excluding current point). | |
2980 | The killed newsgroups can be yanked by using \\[gnus-group-yank-group]." | |
2981 | (interactive "r") | |
2982 | (let ((lines | |
2983 | ;; Count lines. | |
2984 | (save-excursion | |
2985 | (count-lines | |
2986 | (progn | |
2987 | (goto-char begin) | |
2988 | (beginning-of-line) | |
2989 | (point)) | |
2990 | (progn | |
2991 | (goto-char end) | |
2992 | (beginning-of-line) | |
2993 | (point)))))) | |
2994 | (goto-char begin) | |
2995 | (beginning-of-line) ;Important when LINES < 1 | |
2996 | (gnus-group-kill-group lines))) | |
2997 | ||
2998 | (defun gnus-group-kill-group (&optional n discard) | |
2999 | "Kill the next N groups. | |
3000 | The killed newsgroups can be yanked by using \\[gnus-group-yank-group]. | |
3001 | However, only groups that were alive can be yanked; already killed | |
3002 | groups or zombie groups can't be yanked. | |
3003 | The return value is the name of the group that was killed, or a list | |
3004 | of groups killed." | |
3005 | (interactive "P") | |
3006 | (let ((buffer-read-only nil) | |
3007 | (groups (gnus-group-process-prefix n)) | |
3008 | group entry level out) | |
3009 | (if (< (length groups) 10) | |
3010 | ;; This is faster when there are few groups. | |
3011 | (while groups | |
3012 | (push (setq group (pop groups)) out) | |
3013 | (gnus-group-remove-mark group) | |
3014 | (setq level (gnus-group-group-level)) | |
3015 | (gnus-delete-line) | |
3016 | (when (and (not discard) | |
3017 | (setq entry (gnus-gethash group gnus-newsrc-hashtb))) | |
3018 | (gnus-undo-register | |
3019 | `(progn | |
3020 | (gnus-group-goto-group ,(gnus-group-group-name)) | |
3021 | (gnus-group-yank-group))) | |
3022 | (push (cons (car entry) (nth 2 entry)) | |
3023 | gnus-list-of-killed-groups)) | |
3024 | (gnus-group-change-level | |
16409b0b GM |
3025 | (if entry entry group) gnus-level-killed (if entry nil level)) |
3026 | (message "Killed group %s" group)) | |
eec82323 LMI |
3027 | ;; If there are lots and lots of groups to be killed, we use |
3028 | ;; this thing instead. | |
3029 | (let (entry) | |
3030 | (setq groups (nreverse groups)) | |
3031 | (while groups | |
3032 | (gnus-group-remove-mark (setq group (pop groups))) | |
3033 | (gnus-delete-line) | |
3034 | (push group gnus-killed-list) | |
3035 | (setq gnus-newsrc-alist | |
3036 | (delq (assoc group gnus-newsrc-alist) | |
3037 | gnus-newsrc-alist)) | |
3038 | (when gnus-group-change-level-function | |
6748645f LMI |
3039 | (funcall gnus-group-change-level-function |
3040 | group gnus-level-killed 3)) | |
eec82323 LMI |
3041 | (cond |
3042 | ((setq entry (gnus-gethash group gnus-newsrc-hashtb)) | |
3043 | (push (cons (car entry) (nth 2 entry)) | |
3044 | gnus-list-of-killed-groups) | |
3045 | (setcdr (cdr entry) (cdddr entry))) | |
3046 | ((member group gnus-zombie-list) | |
6748645f LMI |
3047 | (setq gnus-zombie-list (delete group gnus-zombie-list)))) |
3048 | ;; There may be more than one instance displayed. | |
3049 | (while (gnus-group-goto-group group) | |
3050 | (gnus-delete-line))) | |
eec82323 LMI |
3051 | (gnus-make-hashtable-from-newsrc-alist))) |
3052 | ||
3053 | (gnus-group-position-point) | |
3054 | (if (< (length out) 2) (car out) (nreverse out)))) | |
3055 | ||
3056 | (defun gnus-group-yank-group (&optional arg) | |
6748645f LMI |
3057 | "Yank the last newsgroups killed with \\[gnus-group-kill-group], inserting it before the current newsgroup. |
3058 | The numeric ARG specifies how many newsgroups are to be yanked. The | |
3059 | name of the newsgroup yanked is returned, or (if several groups are | |
3060 | yanked) a list of yanked groups is returned." | |
eec82323 LMI |
3061 | (interactive "p") |
3062 | (setq arg (or arg 1)) | |
3063 | (let (info group prev out) | |
3064 | (while (>= (decf arg) 0) | |
3065 | (when (not (setq info (pop gnus-list-of-killed-groups))) | |
3066 | (error "No more newsgroups to yank")) | |
3067 | (push (setq group (nth 1 info)) out) | |
3068 | ;; Find which newsgroup to insert this one before - search | |
3069 | ;; backward until something suitable is found. If there are no | |
3070 | ;; other newsgroups in this buffer, just make this newsgroup the | |
3071 | ;; first newsgroup. | |
3072 | (setq prev (gnus-group-group-name)) | |
3073 | (gnus-group-change-level | |
3074 | info (gnus-info-level (cdr info)) gnus-level-killed | |
3075 | (and prev (gnus-gethash prev gnus-newsrc-hashtb)) | |
3076 | t) | |
3077 | (gnus-group-insert-group-line-info group) | |
3078 | (gnus-undo-register | |
3079 | `(when (gnus-group-goto-group ,group) | |
3080 | (gnus-group-kill-group 1)))) | |
3081 | (forward-line -1) | |
3082 | (gnus-group-position-point) | |
3083 | (if (< (length out) 2) (car out) (nreverse out)))) | |
3084 | ||
3085 | (defun gnus-group-kill-level (level) | |
3086 | "Kill all groups that is on a certain LEVEL." | |
3087 | (interactive "nKill all groups on level: ") | |
3088 | (cond | |
3089 | ((= level gnus-level-zombie) | |
3090 | (setq gnus-killed-list | |
3091 | (nconc gnus-zombie-list gnus-killed-list)) | |
3092 | (setq gnus-zombie-list nil)) | |
3093 | ((and (< level gnus-level-zombie) | |
3094 | (> level 0) | |
3095 | (or gnus-expert-user | |
3096 | (gnus-yes-or-no-p | |
3097 | (format | |
3098 | "Do you really want to kill all groups on level %d? " | |
3099 | level)))) | |
3100 | (let* ((prev gnus-newsrc-alist) | |
3101 | (alist (cdr prev))) | |
3102 | (while alist | |
3103 | (if (= (gnus-info-level (car alist)) level) | |
3104 | (progn | |
3105 | (push (gnus-info-group (car alist)) gnus-killed-list) | |
3106 | (setcdr prev (cdr alist))) | |
3107 | (setq prev alist)) | |
3108 | (setq alist (cdr alist))) | |
3109 | (gnus-make-hashtable-from-newsrc-alist) | |
3110 | (gnus-group-list-groups))) | |
3111 | (t | |
16409b0b | 3112 | (error "Can't kill; invalid level: %d" level)))) |
eec82323 LMI |
3113 | |
3114 | (defun gnus-group-list-all-groups (&optional arg) | |
3115 | "List all newsgroups with level ARG or lower. | |
3116 | Default is gnus-level-unsubscribed, which lists all subscribed and most | |
3117 | unsubscribed groups." | |
3118 | (interactive "P") | |
3119 | (gnus-group-list-groups (or arg gnus-level-unsubscribed) t)) | |
3120 | ||
3121 | ;; Redefine this to list ALL killed groups if prefix arg used. | |
3122 | ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom). | |
3123 | (defun gnus-group-list-killed (&optional arg) | |
3124 | "List all killed newsgroups in the group buffer. | |
3125 | If ARG is non-nil, list ALL killed groups known to Gnus. This may | |
3126 | entail asking the server for the groups." | |
3127 | (interactive "P") | |
3128 | ;; Find all possible killed newsgroups if arg. | |
3129 | (when arg | |
3130 | (gnus-get-killed-groups)) | |
3131 | (if (not gnus-killed-list) | |
3132 | (gnus-message 6 "No killed groups") | |
3133 | (let (gnus-group-list-mode) | |
3134 | (funcall gnus-group-prepare-function | |
3135 | gnus-level-killed t gnus-level-killed)) | |
3136 | (goto-char (point-min))) | |
3137 | (gnus-group-position-point)) | |
3138 | ||
3139 | (defun gnus-group-list-zombies () | |
3140 | "List all zombie newsgroups in the group buffer." | |
3141 | (interactive) | |
3142 | (if (not gnus-zombie-list) | |
3143 | (gnus-message 6 "No zombie groups") | |
3144 | (let (gnus-group-list-mode) | |
3145 | (funcall gnus-group-prepare-function | |
3146 | gnus-level-zombie t gnus-level-zombie)) | |
3147 | (goto-char (point-min))) | |
3148 | (gnus-group-position-point)) | |
3149 | ||
3150 | (defun gnus-group-list-active () | |
3151 | "List all groups that are available from the server(s)." | |
3152 | (interactive) | |
3153 | ;; First we make sure that we have really read the active file. | |
3154 | (unless (gnus-read-active-file-p) | |
16409b0b GM |
3155 | (let ((gnus-read-active-file t) |
3156 | (gnus-agent nil)) ; Trick the agent into ignoring the active file. | |
eec82323 LMI |
3157 | (gnus-read-active-file))) |
3158 | ;; Find all groups and sort them. | |
3159 | (let ((groups | |
3160 | (sort | |
3161 | (let (list) | |
3162 | (mapatoms | |
3163 | (lambda (sym) | |
3164 | (and (boundp sym) | |
3165 | (symbol-value sym) | |
3166 | (push (symbol-name sym) list))) | |
3167 | gnus-active-hashtb) | |
3168 | list) | |
3169 | 'string<)) | |
3170 | (buffer-read-only nil) | |
3171 | group) | |
3172 | (erase-buffer) | |
3173 | (while groups | |
16409b0b | 3174 | (setq group (pop groups)) |
eec82323 LMI |
3175 | (gnus-add-text-properties |
3176 | (point) (prog1 (1+ (point)) | |
3177 | (insert " *: " | |
a1506d29 | 3178 | (gnus-group-name-decode group |
16409b0b GM |
3179 | (gnus-group-name-charset |
3180 | nil group)) | |
3181 | "\n")) | |
eec82323 LMI |
3182 | (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb) |
3183 | 'gnus-unread t | |
3184 | 'gnus-level (inline (gnus-group-level group))))) | |
3185 | (goto-char (point-min)))) | |
3186 | ||
3187 | (defun gnus-activate-all-groups (level) | |
3188 | "Activate absolutely all groups." | |
6748645f | 3189 | (interactive (list gnus-level-unsubscribed)) |
eec82323 LMI |
3190 | (let ((gnus-activate-level level) |
3191 | (gnus-activate-foreign-newsgroups level)) | |
3192 | (gnus-group-get-new-news))) | |
3193 | ||
3194 | (defun gnus-group-get-new-news (&optional arg) | |
3195 | "Get newly arrived articles. | |
3196 | If ARG is a number, it specifies which levels you are interested in | |
3197 | re-scanning. If ARG is non-nil and not a number, this will force | |
3198 | \"hard\" re-reading of the active files from all servers." | |
3199 | (interactive "P") | |
16409b0b GM |
3200 | (require 'nnmail) |
3201 | (let ((gnus-inhibit-demon t) | |
3202 | ;; Binding this variable will inhibit multiple fetchings | |
3203 | ;; of the same mail source. | |
3204 | (nnmail-fetched-sources (list t))) | |
6748645f | 3205 | (gnus-run-hooks 'gnus-get-new-news-hook) |
eec82323 LMI |
3206 | |
3207 | ;; Read any slave files. | |
3208 | (unless gnus-slave | |
3209 | (gnus-master-read-slave-newsrc)) | |
3210 | ||
3211 | ;; We might read in new NoCeM messages here. | |
3212 | (when (and gnus-use-nocem | |
3213 | (null arg)) | |
3214 | (gnus-nocem-scan-groups)) | |
3215 | ;; If ARG is not a number, then we read the active file. | |
3216 | (when (and arg (not (numberp arg))) | |
3217 | (let ((gnus-read-active-file t)) | |
3218 | (gnus-read-active-file)) | |
3219 | (setq arg nil) | |
3220 | ||
3221 | ;; If the user wants it, we scan for new groups. | |
3222 | (when (eq gnus-check-new-newsgroups 'always) | |
3223 | (gnus-find-new-newsgroups))) | |
3224 | ||
3225 | (setq arg (gnus-group-default-level arg t)) | |
3226 | (if (and gnus-read-active-file (not arg)) | |
3227 | (progn | |
3228 | (gnus-read-active-file) | |
3229 | (gnus-get-unread-articles arg)) | |
3230 | (let ((gnus-read-active-file (if arg nil gnus-read-active-file))) | |
3231 | (gnus-get-unread-articles arg))) | |
6748645f | 3232 | (gnus-run-hooks 'gnus-after-getting-new-news-hook) |
eec82323 LMI |
3233 | (gnus-group-list-groups (and (numberp arg) |
3234 | (max (car gnus-group-list-mode) arg))))) | |
3235 | ||
a8151ef7 | 3236 | (defun gnus-group-get-new-news-this-group (&optional n dont-scan) |
eec82323 LMI |
3237 | "Check for newly arrived news in the current group (and the N-1 next groups). |
3238 | The difference between N and the number of newsgroup checked is returned. | |
3239 | If N is negative, this group and the N-1 previous groups will be checked." | |
3240 | (interactive "P") | |
3241 | (let* ((groups (gnus-group-process-prefix n)) | |
3242 | (ret (if (numberp n) (- n (length groups)) 0)) | |
3243 | (beg (unless n | |
3244 | (point))) | |
16409b0b GM |
3245 | group method |
3246 | (gnus-inhibit-demon t) | |
3247 | ;; Binding this variable will inhibit multiple fetchings | |
3248 | ;; of the same mail source. | |
3249 | (nnmail-fetched-sources (list t))) | |
3250 | (gnus-run-hooks 'gnus-get-new-news-hook) | |
eec82323 LMI |
3251 | (while (setq group (pop groups)) |
3252 | (gnus-group-remove-mark group) | |
3253 | ;; Bypass any previous denials from the server. | |
6748645f | 3254 | (gnus-remove-denial (setq method (gnus-find-method-for-group group))) |
a8151ef7 | 3255 | (if (gnus-activate-group group (if dont-scan nil 'scan)) |
eec82323 LMI |
3256 | (progn |
3257 | (gnus-get-unread-articles-in-group | |
3258 | (gnus-get-info group) (gnus-active group) t) | |
3259 | (unless (gnus-virtual-group-p group) | |
3260 | (gnus-close-group group)) | |
16409b0b GM |
3261 | (when gnus-agent |
3262 | (gnus-agent-save-group-info | |
3263 | method (gnus-group-real-name group) (gnus-active group))) | |
eec82323 LMI |
3264 | (gnus-group-update-group group)) |
3265 | (if (eq (gnus-server-status (gnus-find-method-for-group group)) | |
3266 | 'denied) | |
3267 | (gnus-error 3 "Server denied access") | |
3268 | (gnus-error 3 "%s error: %s" group (gnus-status-message group))))) | |
3269 | (when beg | |
3270 | (goto-char beg)) | |
3271 | (when gnus-goto-next-group-when-activating | |
3272 | (gnus-group-next-unread-group 1 t)) | |
3273 | (gnus-summary-position-point) | |
3274 | ret)) | |
3275 | ||
3276 | (defun gnus-group-fetch-faq (group &optional faq-dir) | |
3277 | "Fetch the FAQ for the current group. | |
3278 | If given a prefix argument, prompt for the FAQ dir | |
3279 | to use." | |
3280 | (interactive | |
3281 | (list | |
3282 | (gnus-group-group-name) | |
a8151ef7 LMI |
3283 | (when current-prefix-arg |
3284 | (completing-read | |
8f688cb0 | 3285 | "FAQ dir: " (and (listp gnus-group-faq-directory) |
c6e7b580 | 3286 | (mapcar #'list |
a8151ef7 | 3287 | gnus-group-faq-directory)))))) |
eec82323 LMI |
3288 | (unless group |
3289 | (error "No group name given")) | |
3290 | (let ((dirs (or faq-dir gnus-group-faq-directory)) | |
3291 | dir found file) | |
3292 | (unless (listp dirs) | |
3293 | (setq dirs (list dirs))) | |
3294 | (while (and (not found) | |
3295 | (setq dir (pop dirs))) | |
6748645f | 3296 | (let ((name (gnus-group-real-name group))) |
c6e7b580 | 3297 | (setq file (expand-file-name name dir))) |
eec82323 LMI |
3298 | (if (not (file-exists-p file)) |
3299 | (gnus-message 1 "No such file: %s" file) | |
3300 | (let ((enable-local-variables nil)) | |
3301 | (find-file file) | |
3302 | (setq found t)))))) | |
3303 | ||
3304 | (defun gnus-group-describe-group (force &optional group) | |
3305 | "Display a description of the current newsgroup." | |
3306 | (interactive (list current-prefix-arg (gnus-group-group-name))) | |
3307 | (let* ((method (gnus-find-method-for-group group)) | |
3308 | (mname (gnus-group-prefixed-name "" method)) | |
3309 | desc) | |
3310 | (when (and force | |
3311 | gnus-description-hashtb) | |
3312 | (gnus-sethash mname nil gnus-description-hashtb)) | |
3313 | (unless group | |
3314 | (error "No group name given")) | |
3315 | (when (or (and gnus-description-hashtb | |
3316 | ;; We check whether this group's method has been | |
3317 | ;; queried for a description file. | |
3318 | (gnus-gethash mname gnus-description-hashtb)) | |
3319 | (setq desc (gnus-group-get-description group)) | |
3320 | (gnus-read-descriptions-file method)) | |
3321 | (gnus-message 1 | |
3322 | (or desc (gnus-gethash group gnus-description-hashtb) | |
3323 | "No description available"))))) | |
3324 | ||
3325 | ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
3326 | (defun gnus-group-describe-all-groups (&optional force) | |
3327 | "Pop up a buffer with descriptions of all newsgroups." | |
3328 | (interactive "P") | |
3329 | (when force | |
3330 | (setq gnus-description-hashtb nil)) | |
3331 | (when (not (or gnus-description-hashtb | |
3332 | (gnus-read-all-descriptions-files))) | |
3333 | (error "Couldn't request descriptions file")) | |
3334 | (let ((buffer-read-only nil) | |
3335 | b) | |
3336 | (erase-buffer) | |
3337 | (mapatoms | |
3338 | (lambda (group) | |
3339 | (setq b (point)) | |
16409b0b | 3340 | (let ((charset (gnus-group-name-charset nil (symbol-name group)))) |
a1506d29 | 3341 | (insert (format " *: %-20s %s\n" |
16409b0b GM |
3342 | (gnus-group-name-decode |
3343 | (symbol-name group) charset) | |
3344 | (gnus-group-name-decode | |
3345 | (symbol-value group) charset)))) | |
eec82323 LMI |
3346 | (gnus-add-text-properties |
3347 | b (1+ b) (list 'gnus-group group | |
3348 | 'gnus-unread t 'gnus-marked nil | |
3349 | 'gnus-level (1+ gnus-level-subscribed)))) | |
3350 | gnus-description-hashtb) | |
3351 | (goto-char (point-min)) | |
3352 | (gnus-group-position-point))) | |
3353 | ||
3354 | ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
3355 | (defun gnus-group-apropos (regexp &optional search-description) | |
3356 | "List all newsgroups that have names that match a regexp." | |
3357 | (interactive "sGnus apropos (regexp): ") | |
3358 | (let ((prev "") | |
3359 | (obuf (current-buffer)) | |
3360 | groups des) | |
3361 | ;; Go through all newsgroups that are known to Gnus. | |
3362 | (mapatoms | |
3363 | (lambda (group) | |
3364 | (and (symbol-name group) | |
3365 | (string-match regexp (symbol-name group)) | |
6748645f | 3366 | (symbol-value group) |
eec82323 LMI |
3367 | (push (symbol-name group) groups))) |
3368 | gnus-active-hashtb) | |
3369 | ;; Also go through all descriptions that are known to Gnus. | |
3370 | (when search-description | |
3371 | (mapatoms | |
3372 | (lambda (group) | |
3373 | (and (string-match regexp (symbol-value group)) | |
eec82323 LMI |
3374 | (push (symbol-name group) groups))) |
3375 | gnus-description-hashtb)) | |
3376 | (if (not groups) | |
3377 | (gnus-message 3 "No groups matched \"%s\"." regexp) | |
3378 | ;; Print out all the groups. | |
3379 | (save-excursion | |
3380 | (pop-to-buffer "*Gnus Help*") | |
16409b0b | 3381 | (buffer-disable-undo) |
eec82323 LMI |
3382 | (erase-buffer) |
3383 | (setq groups (sort groups 'string<)) | |
3384 | (while groups | |
3385 | ;; Groups may be entered twice into the list of groups. | |
3386 | (when (not (string= (car groups) prev)) | |
16409b0b GM |
3387 | (setq prev (car groups)) |
3388 | (let ((charset (gnus-group-name-charset nil prev))) | |
3389 | (insert (gnus-group-name-decode prev charset) "\n") | |
3390 | (when (and gnus-description-hashtb | |
3391 | (setq des (gnus-gethash (car groups) | |
3392 | gnus-description-hashtb))) | |
3393 | (insert " " (gnus-group-name-decode des charset) "\n")))) | |
eec82323 LMI |
3394 | (setq groups (cdr groups))) |
3395 | (goto-char (point-min)))) | |
3396 | (pop-to-buffer obuf))) | |
3397 | ||
3398 | (defun gnus-group-description-apropos (regexp) | |
3399 | "List all newsgroups that have names or descriptions that match a regexp." | |
3400 | (interactive "sGnus description apropos (regexp): ") | |
3401 | (when (not (or gnus-description-hashtb | |
3402 | (gnus-read-all-descriptions-files))) | |
3403 | (error "Couldn't request descriptions file")) | |
3404 | (gnus-group-apropos regexp t)) | |
3405 | ||
3406 | ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
3407 | (defun gnus-group-list-matching (level regexp &optional all lowest) | |
3408 | "List all groups with unread articles that match REGEXP. | |
3409 | If the prefix LEVEL is non-nil, it should be a number that says which | |
3410 | level to cut off listing groups. | |
3411 | If ALL, also list groups with no unread articles. | |
3412 | If LOWEST, don't list groups with level lower than LOWEST. | |
3413 | ||
3414 | This command may read the active file." | |
3415 | (interactive "P\nsList newsgroups matching: ") | |
3416 | ;; First make sure active file has been read. | |
3417 | (when (and level | |
3418 | (> (prefix-numeric-value level) gnus-level-killed)) | |
3419 | (gnus-get-killed-groups)) | |
3420 | (gnus-group-prepare-flat | |
3421 | (or level gnus-level-subscribed) all (or lowest 1) regexp) | |
3422 | (goto-char (point-min)) | |
3423 | (gnus-group-position-point)) | |
3424 | ||
3425 | (defun gnus-group-list-all-matching (level regexp &optional lowest) | |
3426 | "List all groups that match REGEXP. | |
3427 | If the prefix LEVEL is non-nil, it should be a number that says which | |
3428 | level to cut off listing groups. | |
3429 | If LOWEST, don't list groups with level lower than LOWEST." | |
3430 | (interactive "P\nsList newsgroups matching: ") | |
3431 | (when level | |
3432 | (setq level (prefix-numeric-value level))) | |
3433 | (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest)) | |
3434 | ||
3435 | ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. | |
3436 | (defun gnus-group-save-newsrc (&optional force) | |
3437 | "Save the Gnus startup files. | |
3438 | If FORCE, force saving whether it is necessary or not." | |
3439 | (interactive "P") | |
3440 | (gnus-save-newsrc-file force)) | |
3441 | ||
3442 | (defun gnus-group-restart (&optional arg) | |
3443 | "Force Gnus to read the .newsrc file." | |
3444 | (interactive "P") | |
3445 | (when (gnus-yes-or-no-p | |
3446 | (format "Are you sure you want to restart Gnus? ")) | |
3447 | (gnus-save-newsrc-file) | |
3448 | (gnus-clear-system) | |
3449 | (gnus))) | |
3450 | ||
3451 | (defun gnus-group-read-init-file () | |
3452 | "Read the Gnus elisp init file." | |
3453 | (interactive) | |
a8151ef7 LMI |
3454 | (gnus-read-init-file) |
3455 | (gnus-message 5 "Read %s" gnus-init-file)) | |
eec82323 LMI |
3456 | |
3457 | (defun gnus-group-check-bogus-groups (&optional silent) | |
3458 | "Check bogus newsgroups. | |
3459 | If given a prefix, don't ask for confirmation before removing a bogus | |
3460 | group." | |
3461 | (interactive "P") | |
3462 | (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user))) | |
3463 | (gnus-group-list-groups)) | |
3464 | ||
a8151ef7 LMI |
3465 | (defun gnus-group-find-new-groups (&optional arg) |
3466 | "Search for new groups and add them. | |
54cf8092 | 3467 | Each new group will be treated with `gnus-subscribe-newsgroup-method'. |
6748645f LMI |
3468 | With 1 C-u, use the `ask-server' method to query the server for new |
3469 | groups. | |
3470 | With 2 C-u's, use most complete method possible to query the server | |
3471 | for new groups, and subscribe the new groups as zombies." | |
3472 | (interactive "p") | |
3473 | (gnus-find-new-newsgroups (or arg 1)) | |
a8151ef7 | 3474 | (gnus-group-list-groups)) |
6748645f | 3475 | |
eec82323 LMI |
3476 | (defun gnus-group-edit-global-kill (&optional article group) |
3477 | "Edit the global kill file. | |
3478 | If GROUP, edit that local kill file instead." | |
3479 | (interactive "P") | |
3480 | (setq gnus-current-kill-article article) | |
3481 | (gnus-kill-file-edit-file group) | |
3482 | (gnus-message | |
3483 | 6 | |
3484 | (substitute-command-keys | |
3485 | (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)" | |
3486 | (if group "local" "global"))))) | |
3487 | ||
3488 | (defun gnus-group-edit-local-kill (article group) | |
3489 | "Edit a local kill file." | |
3490 | (interactive (list nil (gnus-group-group-name))) | |
3491 | (gnus-group-edit-global-kill article group)) | |
3492 | ||
3493 | (defun gnus-group-force-update () | |
3494 | "Update `.newsrc' file." | |
3495 | (interactive) | |
3496 | (gnus-save-newsrc-file)) | |
3497 | ||
3498 | (defun gnus-group-suspend () | |
3499 | "Suspend the current Gnus session. | |
3500 | In fact, cleanup buffers except for group mode buffer. | |
3501 | The hook gnus-suspend-gnus-hook is called before actually suspending." | |
3502 | (interactive) | |
6748645f | 3503 | (gnus-run-hooks 'gnus-suspend-gnus-hook) |
eec82323 | 3504 | ;; Kill Gnus buffers except for group mode buffer. |
6748645f | 3505 | (let ((group-buf (get-buffer gnus-group-buffer))) |
5429ab59 SS |
3506 | (dolist (buf (gnus-buffers)) |
3507 | (unless (or (eq buf group-buf) (eq buf gnus-dribble-buffer)) | |
3508 | (kill-buffer buf))) | |
eec82323 LMI |
3509 | (gnus-kill-gnus-frames) |
3510 | (when group-buf | |
eec82323 LMI |
3511 | (bury-buffer group-buf) |
3512 | (delete-windows-on group-buf t)))) | |
3513 | ||
3514 | (defun gnus-group-clear-dribble () | |
3515 | "Clear all information from the dribble buffer." | |
3516 | (interactive) | |
3517 | (gnus-dribble-clear) | |
3518 | (gnus-message 7 "Cleared dribble buffer")) | |
3519 | ||
3520 | (defun gnus-group-exit () | |
3521 | "Quit reading news after updating .newsrc.eld and .newsrc. | |
3522 | The hook `gnus-exit-gnus-hook' is called before actually exiting." | |
3523 | (interactive) | |
3524 | (when | |
3525 | (or noninteractive ;For gnus-batch-kill | |
3526 | (not gnus-interactive-exit) ;Without confirmation | |
3527 | gnus-expert-user | |
3528 | (gnus-y-or-n-p "Are you sure you want to quit reading news? ")) | |
6748645f | 3529 | (gnus-run-hooks 'gnus-exit-gnus-hook) |
eec82323 LMI |
3530 | ;; Offer to save data from non-quitted summary buffers. |
3531 | (gnus-offer-save-summaries) | |
3532 | ;; Save the newsrc file(s). | |
3533 | (gnus-save-newsrc-file) | |
3534 | ;; Kill-em-all. | |
3535 | (gnus-close-backends) | |
3536 | ;; Reset everything. | |
3537 | (gnus-clear-system) | |
3538 | ;; Allow the user to do things after cleaning up. | |
6748645f | 3539 | (gnus-run-hooks 'gnus-after-exiting-gnus-hook))) |
eec82323 LMI |
3540 | |
3541 | (defun gnus-group-quit () | |
3542 | "Quit reading news without updating .newsrc.eld or .newsrc. | |
3543 | The hook `gnus-exit-gnus-hook' is called before actually exiting." | |
3544 | (interactive) | |
3545 | (when (or noninteractive ;For gnus-batch-kill | |
3546 | (zerop (buffer-size)) | |
3547 | (not (gnus-server-opened gnus-select-method)) | |
3548 | gnus-expert-user | |
3549 | (not gnus-current-startup-file) | |
3550 | (gnus-yes-or-no-p | |
3551 | (format "Quit reading news without saving %s? " | |
3552 | (file-name-nondirectory gnus-current-startup-file)))) | |
6748645f | 3553 | (gnus-run-hooks 'gnus-exit-gnus-hook) |
eec82323 LMI |
3554 | (gnus-configure-windows 'group t) |
3555 | (gnus-dribble-save) | |
3556 | (gnus-close-backends) | |
3557 | (gnus-clear-system) | |
3558 | (gnus-kill-buffer gnus-group-buffer) | |
3559 | ;; Allow the user to do things after cleaning up. | |
6748645f | 3560 | (gnus-run-hooks 'gnus-after-exiting-gnus-hook))) |
eec82323 LMI |
3561 | |
3562 | (defun gnus-group-describe-briefly () | |
3563 | "Give a one line description of the group mode commands." | |
3564 | (interactive) | |
3565 | (gnus-message 7 (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-read-group]:Select \\[gnus-group-next-unread-group]:Forward \\[gnus-group-prev-unread-group]:Backward \\[gnus-group-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-group-describe-briefly]:This help"))) | |
3566 | ||
3567 | (defun gnus-group-browse-foreign-server (method) | |
3568 | "Browse a foreign news server. | |
3569 | If called interactively, this function will ask for a select method | |
3570 | (nntp, nnspool, etc.) and a server address (eg. nntp.some.where). | |
3571 | If not, METHOD should be a list where the first element is the method | |
3572 | and the second element is the address." | |
3573 | (interactive | |
3574 | (list (let ((how (completing-read | |
3575 | "Which backend: " | |
3576 | (append gnus-valid-select-methods gnus-server-alist) | |
3577 | nil t (cons "nntp" 0) 'gnus-method-history))) | |
3578 | ;; We either got a backend name or a virtual server name. | |
3579 | ;; If the first, we also need an address. | |
3580 | (if (assoc how gnus-valid-select-methods) | |
3581 | (list (intern how) | |
3582 | ;; Suggested by mapjph@bath.ac.uk. | |
3583 | (completing-read | |
3584 | "Address: " | |
3585 | (mapcar (lambda (server) (list server)) | |
3586 | gnus-secondary-servers))) | |
3587 | ;; We got a server name. | |
3588 | how)))) | |
3589 | (gnus-browse-foreign-server method)) | |
3590 | ||
3591 | (defun gnus-group-set-info (info &optional method-only-group part) | |
16409b0b GM |
3592 | (when (or info part) |
3593 | (let* ((entry (gnus-gethash | |
3594 | (or method-only-group (gnus-info-group info)) | |
3595 | gnus-newsrc-hashtb)) | |
3596 | (part-info info) | |
3597 | (info (if method-only-group (nth 2 entry) info)) | |
3598 | method) | |
3599 | (when method-only-group | |
3600 | (unless entry | |
3601 | (error "Trying to change non-existent group %s" method-only-group)) | |
3602 | ;; We have received parts of the actual group info - either the | |
3603 | ;; select method or the group parameters. We first check | |
3604 | ;; whether we have to extend the info, and if so, do that. | |
3605 | (let ((len (length info)) | |
3606 | (total (if (eq part 'method) 5 6))) | |
3607 | (when (< len total) | |
3608 | (setcdr (nthcdr (1- len) info) | |
3609 | (make-list (- total len) nil))) | |
3610 | ;; Then we enter the new info. | |
3611 | (setcar (nthcdr (1- total) info) part-info))) | |
eec82323 | 3612 | (unless entry |
16409b0b | 3613 | ;; This is a new group, so we just create it. |
eec82323 LMI |
3614 | (save-excursion |
3615 | (set-buffer gnus-group-buffer) | |
16409b0b GM |
3616 | (setq method (gnus-info-method info)) |
3617 | (when (gnus-server-equal method "native") | |
3618 | (setq method nil)) | |
3619 | (save-excursion | |
3620 | (set-buffer gnus-group-buffer) | |
3621 | (if method | |
3622 | ;; It's a foreign group... | |
3623 | (gnus-group-make-group | |
3624 | (gnus-group-real-name (gnus-info-group info)) | |
3625 | (if (stringp method) method | |
3626 | (prin1-to-string (car method))) | |
3627 | (and (consp method) | |
3628 | (nth 1 (gnus-info-method info)))) | |
3629 | ;; It's a native group. | |
3630 | (gnus-group-make-group (gnus-info-group info)))) | |
3631 | (gnus-message 6 "Note: New group created") | |
3632 | (setq entry | |
3633 | (gnus-gethash (gnus-group-prefixed-name | |
3634 | (gnus-group-real-name (gnus-info-group info)) | |
3635 | (or (gnus-info-method info) gnus-select-method)) | |
3636 | gnus-newsrc-hashtb)))) | |
3637 | ;; Whether it was a new group or not, we now have the entry, so we | |
3638 | ;; can do the update. | |
3639 | (if entry | |
3640 | (progn | |
3641 | (setcar (nthcdr 2 entry) info) | |
3642 | (when (and (not (eq (car entry) t)) | |
3643 | (gnus-active (gnus-info-group info))) | |
3644 | (setcar entry (length (gnus-list-of-unread-articles (car info)))))) | |
3645 | (error "No such group: %s" (gnus-info-group info)))))) | |
eec82323 LMI |
3646 | |
3647 | (defun gnus-group-set-method-info (group select-method) | |
3648 | (gnus-group-set-info select-method group 'method)) | |
3649 | ||
3650 | (defun gnus-group-set-params-info (group params) | |
3651 | (gnus-group-set-info params group 'params)) | |
3652 | ||
3653 | (defun gnus-add-marked-articles (group type articles &optional info force) | |
3654 | ;; Add ARTICLES of TYPE to the info of GROUP. | |
16409b0b | 3655 | ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't |
eec82323 LMI |
3656 | ;; add, but replace marked articles of TYPE with ARTICLES. |
3657 | (let ((info (or info (gnus-get-info group))) | |
eec82323 LMI |
3658 | marked m) |
3659 | (or (not info) | |
3660 | (and (not (setq marked (nthcdr 3 info))) | |
3661 | (or (null articles) | |
3662 | (setcdr (nthcdr 2 info) | |
3663 | (list (list (cons type (gnus-compress-sequence | |
3664 | articles t))))))) | |
3665 | (and (not (setq m (assq type (car marked)))) | |
3666 | (or (null articles) | |
3667 | (setcar marked | |
3668 | (cons (cons type (gnus-compress-sequence articles t) ) | |
3669 | (car marked))))) | |
3670 | (if force | |
3671 | (if (null articles) | |
3672 | (setcar (nthcdr 3 info) | |
6748645f | 3673 | (gnus-delete-alist type (car marked))) |
eec82323 LMI |
3674 | (setcdr m (gnus-compress-sequence articles t))) |
3675 | (setcdr m (gnus-compress-sequence | |
3676 | (sort (nconc (gnus-uncompress-range (cdr m)) | |
3677 | (copy-sequence articles)) '<) t)))))) | |
3678 | ||
3679 | ;;; | |
3680 | ;;; Group timestamps | |
3681 | ;;; | |
3682 | ||
3683 | (defun gnus-group-set-timestamp () | |
3684 | "Change the timestamp of the current group to the current time. | |
3685 | This function can be used in hooks like `gnus-select-group-hook' | |
3686 | or `gnus-group-catchup-group-hook'." | |
3687 | (when gnus-newsgroup-name | |
3688 | (let ((time (current-time))) | |
3689 | (setcdr (cdr time) nil) | |
3690 | (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time)))) | |
3691 | ||
3692 | (defsubst gnus-group-timestamp (group) | |
3693 | "Return the timestamp for GROUP." | |
6748645f | 3694 | (gnus-group-get-parameter group 'timestamp t)) |
eec82323 LMI |
3695 | |
3696 | (defun gnus-group-timestamp-delta (group) | |
3697 | "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number." | |
3698 | (let* ((time (or (gnus-group-timestamp group) | |
16409b0b GM |
3699 | (list 0 0))) |
3700 | (delta (subtract-time (current-time) time))) | |
eec82323 LMI |
3701 | (+ (* (nth 0 delta) 65536.0) |
3702 | (nth 1 delta)))) | |
3703 | ||
3704 | (defun gnus-group-timestamp-string (group) | |
3705 | "Return a string of the timestamp for GROUP." | |
3706 | (let ((time (gnus-group-timestamp group))) | |
3707 | (if (not time) | |
3708 | "" | |
3709 | (gnus-time-iso8601 time)))) | |
3710 | ||
a1506d29 | 3711 | (defun gnus-group-prepare-flat-list-dead-predicate |
16409b0b GM |
3712 | (groups level mark predicate) |
3713 | (let (group) | |
3714 | (if predicate | |
3715 | ;; This loop is used when listing groups that match some | |
3716 | ;; regexp. | |
3717 | (while (setq group (pop groups)) | |
3718 | (when (funcall predicate group) | |
3719 | (gnus-add-text-properties | |
3720 | (point) (prog1 (1+ (point)) | |
a1506d29 JB |
3721 | (insert " " mark " *: " |
3722 | (gnus-group-name-decode group | |
16409b0b GM |
3723 | (gnus-group-name-charset |
3724 | nil group)) | |
3725 | "\n")) | |
3726 | (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb) | |
3727 | 'gnus-unread t | |
3728 | 'gnus-level level))))))) | |
3729 | ||
3730 | (defun gnus-group-prepare-flat-predicate (level predicate &optional lowest | |
3731 | dead-predicate) | |
3732 | "List all newsgroups with unread articles of level LEVEL or lower. | |
3733 | If LOWEST is non-nil, list all newsgroups of level LOWEST or higher. | |
3734 | If PREDICATE, only list groups which PREDICATE returns non-nil. | |
3735 | If DEAD-PREDICATE, list dead groups which DEAD-PREDICATE returns non-nil." | |
3736 | (set-buffer gnus-group-buffer) | |
3737 | (let ((buffer-read-only nil) | |
3738 | (newsrc (cdr gnus-newsrc-alist)) | |
3739 | (lowest (or lowest 1)) | |
3740 | info clevel unread group params) | |
3741 | (erase-buffer) | |
3742 | ;; List living groups. | |
3743 | (while newsrc | |
3744 | (setq info (car newsrc) | |
3745 | group (gnus-info-group info) | |
3746 | params (gnus-info-params info) | |
3747 | newsrc (cdr newsrc) | |
3748 | unread (car (gnus-gethash group gnus-newsrc-hashtb))) | |
3749 | (and unread ; This group might be unchecked | |
3750 | (funcall predicate info) | |
3751 | (<= (setq clevel (gnus-info-level info)) level) | |
3752 | (>= clevel lowest) | |
3753 | (gnus-group-insert-group-line | |
3754 | group (gnus-info-level info) | |
3755 | (gnus-info-marks info) unread (gnus-info-method info)))) | |
3756 | ||
3757 | ;; List dead groups. | |
3758 | (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie) | |
3759 | (gnus-group-prepare-flat-list-dead-predicate | |
3760 | (setq gnus-zombie-list (sort gnus-zombie-list 'string<)) | |
3761 | gnus-level-zombie ?Z | |
3762 | dead-predicate)) | |
3763 | (and (>= level gnus-level-killed) (<= lowest gnus-level-killed) | |
3764 | (gnus-group-prepare-flat-list-dead-predicate | |
3765 | (setq gnus-killed-list (sort gnus-killed-list 'string<)) | |
3766 | gnus-level-killed ?K dead-predicate)) | |
3767 | ||
3768 | (gnus-group-set-mode-line) | |
3769 | (setq gnus-group-list-mode (cons level t)) | |
3770 | (gnus-run-hooks 'gnus-group-prepare-hook) | |
3771 | t)) | |
3772 | ||
3773 | (defun gnus-group-list-cached (level &optional lowest) | |
3774 | "List all groups with cached articles. | |
3775 | If the prefix LEVEL is non-nil, it should be a number that says which | |
3776 | level to cut off listing groups. | |
3777 | If LOWEST, don't list groups with level lower than LOWEST. | |
3778 | ||
3779 | This command may read the active file." | |
3780 | (interactive "P") | |
3781 | (when level | |
3782 | (setq level (prefix-numeric-value level))) | |
3783 | (when (or (not level) (>= level gnus-level-zombie)) | |
3784 | (gnus-cache-open)) | |
3785 | (gnus-group-prepare-flat-predicate (or level gnus-level-subscribed) | |
3786 | #'(lambda (info) | |
3787 | (let ((marks (gnus-info-marks info))) | |
3788 | (assq 'cache marks))) | |
3789 | lowest | |
3790 | #'(lambda (group) | |
a1506d29 | 3791 | (or (gnus-gethash group |
16409b0b | 3792 | gnus-cache-active-hashtb) |
a1506d29 | 3793 | ;; Cache active file might use "." |
16409b0b | 3794 | ;; instead of ":". |
a1506d29 | 3795 | (gnus-gethash |
16409b0b GM |
3796 | (mapconcat 'identity |
3797 | (split-string group ":") | |
3798 | ".") | |
3799 | gnus-cache-active-hashtb)))) | |
3800 | (goto-char (point-min)) | |
3801 | (gnus-group-position-point)) | |
3802 | ||
3803 | (defun gnus-group-list-dormant (level &optional lowest) | |
3804 | "List all groups with dormant articles. | |
3805 | If the prefix LEVEL is non-nil, it should be a number that says which | |
3806 | level to cut off listing groups. | |
3807 | If LOWEST, don't list groups with level lower than LOWEST. | |
3808 | ||
3809 | This command may read the active file." | |
3810 | (interactive "P") | |
3811 | (when level | |
3812 | (setq level (prefix-numeric-value level))) | |
3813 | (when (or (not level) (>= level gnus-level-zombie)) | |
3814 | (gnus-cache-open)) | |
3815 | (gnus-group-prepare-flat-predicate (or level gnus-level-subscribed) | |
3816 | #'(lambda (info) | |
3817 | (let ((marks (gnus-info-marks info))) | |
3818 | (assq 'dormant marks))) | |
3819 | lowest) | |
3820 | (goto-char (point-min)) | |
3821 | (gnus-group-position-point)) | |
3822 | ||
eec82323 LMI |
3823 | (provide 'gnus-group) |
3824 | ||
3825 | ;;; gnus-group.el ends here |