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