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