Mercurial > hg > xemacs-beta
comparison lisp/gnus/gnus.el @ 98:0d2f883870bc r20-1b1
Import from CVS: tag r20-1b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:13:56 +0200 |
parents | 131b0175ea99 |
children | 4be1180a9e89 |
comparison
equal
deleted
inserted
replaced
97:498bf5da1c90 | 98:0d2f883870bc |
---|---|
1 ;;; gnus.el --- a newsreader for GNU Emacs | 1 ;;; gnus.el --- a newsreader for GNU Emacs |
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc. | 2 ;; Copyright (C) 1987,88,89,90,93,94,95,96,97 Free Software Foundation, Inc. |
3 | 3 |
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> | 4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> |
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no> | 5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no> |
6 ;; Keywords: news | 6 ;; Keywords: news |
7 | 7 |
26 | 26 |
27 ;;; Code: | 27 ;;; Code: |
28 | 28 |
29 (eval '(run-hooks 'gnus-load-hook)) | 29 (eval '(run-hooks 'gnus-load-hook)) |
30 | 30 |
31 (require 'mail-utils) | 31 (require 'custom) |
32 (require 'timezone) | 32 (require 'gnus-load) |
33 | |
34 (defgroup gnus nil | |
35 "The coffee-brewing, all singing, all dancing, kitchen sink newsreader." | |
36 :group 'emacs) | |
37 | |
38 (defgroup gnus-start nil | |
39 "Starting your favorite newsreader." | |
40 :group 'gnus) | |
41 | |
42 ;; These belong to gnus-group.el. | |
43 (defgroup gnus-group nil | |
44 "Group buffers." | |
45 :link '(custom-manual "(gnus)The Group Buffer") | |
46 :group 'gnus) | |
47 | |
48 (defgroup gnus-group-foreign nil | |
49 "Foreign groups." | |
50 :link '(custom-manual "(gnus)Foreign Groups") | |
51 :group 'gnus-group) | |
52 | |
53 (defgroup gnus-group-levels nil | |
54 "Group levels." | |
55 :link '(custom-manual "(gnus)Group Levels") | |
56 :group 'gnus-group) | |
57 | |
58 (defgroup gnus-group-select nil | |
59 "Selecting a Group." | |
60 :link '(custom-manual "(gnus)Selecting a Group") | |
61 :group 'gnus-group) | |
62 | |
63 (defgroup gnus-group-listing nil | |
64 "Showing slices of the group list." | |
65 :link '(custom-manual "(gnus)Listing Groups") | |
66 :group 'gnus-group) | |
67 | |
68 (defgroup gnus-group-visual nil | |
69 "Sorting the group buffer." | |
70 :link '(custom-manual "(gnus)Group Buffer Format") | |
71 :group 'gnus-group | |
72 :group 'gnus-visual) | |
73 | |
74 (defgroup gnus-group-various nil | |
75 "Various group options." | |
76 :link '(custom-manual "(gnus)Scanning New Messages") | |
77 :group 'gnus-group) | |
78 | |
79 ;; These belong to gnus-sum.el. | |
80 (defgroup gnus-summary nil | |
81 "Summary buffers." | |
82 :link '(custom-manual "(gnus)The Summary Buffer") | |
83 :group 'gnus) | |
84 | |
85 (defgroup gnus-summary-exit nil | |
86 "Leaving summary buffers." | |
87 :link '(custom-manual "(gnus)Exiting the Summary Buffer") | |
88 :group 'gnus-summary) | |
89 | |
90 (defgroup gnus-summary-marks nil | |
91 "Marks used in summary buffers." | |
92 :link '(custom-manual "(gnus)Marking Articles") | |
93 :group 'gnus-summary) | |
94 | |
95 (defgroup gnus-thread nil | |
96 "Ordering articles according to replies." | |
97 :link '(custom-manual "(gnus)Threading") | |
98 :group 'gnus-summary) | |
99 | |
100 (defgroup gnus-summary-format nil | |
101 "Formatting of the summary buffer." | |
102 :link '(custom-manual "(gnus)Summary Buffer Format") | |
103 :group 'gnus-summary) | |
104 | |
105 (defgroup gnus-summary-choose nil | |
106 "Choosing Articles." | |
107 :link '(custom-manual "(gnus)Choosing Articles") | |
108 :group 'gnus-summary) | |
109 | |
110 (defgroup gnus-summary-maneuvering nil | |
111 "Summary movement commands." | |
112 :link '(custom-manual "(gnus)Summary Maneuvering") | |
113 :group 'gnus-summary) | |
114 | |
115 (defgroup gnus-summary-mail nil | |
116 "Mail group commands." | |
117 :link '(custom-manual "(gnus)Mail Group Commands") | |
118 :group 'gnus-summary) | |
119 | |
120 (defgroup gnus-summary-sort nil | |
121 "Sorting the summary buffer." | |
122 :link '(custom-manual "(gnus)Sorting") | |
123 :group 'gnus-summary) | |
124 | |
125 (defgroup gnus-summary-visual nil | |
126 "Highlighting and menus in the summary buffer." | |
127 :link '(custom-manual "(gnus)Summary Highlighting") | |
128 :group 'gnus-visual | |
129 :group 'gnus-summary) | |
130 | |
131 (defgroup gnus-summary-various nil | |
132 "Various summary buffer options." | |
133 :link '(custom-manual "(gnus)Various Summary Stuff") | |
134 :group 'gnus-summary) | |
135 | |
136 ;; Belongs to gnus-uu.el | |
137 (defgroup gnus-extract-view nil | |
138 "Viewing extracted files." | |
139 :link '(custom-manual "(gnus)Viewing Files") | |
140 :group 'gnus-extract) | |
141 | |
142 ;; Belongs to gnus-score.el | |
143 (defgroup gnus-score nil | |
144 "Score and kill file handling." | |
145 :group 'gnus) | |
146 | |
147 (defgroup gnus-score-kill nil | |
148 "Kill files." | |
149 :group 'gnus-score) | |
150 | |
151 (defgroup gnus-score-adapt nil | |
152 "Adaptive score files." | |
153 :group 'gnus-score) | |
154 | |
155 (defgroup gnus-score-files nil | |
156 "Score and kill file names." | |
157 :group 'gnus-score | |
158 :group 'gnus-files) | |
159 | |
160 (defgroup gnus-score-various nil | |
161 "Various scoring and killing options." | |
162 :group 'gnus-score) | |
163 | |
164 ;; Other | |
165 (defgroup gnus-visual nil | |
166 "Options controling the visual fluff." | |
167 :group 'gnus) | |
168 | |
169 (defgroup gnus-mail-expire nil | |
170 "Expiring articles in mail backends." | |
171 :group 'gnus-mail) | |
172 | |
173 (defgroup gnus-files nil | |
174 "Files used by Gnus." | |
175 :group 'gnus) | |
176 | |
177 (defgroup gnus-server nil | |
178 "Options related to newsservers and other servers used by Gnus." | |
179 :group 'gnus) | |
180 | |
181 (defgroup gnus-message '((message custom-group)) | |
182 "Composing replies and followups in Gnus." | |
183 :group 'gnus) | |
184 | |
185 (defgroup gnus-meta nil | |
186 "Meta variables controling major portions of Gnus. | |
187 In general, modifying these variables does not take affect until Gnus | |
188 is restarted, and sometimes reloaded." | |
189 :group 'gnus) | |
190 | |
191 (defgroup gnus-various nil | |
192 "Other Gnus options." | |
193 :link '(custom-manual "(gnus)Various Various") | |
194 :group 'gnus) | |
195 | |
196 (defgroup gnus-exit nil | |
197 "Exiting gnus." | |
198 :link '(custom-manual "(gnus)Exiting Gnus") | |
199 :group 'gnus) | |
200 | |
201 (defconst gnus-version-number "5.4.12" | |
202 "Version number for this version of Gnus.") | |
203 | |
204 (defconst gnus-version (format "Gnus v%s" gnus-version-number) | |
205 "Version string for this version of Gnus.") | |
206 | |
207 (defcustom gnus-inhibit-startup-message nil | |
208 "If non-nil, the startup message will not be displayed. | |
209 This variable is used before `.gnus.el' is loaded, so it should | |
210 be set in `.emacs' instead." | |
211 :group 'gnus-start | |
212 :type 'boolean) | |
213 | |
214 (defcustom gnus-play-startup-jingle nil | |
215 "If non-nil, play the Gnus jingle at startup." | |
216 :group 'gnus-start | |
217 :type 'boolean) | |
218 | |
219 ;;; Kludges to help the transition from the old `custom.el'. | |
220 | |
221 (unless (featurep 'gnus-xmas) | |
222 (defalias 'gnus-make-overlay 'make-overlay) | |
223 (defalias 'gnus-overlay-put 'overlay-put) | |
224 (defalias 'gnus-move-overlay 'move-overlay) | |
225 (defalias 'gnus-overlay-end 'overlay-end) | |
226 (defalias 'gnus-extent-detached-p 'ignore) | |
227 (defalias 'gnus-extent-start-open 'ignore) | |
228 (defalias 'gnus-set-text-properties 'set-text-properties) | |
229 (defalias 'gnus-group-remove-excess-properties 'ignore) | |
230 (defalias 'gnus-topic-remove-excess-properties 'ignore) | |
231 (defalias 'gnus-appt-select-lowest-window 'appt-select-lowest-window) | |
232 (defalias 'gnus-mail-strip-quoted-names 'mail-strip-quoted-names) | |
233 (defalias 'gnus-add-hook 'add-hook) | |
234 (defalias 'gnus-character-to-event 'identity) | |
235 (defalias 'gnus-add-text-properties 'add-text-properties) | |
236 (defalias 'gnus-put-text-property 'put-text-property) | |
237 (defalias 'gnus-mode-line-buffer-identification 'identity) | |
238 (defalias 'gnus-characterp 'numberp) | |
239 (defalias 'gnus-key-press-event-p 'numberp)) | |
240 | |
241 ;; The XEmacs people think this is evil, so it must go. | |
242 (defun custom-face-lookup (&optional fg bg stipple bold italic underline) | |
243 "Lookup or create a face with specified attributes." | |
244 (let ((name (intern (format "custom-face-%s-%s-%s-%S-%S-%S" | |
245 (or fg "default") | |
246 (or bg "default") | |
247 (or stipple "default") | |
248 bold italic underline)))) | |
249 (if (and (custom-facep name) | |
250 (fboundp 'make-face)) | |
251 () | |
252 (copy-face 'default name) | |
253 (when (and fg | |
254 (not (string-equal fg "default"))) | |
255 (ignore-errors | |
256 (set-face-foreground name fg))) | |
257 (when (and bg | |
258 (not (string-equal bg "default"))) | |
259 (ignore-errors | |
260 (set-face-background name bg))) | |
261 (when (and stipple | |
262 (not (string-equal stipple "default")) | |
263 (not (eq stipple 'custom:asis)) | |
264 (fboundp 'set-face-stipple)) | |
265 (set-face-stipple name stipple)) | |
266 (when (and bold | |
267 (not (eq bold 'custom:asis))) | |
268 (ignore-errors | |
269 (make-face-bold name))) | |
270 (when (and italic | |
271 (not (eq italic 'custom:asis))) | |
272 (ignore-errors | |
273 (make-face-italic name))) | |
274 (when (and underline | |
275 (not (eq underline 'custom:asis))) | |
276 (ignore-errors | |
277 (set-face-underline-p name t)))) | |
278 name)) | |
279 | |
280 ;; We define these group faces here to avoid the display | |
281 ;; update forced when creating new faces. | |
282 | |
283 (defface gnus-group-news-1-face | |
284 '((((class color) | |
285 (background dark)) | |
286 (:foreground "PaleTurquoise" :bold t)) | |
287 (((class color) | |
288 (background light)) | |
289 (:foreground "ForestGreen" :bold t)) | |
290 (t | |
291 ())) | |
292 "Level 1 newsgroup face.") | |
293 | |
294 (defface gnus-group-news-1-empty-face | |
295 '((((class color) | |
296 (background dark)) | |
297 (:foreground "PaleTurquoise")) | |
298 (((class color) | |
299 (background light)) | |
300 (:foreground "ForestGreen")) | |
301 (t | |
302 ())) | |
303 "Level 1 empty newsgroup face.") | |
304 | |
305 (defface gnus-group-news-2-face | |
306 '((((class color) | |
307 (background dark)) | |
308 (:foreground "turquoise" :bold t)) | |
309 (((class color) | |
310 (background light)) | |
311 (:foreground "CadetBlue4" :bold t)) | |
312 (t | |
313 ())) | |
314 "Level 2 newsgroup face.") | |
315 | |
316 (defface gnus-group-news-2-empty-face | |
317 '((((class color) | |
318 (background dark)) | |
319 (:foreground "turquoise")) | |
320 (((class color) | |
321 (background light)) | |
322 (:foreground "CadetBlue4")) | |
323 (t | |
324 ())) | |
325 "Level 2 empty newsgroup face.") | |
326 | |
327 (defface gnus-group-news-3-face | |
328 '((((class color) | |
329 (background dark)) | |
330 (:bold t)) | |
331 (((class color) | |
332 (background light)) | |
333 (:bold t)) | |
334 (t | |
335 ())) | |
336 "Level 3 newsgroup face.") | |
337 | |
338 (defface gnus-group-news-3-empty-face | |
339 '((((class color) | |
340 (background dark)) | |
341 ()) | |
342 (((class color) | |
343 (background light)) | |
344 ()) | |
345 (t | |
346 ())) | |
347 "Level 3 empty newsgroup face.") | |
348 | |
349 (defface gnus-group-news-low-face | |
350 '((((class color) | |
351 (background dark)) | |
352 (:foreground "DarkTurquoise" :bold t)) | |
353 (((class color) | |
354 (background light)) | |
355 (:foreground "DarkGreen" :bold t)) | |
356 (t | |
357 ())) | |
358 "Low level newsgroup face.") | |
359 | |
360 (defface gnus-group-news-low-empty-face | |
361 '((((class color) | |
362 (background dark)) | |
363 (:foreground "DarkTurquoise")) | |
364 (((class color) | |
365 (background light)) | |
366 (:foreground "DarkGreen")) | |
367 (t | |
368 ())) | |
369 "Low level empty newsgroup face.") | |
370 | |
371 (defface gnus-group-mail-1-face | |
372 '((((class color) | |
373 (background dark)) | |
374 (:foreground "aquamarine1" :bold t)) | |
375 (((class color) | |
376 (background light)) | |
377 (:foreground "DeepPink3" :bold t)) | |
378 (t | |
379 (:bold t))) | |
380 "Level 1 mailgroup face.") | |
381 | |
382 (defface gnus-group-mail-1-empty-face | |
383 '((((class color) | |
384 (background dark)) | |
385 (:foreground "aquamarine1")) | |
386 (((class color) | |
387 (background light)) | |
388 (:foreground "DeepPink3")) | |
389 (t | |
390 (:italic t :bold t))) | |
391 "Level 1 empty mailgroup face.") | |
392 | |
393 (defface gnus-group-mail-2-face | |
394 '((((class color) | |
395 (background dark)) | |
396 (:foreground "aquamarine2" :bold t)) | |
397 (((class color) | |
398 (background light)) | |
399 (:foreground "HotPink3" :bold t)) | |
400 (t | |
401 (:bold t))) | |
402 "Level 2 mailgroup face.") | |
403 | |
404 (defface gnus-group-mail-2-empty-face | |
405 '((((class color) | |
406 (background dark)) | |
407 (:foreground "aquamarine2")) | |
408 (((class color) | |
409 (background light)) | |
410 (:foreground "HotPink3")) | |
411 (t | |
412 (:bold t))) | |
413 "Level 2 empty mailgroup face.") | |
414 | |
415 (defface gnus-group-mail-3-face | |
416 '((((class color) | |
417 (background dark)) | |
418 (:foreground "aquamarine3" :bold t)) | |
419 (((class color) | |
420 (background light)) | |
421 (:foreground "magenta4" :bold t)) | |
422 (t | |
423 (:bold t))) | |
424 "Level 3 mailgroup face.") | |
425 | |
426 (defface gnus-group-mail-3-empty-face | |
427 '((((class color) | |
428 (background dark)) | |
429 (:foreground "aquamarine3")) | |
430 (((class color) | |
431 (background light)) | |
432 (:foreground "magenta4")) | |
433 (t | |
434 ())) | |
435 "Level 3 empty mailgroup face.") | |
436 | |
437 (defface gnus-group-mail-low-face | |
438 '((((class color) | |
439 (background dark)) | |
440 (:foreground "aquamarine4" :bold t)) | |
441 (((class color) | |
442 (background light)) | |
443 (:foreground "DeepPink4" :bold t)) | |
444 (t | |
445 (:bold t))) | |
446 "Low level mailgroup face.") | |
447 | |
448 (defface gnus-group-mail-low-empty-face | |
449 '((((class color) | |
450 (background dark)) | |
451 (:foreground "aquamarine4")) | |
452 (((class color) | |
453 (background light)) | |
454 (:foreground "DeepPink4")) | |
455 (t | |
456 (:bold t))) | |
457 "Low level empty mailgroup face.") | |
458 | |
459 ;; Summary mode faces. | |
460 | |
461 (defface gnus-summary-selected-face '((t | |
462 (:underline t))) | |
463 "Face used for selected articles.") | |
464 | |
465 (defface gnus-summary-cancelled-face | |
466 '((((class color)) | |
467 (:foreground "yellow" :background "black"))) | |
468 "Face used for cancelled articles.") | |
469 | |
470 (defface gnus-summary-high-ticked-face | |
471 '((((class color) | |
472 (background dark)) | |
473 (:foreground "pink" :bold t)) | |
474 (((class color) | |
475 (background light)) | |
476 (:foreground "firebrick" :bold t)) | |
477 (t | |
478 (:bold t))) | |
479 "Face used for high interest ticked articles.") | |
480 | |
481 (defface gnus-summary-low-ticked-face | |
482 '((((class color) | |
483 (background dark)) | |
484 (:foreground "pink" :italic t)) | |
485 (((class color) | |
486 (background light)) | |
487 (:foreground "firebrick" :italic t)) | |
488 (t | |
489 (:italic t))) | |
490 "Face used for low interest ticked articles.") | |
491 | |
492 (defface gnus-summary-normal-ticked-face | |
493 '((((class color) | |
494 (background dark)) | |
495 (:foreground "pink")) | |
496 (((class color) | |
497 (background light)) | |
498 (:foreground "firebrick")) | |
499 (t | |
500 ())) | |
501 "Face used for normal interest ticked articles.") | |
502 | |
503 (defface gnus-summary-high-ancient-face | |
504 '((((class color) | |
505 (background dark)) | |
506 (:foreground "SkyBlue" :bold t)) | |
507 (((class color) | |
508 (background light)) | |
509 (:foreground "RoyalBlue" :bold t)) | |
510 (t | |
511 (:bold t))) | |
512 "Face used for high interest ancient articles.") | |
513 | |
514 (defface gnus-summary-low-ancient-face | |
515 '((((class color) | |
516 (background dark)) | |
517 (:foreground "SkyBlue" :italic t)) | |
518 (((class color) | |
519 (background light)) | |
520 (:foreground "RoyalBlue" :italic t)) | |
521 (t | |
522 (:italic t))) | |
523 "Face used for low interest ancient articles.") | |
524 | |
525 (defface gnus-summary-normal-ancient-face | |
526 '((((class color) | |
527 (background dark)) | |
528 (:foreground "SkyBlue")) | |
529 (((class color) | |
530 (background light)) | |
531 (:foreground "RoyalBlue")) | |
532 (t | |
533 ())) | |
534 "Face used for normal interest ancient articles.") | |
535 | |
536 (defface gnus-summary-high-unread-face | |
537 '((t | |
538 (:bold t))) | |
539 "Face used for high interest unread articles.") | |
540 | |
541 (defface gnus-summary-low-unread-face | |
542 '((t | |
543 (:italic t))) | |
544 "Face used for low interest unread articles.") | |
545 | |
546 (defface gnus-summary-normal-unread-face | |
547 '((t | |
548 ())) | |
549 "Face used for normal interest unread articles.") | |
550 | |
551 (defface gnus-summary-high-read-face | |
552 '((((class color) | |
553 (background dark)) | |
554 (:foreground "PaleGreen" | |
555 :bold t)) | |
556 (((class color) | |
557 (background light)) | |
558 (:foreground "DarkGreen" | |
559 :bold t)) | |
560 (t | |
561 (:bold t))) | |
562 "Face used for high interest read articles.") | |
563 | |
564 (defface gnus-summary-low-read-face | |
565 '((((class color) | |
566 (background dark)) | |
567 (:foreground "PaleGreen" | |
568 :italic t)) | |
569 (((class color) | |
570 (background light)) | |
571 (:foreground "DarkGreen" | |
572 :italic t)) | |
573 (t | |
574 (:italic t))) | |
575 "Face used for low interest read articles.") | |
576 | |
577 (defface gnus-summary-normal-read-face | |
578 '((((class color) | |
579 (background dark)) | |
580 (:foreground "PaleGreen")) | |
581 (((class color) | |
582 (background light)) | |
583 (:foreground "DarkGreen")) | |
584 (t | |
585 ())) | |
586 "Face used for normal interest read articles.") | |
587 | |
588 | |
589 ;;; Splash screen. | |
590 | |
591 (defvar gnus-group-buffer "*Group*") | |
592 | |
593 (eval-and-compile | |
594 (autoload 'gnus-play-jingle "gnus-audio")) | |
595 | |
596 (defface gnus-splash-face | |
597 '((((class color) | |
598 (background dark)) | |
599 (:foreground "red")) | |
600 (((class color) | |
601 (background light)) | |
602 (:foreground "red")) | |
603 (t | |
604 ())) | |
605 "Level 1 newsgroup face.") | |
606 | |
607 (defun gnus-splash () | |
608 (save-excursion | |
609 (switch-to-buffer gnus-group-buffer) | |
610 (let ((buffer-read-only nil)) | |
611 (erase-buffer) | |
612 (unless gnus-inhibit-startup-message | |
613 (gnus-group-startup-message) | |
614 (sit-for 0) | |
615 (when gnus-play-startup-jingle | |
616 (gnus-play-jingle)))))) | |
617 | |
618 (defun gnus-indent-rigidly (start end arg) | |
619 "Indent rigidly using only spaces and no tabs." | |
620 (save-excursion | |
621 (save-restriction | |
622 (narrow-to-region start end) | |
623 (indent-rigidly start end arg) | |
624 ;; We translate tabs into spaces -- not everybody uses | |
625 ;; an 8-character tab. | |
626 (goto-char (point-min)) | |
627 (while (search-forward "\t" nil t) | |
628 (replace-match " " t t))))) | |
629 | |
630 (defvar gnus-simple-splash nil) | |
631 | |
632 (defun gnus-group-startup-message (&optional x y) | |
633 "Insert startup message in current buffer." | |
634 ;; Insert the message. | |
635 (erase-buffer) | |
636 (insert | |
637 (format " %s | |
638 _ ___ _ _ | |
639 _ ___ __ ___ __ _ ___ | |
640 __ _ ___ __ ___ | |
641 _ ___ _ | |
642 _ _ __ _ | |
643 ___ __ _ | |
644 __ _ | |
645 _ _ _ | |
646 _ _ _ | |
647 _ _ _ | |
648 __ ___ | |
649 _ _ _ _ | |
650 _ _ | |
651 _ _ | |
652 _ _ | |
653 _ | |
654 __ | |
655 | |
656 " | |
657 "")) | |
658 ;; And then hack it. | |
659 (gnus-indent-rigidly (point-min) (point-max) | |
660 (/ (max (- (window-width) (or x 46)) 0) 2)) | |
661 (goto-char (point-min)) | |
662 (forward-line 1) | |
663 (let* ((pheight (count-lines (point-min) (point-max))) | |
664 (wheight (window-height)) | |
665 (rest (- wheight pheight))) | |
666 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))) | |
667 ;; Fontify some. | |
668 (put-text-property (point-min) (point-max) 'face 'gnus-splash-face) | |
669 (goto-char (point-min)) | |
670 (setq mode-line-buffer-identification (concat " " gnus-version)) | |
671 (setq gnus-simple-splash t) | |
672 (set-buffer-modified-p t)) | |
673 | |
674 (eval-when (load) | |
675 (let ((command (format "%s" this-command))) | |
676 (when (and (string-match "gnus" command) | |
677 (not (string-match "gnus-other-frame" command))) | |
678 (gnus-splash)))) | |
679 | |
680 ;;; Do the rest. | |
681 | |
682 (require 'custom) | |
683 (require 'gnus-util) | |
33 (require 'nnheader) | 684 (require 'nnheader) |
34 (require 'nnmail) | 685 |
35 (require 'nnoo) | 686 (defcustom gnus-directory (or (getenv "SAVEDIR") "~/News/") |
36 | 687 "Directory variable from which all other Gnus file variables are derived." |
37 (eval-when-compile (require 'cl)) | 688 :group 'gnus-files |
38 | 689 :type 'directory) |
39 (defvar gnus-directory (or (getenv "SAVEDIR") "~/News/") | 690 |
40 "*Directory variable from which all other Gnus file variables are derived.") | 691 (defcustom gnus-default-directory nil |
692 "*Default directory for all Gnus buffers." | |
693 :group 'gnus-files | |
694 :type '(choice (const :tag "current" nil) | |
695 directory)) | |
41 | 696 |
42 ;; Site dependent variables. These variables should be defined in | 697 ;; Site dependent variables. These variables should be defined in |
43 ;; paths.el. | 698 ;; paths.el. |
44 | 699 |
45 (defvar gnus-default-nntp-server nil | 700 (defvar gnus-default-nntp-server nil |
47 This variable should be defined in paths.el, and should never be set | 702 This variable should be defined in paths.el, and should never be set |
48 by the user. | 703 by the user. |
49 If you want to change servers, you should use `gnus-select-method'. | 704 If you want to change servers, you should use `gnus-select-method'. |
50 See the documentation to that variable.") | 705 See the documentation to that variable.") |
51 | 706 |
52 (defvar gnus-backup-default-subscribed-newsgroups | |
53 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus") | |
54 "Default default new newsgroups the first time Gnus is run. | |
55 Should be set in paths.el, and shouldn't be touched by the user.") | |
56 | |
57 (defvar gnus-local-domain nil | |
58 "Local domain name without a host name. | |
59 The DOMAINNAME environment variable is used instead if it is defined. | |
60 If the `system-name' function returns the full Internet name, there is | |
61 no need to set this variable.") | |
62 | |
63 (defvar gnus-local-organization nil | |
64 "String with a description of what organization (if any) the user belongs to. | |
65 The ORGANIZATION environment variable is used instead if it is defined. | |
66 If this variable contains a function, this function will be called | |
67 with the current newsgroup name as the argument. The function should | |
68 return a string. | |
69 | |
70 In any case, if the string (either in the variable, in the environment | |
71 variable, or returned by the function) is a file name, the contents of | |
72 this file will be used as the organization.") | |
73 | |
74 ;; Customization variables | |
75 | |
76 ;; Don't touch this variable. | 707 ;; Don't touch this variable. |
77 (defvar gnus-nntp-service "nntp" | 708 (defvar gnus-nntp-service "nntp" |
78 "*NNTP service name (\"nntp\" or 119). | 709 "NNTP service name (\"nntp\" or 119). |
79 This is an obsolete variable, which is scarcely used. If you use an | 710 This is an obsolete variable, which is scarcely used. If you use an |
80 nntp server for your newsgroup and want to change the port number | 711 nntp server for your newsgroup and want to change the port number |
81 used to 899, you would say something along these lines: | 712 used to 899, you would say something along these lines: |
82 | 713 |
83 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))") | 714 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))") |
84 | 715 |
85 (defvar gnus-nntpserver-file "/etc/nntpserver" | 716 (defcustom gnus-nntpserver-file "/etc/nntpserver" |
86 "*A file with only the name of the nntp server in it.") | 717 "A file with only the name of the nntp server in it." |
718 :group 'gnus-files | |
719 :group 'gnus-server | |
720 :type 'file) | |
87 | 721 |
88 ;; This function is used to check both the environment variable | 722 ;; This function is used to check both the environment variable |
89 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find | 723 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find |
90 ;; an nntp server name default. | 724 ;; an nntp server name default. |
91 (defun gnus-getenv-nntpserver () | 725 (defun gnus-getenv-nntpserver () |
100 (if (string-match "^[ \t\n]*$" name) | 734 (if (string-match "^[ \t\n]*$" name) |
101 nil | 735 nil |
102 name) | 736 name) |
103 (kill-buffer (current-buffer)))))))) | 737 (kill-buffer (current-buffer)))))))) |
104 | 738 |
105 (defvar gnus-select-method | 739 (defcustom gnus-select-method |
106 (nconc | 740 (ignore-errors |
107 (list 'nntp (or (condition-case () | 741 (nconc |
108 (gnus-getenv-nntpserver) | 742 (list 'nntp (or (ignore-errors |
109 (error nil)) | 743 (gnus-getenv-nntpserver)) |
110 (if (and gnus-default-nntp-server | 744 (when (and gnus-default-nntp-server |
111 (not (string= gnus-default-nntp-server ""))) | 745 (not (string= gnus-default-nntp-server ""))) |
112 gnus-default-nntp-server) | 746 gnus-default-nntp-server) |
113 (system-name))) | 747 (system-name))) |
114 (if (or (null gnus-nntp-service) | 748 (if (or (null gnus-nntp-service) |
115 (equal gnus-nntp-service "nntp")) | 749 (equal gnus-nntp-service "nntp")) |
116 nil | 750 nil |
117 (list gnus-nntp-service))) | 751 (list gnus-nntp-service)))) |
118 "*Default method for selecting a newsgroup. | 752 "Default method for selecting a newsgroup. |
119 This variable should be a list, where the first element is how the | 753 This variable should be a list, where the first element is how the |
120 news is to be fetched, the second is the address. | 754 news is to be fetched, the second is the address. |
121 | 755 |
122 For instance, if you want to get your news via NNTP from | 756 For instance, if you want to get your news via NNTP from |
123 \"flab.flab.edu\", you could say: | 757 \"flab.flab.edu\", you could say: |
124 | 758 |
125 (setq gnus-select-method '(nntp \"flab.flab.edu\")) | 759 \(setq gnus-select-method '(nntp \"flab.flab.edu\")) |
126 | 760 |
127 If you want to use your local spool, say: | 761 If you want to use your local spool, say: |
128 | 762 |
129 (setq gnus-select-method (list 'nnspool (system-name))) | 763 \(setq gnus-select-method (list 'nnspool (system-name))) |
130 | 764 |
131 If you use this variable, you must set `gnus-nntp-server' to nil. | 765 If you use this variable, you must set `gnus-nntp-server' to nil. |
132 | 766 |
133 There is a lot more to know about select methods and virtual servers - | 767 There is a lot more to know about select methods and virtual servers - |
134 see the manual for details.") | 768 see the manual for details." |
135 | 769 :group 'gnus-server |
136 (defvar gnus-message-archive-method | 770 :type 'gnus-select-method) |
771 | |
772 (defcustom gnus-message-archive-method | |
137 `(nnfolder | 773 `(nnfolder |
138 "archive" | 774 "archive" |
139 (nnfolder-directory ,(nnheader-concat message-directory "archive")) | 775 (nnfolder-directory ,(nnheader-concat message-directory "archive")) |
140 (nnfolder-active-file | 776 (nnfolder-active-file |
141 ,(nnheader-concat message-directory "archive/active")) | 777 ,(nnheader-concat message-directory "archive/active")) |
142 (nnfolder-get-new-mail nil) | 778 (nnfolder-get-new-mail nil) |
143 (nnfolder-inhibit-expiry t)) | 779 (nnfolder-inhibit-expiry t)) |
144 "*Method used for archiving messages you've sent. | 780 "Method used for archiving messages you've sent. |
145 This should be a mail method. | 781 This should be a mail method. |
146 | 782 |
147 It's probably not a very effective to change this variable once you've | 783 It's probably not a very effective to change this variable once you've |
148 run Gnus once. After doing that, you must edit this server from the | 784 run Gnus once. After doing that, you must edit this server from the |
149 server buffer.") | 785 server buffer." |
150 | 786 :group 'gnus-server |
151 (defvar gnus-message-archive-group nil | 787 :group 'gnus-message |
788 :type 'gnus-select-method) | |
789 | |
790 (defcustom gnus-message-archive-group nil | |
152 "*Name of the group in which to save the messages you've written. | 791 "*Name of the group in which to save the messages you've written. |
153 This can either be a string, a list of strings; or an alist | 792 This can either be a string, a list of strings; or an alist |
154 of regexps/functions/forms to be evaluated to return a string (or a list | 793 of regexps/functions/forms to be evaluated to return a string (or a list |
155 of strings). The functions are called with the name of the current | 794 of strings). The functions are called with the name of the current |
156 group (or nil) as a parameter. | 795 group (or nil) as a parameter. |
162 '((if (message-news-p) | 801 '((if (message-news-p) |
163 \"misc-news\" | 802 \"misc-news\" |
164 \"misc-mail\"))) | 803 \"misc-mail\"))) |
165 | 804 |
166 Normally the group names returned by this variable should be | 805 Normally the group names returned by this variable should be |
167 unprefixed -- which implictly means \"store on the archive server\". | 806 unprefixed -- which implicitly means \"store on the archive server\". |
168 However, you may wish to store the message on some other server. In | 807 However, you may wish to store the message on some other server. In |
169 that case, just return a fully prefixed name of the group -- | 808 that case, just return a fully prefixed name of the group -- |
170 \"nnml+private:mail.misc\", for instance.") | 809 \"nnml+private:mail.misc\", for instance." |
171 | 810 :group 'gnus-message |
172 (defvar gnus-refer-article-method nil | 811 :type '(choice (const :tag "none" nil) |
173 "*Preferred method for fetching an article by Message-ID. | 812 string)) |
813 | |
814 (defcustom gnus-secondary-servers nil | |
815 "List of NNTP servers that the user can choose between interactively. | |
816 To make Gnus query you for a server, you have to give `gnus' a | |
817 non-numeric prefix - `C-u M-x gnus', in short." | |
818 :group 'gnus-server | |
819 :type '(repeat string)) | |
820 | |
821 (defcustom gnus-nntp-server nil | |
822 "*The name of the host running the NNTP server. | |
823 This variable is semi-obsolete. Use the `gnus-select-method' | |
824 variable instead." | |
825 :group 'gnus-server | |
826 :type '(choice (const :tag "disable" nil) | |
827 string)) | |
828 | |
829 (defcustom gnus-secondary-select-methods nil | |
830 "A list of secondary methods that will be used for reading news. | |
831 This is a list where each element is a complete select method (see | |
832 `gnus-select-method'). | |
833 | |
834 If, for instance, you want to read your mail with the nnml backend, | |
835 you could set this variable: | |
836 | |
837 \(setq gnus-secondary-select-methods '((nnml \"\")))" | |
838 :group 'gnus-server | |
839 :type '(repeat gnus-select-method)) | |
840 | |
841 (defvar gnus-backup-default-subscribed-newsgroups | |
842 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus") | |
843 "Default default new newsgroups the first time Gnus is run. | |
844 Should be set in paths.el, and shouldn't be touched by the user.") | |
845 | |
846 (defcustom gnus-local-domain nil | |
847 "Local domain name without a host name. | |
848 The DOMAINNAME environment variable is used instead if it is defined. | |
849 If the `system-name' function returns the full Internet name, there is | |
850 no need to set this variable." | |
851 :group 'gnus-message | |
852 :type '(choice (const :tag "default" nil) | |
853 string)) | |
854 | |
855 (defcustom gnus-local-organization nil | |
856 "String with a description of what organization (if any) the user belongs to. | |
857 The ORGANIZATION environment variable is used instead if it is defined. | |
858 If this variable contains a function, this function will be called | |
859 with the current newsgroup name as the argument. The function should | |
860 return a string. | |
861 | |
862 In any case, if the string (either in the variable, in the environment | |
863 variable, or returned by the function) is a file name, the contents of | |
864 this file will be used as the organization." | |
865 :group 'gnus-message | |
866 :type '(choice (const :tag "default" nil) | |
867 string)) | |
868 | |
869 ;; Customization variables | |
870 | |
871 (defcustom gnus-refer-article-method nil | |
872 "Preferred method for fetching an article by Message-ID. | |
174 If you are reading news from the local spool (with nnspool), fetching | 873 If you are reading news from the local spool (with nnspool), fetching |
175 articles by Message-ID is painfully slow. By setting this method to an | 874 articles by Message-ID is painfully slow. By setting this method to an |
176 nntp method, you might get acceptable results. | 875 nntp method, you might get acceptable results. |
177 | 876 |
178 The value of this variable must be a valid select method as discussed | 877 The value of this variable must be a valid select method as discussed |
179 in the documentation of `gnus-select-method'.") | 878 in the documentation of `gnus-select-method'." |
180 | 879 :group 'gnus-server |
181 (defvar gnus-secondary-select-methods nil | 880 :type '(choice (const :tag "default" nil) |
182 "*A list of secondary methods that will be used for reading news. | 881 gnus-select-method)) |
183 This is a list where each element is a complete select method (see | 882 |
184 `gnus-select-method'). | 883 (defcustom gnus-group-faq-directory |
185 | |
186 If, for instance, you want to read your mail with the nnml backend, | |
187 you could set this variable: | |
188 | |
189 (setq gnus-secondary-select-methods '((nnml \"\")))") | |
190 | |
191 (defvar gnus-secondary-servers nil | |
192 "*List of NNTP servers that the user can choose between interactively. | |
193 To make Gnus query you for a server, you have to give `gnus' a | |
194 non-numeric prefix - `C-u M-x gnus', in short.") | |
195 | |
196 (defvar gnus-nntp-server nil | |
197 "*The name of the host running the NNTP server. | |
198 This variable is semi-obsolete. Use the `gnus-select-method' | |
199 variable instead.") | |
200 | |
201 (defvar gnus-startup-file "~/.newsrc" | |
202 "*Your `.newsrc' file. | |
203 `.newsrc-SERVER' will be used instead if that exists.") | |
204 | |
205 (defvar gnus-init-file "~/.gnus" | |
206 "*Your Gnus elisp startup file. | |
207 If a file with the .el or .elc suffixes exist, it will be read | |
208 instead.") | |
209 | |
210 (defvar gnus-group-faq-directory | |
211 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/" | 884 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/" |
212 "/ftp@sunsite.auc.dk:/pub/usenet/" | 885 "/ftp@sunsite.auc.dk:/pub/usenet/" |
213 "/ftp@sunsite.doc.ic.ac.uk:/pub/usenet/news-faqs/" | 886 "/ftp@sunsite.doc.ic.ac.uk:/pub/usenet/news-faqs/" |
214 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/" | 887 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/" |
215 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/" | 888 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/" |
217 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/" | 890 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/" |
218 "/ftp@ftp.sunet.se:/pub/usenet/" | 891 "/ftp@ftp.sunet.se:/pub/usenet/" |
219 "/ftp@nctuccca.edu.tw:/USENET/FAQ/" | 892 "/ftp@nctuccca.edu.tw:/USENET/FAQ/" |
220 "/ftp@hwarang.postech.ac.kr:/pub/usenet/" | 893 "/ftp@hwarang.postech.ac.kr:/pub/usenet/" |
221 "/ftp@ftp.hk.super.net:/mirror/faqs/") | 894 "/ftp@ftp.hk.super.net:/mirror/faqs/") |
222 "*Directory where the group FAQs are stored. | 895 "Directory where the group FAQs are stored. |
223 This will most commonly be on a remote machine, and the file will be | 896 This will most commonly be on a remote machine, and the file will be |
224 fetched by ange-ftp. | 897 fetched by ange-ftp. |
225 | 898 |
226 This variable can also be a list of directories. In that case, the | 899 This variable can also be a list of directories. In that case, the |
227 first element in the list will be used by default. The others can | 900 first element in the list will be used by default. The others can |
240 src.doc.ic.ac.uk /usenet/news-FAQS | 913 src.doc.ic.ac.uk /usenet/news-FAQS |
241 ftp.sunet.se /pub/usenet | 914 ftp.sunet.se /pub/usenet |
242 sunsite.auc.dk /pub/usenet | 915 sunsite.auc.dk /pub/usenet |
243 Asia: nctuccca.edu.tw /USENET/FAQ | 916 Asia: nctuccca.edu.tw /USENET/FAQ |
244 hwarang.postech.ac.kr /pub/usenet | 917 hwarang.postech.ac.kr /pub/usenet |
245 ftp.hk.super.net /mirror/faqs") | 918 ftp.hk.super.net /mirror/faqs" |
246 | 919 :group 'gnus-group-various |
247 (defvar gnus-group-archive-directory | 920 :type '(choice directory |
248 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/" | 921 (repeat directory))) |
249 "*The address of the (ding) archives.") | 922 |
250 | 923 (defcustom gnus-use-cross-reference t |
251 (defvar gnus-group-recent-archive-directory | |
252 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/" | |
253 "*The address of the most recent (ding) articles.") | |
254 | |
255 (defvar gnus-default-subscribed-newsgroups nil | |
256 "*This variable lists what newsgroups should be subscribed the first time Gnus is used. | |
257 It should be a list of strings. | |
258 If it is `t', Gnus will not do anything special the first time it is | |
259 started; it'll just use the normal newsgroups subscription methods.") | |
260 | |
261 (defvar gnus-use-cross-reference t | |
262 "*Non-nil means that cross referenced articles will be marked as read. | 924 "*Non-nil means that cross referenced articles will be marked as read. |
263 If nil, ignore cross references. If t, mark articles as read in | 925 If nil, ignore cross references. If t, mark articles as read in |
264 subscribed newsgroups. If neither t nor nil, mark as read in all | 926 subscribed newsgroups. If neither t nor nil, mark as read in all |
265 newsgroups.") | 927 newsgroups." |
266 | 928 :group 'gnus-server |
267 (defvar gnus-single-article-buffer t | 929 :type '(choice (const :tag "off" nil) |
268 "*If non-nil, display all articles in the same buffer. | 930 (const :tag "subscribed" t) |
269 If nil, each group will get its own article buffer.") | 931 (sexp :format "all" |
270 | 932 :value always))) |
271 (defvar gnus-use-dribble-file t | 933 |
272 "*Non-nil means that Gnus will use a dribble file to store user updates. | 934 (defcustom gnus-process-mark ?# |
273 If Emacs should crash without saving the .newsrc files, complete | 935 "*Process mark." |
274 information can be restored from the dribble file.") | 936 :group 'gnus-group-visual |
275 | 937 :group 'gnus-summary-marks |
276 (defvar gnus-dribble-directory nil | 938 :type 'character) |
277 "*The directory where dribble files will be saved. | 939 |
278 If this variable is nil, the directory where the .newsrc files are | 940 (defcustom gnus-asynchronous nil |
279 saved will be used.") | 941 "*If non-nil, Gnus will supply backends with data needed for async article fetching." |
280 | 942 :group 'gnus-asynchronous |
281 (defvar gnus-asynchronous nil | 943 :type 'boolean) |
282 "*If non-nil, Gnus will supply backends with data needed for async article fetching.") | 944 |
283 | 945 (defcustom gnus-large-newsgroup 200 |
284 (defvar gnus-kill-summary-on-exit t | |
285 "*If non-nil, kill the summary buffer when you exit from it. | |
286 If nil, the summary will become a \"*Dead Summary*\" buffer, and | |
287 it will be killed sometime later.") | |
288 | |
289 (defvar gnus-large-newsgroup 200 | |
290 "*The number of articles which indicates a large newsgroup. | 946 "*The number of articles which indicates a large newsgroup. |
291 If the number of articles in a newsgroup is greater than this value, | 947 If the number of articles in a newsgroup is greater than this value, |
292 confirmation is required for selecting the newsgroup.") | 948 confirmation is required for selecting the newsgroup." |
293 | 949 :group 'gnus-group-select |
294 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>. | 950 :type 'integer) |
295 (defvar gnus-no-groups-message "No news is horrible news" | 951 |
296 "*Message displayed by Gnus when no groups are available.") | 952 (defcustom gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix))) |
297 | |
298 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix))) | |
299 "*Non-nil means that the default name of a file to save articles in is the group name. | 953 "*Non-nil means that the default name of a file to save articles in is the group name. |
300 If it's nil, the directory form of the group name is used instead. | 954 If it's nil, the directory form of the group name is used instead. |
301 | 955 |
302 If this variable is a list, and the list contains the element | 956 If this variable is a list, and the list contains the element |
303 `not-score', long file names will not be used for score files; if it | 957 `not-score', long file names will not be used for score files; if it |
305 saving; and if it contains the element `not-kill', long file names | 959 saving; and if it contains the element `not-kill', long file names |
306 will not be used for kill files. | 960 will not be used for kill files. |
307 | 961 |
308 Note that the default for this variable varies according to what system | 962 Note that the default for this variable varies according to what system |
309 type you're using. On `usg-unix-v' and `xenix' this variable defaults | 963 type you're using. On `usg-unix-v' and `xenix' this variable defaults |
310 to nil while on all other systems it defaults to t.") | 964 to nil while on all other systems it defaults to t." |
311 | 965 :group 'gnus-start |
312 (defvar gnus-article-save-directory gnus-directory | 966 :type 'boolean) |
313 "*Name of the directory articles will be saved in (default \"~/News\").") | 967 |
314 | 968 (defcustom gnus-kill-files-directory gnus-directory |
315 (defvar gnus-kill-files-directory gnus-directory | 969 "*Name of the directory where kill files will be stored (default \"~/News\")." |
316 "*Name of the directory where kill files will be stored (default \"~/News\").") | 970 :group 'gnus-score-files |
317 | 971 :group 'gnus-score-kill |
318 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail | 972 :type 'directory) |
319 "*A function to save articles in your favorite format. | 973 |
320 The function must be interactively callable (in other words, it must | 974 (defcustom gnus-save-score nil |
321 be an Emacs command). | 975 "*If non-nil, save group scoring info." |
322 | 976 :group 'gnus-score-various |
323 Gnus provides the following functions: | 977 :group 'gnus-start |
324 | 978 :type 'boolean) |
325 * gnus-summary-save-in-rmail (Rmail format) | 979 |
326 * gnus-summary-save-in-mail (Unix mail format) | 980 (defcustom gnus-use-undo t |
327 * gnus-summary-save-in-folder (MH folder) | 981 "*If non-nil, allow undoing in Gnus group mode buffers." |
328 * gnus-summary-save-in-file (article format). | 982 :group 'gnus-meta |
329 * gnus-summary-save-in-vm (use VM's folder format).") | 983 :type 'boolean) |
330 | 984 |
331 (defvar gnus-prompt-before-saving 'always | 985 (defcustom gnus-use-adaptive-scoring nil |
332 "*This variable says how much prompting is to be done when saving articles. | 986 "*If non-nil, use some adaptive scoring scheme. |
333 If it is nil, no prompting will be done, and the articles will be | 987 If a list, then the values `word' and `line' are meaningful. The |
334 saved to the default files. If this variable is `always', each and | 988 former will perform adaption on individual words in the subject |
335 every article that is saved will be preceded by a prompt, even when | 989 header while `line' will perform adaption on several headers." |
336 saving large batches of articles. If this variable is neither nil not | 990 :group 'gnus-meta |
337 `always', there the user will be prompted once for a file name for | 991 :group 'gnus-score-adapt |
338 each invocation of the saving commands.") | 992 :type '(set (const word) (const line))) |
339 | 993 |
340 (defvar gnus-rmail-save-name (function gnus-plain-save-name) | 994 (defcustom gnus-use-cache 'passive |
341 "*A function generating a file name to save articles in Rmail format. | |
342 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.") | |
343 | |
344 (defvar gnus-mail-save-name (function gnus-plain-save-name) | |
345 "*A function generating a file name to save articles in Unix mail format. | |
346 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.") | |
347 | |
348 (defvar gnus-folder-save-name (function gnus-folder-save-name) | |
349 "*A function generating a file name to save articles in MH folder. | |
350 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.") | |
351 | |
352 (defvar gnus-file-save-name (function gnus-numeric-save-name) | |
353 "*A function generating a file name to save articles in article format. | |
354 The function is called with NEWSGROUP, HEADERS, and optional | |
355 LAST-FILE.") | |
356 | |
357 (defvar gnus-split-methods | |
358 '((gnus-article-archive-name)) | |
359 "*Variable used to suggest where articles are to be saved. | |
360 For instance, if you would like to save articles related to Gnus in | |
361 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\", | |
362 you could set this variable to something like: | |
363 | |
364 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\") | |
365 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\")) | |
366 | |
367 This variable is an alist where the where the key is the match and the | |
368 value is a list of possible files to save in if the match is non-nil. | |
369 | |
370 If the match is a string, it is used as a regexp match on the | |
371 article. If the match is a symbol, that symbol will be funcalled | |
372 from the buffer of the article to be saved with the newsgroup as the | |
373 parameter. If it is a list, it will be evaled in the same buffer. | |
374 | |
375 If this form or function returns a string, this string will be used as | |
376 a possible file name; and if it returns a non-nil list, that list will | |
377 be used as possible file names.") | |
378 | |
379 (defvar gnus-move-split-methods nil | |
380 "*Variable used to suggest where articles are to be moved to. | |
381 It uses the same syntax as the `gnus-split-methods' variable.") | |
382 | |
383 (defvar gnus-save-score nil | |
384 "*If non-nil, save group scoring info.") | |
385 | |
386 (defvar gnus-use-adaptive-scoring nil | |
387 "*If non-nil, use some adaptive scoring scheme.") | |
388 | |
389 (defvar gnus-use-cache 'passive | |
390 "*If nil, Gnus will ignore the article cache. | 995 "*If nil, Gnus will ignore the article cache. |
391 If `passive', it will allow entering (and reading) articles | 996 If `passive', it will allow entering (and reading) articles |
392 explicitly entered into the cache. If anything else, use the | 997 explicitly entered into the cache. If anything else, use the |
393 cache to the full extent of the law.") | 998 cache to the full extent of the law." |
394 | 999 :group 'gnus-meta |
395 (defvar gnus-use-trees nil | 1000 :group 'gnus-cache |
396 "*If non-nil, display a thread tree buffer.") | 1001 :type '(choice (const :tag "off" nil) |
397 | 1002 (const :tag "passive" passive) |
398 (defvar gnus-use-grouplens nil | 1003 (const :tag "active" t))) |
399 "*If non-nil, use GroupLens ratings.") | 1004 |
400 | 1005 (defcustom gnus-use-trees nil |
401 (defvar gnus-keep-backlog nil | 1006 "*If non-nil, display a thread tree buffer." |
1007 :group 'gnus-meta | |
1008 :type 'boolean) | |
1009 | |
1010 (defcustom gnus-use-grouplens nil | |
1011 "*If non-nil, use GroupLens ratings." | |
1012 :group 'gnus-meta | |
1013 :type 'boolean) | |
1014 | |
1015 (defcustom gnus-keep-backlog nil | |
402 "*If non-nil, Gnus will keep read articles for later re-retrieval. | 1016 "*If non-nil, Gnus will keep read articles for later re-retrieval. |
403 If it is a number N, then Gnus will only keep the last N articles | 1017 If it is a number N, then Gnus will only keep the last N articles |
404 read. If it is neither nil nor a number, Gnus will keep all read | 1018 read. If it is neither nil nor a number, Gnus will keep all read |
405 articles. This is not a good idea.") | 1019 articles. This is not a good idea." |
406 | 1020 :group 'gnus-meta |
407 (defvar gnus-use-nocem nil | 1021 :type '(choice (const :tag "off" nil) |
408 "*If non-nil, Gnus will read NoCeM cancel messages.") | 1022 integer |
409 | 1023 (sexp :format "all" |
410 (defvar gnus-use-demon nil | 1024 :value t))) |
411 "If non-nil, Gnus might use some demons.") | 1025 |
412 | 1026 (defcustom gnus-use-nocem nil |
413 (defvar gnus-use-scoring t | 1027 "*If non-nil, Gnus will read NoCeM cancel messages." |
414 "*If non-nil, enable scoring.") | 1028 :group 'gnus-meta |
415 | 1029 :type 'boolean) |
416 (defvar gnus-use-picons nil | 1030 |
417 "*If non-nil, display picons.") | 1031 (defcustom gnus-suppress-duplicates nil |
418 | 1032 "*If non-nil, Gnus will mark duplicate copies of the same article as read." |
419 (defvar gnus-fetch-old-headers nil | 1033 :group 'gnus-meta |
420 "*Non-nil means that Gnus will try to build threads by grabbing old headers. | 1034 :type 'boolean) |
421 If an unread article in the group refers to an older, already read (or | 1035 |
422 just marked as read) article, the old article will not normally be | 1036 (defcustom gnus-use-demon nil |
423 displayed in the Summary buffer. If this variable is non-nil, Gnus | 1037 "If non-nil, Gnus might use some demons." |
424 will attempt to grab the headers to the old articles, and thereby | 1038 :group 'gnus-meta |
425 build complete threads. If it has the value `some', only enough | 1039 :type 'boolean) |
426 headers to connect otherwise loose threads will be displayed. | 1040 |
427 This variable can also be a number. In that case, no more than that | 1041 (defcustom gnus-use-scoring t |
428 number of old headers will be fetched. | 1042 "*If non-nil, enable scoring." |
429 | 1043 :group 'gnus-meta |
430 The server has to support NOV for any of this to work.") | 1044 :type 'boolean) |
431 | 1045 |
432 ;see gnus-cus.el | 1046 (defcustom gnus-use-picons nil |
433 ;(defvar gnus-visual t | 1047 "*If non-nil, display picons." |
434 ; "*If non-nil, will do various highlighting. | 1048 :group 'gnus-meta |
435 ;If nil, no mouse highlights (or any other highlights) will be | 1049 :type 'boolean) |
436 ;performed. This might speed up Gnus some when generating large group | 1050 |
437 ;and summary buffers.") | 1051 (defcustom gnus-summary-prepare-exit-hook |
438 | 1052 '(gnus-summary-expire-articles) |
439 (defvar gnus-novice-user t | 1053 "A hook called when preparing to exit from the summary buffer. |
1054 It calls `gnus-summary-expire-articles' by default." | |
1055 :group 'gnus-summary-exit | |
1056 :type 'hook) | |
1057 | |
1058 (defcustom gnus-novice-user t | |
440 "*Non-nil means that you are a usenet novice. | 1059 "*Non-nil means that you are a usenet novice. |
441 If non-nil, verbose messages may be displayed and confirmations may be | 1060 If non-nil, verbose messages may be displayed and confirmations may be |
442 required.") | 1061 required." |
443 | 1062 :group 'gnus-meta |
444 (defvar gnus-expert-user nil | 1063 :type 'boolean) |
1064 | |
1065 (defcustom gnus-expert-user nil | |
445 "*Non-nil means that you will never be asked for confirmation about anything. | 1066 "*Non-nil means that you will never be asked for confirmation about anything. |
446 And that means *anything*.") | 1067 And that means *anything*." |
447 | 1068 :group 'gnus-meta |
448 (defvar gnus-verbose 7 | 1069 :type 'boolean) |
449 "*Integer that says how verbose Gnus should be. | 1070 |
450 The higher the number, the more messages Gnus will flash to say what | 1071 (defcustom gnus-interactive-catchup t |
451 it's doing. At zero, Gnus will be totally mute; at five, Gnus will | 1072 "*If non-nil, require your confirmation when catching up a group." |
452 display most important messages; and at ten, Gnus will keep on | 1073 :group 'gnus-group-select |
453 jabbering all the time.") | 1074 :type 'boolean) |
454 | 1075 |
455 (defvar gnus-keep-same-level nil | 1076 (defcustom gnus-interactive-exit t |
456 "*Non-nil means that the next newsgroup after the current will be on the same level. | 1077 "*If non-nil, require your confirmation when exiting Gnus." |
457 When you type, for instance, `n' after reading the last article in the | 1078 :group 'gnus-exit |
458 current newsgroup, you will go to the next newsgroup. If this variable | 1079 :type 'boolean) |
459 is nil, the next newsgroup will be the next from the group | 1080 |
460 buffer. | 1081 (defcustom gnus-extract-address-components 'gnus-extract-address-components |
461 If this variable is non-nil, Gnus will either put you in the | |
462 next newsgroup with the same level, or, if no such newsgroup is | |
463 available, the next newsgroup with the lowest possible level higher | |
464 than the current level. | |
465 If this variable is `best', Gnus will make the next newsgroup the one | |
466 with the best level.") | |
467 | |
468 (defvar gnus-summary-make-false-root 'adopt | |
469 "*nil means that Gnus won't gather loose threads. | |
470 If the root of a thread has expired or been read in a previous | |
471 session, the information necessary to build a complete thread has been | |
472 lost. Instead of having many small sub-threads from this original thread | |
473 scattered all over the summary buffer, Gnus can gather them. | |
474 | |
475 If non-nil, Gnus will try to gather all loose sub-threads from an | |
476 original thread into one large thread. | |
477 | |
478 If this variable is non-nil, it should be one of `none', `adopt', | |
479 `dummy' or `empty'. | |
480 | |
481 If this variable is `none', Gnus will not make a false root, but just | |
482 present the sub-threads after another. | |
483 If this variable is `dummy', Gnus will create a dummy root that will | |
484 have all the sub-threads as children. | |
485 If this variable is `adopt', Gnus will make one of the \"children\" | |
486 the parent and mark all the step-children as such. | |
487 If this variable is `empty', the \"children\" are printed with empty | |
488 subject fields. (Or rather, they will be printed with a string | |
489 given by the `gnus-summary-same-subject' variable.)") | |
490 | |
491 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$" | |
492 "*A regexp to match subjects to be excluded from loose thread gathering. | |
493 As loose thread gathering is done on subjects only, that means that | |
494 there can be many false gatherings performed. By rooting out certain | |
495 common subjects, gathering might become saner.") | |
496 | |
497 (defvar gnus-summary-gather-subject-limit nil | |
498 "*Maximum length of subject comparisons when gathering loose threads. | |
499 Use nil to compare full subjects. Setting this variable to a low | |
500 number will help gather threads that have been corrupted by | |
501 newsreaders chopping off subject lines, but it might also mean that | |
502 unrelated articles that have subject that happen to begin with the | |
503 same few characters will be incorrectly gathered. | |
504 | |
505 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when | |
506 comparing subjects.") | |
507 | |
508 (defvar gnus-simplify-ignored-prefixes nil | |
509 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily.") | |
510 | |
511 (defvar gnus-build-sparse-threads nil | |
512 "*If non-nil, fill in the gaps in threads. | |
513 If `some', only fill in the gaps that are needed to tie loose threads | |
514 together. If `more', fill in all leaf nodes that Gnus can find. If | |
515 non-nil and non-`some', fill in all gaps that Gnus manages to guess.") | |
516 | |
517 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject | |
518 "Function used for gathering loose threads. | |
519 There are two pre-defined functions: `gnus-gather-threads-by-subject', | |
520 which only takes Subjects into consideration; and | |
521 `gnus-gather-threads-by-references', which compared the References | |
522 headers of the articles to find matches.") | |
523 | |
524 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. | |
525 (defvar gnus-summary-same-subject "" | |
526 "*String indicating that the current article has the same subject as the previous. | |
527 This variable will only be used if the value of | |
528 `gnus-summary-make-false-root' is `empty'.") | |
529 | |
530 (defvar gnus-summary-goto-unread t | |
531 "*If non-nil, marking commands will go to the next unread article. | |
532 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article, | |
533 whether it is read or not.") | |
534 | |
535 (defvar gnus-group-goto-unread t | |
536 "*If non-nil, movement commands will go to the next unread and subscribed group.") | |
537 | |
538 (defvar gnus-goto-next-group-when-activating t | |
539 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.") | |
540 | |
541 (defvar gnus-check-new-newsgroups t | |
542 "*Non-nil means that Gnus will run gnus-find-new-newsgroups at startup. | |
543 This normally finds new newsgroups by comparing the active groups the | |
544 servers have already reported with those Gnus already knows, either alive | |
545 or killed. | |
546 | |
547 When any of the following are true, gnus-find-new-newsgroups will instead | |
548 ask the servers (primary, secondary, and archive servers) to list new | |
549 groups since the last time it checked: | |
550 1. This variable is `ask-server'. | |
551 2. This variable is a list of select methods (see below). | |
552 3. `gnus-read-active-file' is nil or `some'. | |
553 4. A prefix argument is given to gnus-find-new-newsgroups interactively. | |
554 | |
555 Thus, if this variable is `ask-server' or a list of select methods or | |
556 `gnus-read-active-file' is nil or `some', then the killed list is no | |
557 longer necessary, so you could safely set `gnus-save-killed-list' to nil. | |
558 | |
559 This variable can be a list of select methods which Gnus will query with | |
560 the `ask-server' method in addition to the primary, secondary, and archive | |
561 servers. | |
562 | |
563 Eg. | |
564 (setq gnus-check-new-newsgroups | |
565 '((nntp \"some.server\") (nntp \"other.server\"))) | |
566 | |
567 If this variable is nil, then you have to tell Gnus explicitly to | |
568 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].") | |
569 | |
570 (defvar gnus-check-bogus-newsgroups nil | |
571 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup. | |
572 If this variable is nil, then you have to tell Gnus explicitly to | |
573 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].") | |
574 | |
575 (defvar gnus-read-active-file t | |
576 "*Non-nil means that Gnus will read the entire active file at startup. | |
577 If this variable is nil, Gnus will only know about the groups in your | |
578 `.newsrc' file. | |
579 | |
580 If this variable is `some', Gnus will try to only read the relevant | |
581 parts of the active file from the server. Not all servers support | |
582 this, and it might be quite slow with other servers, but this should | |
583 generally be faster than both the t and nil value. | |
584 | |
585 If you set this variable to nil or `some', you probably still want to | |
586 be told about new newsgroups that arrive. To do that, set | |
587 `gnus-check-new-newsgroups' to `ask-server'. This may not work | |
588 properly with all servers.") | |
589 | |
590 (defvar gnus-level-subscribed 5 | |
591 "*Groups with levels less than or equal to this variable are subscribed.") | |
592 | |
593 (defvar gnus-level-unsubscribed 7 | |
594 "*Groups with levels less than or equal to this variable are unsubscribed. | |
595 Groups with levels less than `gnus-level-subscribed', which should be | |
596 less than this variable, are subscribed.") | |
597 | |
598 (defvar gnus-level-zombie 8 | |
599 "*Groups with this level are zombie groups.") | |
600 | |
601 (defvar gnus-level-killed 9 | |
602 "*Groups with this level are killed.") | |
603 | |
604 (defvar gnus-level-default-subscribed 3 | |
605 "*New subscribed groups will be subscribed at this level.") | |
606 | |
607 (defvar gnus-level-default-unsubscribed 6 | |
608 "*New unsubscribed groups will be unsubscribed at this level.") | |
609 | |
610 (defvar gnus-activate-level (1+ gnus-level-subscribed) | |
611 "*Groups higher than this level won't be activated on startup. | |
612 Setting this variable to something log might save lots of time when | |
613 you have many groups that you aren't interested in.") | |
614 | |
615 (defvar gnus-activate-foreign-newsgroups 4 | |
616 "*If nil, Gnus will not check foreign newsgroups at startup. | |
617 If it is non-nil, it should be a number between one and nine. Foreign | |
618 newsgroups that have a level lower or equal to this number will be | |
619 activated on startup. For instance, if you want to active all | |
620 subscribed newsgroups, but not the rest, you'd set this variable to | |
621 `gnus-level-subscribed'. | |
622 | |
623 If you subscribe to lots of newsgroups from different servers, startup | |
624 might take a while. By setting this variable to nil, you'll save time, | |
625 but you won't be told how many unread articles there are in the | |
626 groups.") | |
627 | |
628 (defvar gnus-save-newsrc-file t | |
629 "*Non-nil means that Gnus will save the `.newsrc' file. | |
630 Gnus always saves its own startup file, which is called | |
631 \".newsrc.eld\". The file called \".newsrc\" is in a format that can | |
632 be readily understood by other newsreaders. If you don't plan on | |
633 using other newsreaders, set this variable to nil to save some time on | |
634 exit.") | |
635 | |
636 (defvar gnus-save-killed-list t | |
637 "*If non-nil, save the list of killed groups to the startup file. | |
638 If you set this variable to nil, you'll save both time (when starting | |
639 and quitting) and space (both memory and disk), but it will also mean | |
640 that Gnus has no record of which groups are new and which are old, so | |
641 the automatic new newsgroups subscription methods become meaningless. | |
642 | |
643 You should always set `gnus-check-new-newsgroups' to `ask-server' or | |
644 nil if you set this variable to nil.") | |
645 | |
646 (defvar gnus-interactive-catchup t | |
647 "*If non-nil, require your confirmation when catching up a group.") | |
648 | |
649 (defvar gnus-interactive-exit t | |
650 "*If non-nil, require your confirmation when exiting Gnus.") | |
651 | |
652 (defvar gnus-kill-killed t | |
653 "*If non-nil, Gnus will apply kill files to already killed articles. | |
654 If it is nil, Gnus will never apply kill files to articles that have | |
655 already been through the scoring process, which might very well save lots | |
656 of time.") | |
657 | |
658 (defvar gnus-extract-address-components 'gnus-extract-address-components | |
659 "*Function for extracting address components from a From header. | 1082 "*Function for extracting address components from a From header. |
660 Two pre-defined function exist: `gnus-extract-address-components', | 1083 Two pre-defined function exist: `gnus-extract-address-components', |
661 which is the default, quite fast, and too simplistic solution, and | 1084 which is the default, quite fast, and too simplistic solution, and |
662 `mail-extract-address-components', which works much better, but is | 1085 `mail-extract-address-components', which works much better, but is |
663 slower.") | 1086 slower." |
664 | 1087 :group 'gnus-summary-format |
665 (defvar gnus-summary-default-score 0 | 1088 :type '(radio (function-item gnus-extract-address-components) |
666 "*Default article score level. | 1089 (function-item mail-extract-address-components) |
667 If this variable is nil, scoring will be disabled.") | 1090 (function :tag "Other"))) |
668 | 1091 |
669 (defvar gnus-summary-zcore-fuzz 0 | 1092 (defcustom gnus-carpal nil |
670 "*Fuzziness factor for the zcore in the summary buffer. | 1093 "*If non-nil, display clickable icons." |
671 Articles with scores closer than this to `gnus-summary-default-score' | 1094 :group 'gnus-meta |
672 will not be marked.") | 1095 :type 'boolean) |
673 | 1096 |
674 (defvar gnus-simplify-subject-fuzzy-regexp nil | 1097 (defcustom gnus-shell-command-separator ";" |
675 "*Strings to be removed when doing fuzzy matches. | 1098 "String used to separate to shell commands." |
676 This can either be a regular expression or list of regular expressions | 1099 :group 'gnus-files |
677 that will be removed from subject strings if fuzzy subject | 1100 :type 'string) |
678 simplification is selected.") | 1101 |
679 | 1102 (defcustom gnus-valid-select-methods |
680 (defvar gnus-permanently-visible-groups nil | 1103 '(("nntp" post address prompt-address physical-address) |
681 "*Regexp to match groups that should always be listed in the group buffer. | 1104 ("nnspool" post address) |
682 This means that they will still be listed when there are no unread | 1105 ("nnvirtual" post-mail virtual prompt-address) |
683 articles in the groups.") | 1106 ("nnmbox" mail respool address) |
684 | 1107 ("nnml" mail respool address) |
685 (defvar gnus-list-groups-with-ticked-articles t | 1108 ("nnmh" mail respool address) |
686 "*If non-nil, list groups that have only ticked articles. | 1109 ("nndir" post-mail prompt-address physical-address) |
687 If nil, only list groups that have unread articles.") | 1110 ("nneething" none address prompt-address physical-address) |
688 | 1111 ("nndoc" none address prompt-address) |
689 (defvar gnus-group-default-list-level gnus-level-subscribed | 1112 ("nnbabyl" mail address respool) |
690 "*Default listing level. | 1113 ("nnkiboze" post virtual) |
691 Ignored if `gnus-group-use-permanent-levels' is non-nil.") | 1114 ("nnsoup" post-mail address) |
692 | 1115 ("nndraft" post-mail) |
693 (defvar gnus-group-use-permanent-levels nil | 1116 ("nnfolder" mail respool address) |
694 "*If non-nil, once you set a level, Gnus will use this level.") | 1117 ("nngateway" none address prompt-address physical-address) |
695 | 1118 ("nnweb" none)) |
696 (defvar gnus-group-list-inactive-groups t | 1119 "An alist of valid select methods. |
697 "*If non-nil, inactive groups will be listed.") | 1120 The first element of each list lists should be a string with the name |
698 | 1121 of the select method. The other elements may be the category of |
699 (defvar gnus-show-mime nil | 1122 this method (i. e., `post', `mail', `none' or whatever) or other |
700 "*If non-nil, do mime processing of articles. | 1123 properties that this method has (like being respoolable). |
701 The articles will simply be fed to the function given by | 1124 If you implement a new select method, all you should have to change is |
702 `gnus-show-mime-method'.") | 1125 this variable. I think." |
703 | 1126 :group 'gnus-server |
704 (defvar gnus-strict-mime t | 1127 :type '(repeat (group (string :tag "Name") |
705 "*If nil, MIME-decode even if there is no Mime-Version header in the article.") | 1128 (radio-button-choice (const :format "%v " post) |
706 | 1129 (const :format "%v " mail) |
707 (defvar gnus-show-mime-method 'metamail-buffer | 1130 (const :format "%v " none) |
708 "*Function to process a MIME message. | 1131 (const post-mail)) |
709 The function is called from the article buffer.") | 1132 (checklist :inline t |
710 | 1133 (const :format "%v " address) |
711 (defvar gnus-decode-encoded-word-method (lambda ()) | 1134 (const :format "%v " prompt-address) |
712 "*Function to decode a MIME encoded-words. | 1135 (const :format "%v " virtual) |
713 The function is called from the article buffer.") | 1136 (const respool))))) |
714 | 1137 |
715 (defvar gnus-show-threads t | 1138 (define-widget 'gnus-select-method 'list |
716 "*If non-nil, display threads in summary mode.") | 1139 "Widget for entering a select method." |
717 | 1140 :args `((choice :tag "Method" |
718 (defvar gnus-thread-hide-subtree nil | 1141 ,@(mapcar (lambda (entry) |
719 "*If non-nil, hide all threads initially. | 1142 (list 'const :format "%v\n" |
720 If threads are hidden, you have to run the command | 1143 (intern (car entry)))) |
721 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook' | 1144 gnus-valid-select-methods)) |
722 to expose hidden threads.") | 1145 (string :tag "Address") |
723 | 1146 (editable-list :inline t |
724 (defvar gnus-thread-hide-killed t | 1147 (list :format "%v" |
725 "*If non-nil, hide killed threads automatically.") | 1148 variable |
726 | 1149 (sexp :tag "Value"))))) |
727 (defvar gnus-thread-ignore-subject nil | 1150 |
728 "*If non-nil, ignore subjects and do all threading based on the Reference header. | 1151 (defcustom gnus-updated-mode-lines '(group article summary tree) |
729 If nil, which is the default, articles that have different subjects | 1152 "List of buffers that should update their mode lines. |
730 from their parents will start separate threads.") | 1153 The list may contain the symbols `group', `article', `tree' and |
731 | 1154 `summary'. If the corresponding symbol is present, Gnus will keep |
732 (defvar gnus-thread-operation-ignore-subject t | 1155 that mode line updated with information that may be pertinent. |
733 "*If non-nil, subjects will be ignored when doing thread commands. | 1156 If this variable is nil, screen refresh may be quicker." |
734 This affects commands like `gnus-summary-kill-thread' and | 1157 :group 'gnus-various |
735 `gnus-summary-lower-thread'. | 1158 :type '(set (const group) |
736 | 1159 (const article) |
737 If this variable is nil, articles in the same thread with different | 1160 (const summary) |
738 subjects will not be included in the operation in question. If this | 1161 (const tree))) |
739 variable is `fuzzy', only articles that have subjects that are fuzzily | 1162 |
740 equal will be included.") | 1163 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>. |
741 | 1164 (defcustom gnus-mode-non-string-length nil |
742 (defvar gnus-thread-indent-level 4 | 1165 "*Max length of mode-line non-string contents. |
743 "*Number that says how much each sub-thread should be indented.") | 1166 If this is nil, Gnus will take space as is needed, leaving the rest |
744 | 1167 of the modeline intact. Note that the default of nil is unlikely |
745 (defvar gnus-ignored-newsgroups | 1168 to be desirable; see the manual for further details." |
746 (purecopy (mapconcat 'identity | 1169 :group 'gnus-various |
747 '("^to\\." ; not "real" groups | 1170 :type '(choice (const nil) |
748 "^[0-9. \t]+ " ; all digits in name | 1171 integer)) |
749 "[][\"#'()]" ; bogus characters | 1172 |
750 ) | 1173 (defcustom gnus-auto-expirable-newsgroups nil |
751 "\\|")) | 1174 "*Groups in which to automatically mark read articles as expirable. |
752 "*A regexp to match uninteresting newsgroups in the active file. | 1175 If non-nil, this should be a regexp that should match all groups in |
753 Any lines in the active file matching this regular expression are | 1176 which to perform auto-expiry. This only makes sense for mail groups." |
754 removed from the newsgroup list before anything else is done to it, | 1177 :group 'gnus-mail-expire |
755 thus making them effectively non-existent.") | 1178 :type '(choice (const nil) |
756 | 1179 regexp)) |
757 (defvar gnus-ignored-headers | 1180 |
758 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:" | 1181 (defcustom gnus-total-expirable-newsgroups nil |
759 "*All headers that match this regexp will be hidden. | 1182 "*Groups in which to perform expiry of all read articles. |
760 This variable can also be a list of regexps of headers to be ignored. | 1183 Use with extreme caution. All groups that match this regexp will be |
761 If `gnus-visible-headers' is non-nil, this variable will be ignored.") | 1184 expiring - which means that all read articles will be deleted after |
762 | 1185 \(say) one week. (This only goes for mail groups and the like, of |
763 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-" | 1186 course.)" |
764 "*All headers that do not match this regexp will be hidden. | 1187 :group 'gnus-mail-expire |
765 This variable can also be a list of regexp of headers to remain visible. | 1188 :type '(choice (const nil) |
766 If this variable is non-nil, `gnus-ignored-headers' will be ignored.") | 1189 regexp)) |
767 | 1190 |
768 (defvar gnus-sorted-header-list | 1191 (defcustom gnus-group-uncollapsed-levels 1 |
769 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:" | 1192 "Number of group name elements to leave alone when making a short group name." |
770 "^Cc:" "^Date:" "^Organization:") | 1193 :group 'gnus-group-visual |
771 "*This variable is a list of regular expressions. | 1194 :type 'integer) |
772 If it is non-nil, headers that match the regular expressions will | 1195 |
773 be placed first in the article buffer in the sequence specified by | 1196 (defcustom gnus-group-use-permanent-levels nil |
774 this list.") | 1197 "*If non-nil, once you set a level, Gnus will use this level." |
775 | 1198 :group 'gnus-group-levels |
776 (defvar gnus-boring-article-headers | 1199 :type 'boolean) |
777 '(empty followup-to reply-to) | 1200 |
778 "*Headers that are only to be displayed if they have interesting data. | 1201 ;; Hooks. |
779 Possible values in this list are `empty', `newsgroups', `followup-to', | 1202 |
780 `reply-to', and `date'.") | 1203 (defcustom gnus-load-hook nil |
781 | 1204 "A hook run while Gnus is loaded." |
782 (defvar gnus-show-all-headers nil | 1205 :group 'gnus-start |
783 "*If non-nil, don't hide any headers.") | 1206 :type 'hook) |
784 | 1207 |
785 (defvar gnus-save-all-headers t | 1208 (defcustom gnus-apply-kill-hook '(gnus-apply-kill-file) |
786 "*If non-nil, don't remove any headers before saving.") | 1209 "A hook called to apply kill files to a group. |
787 | 1210 This hook is intended to apply a kill file to the selected newsgroup. |
788 (defvar gnus-saved-headers gnus-visible-headers | 1211 The function `gnus-apply-kill-file' is called by default. |
789 "*Headers to keep if `gnus-save-all-headers' is nil. | 1212 |
790 If `gnus-save-all-headers' is non-nil, this variable will be ignored. | 1213 Since a general kill file is too heavy to use only for a few |
791 If that variable is nil, however, all headers that match this regexp | 1214 newsgroups, I recommend you to use a lighter hook function. For |
792 will be kept while the rest will be deleted before saving.") | 1215 example, if you'd like to apply a kill file to articles which contains |
793 | 1216 a string `rmgroup' in subject in newsgroup `control', you can use the |
794 (defvar gnus-inhibit-startup-message nil | 1217 following hook: |
795 "*If non-nil, the startup message will not be displayed.") | 1218 |
796 | 1219 (setq gnus-apply-kill-hook |
797 (defvar gnus-signature-separator "^-- *$" | 1220 (list |
798 "Regexp matching signature separator.") | 1221 (lambda () |
799 | 1222 (cond ((string-match \"control\" gnus-newsgroup-name) |
800 (defvar gnus-signature-limit nil | 1223 (gnus-kill \"Subject\" \"rmgroup\") |
801 "Provide a limit to what is considered a signature. | 1224 (gnus-expunge \"X\"))))))" |
802 If it is a number, no signature may not be longer (in characters) than | 1225 :group 'gnus-score-kill |
803 that number. If it is a function, the function will be called without | 1226 :options '(gnus-apply-kill-file) |
804 any parameters, and if it returns nil, there is no signature in the | 1227 :type 'hook) |
805 buffer. If it is a string, it will be used as a regexp. If it | 1228 |
806 matches, the text in question is not a signature.") | 1229 (defcustom gnus-group-change-level-function nil |
807 | 1230 "Function run when a group level is changed. |
808 (defvar gnus-auto-extend-newsgroup t | 1231 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL." |
809 "*If non-nil, extend newsgroup forward and backward when requested.") | 1232 :group 'gnus-group-level |
810 | 1233 :type 'function) |
811 (defvar gnus-auto-select-first t | 1234 |
812 "*If nil, don't select the first unread article when entering a group. | 1235 ;;; Face thingies. |
813 If this variable is `best', select the highest-scored unread article | 1236 |
814 in the group. If neither nil nor `best', select the first unread | 1237 (defcustom gnus-visual |
815 article. | 1238 '(summary-highlight group-highlight article-highlight |
816 | 1239 mouse-face |
817 If you want to prevent automatic selection of the first unread article | 1240 summary-menu group-menu article-menu |
818 in some newsgroups, set the variable to nil in | 1241 tree-highlight menu highlight |
819 `gnus-select-group-hook'.") | 1242 browse-menu server-menu |
820 | 1243 page-marker tree-menu binary-menu pick-menu |
821 (defvar gnus-auto-select-next t | 1244 grouplens-menu) |
822 "*If non-nil, offer to go to the next group from the end of the previous. | 1245 "Enable visual features. |
823 If the value is t and the next newsgroup is empty, Gnus will exit | 1246 If `visual' is disabled, there will be no menus and few faces. Most of |
824 summary mode and go back to group mode. If the value is neither nil | 1247 the visual customization options below will be ignored. Gnus will use |
825 nor t, Gnus will select the following unread newsgroup. In | 1248 less space and be faster as a result. |
826 particular, if the value is the symbol `quietly', the next unread | 1249 |
827 newsgroup will be selected without any confirmation, and if it is | 1250 This variable can also be a list of visual elements to switch on. For |
828 `almost-quietly', the next group will be selected without any | 1251 instance, to switch off all visual things except menus, you can say: |
829 confirmation if you are located on the last article in the group. | 1252 |
830 Finally, if this variable is `slightly-quietly', the `Z n' command | 1253 (setq gnus-visual '(menu)) |
831 will go to the next group without confirmation.") | 1254 |
832 | 1255 Valid elements include `summary-highlight', `group-highlight', |
833 (defvar gnus-auto-select-same nil | 1256 `article-highlight', `mouse-face', `summary-menu', `group-menu', |
834 "*If non-nil, select the next article with the same subject.") | 1257 `article-menu', `tree-highlight', `menu', `highlight', `browse-menu', |
835 | 1258 `server-menu', `page-marker', `tree-menu', `binary-menu', `pick-menu', |
836 (defvar gnus-summary-check-current nil | 1259 and `grouplens-menu'." |
837 "*If non-nil, consider the current article when moving. | 1260 :group 'gnus-meta |
838 The \"unread\" movement commands will stay on the same line if the | 1261 :group 'gnus-visual |
839 current article is unread.") | 1262 :type '(set (const summary-highlight) |
840 | 1263 (const group-highlight) |
841 (defvar gnus-auto-center-summary t | 1264 (const article-highlight) |
842 "*If non-nil, always center the current summary buffer. | 1265 (const mouse-face) |
843 In particular, if `vertical' do only vertical recentering. If non-nil | 1266 (const summary-menu) |
844 and non-`vertical', do both horizontal and vertical recentering.") | 1267 (const group-menu) |
845 | 1268 (const article-menu) |
846 (defvar gnus-break-pages t | 1269 (const tree-highlight) |
847 "*If non-nil, do page breaking on articles. | 1270 (const menu) |
848 The page delimiter is specified by the `gnus-page-delimiter' | 1271 (const highlight) |
849 variable.") | 1272 (const browse-menu) |
850 | 1273 (const server-menu) |
851 (defvar gnus-page-delimiter "^\^L" | 1274 (const page-marker) |
852 "*Regexp describing what to use as article page delimiters. | 1275 (const tree-menu) |
853 The default value is \"^\^L\", which is a form linefeed at the | 1276 (const binary-menu) |
854 beginning of a line.") | 1277 (const pick-menu) |
855 | 1278 (const grouplens-menu))) |
856 (defvar gnus-use-full-window t | 1279 |
857 "*If non-nil, use the entire Emacs screen.") | 1280 (defcustom gnus-mouse-face |
858 | 1281 (condition-case () |
859 (defvar gnus-window-configuration nil | 1282 (if (gnus-visual-p 'mouse-face 'highlight) |
860 "Obsolete variable. See `gnus-buffer-configuration'.") | 1283 (if (boundp 'gnus-mouse-face) |
861 | 1284 (or gnus-mouse-face 'highlight) |
862 (defvar gnus-window-min-width 2 | 1285 'highlight) |
863 "*Minimum width of Gnus buffers.") | 1286 'default) |
864 | 1287 (error 'highlight)) |
865 (defvar gnus-window-min-height 1 | 1288 "Face used for group or summary buffer mouse highlighting. |
866 "*Minimum height of Gnus buffers.") | 1289 The line beneath the mouse pointer will be highlighted with this |
867 | 1290 face." |
868 (defvar gnus-buffer-configuration | 1291 :group 'gnus-visual |
869 '((group | 1292 :type 'face) |
870 (vertical 1.0 | 1293 |
871 (group 1.0 point) | 1294 (defcustom gnus-article-display-hook |
872 (if gnus-carpal '(group-carpal 4)))) | 1295 (if (and (string-match "XEmacs" emacs-version) |
873 (summary | 1296 (featurep 'xface)) |
874 (vertical 1.0 | 1297 '(gnus-article-hide-headers-if-wanted |
875 (summary 1.0 point) | 1298 gnus-article-hide-boring-headers |
876 (if gnus-carpal '(summary-carpal 4)))) | 1299 gnus-article-treat-overstrike |
877 (article | 1300 gnus-article-maybe-highlight |
878 (cond | 1301 gnus-article-display-x-face) |
879 (gnus-use-picons | 1302 '(gnus-article-hide-headers-if-wanted |
880 '(frame 1.0 | 1303 gnus-article-hide-boring-headers |
881 (vertical 1.0 | 1304 gnus-article-treat-overstrike |
882 (summary 0.25 point) | 1305 gnus-article-maybe-highlight)) |
883 (if gnus-carpal '(summary-carpal 4)) | 1306 "Controls how the article buffer will look. |
884 (article 1.0)) | 1307 |
885 (vertical ((height . 5) (width . 15) | 1308 If you leave the list empty, the article will appear exactly as it is |
886 (user-position . t) | 1309 stored on the disk. The list entries will hide or highlight various |
887 (left . -1) (top . 1)) | 1310 parts of the article, making it easier to find the information you |
888 (picons 1.0)))) | 1311 want." |
889 (gnus-use-trees | 1312 :group 'gnus-article-highlight |
890 '(vertical 1.0 | 1313 :group 'gnus-visual |
891 (summary 0.25 point) | 1314 :type 'hook |
892 (tree 0.25) | 1315 :options '(gnus-article-add-buttons |
893 (article 1.0))) | 1316 gnus-article-add-buttons-to-head |
894 (t | 1317 gnus-article-emphasize |
895 '(vertical 1.0 | 1318 gnus-article-fill-cited-article |
896 (summary 0.25 point) | 1319 gnus-article-remove-cr |
897 (if gnus-carpal '(summary-carpal 4)) | 1320 gnus-article-de-quoted-unreadable |
898 (article 1.0))))) | 1321 gnus-article-display-x-face |
899 (server | 1322 gnus-summary-stop-page-breaking |
900 (vertical 1.0 | 1323 ;; gnus-summary-caesar-message |
901 (server 1.0 point) | 1324 ;; gnus-summary-verbose-headers |
902 (if gnus-carpal '(server-carpal 2)))) | 1325 gnus-summary-toggle-mime |
903 (browse | 1326 gnus-article-hide |
904 (vertical 1.0 | 1327 gnus-article-hide-headers |
905 (browse 1.0 point) | 1328 gnus-article-hide-boring-headers |
906 (if gnus-carpal '(browse-carpal 2)))) | 1329 gnus-article-hide-signature |
907 (message | 1330 gnus-article-hide-citation |
908 (vertical 1.0 | 1331 gnus-article-hide-pgp |
909 (message 1.0 point))) | 1332 gnus-article-hide-pem |
910 (pick | 1333 gnus-article-highlight |
911 (vertical 1.0 | 1334 gnus-article-highlight-headers |
912 (article 1.0 point))) | 1335 gnus-article-highlight-citation |
913 (info | 1336 gnus-article-highlight-signature |
914 (vertical 1.0 | 1337 gnus-article-date-ut |
915 (info 1.0 point))) | 1338 gnus-article-date-local |
916 (summary-faq | 1339 gnus-article-date-lapsed |
917 (vertical 1.0 | 1340 gnus-article-date-original |
918 (summary 0.25) | 1341 gnus-article-remove-trailing-blank-lines |
919 (faq 1.0 point))) | 1342 gnus-article-strip-leading-blank-lines |
920 (edit-group | 1343 gnus-article-strip-multiple-blank-lines |
921 (vertical 1.0 | 1344 gnus-article-strip-blank-lines |
922 (group 0.5) | 1345 gnus-article-treat-overstrike |
923 (edit-group 1.0 point))) | 1346 )) |
924 (edit-server | 1347 |
925 (vertical 1.0 | 1348 |
926 (server 0.5) | 1349 ;;; Internal variables |
927 (edit-server 1.0 point))) | 1350 |
928 (edit-score | 1351 (defvar gnus-group-get-parameter-function 'gnus-group-get-parameter) |
929 (vertical 1.0 | 1352 (defvar gnus-original-article-buffer " *Original Article*") |
930 (summary 0.25) | 1353 (defvar gnus-newsgroup-name nil) |
931 (edit-score 1.0 point))) | 1354 |
932 (post | 1355 (defvar gnus-current-select-method nil |
933 (vertical 1.0 | 1356 "The current method for selecting a newsgroup.") |
934 (post 1.0 point))) | 1357 |
935 (reply | 1358 (defvar gnus-tree-buffer "*Tree*" |
936 (vertical 1.0 | 1359 "Buffer where Gnus thread trees are displayed.") |
937 (article-copy 0.5) | 1360 |
938 (message 1.0 point))) | 1361 ;; Dummy variable. |
939 (forward | 1362 (defvar gnus-use-generic-from nil) |
940 (vertical 1.0 | 1363 |
941 (message 1.0 point))) | 1364 ;; Variable holding the user answers to all method prompts. |
942 (reply-yank | 1365 (defvar gnus-method-history nil) |
943 (vertical 1.0 | 1366 (defvar gnus-group-history nil) |
944 (message 1.0 point))) | 1367 |
945 (mail-bounce | 1368 ;; Variable holding the user answers to all mail method prompts. |
946 (vertical 1.0 | 1369 (defvar gnus-mail-method-history nil) |
947 (article 0.5) | 1370 |
948 (message 1.0 point))) | 1371 ;; Variable holding the user answers to all group prompts. |
949 (draft | 1372 (defvar gnus-group-history nil) |
950 (vertical 1.0 | 1373 |
951 (draft 1.0 point))) | 1374 (defvar gnus-server-alist nil |
952 (pipe | 1375 "List of available servers.") |
953 (vertical 1.0 | 1376 |
954 (summary 0.25 point) | 1377 (defvar gnus-predefined-server-alist |
955 (if gnus-carpal '(summary-carpal 4)) | 1378 `(("cache" |
956 ("*Shell Command Output*" 1.0))) | 1379 (nnspool "cache" |
957 (bug | 1380 (nnspool-spool-directory "~/News/cache/") |
958 (vertical 1.0 | 1381 (nnspool-nov-directory "~/News/cache/") |
959 ("*Gnus Help Bug*" 0.5) | 1382 (nnspool-active-file "~/News/cache/active")))) |
960 ("*Gnus Bug*" 1.0 point))) | 1383 "List of predefined (convenience) servers.") |
961 (compose-bounce | 1384 |
962 (vertical 1.0 | 1385 (defvar gnus-topic-indentation "") ;; Obsolete variable. |
963 (article 0.5) | 1386 |
964 (message 1.0 point)))) | 1387 (defconst gnus-article-mark-lists |
965 "Window configuration for all possible Gnus buffers. | 1388 '((marked . tick) (replied . reply) |
966 This variable is a list of lists. Each of these lists has a NAME and | 1389 (expirable . expire) (killed . killed) |
967 a RULE. The NAMEs are commonsense names like `group', which names a | 1390 (bookmarks . bookmark) (dormant . dormant) |
968 rule used when displaying the group buffer; `summary', which names a | 1391 (scored . score) (saved . save) |
969 rule for what happens when you enter a group and do not display an | 1392 (cached . cache))) |
970 article buffer; and so on. See the value of this variable for a | 1393 |
971 complete list of NAMEs. | 1394 (defvar gnus-headers-retrieved-by nil) |
972 | 1395 (defvar gnus-article-reply nil) |
973 Each RULE is a list of vectors. The first element in this vector is | 1396 (defvar gnus-override-method nil) |
974 the name of the buffer to be displayed; the second element is the | 1397 (defvar gnus-article-check-size nil) |
975 percentage of the screen this buffer is to occupy (a number in the | 1398 (defvar gnus-opened-servers nil) |
976 0.0-0.99 range); the optional third element is `point', which should | 1399 |
977 be present to denote which buffer point is to go to after making this | 1400 (defvar gnus-current-kill-article nil) |
978 buffer configuration.") | 1401 |
979 | 1402 (defvar gnus-have-read-active-file nil) |
980 (defvar gnus-window-to-buffer | 1403 |
981 '((group . gnus-group-buffer) | 1404 (defconst gnus-maintainer |
982 (summary . gnus-summary-buffer) | 1405 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)" |
983 (article . gnus-article-buffer) | 1406 "The mail address of the Gnus maintainers.") |
984 (server . gnus-server-buffer) | 1407 |
985 (browse . "*Gnus Browse Server*") | 1408 (defvar gnus-info-nodes |
986 (edit-group . gnus-group-edit-buffer) | 1409 '((gnus-group-mode "(gnus)The Group Buffer") |
987 (edit-server . gnus-server-edit-buffer) | 1410 (gnus-summary-mode "(gnus)The Summary Buffer") |
988 (group-carpal . gnus-carpal-group-buffer) | 1411 (gnus-article-mode "(gnus)The Article Buffer") |
989 (summary-carpal . gnus-carpal-summary-buffer) | 1412 (mime/viewer-mode "(gnus)The Article Buffer") |
990 (server-carpal . gnus-carpal-server-buffer) | 1413 (gnus-server-mode "(gnus)The Server Buffer") |
991 (browse-carpal . gnus-carpal-browse-buffer) | 1414 (gnus-browse-mode "(gnus)Browse Foreign Server") |
992 (edit-score . gnus-score-edit-buffer) | 1415 (gnus-tree-mode "(gnus)Tree Display")) |
993 (message . gnus-message-buffer) | 1416 "Alist of major modes and related Info nodes.") |
994 (mail . gnus-message-buffer) | 1417 |
995 (post-news . gnus-message-buffer) | 1418 (defvar gnus-group-buffer "*Group*") |
996 (faq . gnus-faq-buffer) | 1419 (defvar gnus-summary-buffer "*Summary*") |
997 (picons . "*Picons*") | 1420 (defvar gnus-article-buffer "*Article*") |
998 (tree . gnus-tree-buffer) | 1421 (defvar gnus-server-buffer "*Server*") |
999 (info . gnus-info-buffer) | 1422 |
1000 (article-copy . gnus-article-copy) | 1423 (defvar gnus-buffer-list nil |
1001 (draft . gnus-draft-buffer)) | 1424 "Gnus buffers that should be killed on exit.") |
1002 "Mapping from short symbols to buffer names or buffer variables.") | 1425 |
1003 | 1426 (defvar gnus-slave nil |
1004 (defvar gnus-carpal nil | 1427 "Whether this Gnus is a slave or not.") |
1005 "*If non-nil, display clickable icons.") | 1428 |
1006 | 1429 (defvar gnus-batch-mode nil |
1007 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies | 1430 "Whether this Gnus is running in batch mode or not.") |
1008 "*Function called with a group name when new group is detected. | 1431 |
1009 A few pre-made functions are supplied: `gnus-subscribe-randomly' | 1432 (defvar gnus-variable-list |
1010 inserts new groups at the beginning of the list of groups; | 1433 '(gnus-newsrc-options gnus-newsrc-options-n |
1011 `gnus-subscribe-alphabetically' inserts new groups in strict | 1434 gnus-newsrc-last-checked-date |
1012 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups | 1435 gnus-newsrc-alist gnus-server-alist |
1013 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks | 1436 gnus-killed-list gnus-zombie-list |
1014 for your decision; `gnus-subscribe-killed' kills all new groups; | 1437 gnus-topic-topology gnus-topic-alist |
1015 `gnus-subscribe-zombies' will make all new groups into zombies.") | 1438 gnus-format-specs) |
1016 | 1439 "Gnus variables saved in the quick startup file.") |
1017 ;; Suggested by a bug report by Hallvard B Furuseth. | 1440 |
1018 ;; <h.b.furuseth@usit.uio.no>. | 1441 (defvar gnus-newsrc-alist nil |
1019 (defvar gnus-subscribe-options-newsgroup-method | 1442 "Assoc list of read articles. |
1020 (function gnus-subscribe-alphabetically) | 1443 gnus-newsrc-hashtb should be kept so that both hold the same information.") |
1021 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines. | 1444 |
1022 If, for instance, you want to subscribe to all newsgroups in the | 1445 (defvar gnus-newsrc-hashtb nil |
1023 \"no\" and \"alt\" hierarchies, you'd put the following in your | 1446 "Hashtable of gnus-newsrc-alist.") |
1024 .newsrc file: | 1447 |
1025 | 1448 (defvar gnus-killed-list nil |
1026 options -n no.all alt.all | 1449 "List of killed newsgroups.") |
1027 | 1450 |
1028 Gnus will the subscribe all new newsgroups in these hierarchies with | 1451 (defvar gnus-killed-hashtb nil |
1029 the subscription method in this variable.") | 1452 "Hash table equivalent of gnus-killed-list.") |
1030 | 1453 |
1031 (defvar gnus-subscribe-hierarchical-interactive nil | 1454 (defvar gnus-zombie-list nil |
1032 "*If non-nil, Gnus will offer to subscribe hierarchically. | 1455 "List of almost dead newsgroups.") |
1033 When a new hierarchy appears, Gnus will ask the user: | 1456 |
1034 | 1457 (defvar gnus-description-hashtb nil |
1035 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys): | 1458 "Descriptions of newsgroups.") |
1036 | 1459 |
1037 If the user pressed `d', Gnus will descend the hierarchy, `y' will | 1460 (defvar gnus-list-of-killed-groups nil |
1038 subscribe to all newsgroups in the hierarchy and `s' will skip this | 1461 "List of newsgroups that have recently been killed by the user.") |
1039 hierarchy in its entirety.") | 1462 |
1040 | 1463 (defvar gnus-active-hashtb nil |
1041 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet | 1464 "Hashtable of active articles.") |
1042 "*Function used for sorting the group buffer. | 1465 |
1043 This function will be called with group info entries as the arguments | 1466 (defvar gnus-moderated-hashtb nil |
1044 for the groups to be sorted. Pre-made functions include | 1467 "Hashtable of moderated newsgroups.") |
1045 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread', | 1468 |
1046 `gnus-group-sort-by-level', `gnus-group-sort-by-score', | 1469 ;; Save window configuration. |
1047 `gnus-group-sort-by-method', and `gnus-group-sort-by-rank'. | 1470 (defvar gnus-prev-winconf nil) |
1048 | 1471 |
1049 This variable can also be a list of sorting functions. In that case, | 1472 (defvar gnus-reffed-article-number nil) |
1050 the most significant sort function should be the last function in the | 1473 |
1051 list.") | 1474 ;;; Let the byte-compiler know that we know about this variable. |
1052 | 1475 (defvar rmail-default-rmail-file) |
1053 ;; Mark variables suggested by Thomas Michanek | 1476 |
1054 ;; <Thomas.Michanek@telelogic.se>. | 1477 (defvar gnus-dead-summary nil) |
1055 (defvar gnus-unread-mark ? | 1478 |
1056 "*Mark used for unread articles.") | 1479 ;;; End of variables. |
1057 (defvar gnus-ticked-mark ?! | 1480 |
1058 "*Mark used for ticked articles.") | 1481 ;; Define some autoload functions Gnus might use. |
1059 (defvar gnus-dormant-mark ?? | 1482 (eval-and-compile |
1060 "*Mark used for dormant articles.") | 1483 |
1061 (defvar gnus-del-mark ?r | 1484 ;; This little mapcar goes through the list below and marks the |
1062 "*Mark used for del'd articles.") | 1485 ;; symbols in question as autoloaded functions. |
1063 (defvar gnus-read-mark ?R | 1486 (mapcar |
1064 "*Mark used for read articles.") | 1487 (lambda (package) |
1065 (defvar gnus-expirable-mark ?E | 1488 (let ((interactive (nth 1 (memq ':interactive package)))) |
1066 "*Mark used for expirable articles.") | 1489 (mapcar |
1067 (defvar gnus-killed-mark ?K | 1490 (lambda (function) |
1068 "*Mark used for killed articles.") | 1491 (let (keymap) |
1069 (defvar gnus-souped-mark ?F | 1492 (when (consp function) |
1070 "*Mark used for killed articles.") | 1493 (setq keymap (car (memq 'keymap function))) |
1071 (defvar gnus-kill-file-mark ?X | 1494 (setq function (car function))) |
1072 "*Mark used for articles killed by kill files.") | 1495 (autoload function (car package) nil interactive keymap))) |
1073 (defvar gnus-low-score-mark ?Y | 1496 (if (eq (nth 1 package) ':interactive) |
1074 "*Mark used for articles with a low score.") | 1497 (cdddr package) |
1075 (defvar gnus-catchup-mark ?C | 1498 (cdr package))))) |
1076 "*Mark used for articles that are caught up.") | 1499 '(("metamail" metamail-buffer) |
1077 (defvar gnus-replied-mark ?A | 1500 ("info" Info-goto-node) |
1078 "*Mark used for articles that have been replied to.") | 1501 ("hexl" hexl-hex-string-to-integer) |
1079 (defvar gnus-cached-mark ?* | 1502 ("pp" pp pp-to-string pp-eval-expression) |
1080 "*Mark used for articles that are in the cache.") | 1503 ("ps-print" ps-print-preprint) |
1081 (defvar gnus-saved-mark ?S | 1504 ("mail-extr" mail-extract-address-components) |
1082 "*Mark used for articles that have been saved to.") | 1505 ("message" :interactive t |
1083 (defvar gnus-process-mark ?# | 1506 message-send-and-exit message-yank-original) |
1084 "*Process mark.") | 1507 ("nnmail" nnmail-split-fancy nnmail-article-group nnmail-date-to-time) |
1085 (defvar gnus-ancient-mark ?O | 1508 ("nnvirtual" nnvirtual-catchup-group nnvirtual-convert-headers) |
1086 "*Mark used for ancient articles.") | 1509 ("timezone" timezone-make-date-arpa-standard timezone-fix-time |
1087 (defvar gnus-sparse-mark ?Q | 1510 timezone-make-sortable-date timezone-make-time-string) |
1088 "*Mark used for sparsely reffed articles.") | 1511 ("rmailout" rmail-output) |
1089 (defvar gnus-canceled-mark ?G | 1512 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages |
1090 "*Mark used for canceled articles.") | 1513 rmail-show-message) |
1091 (defvar gnus-score-over-mark ?+ | 1514 ("gnus-audio" :interactive t gnus-audio-play) |
1092 "*Score mark used for articles with high scores.") | 1515 ("gnus-xmas" gnus-xmas-splash) |
1093 (defvar gnus-score-below-mark ?- | 1516 ("gnus-soup" :interactive t |
1094 "*Score mark used for articles with low scores.") | 1517 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article |
1095 (defvar gnus-empty-thread-mark ? | 1518 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet) |
1096 "*There is no thread under the article.") | 1519 ("nnsoup" nnsoup-pack-replies) |
1097 (defvar gnus-not-empty-thread-mark ?= | 1520 ("score-mode" :interactive t gnus-score-mode) |
1098 "*There is a thread under the article.") | 1521 ("gnus-mh" gnus-summary-save-article-folder |
1099 | 1522 gnus-Folder-save-name gnus-folder-save-name) |
1100 (defvar gnus-shell-command-separator ";" | 1523 ("gnus-mh" :interactive t gnus-summary-save-in-folder) |
1101 "String used to separate to shell commands.") | 1524 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail |
1102 | 1525 gnus-demon-add-rescan gnus-demon-add-scan-timestamps |
1103 (defvar gnus-view-pseudo-asynchronously nil | 1526 gnus-demon-add-disconnection gnus-demon-add-handler |
1104 "*If non-nil, Gnus will view pseudo-articles asynchronously.") | 1527 gnus-demon-remove-handler) |
1105 | 1528 ("gnus-demon" :interactive t |
1106 (defvar gnus-view-pseudos nil | 1529 gnus-demon-init gnus-demon-cancel) |
1107 "*If `automatic', pseudo-articles will be viewed automatically. | 1530 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree |
1108 If `not-confirm', pseudos will be viewed automatically, and the user | 1531 gnus-tree-open gnus-tree-close gnus-carpal-setup-buffer) |
1109 will not be asked to confirm the command.") | 1532 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close |
1110 | 1533 gnus-nocem-unwanted-article-p) |
1111 (defvar gnus-view-pseudos-separately t | 1534 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info) |
1112 "*If non-nil, one pseudo-article will be created for each file to be viewed. | 1535 ("gnus-srvr" gnus-browse-foreign-server) |
1113 If nil, all files that use the same viewing command will be given as a | 1536 ("gnus-cite" :interactive t |
1114 list of parameters to that command.") | 1537 gnus-article-highlight-citation gnus-article-hide-citation-maybe |
1115 | 1538 gnus-article-hide-citation gnus-article-fill-cited-article |
1116 (defvar gnus-insert-pseudo-articles t | 1539 gnus-article-hide-citation-in-followups) |
1117 "*If non-nil, insert pseudo-articles when decoding articles.") | 1540 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal |
1118 | 1541 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author |
1119 (defvar gnus-group-line-format "%M\%S\%p\%P\%5y: %(%g%)%l\n" | 1542 gnus-execute gnus-expunge) |
1120 "*Format of group lines. | 1543 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers |
1121 It works along the same lines as a normal formatting string, | 1544 gnus-cache-possibly-remove-articles gnus-cache-request-article |
1122 with some simple extensions. | 1545 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active |
1123 | 1546 gnus-cache-enter-remove-article gnus-cached-article-p |
1124 %M Only marked articles (character, \"*\" or \" \") | 1547 gnus-cache-open gnus-cache-close gnus-cache-update-article) |
1125 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \") | 1548 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article |
1126 %L Level of subscribedness (integer) | 1549 gnus-cache-remove-article gnus-summary-insert-cached-articles) |
1127 %N Number of unread articles (integer) | 1550 ("gnus-score" :interactive t |
1128 %I Number of dormant articles (integer) | 1551 gnus-summary-increase-score gnus-summary-set-score |
1129 %i Number of ticked and dormant (integer) | 1552 gnus-summary-raise-thread gnus-summary-raise-same-subject |
1130 %T Number of ticked articles (integer) | 1553 gnus-summary-raise-score gnus-summary-raise-same-subject-and-select |
1131 %R Number of read articles (integer) | 1554 gnus-summary-lower-thread gnus-summary-lower-same-subject |
1132 %t Total number of articles (integer) | 1555 gnus-summary-lower-score gnus-summary-lower-same-subject-and-select |
1133 %y Number of unread, unticked articles (integer) | 1556 gnus-summary-current-score gnus-score-default |
1134 %G Group name (string) | 1557 gnus-score-flush-cache gnus-score-close |
1135 %g Qualified group name (string) | 1558 gnus-possibly-score-headers gnus-score-followup-article |
1136 %D Group description (string) | 1559 gnus-score-followup-thread) |
1137 %s Select method (string) | 1560 ("gnus-score" |
1138 %o Moderated group (char, \"m\") | 1561 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers |
1139 %p Process mark (char) | 1562 gnus-current-score-file-nondirectory gnus-score-adaptive |
1140 %O Moderated group (string, \"(m)\" or \"\") | 1563 gnus-score-find-trace gnus-score-file-name) |
1141 %P Topic indentation (string) | 1564 ("gnus-cus" :interactive t gnus-group-customize gnus-score-customize) |
1142 %l Whether there are GroupLens predictions for this group (string) | 1565 ("gnus-topic" :interactive t gnus-topic-mode) |
1143 %n Select from where (string) | 1566 ("gnus-topic" gnus-topic-remove-group gnus-topic-set-parameters) |
1144 %z A string that look like `<%s:%n>' if a foreign select method is used | 1567 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode) |
1145 %u User defined specifier. The next character in the format string should | 1568 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap)) |
1146 be a letter. Gnus will call the function gnus-user-format-function-X, | 1569 ("gnus-uu" :interactive t |
1147 where X is the letter following %u. The function will be passed the | 1570 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward |
1148 current header as argument. The function should return a string, which | 1571 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer |
1149 will be inserted into the buffer just like information from any other | 1572 gnus-uu-mark-by-regexp gnus-uu-mark-all |
1150 group specifier. | 1573 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu |
1151 | 1574 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar |
1152 Text between %( and %) will be highlighted with `gnus-mouse-face' when | 1575 gnus-uu-decode-unshar-and-save gnus-uu-decode-save |
1153 the mouse point move inside the area. There can only be one such area. | 1576 gnus-uu-decode-binhex gnus-uu-decode-uu-view |
1154 | 1577 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view |
1155 Note that this format specification is not always respected. For | 1578 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view |
1156 reasons of efficiency, when listing killed groups, this specification | 1579 gnus-uu-decode-binhex-view) |
1157 is ignored altogether. If the spec is changed considerably, your | 1580 ("gnus-uu" gnus-uu-delete-work-dir) |
1158 output may end up looking strange when listing both alive and killed | 1581 ("gnus-msg" (gnus-summary-send-map keymap) |
1159 groups. | 1582 gnus-article-mail gnus-copy-article-buffer gnus-extended-version) |
1160 | 1583 ("gnus-msg" :interactive t |
1161 If you use %o or %O, reading the active file will be slower and quite | 1584 gnus-group-post-news gnus-group-mail gnus-summary-post-news |
1162 a bit of extra memory will be used. %D will also worsen performance. | 1585 gnus-summary-followup gnus-summary-followup-with-original |
1163 Also note that if you change the format specification to include any | 1586 gnus-summary-cancel-article gnus-summary-supersede-article |
1164 of these specs, you must probably re-start Gnus to see them go into | 1587 gnus-post-news gnus-summary-reply gnus-summary-reply-with-original |
1165 effect.") | 1588 gnus-summary-mail-forward gnus-summary-mail-other-window |
1166 | 1589 gnus-summary-resend-message gnus-summary-resend-bounced-mail |
1167 (defvar gnus-summary-line-format "%U\%R\%z\%I\%(%[%4L: %-20,20n%]%) %s\n" | 1590 gnus-bug) |
1591 ("gnus-picon" :interactive t gnus-article-display-picons | |
1592 gnus-group-display-picons gnus-picons-article-display-x-face | |
1593 gnus-picons-display-x-face) | |
1594 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p | |
1595 gnus-grouplens-mode) | |
1596 ("smiley" :interactive t gnus-smiley-display) | |
1597 ("gnus-win" gnus-configure-windows gnus-add-configuration) | |
1598 ("gnus-sum" gnus-summary-insert-line gnus-summary-read-group | |
1599 gnus-list-of-unread-articles gnus-list-of-read-articles | |
1600 gnus-offer-save-summaries gnus-make-thread-indent-array | |
1601 gnus-summary-exit gnus-update-read-articles) | |
1602 ("gnus-group" gnus-group-insert-group-line gnus-group-quit | |
1603 gnus-group-list-groups gnus-group-first-unread-group | |
1604 gnus-group-set-mode-line gnus-group-set-info gnus-group-save-newsrc | |
1605 gnus-group-setup-buffer gnus-group-get-new-news | |
1606 gnus-group-make-help-group gnus-group-update-group) | |
1607 ("gnus-bcklg" gnus-backlog-request-article gnus-backlog-enter-article | |
1608 gnus-backlog-remove-article) | |
1609 ("gnus-art" gnus-article-read-summary-keys gnus-article-save | |
1610 gnus-article-prepare gnus-article-set-window-start | |
1611 gnus-article-next-page gnus-article-prev-page | |
1612 gnus-request-article-this-buffer gnus-article-mode | |
1613 gnus-article-setup-buffer gnus-narrow-to-page) | |
1614 ("gnus-art" :interactive t | |
1615 gnus-article-hide-headers gnus-article-hide-boring-headers | |
1616 gnus-article-treat-overstrike gnus-article-word-wrap | |
1617 gnus-article-remove-cr gnus-article-remove-trailing-blank-lines | |
1618 gnus-article-display-x-face gnus-article-de-quoted-unreadable | |
1619 gnus-article-mime-decode-quoted-printable gnus-article-hide-pgp | |
1620 gnus-article-hide-pem gnus-article-hide-signature | |
1621 gnus-article-strip-leading-blank-lines gnus-article-date-local | |
1622 gnus-article-date-original gnus-article-date-lapsed | |
1623 gnus-article-show-all-headers | |
1624 gnus-article-edit-mode gnus-article-edit-article | |
1625 gnus-article-edit-done gnus-decode-rfc1522 article-decode-rfc1522) | |
1626 ("gnus-int" gnus-request-type) | |
1627 ("gnus-start" gnus-newsrc-parse-options gnus-1 gnus-no-server-1 | |
1628 gnus-dribble-enter) | |
1629 ("gnus-dup" gnus-dup-suppress-articles gnus-dup-unsuppress-article | |
1630 gnus-dup-enter-articles) | |
1631 ("gnus-range" gnus-copy-sequence) | |
1632 ("gnus-eform" gnus-edit-form) | |
1633 ("gnus-move" :interactive t | |
1634 gnus-group-move-group-to-server gnus-change-server) | |
1635 ("gnus-logic" gnus-score-advanced) | |
1636 ("gnus-undo" gnus-undo-mode gnus-undo-register) | |
1637 ("gnus-async" gnus-async-request-fetched-article gnus-async-prefetch-next | |
1638 gnus-async-prefetch-article gnus-async-prefetch-remove-group | |
1639 gnus-async-halt-prefetch) | |
1640 ("gnus-vm" :interactive t gnus-summary-save-in-vm | |
1641 gnus-summary-save-article-vm)))) | |
1642 | |
1643 ;;; gnus-sum.el thingies | |
1644 | |
1645 | |
1646 (defcustom gnus-summary-line-format "%U\%R\%z\%I\%(%[%4L: %-20,20n%]%) %s\n" | |
1168 "*The format specification of the lines in the summary buffer. | 1647 "*The format specification of the lines in the summary buffer. |
1169 | 1648 |
1170 It works along the same lines as a normal formatting string, | 1649 It works along the same lines as a normal formatting string, |
1171 with some simple extensions. | 1650 with some simple extensions. |
1172 | 1651 |
1196 %i Article score (number) | 1675 %i Article score (number) |
1197 %z Article zcore (character) | 1676 %z Article zcore (character) |
1198 %t Number of articles under the current thread (number). | 1677 %t Number of articles under the current thread (number). |
1199 %e Whether the thread is empty or not (character). | 1678 %e Whether the thread is empty or not (character). |
1200 %l GroupLens score (string). | 1679 %l GroupLens score (string). |
1680 %V Total thread score (number). | |
1681 %P The line number (number). | |
1201 %u User defined specifier. The next character in the format string should | 1682 %u User defined specifier. The next character in the format string should |
1202 be a letter. Gnus will call the function gnus-user-format-function-X, | 1683 be a letter. Gnus will call the function gnus-user-format-function-X, |
1203 where X is the letter following %u. The function will be passed the | 1684 where X is the letter following %u. The function will be passed the |
1204 current header as argument. The function should return a string, which | 1685 current header as argument. The function should return a string, which |
1205 will be inserted into the summary just like information from any other | 1686 will be inserted into the summary just like information from any other |
1217 which is bad enough. | 1698 which is bad enough. |
1218 | 1699 |
1219 The smart choice is to have these specs as for to the left as | 1700 The smart choice is to have these specs as for to the left as |
1220 possible. | 1701 possible. |
1221 | 1702 |
1222 This restriction may disappear in later versions of Gnus.") | 1703 This restriction may disappear in later versions of Gnus." |
1223 | 1704 :type 'string |
1224 (defvar gnus-summary-dummy-line-format | 1705 :group 'gnus-summary-format) |
1225 "* %(: :%) %S\n" | 1706 |
1226 "*The format specification for the dummy roots in the summary buffer. | 1707 ;;; |
1227 It works along the same lines as a normal formatting string, | 1708 ;;; Skeleton keymaps |
1228 with some simple extensions. | 1709 ;;; |
1229 | 1710 |
1230 %S The subject") | 1711 (defun gnus-suppress-keymap (keymap) |
1231 | 1712 (suppress-keymap keymap) |
1232 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z" | 1713 (let ((keys `([delete] "\177" "\M-u"))) ;gnus-mouse-2 |
1233 "*The format specification for the summary mode line. | 1714 (while keys |
1234 It works along the same lines as a normal formatting string, | 1715 (define-key keymap (pop keys) 'undefined)))) |
1235 with some simple extensions: | 1716 |
1236 | 1717 (defvar gnus-article-mode-map |
1237 %G Group name | 1718 (let ((keymap (make-keymap))) |
1238 %p Unprefixed group name | 1719 (gnus-suppress-keymap keymap) |
1239 %A Current article number | 1720 keymap)) |
1240 %V Gnus version | 1721 (defvar gnus-summary-mode-map |
1241 %U Number of unread articles in the group | 1722 (let ((keymap (make-keymap))) |
1242 %e Number of unselected articles in the group | 1723 (gnus-suppress-keymap keymap) |
1243 %Z A string with unread/unselected article counts | 1724 keymap)) |
1244 %g Shortish group name | 1725 (defvar gnus-group-mode-map |
1245 %S Subject of the current article | 1726 (let ((keymap (make-keymap))) |
1246 %u User-defined spec | 1727 (gnus-suppress-keymap keymap) |
1247 %s Current score file name | 1728 keymap)) |
1248 %d Number of dormant articles | |
1249 %r Number of articles that have been marked as read in this session | |
1250 %E Number of articles expunged by the score files") | |
1251 | |
1252 (defvar gnus-article-mode-line-format "Gnus: %%b %S" | |
1253 "*The format specification for the article mode line. | |
1254 See `gnus-summary-mode-line-format' for a closer description.") | |
1255 | |
1256 (defvar gnus-group-mode-line-format "Gnus: %%b {%M\%:%S}" | |
1257 "*The format specification for the group mode line. | |
1258 It works along the same lines as a normal formatting string, | |
1259 with some simple extensions: | |
1260 | |
1261 %S The native news server. | |
1262 %M The native select method. | |
1263 %: \":\" if %S isn't \"\".") | |
1264 | |
1265 (defvar gnus-valid-select-methods | |
1266 '(("nntp" post address prompt-address) | |
1267 ("nnspool" post address) | |
1268 ("nnvirtual" post-mail virtual prompt-address) | |
1269 ("nnmbox" mail respool address) | |
1270 ("nnml" mail respool address) | |
1271 ("nnmh" mail respool address) | |
1272 ("nndir" post-mail prompt-address address) | |
1273 ("nneething" none address prompt-address) | |
1274 ("nndoc" none address prompt-address) | |
1275 ("nnbabyl" mail address respool) | |
1276 ("nnkiboze" post virtual) | |
1277 ("nnsoup" post-mail address) | |
1278 ("nndraft" post-mail) | |
1279 ("nnfolder" mail respool address)) | |
1280 "An alist of valid select methods. | |
1281 The first element of each list lists should be a string with the name | |
1282 of the select method. The other elements may be the category of | |
1283 this method (ie. `post', `mail', `none' or whatever) or other | |
1284 properties that this method has (like being respoolable). | |
1285 If you implement a new select method, all you should have to change is | |
1286 this variable. I think.") | |
1287 | |
1288 (defvar gnus-updated-mode-lines '(group article summary tree) | |
1289 "*List of buffers that should update their mode lines. | |
1290 The list may contain the symbols `group', `article' and `summary'. If | |
1291 the corresponding symbol is present, Gnus will keep that mode line | |
1292 updated with information that may be pertinent. | |
1293 If this variable is nil, screen refresh may be quicker.") | |
1294 | |
1295 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>. | |
1296 (defvar gnus-mode-non-string-length nil | |
1297 "*Max length of mode-line non-string contents. | |
1298 If this is nil, Gnus will take space as is needed, leaving the rest | |
1299 of the modeline intact.") | |
1300 | |
1301 ;see gnus-cus.el | |
1302 ;(defvar gnus-mouse-face 'highlight | |
1303 ; "*Face used for mouse highlighting in Gnus. | |
1304 ;No mouse highlights will be done if `gnus-visual' is nil.") | |
1305 | |
1306 (defvar gnus-summary-mark-below 0 | |
1307 "*Mark all articles with a score below this variable as read. | |
1308 This variable is local to each summary buffer and usually set by the | |
1309 score file.") | |
1310 | |
1311 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number) | |
1312 "*List of functions used for sorting articles in the summary buffer. | |
1313 This variable is only used when not using a threaded display.") | |
1314 | |
1315 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number) | |
1316 "*List of functions used for sorting threads in the summary buffer. | |
1317 By default, threads are sorted by article number. | |
1318 | |
1319 Each function takes two threads and return non-nil if the first thread | |
1320 should be sorted before the other. If you use more than one function, | |
1321 the primary sort function should be the last. You should probably | |
1322 always include `gnus-thread-sort-by-number' in the list of sorting | |
1323 functions -- preferably first. | |
1324 | |
1325 Ready-mady functions include `gnus-thread-sort-by-number', | |
1326 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject', | |
1327 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and | |
1328 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').") | |
1329 | |
1330 (defvar gnus-thread-score-function '+ | |
1331 "*Function used for calculating the total score of a thread. | |
1332 | |
1333 The function is called with the scores of the article and each | |
1334 subthread and should then return the score of the thread. | |
1335 | |
1336 Some functions you can use are `+', `max', or `min'.") | |
1337 | |
1338 (defvar gnus-summary-expunge-below nil | |
1339 "All articles that have a score less than this variable will be expunged.") | |
1340 | |
1341 (defvar gnus-thread-expunge-below nil | |
1342 "All threads that have a total score less than this variable will be expunged. | |
1343 See `gnus-thread-score-function' for en explanation of what a | |
1344 \"thread score\" is.") | |
1345 | |
1346 (defvar gnus-auto-subscribed-groups | |
1347 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl" | |
1348 "*All new groups that match this regexp will be subscribed automatically. | |
1349 Note that this variable only deals with new groups. It has no effect | |
1350 whatsoever on old groups. | |
1351 | |
1352 New groups that match this regexp will not be handled by | |
1353 `gnus-subscribe-newsgroup-method'. Instead, they will | |
1354 be subscribed using `gnus-subscribe-options-newsgroup-method'.") | |
1355 | |
1356 (defvar gnus-options-subscribe nil | |
1357 "*All new groups matching this regexp will be subscribed unconditionally. | |
1358 Note that this variable deals only with new newsgroups. This variable | |
1359 does not affect old newsgroups. | |
1360 | |
1361 New groups that match this regexp will not be handled by | |
1362 `gnus-subscribe-newsgroup-method'. Instead, they will | |
1363 be subscribed using `gnus-subscribe-options-newsgroup-method'.") | |
1364 | |
1365 (defvar gnus-options-not-subscribe nil | |
1366 "*All new groups matching this regexp will be ignored. | |
1367 Note that this variable deals only with new newsgroups. This variable | |
1368 does not affect old (already subscribed) newsgroups.") | |
1369 | |
1370 (defvar gnus-auto-expirable-newsgroups nil | |
1371 "*Groups in which to automatically mark read articles as expirable. | |
1372 If non-nil, this should be a regexp that should match all groups in | |
1373 which to perform auto-expiry. This only makes sense for mail groups.") | |
1374 | |
1375 (defvar gnus-total-expirable-newsgroups nil | |
1376 "*Groups in which to perform expiry of all read articles. | |
1377 Use with extreme caution. All groups that match this regexp will be | |
1378 expiring - which means that all read articles will be deleted after | |
1379 (say) one week. (This only goes for mail groups and the like, of | |
1380 course.)") | |
1381 | |
1382 (defvar gnus-group-uncollapsed-levels 1 | |
1383 "Number of group name elements to leave alone when making a short group name.") | |
1384 | |
1385 (defvar gnus-hidden-properties '(invisible t intangible t) | |
1386 "Property list to use for hiding text.") | |
1387 | |
1388 (defvar gnus-modtime-botch nil | |
1389 "*Non-nil means .newsrc should be deleted prior to save. | |
1390 Its use is due to the bogus appearance that .newsrc was modified on | |
1391 disc.") | |
1392 | |
1393 ;; Hooks. | |
1394 | |
1395 (defvar gnus-group-mode-hook nil | |
1396 "*A hook for Gnus group mode.") | |
1397 | |
1398 (defvar gnus-summary-mode-hook nil | |
1399 "*A hook for Gnus summary mode. | |
1400 This hook is run before any variables are set in the summary buffer.") | |
1401 | |
1402 (defvar gnus-article-mode-hook nil | |
1403 "*A hook for Gnus article mode.") | |
1404 | |
1405 (defvar gnus-summary-prepare-exit-hook nil | |
1406 "*A hook called when preparing to exit from the summary buffer. | |
1407 It calls `gnus-summary-expire-articles' by default.") | |
1408 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles) | |
1409 | |
1410 (defvar gnus-summary-exit-hook nil | |
1411 "*A hook called on exit from the summary buffer.") | |
1412 | |
1413 (defvar gnus-check-bogus-groups-hook nil | |
1414 "A hook run after removing bogus groups.") | |
1415 | |
1416 (defvar gnus-group-catchup-group-hook nil | |
1417 "*A hook run when catching up a group from the group buffer.") | |
1418 | |
1419 (defvar gnus-group-update-group-hook nil | |
1420 "*A hook called when updating group lines.") | |
1421 | |
1422 (defvar gnus-open-server-hook nil | |
1423 "*A hook called just before opening connection to the news server.") | |
1424 | |
1425 (defvar gnus-load-hook nil | |
1426 "*A hook run while Gnus is loaded.") | |
1427 | |
1428 (defvar gnus-startup-hook nil | |
1429 "*A hook called at startup. | |
1430 This hook is called after Gnus is connected to the NNTP server.") | |
1431 | |
1432 (defvar gnus-get-new-news-hook nil | |
1433 "*A hook run just before Gnus checks for new news.") | |
1434 | |
1435 (defvar gnus-after-getting-new-news-hook nil | |
1436 "*A hook run after Gnus checks for new news.") | |
1437 | |
1438 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat | |
1439 "*A function that is called to generate the group buffer. | |
1440 The function is called with three arguments: The first is a number; | |
1441 all group with a level less or equal to that number should be listed, | |
1442 if the second is non-nil, empty groups should also be displayed. If | |
1443 the third is non-nil, it is a number. No groups with a level lower | |
1444 than this number should be displayed. | |
1445 | |
1446 The only current function implemented is `gnus-group-prepare-flat'.") | |
1447 | |
1448 (defvar gnus-group-prepare-hook nil | |
1449 "*A hook called after the group buffer has been generated. | |
1450 If you want to modify the group buffer, you can use this hook.") | |
1451 | |
1452 (defvar gnus-summary-prepare-hook nil | |
1453 "*A hook called after the summary buffer has been generated. | |
1454 If you want to modify the summary buffer, you can use this hook.") | |
1455 | |
1456 (defvar gnus-summary-generate-hook nil | |
1457 "*A hook run just before generating the summary buffer. | |
1458 This hook is commonly used to customize threading variables and the | |
1459 like.") | |
1460 | |
1461 (defvar gnus-article-prepare-hook nil | |
1462 "*A hook called after an article has been prepared in the article buffer. | |
1463 If you want to run a special decoding program like nkf, use this hook.") | |
1464 | |
1465 ;(defvar gnus-article-display-hook nil | |
1466 ; "*A hook called after the article is displayed in the article buffer. | |
1467 ;The hook is designed to change the contents of the article | |
1468 ;buffer. Typical functions that this hook may contain are | |
1469 ;`gnus-article-hide-headers' (hide selected headers), | |
1470 ;`gnus-article-maybe-highlight' (perform fancy article highlighting), | |
1471 ;`gnus-article-hide-signature' (hide signature) and | |
1472 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).") | |
1473 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted) | |
1474 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike) | |
1475 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight) | |
1476 | |
1477 (defvar gnus-article-x-face-too-ugly nil | |
1478 "Regexp matching posters whose face shouldn't be shown automatically.") | |
1479 | |
1480 (defvar gnus-select-group-hook nil | |
1481 "*A hook called when a newsgroup is selected. | |
1482 | |
1483 If you'd like to simplify subjects like the | |
1484 `gnus-summary-next-same-subject' command does, you can use the | |
1485 following hook: | |
1486 | |
1487 (setq gnus-select-group-hook | |
1488 (list | |
1489 (lambda () | |
1490 (mapcar (lambda (header) | |
1491 (mail-header-set-subject | |
1492 header | |
1493 (gnus-simplify-subject | |
1494 (mail-header-subject header) 're-only))) | |
1495 gnus-newsgroup-headers))))") | |
1496 | |
1497 (defvar gnus-select-article-hook nil | |
1498 "*A hook called when an article is selected.") | |
1499 | |
1500 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file) | |
1501 "*A hook called to apply kill files to a group. | |
1502 This hook is intended to apply a kill file to the selected newsgroup. | |
1503 The function `gnus-apply-kill-file' is called by default. | |
1504 | |
1505 Since a general kill file is too heavy to use only for a few | |
1506 newsgroups, I recommend you to use a lighter hook function. For | |
1507 example, if you'd like to apply a kill file to articles which contains | |
1508 a string `rmgroup' in subject in newsgroup `control', you can use the | |
1509 following hook: | |
1510 | |
1511 (setq gnus-apply-kill-hook | |
1512 (list | |
1513 (lambda () | |
1514 (cond ((string-match \"control\" gnus-newsgroup-name) | |
1515 (gnus-kill \"Subject\" \"rmgroup\") | |
1516 (gnus-expunge \"X\"))))))") | |
1517 | |
1518 (defvar gnus-visual-mark-article-hook | |
1519 (list 'gnus-highlight-selected-summary) | |
1520 "*Hook run after selecting an article in the summary buffer. | |
1521 It is meant to be used for highlighting the article in some way. It | |
1522 is not run if `gnus-visual' is nil.") | |
1523 | |
1524 (defvar gnus-parse-headers-hook nil | |
1525 "*A hook called before parsing the headers.") | |
1526 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522) | |
1527 | |
1528 (defvar gnus-exit-group-hook nil | |
1529 "*A hook called when exiting (not quitting) summary mode.") | |
1530 | |
1531 (defvar gnus-suspend-gnus-hook nil | |
1532 "*A hook called when suspending (not exiting) Gnus.") | |
1533 | |
1534 (defvar gnus-exit-gnus-hook nil | |
1535 "*A hook called when exiting Gnus.") | |
1536 | |
1537 (defvar gnus-after-exiting-gnus-hook nil | |
1538 "*A hook called after exiting Gnus.") | |
1539 | |
1540 (defvar gnus-save-newsrc-hook nil | |
1541 "*A hook called before saving any of the newsrc files.") | |
1542 | |
1543 (defvar gnus-save-quick-newsrc-hook nil | |
1544 "*A hook called just before saving the quick newsrc file. | |
1545 Can be used to turn version control on or off.") | |
1546 | |
1547 (defvar gnus-save-standard-newsrc-hook nil | |
1548 "*A hook called just before saving the standard newsrc file. | |
1549 Can be used to turn version control on or off.") | |
1550 | |
1551 (defvar gnus-summary-update-hook | |
1552 (list 'gnus-summary-highlight-line) | |
1553 "*A hook called when a summary line is changed. | |
1554 The hook will not be called if `gnus-visual' is nil. | |
1555 | |
1556 The default function `gnus-summary-highlight-line' will | |
1557 highlight the line according to the `gnus-summary-highlight' | |
1558 variable.") | |
1559 | |
1560 (defvar gnus-group-update-hook '(gnus-group-highlight-line) | |
1561 "*A hook called when a group line is changed. | |
1562 The hook will not be called if `gnus-visual' is nil. | |
1563 | |
1564 The default function `gnus-group-highlight-line' will | |
1565 highlight the line according to the `gnus-group-highlight' | |
1566 variable.") | |
1567 | |
1568 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read) | |
1569 "*A hook called when an article is selected for the first time. | |
1570 The hook is intended to mark an article as read (or unread) | |
1571 automatically when it is selected.") | |
1572 | |
1573 (defvar gnus-group-change-level-function nil | |
1574 "Function run when a group level is changed. | |
1575 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.") | |
1576 | |
1577 ;; Remove any hilit infestation. | |
1578 (add-hook 'gnus-startup-hook | |
1579 (lambda () | |
1580 (remove-hook 'gnus-summary-prepare-hook | |
1581 'hilit-rehighlight-buffer-quietly) | |
1582 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks) | |
1583 (setq gnus-mark-article-hook | |
1584 '(gnus-summary-mark-read-and-unread-as-read)) | |
1585 (remove-hook 'gnus-article-prepare-hook | |
1586 'hilit-rehighlight-buffer-quietly))) | |
1587 | |
1588 | |
1589 ;; Internal variables | |
1590 | |
1591 (defvar gnus-tree-buffer "*Tree*" | |
1592 "Buffer where Gnus thread trees are displayed.") | |
1593 | |
1594 ;; Dummy variable. | |
1595 (defvar gnus-use-generic-from nil) | |
1596 | |
1597 (defvar gnus-thread-indent-array nil) | |
1598 (defvar gnus-thread-indent-array-level gnus-thread-indent-level) | |
1599 | |
1600 (defvar gnus-newsrc-file-version nil) | |
1601 | |
1602 (defvar gnus-method-history nil) | |
1603 ;; Variable holding the user answers to all method prompts. | |
1604 | |
1605 (defvar gnus-group-history nil) | |
1606 ;; Variable holding the user answers to all group prompts. | |
1607 | |
1608 (defvar gnus-server-alist nil | |
1609 "List of available servers.") | |
1610 | |
1611 (defvar gnus-group-indentation-function nil) | |
1612 | |
1613 (defvar gnus-topic-indentation "") ;; Obsolete variable. | |
1614 | |
1615 (defvar gnus-goto-missing-group-function nil) | |
1616 | |
1617 (defvar gnus-override-subscribe-method nil) | |
1618 | |
1619 (defvar gnus-group-goto-next-group-function nil | |
1620 "Function to override finding the next group after listing groups.") | |
1621 | |
1622 (defconst gnus-article-mark-lists | |
1623 '((marked . tick) (replied . reply) | |
1624 (expirable . expire) (killed . killed) | |
1625 (bookmarks . bookmark) (dormant . dormant) | |
1626 (scored . score) (saved . save) | |
1627 (cached . cache) | |
1628 )) | |
1629 | |
1630 ;; Avoid highlighting in kill files. | |
1631 (defvar gnus-summary-inhibit-highlight nil) | |
1632 (defvar gnus-newsgroup-selected-overlay nil) | |
1633 | |
1634 (defvar gnus-inhibit-hiding nil) | |
1635 (defvar gnus-group-indentation "") | |
1636 (defvar gnus-inhibit-limiting nil) | |
1637 (defvar gnus-created-frames nil) | |
1638 | |
1639 (defvar gnus-article-mode-map nil) | |
1640 (defvar gnus-dribble-buffer nil) | |
1641 (defvar gnus-headers-retrieved-by nil) | |
1642 (defvar gnus-article-reply nil) | |
1643 (defvar gnus-override-method nil) | |
1644 (defvar gnus-article-check-size nil) | |
1645 | |
1646 (defvar gnus-current-score-file nil) | |
1647 (defvar gnus-newsgroup-adaptive-score-file nil) | |
1648 (defvar gnus-scores-exclude-files nil) | |
1649 | |
1650 (defvar gnus-opened-servers nil) | |
1651 | |
1652 (defvar gnus-current-move-group nil) | |
1653 (defvar gnus-current-copy-group nil) | |
1654 (defvar gnus-current-crosspost-group nil) | |
1655 | |
1656 (defvar gnus-newsgroup-dependencies nil) | |
1657 (defvar gnus-newsgroup-async nil) | |
1658 (defvar gnus-group-edit-buffer nil) | |
1659 | |
1660 (defvar gnus-newsgroup-adaptive nil) | |
1661 | |
1662 (defvar gnus-summary-display-table nil) | |
1663 (defvar gnus-summary-display-article-function nil) | |
1664 | |
1665 (defvar gnus-summary-highlight-line-function nil | |
1666 "Function called after highlighting a summary line.") | |
1667 | |
1668 (defvar gnus-group-line-format-alist | |
1669 `((?M gnus-tmp-marked-mark ?c) | |
1670 (?S gnus-tmp-subscribed ?c) | |
1671 (?L gnus-tmp-level ?d) | |
1672 (?N (cond ((eq number t) "*" ) | |
1673 ((numberp number) | |
1674 (int-to-string | |
1675 (+ number | |
1676 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) | |
1677 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))))) | |
1678 (t number)) ?s) | |
1679 (?R gnus-tmp-number-of-read ?s) | |
1680 (?t gnus-tmp-number-total ?d) | |
1681 (?y gnus-tmp-number-of-unread ?s) | |
1682 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d) | |
1683 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d) | |
1684 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) | |
1685 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d) | |
1686 (?g gnus-tmp-group ?s) | |
1687 (?G gnus-tmp-qualified-group ?s) | |
1688 (?c (gnus-short-group-name gnus-tmp-group) ?s) | |
1689 (?D gnus-tmp-newsgroup-description ?s) | |
1690 (?o gnus-tmp-moderated ?c) | |
1691 (?O gnus-tmp-moderated-string ?s) | |
1692 (?p gnus-tmp-process-marked ?c) | |
1693 (?s gnus-tmp-news-server ?s) | |
1694 (?n gnus-tmp-news-method ?s) | |
1695 (?P gnus-group-indentation ?s) | |
1696 (?l gnus-tmp-grouplens ?s) | |
1697 (?z gnus-tmp-news-method-string ?s) | |
1698 (?u gnus-tmp-user-defined ?s))) | |
1699 | |
1700 (defvar gnus-summary-line-format-alist | |
1701 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d) | |
1702 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s) | |
1703 (?s gnus-tmp-subject-or-nil ?s) | |
1704 (?n gnus-tmp-name ?s) | |
1705 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from))) | |
1706 ?s) | |
1707 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from)) | |
1708 gnus-tmp-from) ?s) | |
1709 (?F gnus-tmp-from ?s) | |
1710 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s) | |
1711 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s) | |
1712 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s) | |
1713 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s) | |
1714 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s) | |
1715 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d) | |
1716 (?L gnus-tmp-lines ?d) | |
1717 (?I gnus-tmp-indentation ?s) | |
1718 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s) | |
1719 (?R gnus-tmp-replied ?c) | |
1720 (?\[ gnus-tmp-opening-bracket ?c) | |
1721 (?\] gnus-tmp-closing-bracket ?c) | |
1722 (?\> (make-string gnus-tmp-level ? ) ?s) | |
1723 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s) | |
1724 (?i gnus-tmp-score ?d) | |
1725 (?z gnus-tmp-score-char ?c) | |
1726 (?l (bbb-grouplens-score gnus-tmp-header) ?s) | |
1727 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d) | |
1728 (?U gnus-tmp-unread ?c) | |
1729 (?t (gnus-summary-number-of-articles-in-thread | |
1730 (and (boundp 'thread) (car thread)) gnus-tmp-level) | |
1731 ?d) | |
1732 (?e (gnus-summary-number-of-articles-in-thread | |
1733 (and (boundp 'thread) (car thread)) gnus-tmp-level t) | |
1734 ?c) | |
1735 (?u gnus-tmp-user-defined ?s)) | |
1736 "An alist of format specifications that can appear in summary lines, | |
1737 and what variables they correspond with, along with the type of the | |
1738 variable (string, integer, character, etc).") | |
1739 | |
1740 (defvar gnus-summary-dummy-line-format-alist | |
1741 `((?S gnus-tmp-subject ?s) | |
1742 (?N gnus-tmp-number ?d) | |
1743 (?u gnus-tmp-user-defined ?s))) | |
1744 | |
1745 (defvar gnus-summary-mode-line-format-alist | |
1746 `((?G gnus-tmp-group-name ?s) | |
1747 (?g (gnus-short-group-name gnus-tmp-group-name) ?s) | |
1748 (?p (gnus-group-real-name gnus-tmp-group-name) ?s) | |
1749 (?A gnus-tmp-article-number ?d) | |
1750 (?Z gnus-tmp-unread-and-unselected ?s) | |
1751 (?V gnus-version ?s) | |
1752 (?U gnus-tmp-unread-and-unticked ?d) | |
1753 (?S gnus-tmp-subject ?s) | |
1754 (?e gnus-tmp-unselected ?d) | |
1755 (?u gnus-tmp-user-defined ?s) | |
1756 (?d (length gnus-newsgroup-dormant) ?d) | |
1757 (?t (length gnus-newsgroup-marked) ?d) | |
1758 (?r (length gnus-newsgroup-reads) ?d) | |
1759 (?E gnus-newsgroup-expunged-tally ?d) | |
1760 (?s (gnus-current-score-file-nondirectory) ?s))) | |
1761 | |
1762 (defvar gnus-article-mode-line-format-alist | |
1763 gnus-summary-mode-line-format-alist) | |
1764 | |
1765 (defvar gnus-group-mode-line-format-alist | |
1766 `((?S gnus-tmp-news-server ?s) | |
1767 (?M gnus-tmp-news-method ?s) | |
1768 (?u gnus-tmp-user-defined ?s) | |
1769 (?: gnus-tmp-colon ?s))) | |
1770 | |
1771 (defvar gnus-have-read-active-file nil) | |
1772 | |
1773 (defconst gnus-maintainer | |
1774 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)" | |
1775 "The mail address of the Gnus maintainers.") | |
1776 | |
1777 (defconst gnus-version-number "5.2.40" | |
1778 "Version number for this version of Gnus.") | |
1779 | |
1780 (defconst gnus-version (format "Gnus v%s" gnus-version-number) | |
1781 "Version string for this version of Gnus.") | |
1782 | |
1783 (defvar gnus-info-nodes | |
1784 '((gnus-group-mode "(gnus)The Group Buffer") | |
1785 (gnus-summary-mode "(gnus)The Summary Buffer") | |
1786 (gnus-article-mode "(gnus)The Article Buffer") | |
1787 (gnus-server-mode "(gnus)The Server Buffer") | |
1788 (gnus-browse-mode "(gnus)Browse Foreign Server") | |
1789 (gnus-tree-mode "(gnus)Tree Display") | |
1790 ) | |
1791 "Alist of major modes and related Info nodes.") | |
1792 | |
1793 (defvar gnus-group-buffer "*Group*") | |
1794 (defvar gnus-summary-buffer "*Summary*") | |
1795 (defvar gnus-article-buffer "*Article*") | |
1796 (defvar gnus-server-buffer "*Server*") | |
1797 | |
1798 (defvar gnus-work-buffer " *gnus work*") | |
1799 | |
1800 (defvar gnus-original-article-buffer " *Original Article*") | |
1801 (defvar gnus-original-article nil) | |
1802 | |
1803 (defvar gnus-buffer-list nil | |
1804 "Gnus buffers that should be killed on exit.") | |
1805 | |
1806 (defvar gnus-slave nil | |
1807 "Whether this Gnus is a slave or not.") | |
1808 | |
1809 (defvar gnus-variable-list | |
1810 '(gnus-newsrc-options gnus-newsrc-options-n | |
1811 gnus-newsrc-last-checked-date | |
1812 gnus-newsrc-alist gnus-server-alist | |
1813 gnus-killed-list gnus-zombie-list | |
1814 gnus-topic-topology gnus-topic-alist | |
1815 gnus-format-specs) | |
1816 "Gnus variables saved in the quick startup file.") | |
1817 | |
1818 (defvar gnus-newsrc-options nil | |
1819 "Options line in the .newsrc file.") | |
1820 | |
1821 (defvar gnus-newsrc-options-n nil | |
1822 "List of regexps representing groups to be subscribed/ignored unconditionally.") | |
1823 | |
1824 (defvar gnus-newsrc-last-checked-date nil | |
1825 "Date Gnus last asked server for new newsgroups.") | |
1826 | |
1827 (defvar gnus-topic-topology nil | |
1828 "The complete topic hierarchy.") | |
1829 | |
1830 (defvar gnus-topic-alist nil | |
1831 "The complete topic-group alist.") | |
1832 | |
1833 (defvar gnus-newsrc-alist nil | |
1834 "Assoc list of read articles. | |
1835 gnus-newsrc-hashtb should be kept so that both hold the same information.") | |
1836 | |
1837 (defvar gnus-newsrc-hashtb nil | |
1838 "Hashtable of gnus-newsrc-alist.") | |
1839 | |
1840 (defvar gnus-killed-list nil | |
1841 "List of killed newsgroups.") | |
1842 | |
1843 (defvar gnus-killed-hashtb nil | |
1844 "Hash table equivalent of gnus-killed-list.") | |
1845 | |
1846 (defvar gnus-zombie-list nil | |
1847 "List of almost dead newsgroups.") | |
1848 | |
1849 (defvar gnus-description-hashtb nil | |
1850 "Descriptions of newsgroups.") | |
1851 | |
1852 (defvar gnus-list-of-killed-groups nil | |
1853 "List of newsgroups that have recently been killed by the user.") | |
1854 | |
1855 (defvar gnus-active-hashtb nil | |
1856 "Hashtable of active articles.") | |
1857 | |
1858 (defvar gnus-moderated-list nil | |
1859 "List of moderated newsgroups.") | |
1860 | |
1861 (defvar gnus-group-marked nil) | |
1862 | |
1863 (defvar gnus-current-startup-file nil | |
1864 "Startup file for the current host.") | |
1865 | |
1866 (defvar gnus-last-search-regexp nil | |
1867 "Default regexp for article search command.") | |
1868 | |
1869 (defvar gnus-last-shell-command nil | |
1870 "Default shell command on article.") | |
1871 | |
1872 (defvar gnus-current-select-method nil | |
1873 "The current method for selecting a newsgroup.") | |
1874 | |
1875 (defvar gnus-group-list-mode nil) | |
1876 | |
1877 (defvar gnus-article-internal-prepare-hook nil) | |
1878 | |
1879 (defvar gnus-newsgroup-name nil) | |
1880 (defvar gnus-newsgroup-begin nil) | |
1881 (defvar gnus-newsgroup-end nil) | |
1882 (defvar gnus-newsgroup-last-rmail nil) | |
1883 (defvar gnus-newsgroup-last-mail nil) | |
1884 (defvar gnus-newsgroup-last-folder nil) | |
1885 (defvar gnus-newsgroup-last-file nil) | |
1886 (defvar gnus-newsgroup-auto-expire nil) | |
1887 (defvar gnus-newsgroup-active nil) | |
1888 | |
1889 (defvar gnus-newsgroup-data nil) | |
1890 (defvar gnus-newsgroup-data-reverse nil) | |
1891 (defvar gnus-newsgroup-limit nil) | |
1892 (defvar gnus-newsgroup-limits nil) | |
1893 | |
1894 (defvar gnus-newsgroup-unreads nil | |
1895 "List of unread articles in the current newsgroup.") | |
1896 | |
1897 (defvar gnus-newsgroup-unselected nil | |
1898 "List of unselected unread articles in the current newsgroup.") | |
1899 | |
1900 (defvar gnus-newsgroup-reads nil | |
1901 "Alist of read articles and article marks in the current newsgroup.") | |
1902 | |
1903 (defvar gnus-newsgroup-expunged-tally nil) | |
1904 | |
1905 (defvar gnus-newsgroup-marked nil | |
1906 "List of ticked articles in the current newsgroup (a subset of unread art).") | |
1907 | |
1908 (defvar gnus-newsgroup-killed nil | |
1909 "List of ranges of articles that have been through the scoring process.") | |
1910 | |
1911 (defvar gnus-newsgroup-cached nil | |
1912 "List of articles that come from the article cache.") | |
1913 | |
1914 (defvar gnus-newsgroup-saved nil | |
1915 "List of articles that have been saved.") | |
1916 | |
1917 (defvar gnus-newsgroup-kill-headers nil) | |
1918 | |
1919 (defvar gnus-newsgroup-replied nil | |
1920 "List of articles that have been replied to in the current newsgroup.") | |
1921 | |
1922 (defvar gnus-newsgroup-expirable nil | |
1923 "List of articles in the current newsgroup that can be expired.") | |
1924 | |
1925 (defvar gnus-newsgroup-processable nil | |
1926 "List of articles in the current newsgroup that can be processed.") | |
1927 | |
1928 (defvar gnus-newsgroup-bookmarks nil | |
1929 "List of articles in the current newsgroup that have bookmarks.") | |
1930 | |
1931 (defvar gnus-newsgroup-dormant nil | |
1932 "List of dormant articles in the current newsgroup.") | |
1933 | |
1934 (defvar gnus-newsgroup-scored nil | |
1935 "List of scored articles in the current newsgroup.") | |
1936 | |
1937 (defvar gnus-newsgroup-headers nil | |
1938 "List of article headers in the current newsgroup.") | |
1939 | |
1940 (defvar gnus-newsgroup-threads nil) | |
1941 | |
1942 (defvar gnus-newsgroup-prepared nil | |
1943 "Whether the current group has been prepared properly.") | |
1944 | |
1945 (defvar gnus-newsgroup-ancient nil | |
1946 "List of `gnus-fetch-old-headers' articles in the current newsgroup.") | |
1947 | |
1948 (defvar gnus-newsgroup-sparse nil) | |
1949 | |
1950 (defvar gnus-current-article nil) | |
1951 (defvar gnus-article-current nil) | |
1952 (defvar gnus-current-headers nil) | |
1953 (defvar gnus-have-all-headers nil) | |
1954 (defvar gnus-last-article nil) | |
1955 (defvar gnus-newsgroup-history nil) | |
1956 (defvar gnus-current-kill-article nil) | |
1957 | |
1958 ;; Save window configuration. | |
1959 (defvar gnus-prev-winconf nil) | |
1960 | |
1961 (defvar gnus-summary-mark-positions nil) | |
1962 (defvar gnus-group-mark-positions nil) | |
1963 | |
1964 (defvar gnus-reffed-article-number nil) | |
1965 | |
1966 ;;; Let the byte-compiler know that we know about this variable. | |
1967 (defvar rmail-default-rmail-file) | |
1968 | |
1969 (defvar gnus-cache-removable-articles nil) | |
1970 | |
1971 (defvar gnus-dead-summary nil) | |
1972 | |
1973 (defconst gnus-summary-local-variables | |
1974 '(gnus-newsgroup-name | |
1975 gnus-newsgroup-begin gnus-newsgroup-end | |
1976 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail | |
1977 gnus-newsgroup-last-folder gnus-newsgroup-last-file | |
1978 gnus-newsgroup-auto-expire gnus-newsgroup-unreads | |
1979 gnus-newsgroup-unselected gnus-newsgroup-marked | |
1980 gnus-newsgroup-reads gnus-newsgroup-saved | |
1981 gnus-newsgroup-replied gnus-newsgroup-expirable | |
1982 gnus-newsgroup-processable gnus-newsgroup-killed | |
1983 gnus-newsgroup-bookmarks gnus-newsgroup-dormant | |
1984 gnus-newsgroup-headers gnus-newsgroup-threads | |
1985 gnus-newsgroup-prepared gnus-summary-highlight-line-function | |
1986 gnus-current-article gnus-current-headers gnus-have-all-headers | |
1987 gnus-last-article gnus-article-internal-prepare-hook | |
1988 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay | |
1989 gnus-newsgroup-scored gnus-newsgroup-kill-headers | |
1990 gnus-newsgroup-async gnus-thread-expunge-below | |
1991 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below | |
1992 (gnus-summary-mark-below . global) | |
1993 gnus-newsgroup-active gnus-scores-exclude-files | |
1994 gnus-newsgroup-history gnus-newsgroup-ancient | |
1995 gnus-newsgroup-sparse | |
1996 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring) | |
1997 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1) | |
1998 (gnus-newsgroup-expunged-tally . 0) | |
1999 gnus-cache-removable-articles gnus-newsgroup-cached | |
2000 gnus-newsgroup-data gnus-newsgroup-data-reverse | |
2001 gnus-newsgroup-limit gnus-newsgroup-limits) | |
2002 "Variables that are buffer-local to the summary buffers.") | |
2003 | |
2004 (defconst gnus-bug-message | |
2005 "Sending a bug report to the Gnus Towers. | |
2006 ======================================== | |
2007 | |
2008 The buffer below is a mail buffer. When you press `C-c C-c', it will | |
2009 be sent to the Gnus Bug Exterminators. | |
2010 | |
2011 At the bottom of the buffer you'll see lots of variable settings. | |
2012 Please do not delete those. They will tell the Bug People what your | |
2013 environment is, so that it will be easier to locate the bugs. | |
2014 | |
2015 If you have found a bug that makes Emacs go \"beep\", set | |
2016 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET') | |
2017 and include the backtrace in your bug report. | |
2018 | |
2019 Please describe the bug in annoying, painstaking detail. | |
2020 | |
2021 Thank you for your help in stamping out bugs. | |
2022 ") | |
2023 | |
2024 ;;; End of variables. | |
2025 | |
2026 ;; Define some autoload functions Gnus might use. | |
2027 (eval-and-compile | |
2028 | |
2029 ;; This little mapcar goes through the list below and marks the | |
2030 ;; symbols in question as autoloaded functions. | |
2031 (mapcar | |
2032 (lambda (package) | |
2033 (let ((interactive (nth 1 (memq ':interactive package)))) | |
2034 (mapcar | |
2035 (lambda (function) | |
2036 (let (keymap) | |
2037 (when (consp function) | |
2038 (setq keymap (car (memq 'keymap function))) | |
2039 (setq function (car function))) | |
2040 (autoload function (car package) nil interactive keymap))) | |
2041 (if (eq (nth 1 package) ':interactive) | |
2042 (cdddr package) | |
2043 (cdr package))))) | |
2044 '(("metamail" metamail-buffer) | |
2045 ("info" Info-goto-node) | |
2046 ("hexl" hexl-hex-string-to-integer) | |
2047 ("pp" pp pp-to-string pp-eval-expression) | |
2048 ("mail-extr" mail-extract-address-components) | |
2049 ("nnmail" nnmail-split-fancy nnmail-article-group) | |
2050 ("nnvirtual" nnvirtual-catchup-group) | |
2051 ("timezone" timezone-make-date-arpa-standard timezone-fix-time | |
2052 timezone-make-sortable-date timezone-make-time-string) | |
2053 ("rmailout" rmail-output) | |
2054 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages | |
2055 rmail-show-message) | |
2056 ("gnus-soup" :interactive t | |
2057 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article | |
2058 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet) | |
2059 ("nnsoup" nnsoup-pack-replies) | |
2060 ("score-mode" :interactive t gnus-score-mode) | |
2061 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder | |
2062 gnus-Folder-save-name gnus-folder-save-name) | |
2063 ("gnus-mh" :interactive t gnus-summary-save-in-folder) | |
2064 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar | |
2065 gnus-server-make-menu-bar gnus-article-make-menu-bar | |
2066 gnus-browse-make-menu-bar gnus-highlight-selected-summary | |
2067 gnus-summary-highlight-line gnus-carpal-setup-buffer | |
2068 gnus-group-highlight-line | |
2069 gnus-article-add-button gnus-insert-next-page-button | |
2070 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu) | |
2071 ("gnus-vis" :interactive t | |
2072 gnus-article-push-button gnus-article-press-button | |
2073 gnus-article-highlight gnus-article-highlight-some | |
2074 gnus-article-highlight-headers gnus-article-highlight-signature | |
2075 gnus-article-add-buttons gnus-article-add-buttons-to-head | |
2076 gnus-article-next-button gnus-article-prev-button) | |
2077 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail | |
2078 gnus-demon-add-disconnection gnus-demon-add-handler | |
2079 gnus-demon-remove-handler) | |
2080 ("gnus-demon" :interactive t | |
2081 gnus-demon-init gnus-demon-cancel) | |
2082 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree | |
2083 gnus-tree-open gnus-tree-close) | |
2084 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close | |
2085 gnus-nocem-unwanted-article-p) | |
2086 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info) | |
2087 ("gnus-srvr" gnus-browse-foreign-server) | |
2088 ("gnus-cite" :interactive t | |
2089 gnus-article-highlight-citation gnus-article-hide-citation-maybe | |
2090 gnus-article-hide-citation gnus-article-fill-cited-article | |
2091 gnus-article-hide-citation-in-followups) | |
2092 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal | |
2093 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author | |
2094 gnus-execute gnus-expunge) | |
2095 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers | |
2096 gnus-cache-possibly-remove-articles gnus-cache-request-article | |
2097 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active | |
2098 gnus-cache-enter-remove-article gnus-cached-article-p | |
2099 gnus-cache-open gnus-cache-close gnus-cache-update-article) | |
2100 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article | |
2101 gnus-cache-remove-article) | |
2102 ("gnus-score" :interactive t | |
2103 gnus-summary-increase-score gnus-summary-lower-score | |
2104 gnus-score-flush-cache gnus-score-close | |
2105 gnus-score-raise-same-subject-and-select | |
2106 gnus-score-raise-same-subject gnus-score-default | |
2107 gnus-score-raise-thread gnus-score-lower-same-subject-and-select | |
2108 gnus-score-lower-same-subject gnus-score-lower-thread | |
2109 gnus-possibly-score-headers gnus-summary-raise-score | |
2110 gnus-summary-set-score gnus-summary-current-score) | |
2111 ("gnus-score" | |
2112 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers | |
2113 gnus-current-score-file-nondirectory gnus-score-adaptive | |
2114 gnus-score-find-trace gnus-score-file-name) | |
2115 ("gnus-edit" :interactive t gnus-score-customize) | |
2116 ("gnus-topic" :interactive t gnus-topic-mode) | |
2117 ("gnus-topic" gnus-topic-remove-group) | |
2118 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode) | |
2119 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap)) | |
2120 ("gnus-uu" :interactive t | |
2121 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward | |
2122 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer | |
2123 gnus-uu-mark-by-regexp gnus-uu-mark-all | |
2124 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu | |
2125 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar | |
2126 gnus-uu-decode-unshar-and-save gnus-uu-decode-save | |
2127 gnus-uu-decode-binhex gnus-uu-decode-uu-view | |
2128 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view | |
2129 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view | |
2130 gnus-uu-decode-binhex-view) | |
2131 ("gnus-msg" (gnus-summary-send-map keymap) | |
2132 gnus-mail-yank-original gnus-mail-send-and-exit | |
2133 gnus-article-mail gnus-new-mail gnus-mail-reply | |
2134 gnus-copy-article-buffer) | |
2135 ("gnus-msg" :interactive t | |
2136 gnus-group-post-news gnus-group-mail gnus-summary-post-news | |
2137 gnus-summary-followup gnus-summary-followup-with-original | |
2138 gnus-summary-cancel-article gnus-summary-supersede-article | |
2139 gnus-post-news gnus-inews-news | |
2140 gnus-summary-reply gnus-summary-reply-with-original | |
2141 gnus-summary-mail-forward gnus-summary-mail-other-window | |
2142 gnus-bug) | |
2143 ("gnus-picon" :interactive t gnus-article-display-picons | |
2144 gnus-group-display-picons gnus-picons-article-display-x-face | |
2145 gnus-picons-display-x-face) | |
2146 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p | |
2147 gnus-grouplens-mode) | |
2148 ("smiley" :interactive t gnus-smiley-display) | |
2149 ("gnus-vm" gnus-vm-mail-setup) | |
2150 ("gnus-vm" :interactive t gnus-summary-save-in-vm | |
2151 gnus-summary-save-article-vm)))) | |
2152 | 1729 |
2153 | 1730 |
2154 | 1731 |
2155 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | 1732 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. |
2156 ;; If you want the cursor to go somewhere else, set these two | 1733 ;; If you want the cursor to go somewhere else, set these two |
2161 ;;; Various macros and substs. | 1738 ;;; Various macros and substs. |
2162 | 1739 |
2163 (defun gnus-header-from (header) | 1740 (defun gnus-header-from (header) |
2164 (mail-header-from header)) | 1741 (mail-header-from header)) |
2165 | 1742 |
2166 (defmacro gnus-eval-in-buffer-window (buffer &rest forms) | |
2167 "Pop to BUFFER, evaluate FORMS, and then return to the original window." | |
2168 (let ((tempvar (make-symbol "GnusStartBufferWindow")) | |
2169 (w (make-symbol "w")) | |
2170 (buf (make-symbol "buf"))) | |
2171 `(let* ((,tempvar (selected-window)) | |
2172 (,buf ,buffer) | |
2173 (,w (get-buffer-window ,buf 'visible))) | |
2174 (unwind-protect | |
2175 (progn | |
2176 (if ,w | |
2177 (select-window ,w) | |
2178 (pop-to-buffer ,buf)) | |
2179 ,@forms) | |
2180 (select-window ,tempvar))))) | |
2181 | |
2182 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1) | |
2183 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1) | |
2184 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body)) | |
2185 | |
2186 (defmacro gnus-gethash (string hashtable) | 1743 (defmacro gnus-gethash (string hashtable) |
2187 "Get hash value of STRING in HASHTABLE." | 1744 "Get hash value of STRING in HASHTABLE." |
2188 `(symbol-value (intern-soft ,string ,hashtable))) | 1745 `(symbol-value (intern-soft ,string ,hashtable))) |
2189 | 1746 |
2190 (defmacro gnus-sethash (string value hashtable) | 1747 (defmacro gnus-sethash (string value hashtable) |
2191 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE." | 1748 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE." |
2192 `(set (intern ,string ,hashtable) ,value)) | 1749 `(set (intern ,string ,hashtable) ,value)) |
2193 | 1750 (put 'gnus-sethash 'edebug-form-spec '(form form form)) |
2194 (defmacro gnus-intern-safe (string hashtable) | |
2195 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE." | |
2196 `(let ((symbol (intern ,string ,hashtable))) | |
2197 (or (boundp symbol) | |
2198 (set symbol nil)) | |
2199 symbol)) | |
2200 | 1751 |
2201 (defmacro gnus-group-unread (group) | 1752 (defmacro gnus-group-unread (group) |
2202 "Get the currently computed number of unread articles in GROUP." | 1753 "Get the currently computed number of unread articles in GROUP." |
2203 `(car (gnus-gethash ,group gnus-newsrc-hashtb))) | 1754 `(car (gnus-gethash ,group gnus-newsrc-hashtb))) |
2204 | 1755 |
2212 | 1763 |
2213 (defmacro gnus-set-active (group active) | 1764 (defmacro gnus-set-active (group active) |
2214 "Set GROUP's active info." | 1765 "Set GROUP's active info." |
2215 `(gnus-sethash ,group ,active gnus-active-hashtb)) | 1766 `(gnus-sethash ,group ,active gnus-active-hashtb)) |
2216 | 1767 |
2217 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp> | |
2218 ;; function `substring' might cut on a middle of multi-octet | |
2219 ;; character. | |
2220 (defun gnus-truncate-string (str width) | |
2221 (substring str 0 width)) | |
2222 | |
2223 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way | |
2224 ;; to limit the length of a string. This function is necessary since | |
2225 ;; `(substr "abc" 0 30)' pukes with "Args out of range". | |
2226 (defsubst gnus-limit-string (str width) | |
2227 (if (> (length str) width) | |
2228 (substring str 0 width) | |
2229 str)) | |
2230 | |
2231 (defsubst gnus-simplify-subject-re (subject) | |
2232 "Remove \"Re:\" from subject lines." | |
2233 (if (string-match "^[Rr][Ee]: *" subject) | |
2234 (substring subject (match-end 0)) | |
2235 subject)) | |
2236 | |
2237 (defsubst gnus-functionp (form) | |
2238 "Return non-nil if FORM is funcallable." | |
2239 (or (and (symbolp form) (fboundp form)) | |
2240 (and (listp form) (eq (car form) 'lambda)))) | |
2241 | |
2242 (defsubst gnus-goto-char (point) | |
2243 (and point (goto-char point))) | |
2244 | |
2245 (defmacro gnus-buffer-exists-p (buffer) | |
2246 `(let ((buffer ,buffer)) | |
2247 (and buffer | |
2248 (funcall (if (stringp buffer) 'get-buffer 'buffer-name) | |
2249 buffer)))) | |
2250 | |
2251 (defmacro gnus-kill-buffer (buffer) | |
2252 `(let ((buf ,buffer)) | |
2253 (if (gnus-buffer-exists-p buf) | |
2254 (kill-buffer buf)))) | |
2255 | |
2256 (defsubst gnus-point-at-bol () | |
2257 "Return point at the beginning of the line." | |
2258 (let ((p (point))) | |
2259 (beginning-of-line) | |
2260 (prog1 | |
2261 (point) | |
2262 (goto-char p)))) | |
2263 | |
2264 (defsubst gnus-point-at-eol () | |
2265 "Return point at the end of the line." | |
2266 (let ((p (point))) | |
2267 (end-of-line) | |
2268 (prog1 | |
2269 (point) | |
2270 (goto-char p)))) | |
2271 | |
2272 (defun gnus-alive-p () | 1768 (defun gnus-alive-p () |
2273 "Say whether Gnus is running or not." | 1769 "Say whether Gnus is running or not." |
2274 (and gnus-group-buffer | 1770 (and gnus-group-buffer |
2275 (get-buffer gnus-group-buffer))) | 1771 (get-buffer gnus-group-buffer) |
2276 | 1772 (save-excursion |
2277 (defun gnus-delete-first (elt list) | 1773 (set-buffer gnus-group-buffer) |
2278 "Delete by side effect the first occurrence of ELT as a member of LIST." | 1774 (eq major-mode 'gnus-group-mode)))) |
2279 (if (equal (car list) elt) | |
2280 (cdr list) | |
2281 (let ((total list)) | |
2282 (while (and (cdr list) | |
2283 (not (equal (cadr list) elt))) | |
2284 (setq list (cdr list))) | |
2285 (when (cdr list) | |
2286 (setcdr list (cddr list))) | |
2287 total))) | |
2288 | |
2289 ;; Delete the current line (and the next N lines.); | |
2290 (defmacro gnus-delete-line (&optional n) | |
2291 `(delete-region (progn (beginning-of-line) (point)) | |
2292 (progn (forward-line ,(or n 1)) (point)))) | |
2293 | |
2294 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>. | |
2295 (defvar gnus-init-inhibit nil) | |
2296 (defun gnus-read-init-file (&optional inhibit-next) | |
2297 (if gnus-init-inhibit | |
2298 (setq gnus-init-inhibit nil) | |
2299 (setq gnus-init-inhibit inhibit-next) | |
2300 (and gnus-init-file | |
2301 (or (and (file-exists-p gnus-init-file) | |
2302 ;; Don't try to load a directory. | |
2303 (not (file-directory-p gnus-init-file))) | |
2304 (file-exists-p (concat gnus-init-file ".el")) | |
2305 (file-exists-p (concat gnus-init-file ".elc"))) | |
2306 (condition-case var | |
2307 (load gnus-init-file nil t) | |
2308 (error | |
2309 (error "Error in %s: %s" gnus-init-file var)))))) | |
2310 | 1775 |
2311 ;; Info access macros. | 1776 ;; Info access macros. |
2312 | 1777 |
2313 (defmacro gnus-info-group (info) | 1778 (defmacro gnus-info-group (info) |
2314 `(nth 0 ,info)) | 1779 `(nth 0 ,info)) |
2336 `(setcar ,info ,group)) | 1801 `(setcar ,info ,group)) |
2337 (defmacro gnus-info-set-rank (info rank) | 1802 (defmacro gnus-info-set-rank (info rank) |
2338 `(setcar (nthcdr 1 ,info) ,rank)) | 1803 `(setcar (nthcdr 1 ,info) ,rank)) |
2339 (defmacro gnus-info-set-read (info read) | 1804 (defmacro gnus-info-set-read (info read) |
2340 `(setcar (nthcdr 2 ,info) ,read)) | 1805 `(setcar (nthcdr 2 ,info) ,read)) |
2341 (defmacro gnus-info-set-marks (info marks) | 1806 (defmacro gnus-info-set-marks (info marks &optional extend) |
2342 `(setcar (nthcdr 3 ,info) ,marks)) | 1807 (if extend |
2343 (defmacro gnus-info-set-method (info method) | 1808 `(gnus-info-set-entry ,info ,marks 3) |
2344 `(setcar (nthcdr 4 ,info) ,method)) | 1809 `(setcar (nthcdr 3 ,info) ,marks))) |
2345 (defmacro gnus-info-set-params (info params) | 1810 (defmacro gnus-info-set-method (info method &optional extend) |
2346 `(setcar (nthcdr 5 ,info) ,params)) | 1811 (if extend |
1812 `(gnus-info-set-entry ,info ,method 4) | |
1813 `(setcar (nthcdr 4 ,info) ,method))) | |
1814 (defmacro gnus-info-set-params (info params &optional extend) | |
1815 (if extend | |
1816 `(gnus-info-set-entry ,info ,params 5) | |
1817 `(setcar (nthcdr 5 ,info) ,params))) | |
1818 | |
1819 (defun gnus-info-set-entry (info entry number) | |
1820 ;; Extend the info until we have enough elements. | |
1821 (while (<= (length info) number) | |
1822 (nconc info (list nil))) | |
1823 ;; Set the entry. | |
1824 (setcar (nthcdr number info) entry)) | |
2347 | 1825 |
2348 (defmacro gnus-info-set-level (info level) | 1826 (defmacro gnus-info-set-level (info level) |
2349 `(let ((rank (cdr ,info))) | 1827 `(let ((rank (cdr ,info))) |
2350 (if (consp (car rank)) | 1828 (if (consp (car rank)) |
2351 (setcar (car rank) ,level) | 1829 (setcar (car rank) ,level) |
2357 (setcar rank (cons (car rank) ,score))))) | 1835 (setcar rank (cons (car rank) ,score))))) |
2358 | 1836 |
2359 (defmacro gnus-get-info (group) | 1837 (defmacro gnus-get-info (group) |
2360 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb))) | 1838 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb))) |
2361 | 1839 |
2362 (defun gnus-byte-code (func) | 1840 ;; Byte-compiler warning. |
2363 "Return a form that can be `eval'ed based on FUNC." | 1841 (defvar gnus-visual) |
2364 (let ((fval (symbol-function func))) | |
2365 (if (byte-code-function-p fval) | |
2366 (let ((flist (append fval nil))) | |
2367 (setcar flist 'byte-code) | |
2368 flist) | |
2369 (cons 'progn (cddr fval))))) | |
2370 | |
2371 ;; Find out whether the gnus-visual TYPE is wanted. | 1842 ;; Find out whether the gnus-visual TYPE is wanted. |
2372 (defun gnus-visual-p (&optional type class) | 1843 (defun gnus-visual-p (&optional type class) |
2373 (and gnus-visual ; Has to be non-nil, at least. | 1844 (and gnus-visual ; Has to be non-nil, at least. |
2374 (if (not type) ; We don't care about type. | 1845 (if (not type) ; We don't care about type. |
2375 gnus-visual | 1846 gnus-visual |
2378 (memq class gnus-visual)) | 1849 (memq class gnus-visual)) |
2379 t)))) | 1850 t)))) |
2380 | 1851 |
2381 ;;; Load the compatability functions. | 1852 ;;; Load the compatability functions. |
2382 | 1853 |
2383 (require 'gnus-cus) | |
2384 (require 'gnus-ems) | 1854 (require 'gnus-ems) |
2385 | 1855 |
2386 | 1856 |
2387 ;;; | 1857 ;;; |
2388 ;;; Shutdown | 1858 ;;; Shutdown |
2401 (while (setq entry (pop alist)) | 1871 (while (setq entry (pop alist)) |
2402 (when (memq symbol (cdr entry)) | 1872 (when (memq symbol (cdr entry)) |
2403 (funcall (car entry)))))) | 1873 (funcall (car entry)))))) |
2404 | 1874 |
2405 | 1875 |
2406 | |
2407 ;; Format specs. The chunks below are the machine-generated forms | |
2408 ;; that are to be evaled as the result of the default format strings. | |
2409 ;; We write them in here to get them byte-compiled. That way the | |
2410 ;; default actions will be quite fast, while still retaining the full | |
2411 ;; flexibility of the user-defined format specs. | |
2412 | |
2413 ;; First we have lots of dummy defvars to let the compiler know these | |
2414 ;; are really dynamic variables. | |
2415 | |
2416 (defvar gnus-tmp-unread) | |
2417 (defvar gnus-tmp-replied) | |
2418 (defvar gnus-tmp-score-char) | |
2419 (defvar gnus-tmp-indentation) | |
2420 (defvar gnus-tmp-opening-bracket) | |
2421 (defvar gnus-tmp-lines) | |
2422 (defvar gnus-tmp-name) | |
2423 (defvar gnus-tmp-closing-bracket) | |
2424 (defvar gnus-tmp-subject-or-nil) | |
2425 (defvar gnus-tmp-subject) | |
2426 (defvar gnus-tmp-marked) | |
2427 (defvar gnus-tmp-marked-mark) | |
2428 (defvar gnus-tmp-subscribed) | |
2429 (defvar gnus-tmp-process-marked) | |
2430 (defvar gnus-tmp-number-of-unread) | |
2431 (defvar gnus-tmp-group-name) | |
2432 (defvar gnus-tmp-group) | |
2433 (defvar gnus-tmp-article-number) | |
2434 (defvar gnus-tmp-unread-and-unselected) | |
2435 (defvar gnus-tmp-news-method) | |
2436 (defvar gnus-tmp-news-server) | |
2437 (defvar gnus-tmp-article-number) | |
2438 (defvar gnus-mouse-face) | |
2439 (defvar gnus-mouse-face-prop) | |
2440 | |
2441 (defun gnus-summary-line-format-spec () | |
2442 (insert gnus-tmp-unread gnus-tmp-replied | |
2443 gnus-tmp-score-char gnus-tmp-indentation) | |
2444 (gnus-put-text-property | |
2445 (point) | |
2446 (progn | |
2447 (insert | |
2448 gnus-tmp-opening-bracket | |
2449 (format "%4d: %-20s" | |
2450 gnus-tmp-lines | |
2451 (if (> (length gnus-tmp-name) 20) | |
2452 (substring gnus-tmp-name 0 20) | |
2453 gnus-tmp-name)) | |
2454 gnus-tmp-closing-bracket) | |
2455 (point)) | |
2456 gnus-mouse-face-prop gnus-mouse-face) | |
2457 (insert " " gnus-tmp-subject-or-nil "\n")) | |
2458 | |
2459 (defvar gnus-summary-line-format-spec | |
2460 (gnus-byte-code 'gnus-summary-line-format-spec)) | |
2461 | |
2462 (defun gnus-summary-dummy-line-format-spec () | |
2463 (insert "* ") | |
2464 (gnus-put-text-property | |
2465 (point) | |
2466 (progn | |
2467 (insert ": :") | |
2468 (point)) | |
2469 gnus-mouse-face-prop gnus-mouse-face) | |
2470 (insert " " gnus-tmp-subject "\n")) | |
2471 | |
2472 (defvar gnus-summary-dummy-line-format-spec | |
2473 (gnus-byte-code 'gnus-summary-dummy-line-format-spec)) | |
2474 | |
2475 (defun gnus-group-line-format-spec () | |
2476 (insert gnus-tmp-marked-mark gnus-tmp-subscribed | |
2477 gnus-tmp-process-marked | |
2478 gnus-group-indentation | |
2479 (format "%5s: " gnus-tmp-number-of-unread)) | |
2480 (gnus-put-text-property | |
2481 (point) | |
2482 (progn | |
2483 (insert gnus-tmp-group "\n") | |
2484 (1- (point))) | |
2485 gnus-mouse-face-prop gnus-mouse-face)) | |
2486 (defvar gnus-group-line-format-spec | |
2487 (gnus-byte-code 'gnus-group-line-format-spec)) | |
2488 | |
2489 (defvar gnus-format-specs | |
2490 `((version . ,emacs-version) | |
2491 (group ,gnus-group-line-format ,gnus-group-line-format-spec) | |
2492 (summary-dummy ,gnus-summary-dummy-line-format | |
2493 ,gnus-summary-dummy-line-format-spec) | |
2494 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec))) | |
2495 | |
2496 (defvar gnus-article-mode-line-format-spec nil) | |
2497 (defvar gnus-summary-mode-line-format-spec nil) | |
2498 (defvar gnus-group-mode-line-format-spec nil) | |
2499 | |
2500 ;;; Phew. All that gruft is over, fortunately. | |
2501 | |
2502 | |
2503 ;;; | 1876 ;;; |
2504 ;;; Gnus Utility Functions | 1877 ;;; Gnus Utility Functions |
2505 ;;; | 1878 ;;; |
2506 | 1879 |
2507 (defun gnus-extract-address-components (from) | |
2508 (let (name address) | |
2509 ;; First find the address - the thing with the @ in it. This may | |
2510 ;; not be accurate in mail addresses, but does the trick most of | |
2511 ;; the time in news messages. | |
2512 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from) | |
2513 (setq address (substring from (match-beginning 0) (match-end 0)))) | |
2514 ;; Then we check whether the "name <address>" format is used. | |
2515 (and address | |
2516 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp> | |
2517 ;; Linear white space is not required. | |
2518 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from) | |
2519 (and (setq name (substring from 0 (match-beginning 0))) | |
2520 ;; Strip any quotes from the name. | |
2521 (string-match "\".*\"" name) | |
2522 (setq name (substring name 1 (1- (match-end 0)))))) | |
2523 ;; If not, then "address (name)" is used. | |
2524 (or name | |
2525 (and (string-match "(.+)" from) | |
2526 (setq name (substring from (1+ (match-beginning 0)) | |
2527 (1- (match-end 0))))) | |
2528 (and (string-match "()" from) | |
2529 (setq name address)) | |
2530 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>. | |
2531 ;; XOVER might not support folded From headers. | |
2532 (and (string-match "(.*" from) | |
2533 (setq name (substring from (1+ (match-beginning 0)) | |
2534 (match-end 0))))) | |
2535 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
2536 (list (or name from) (or address from)))) | |
2537 | |
2538 (defun gnus-fetch-field (field) | |
2539 "Return the value of the header FIELD of current article." | |
2540 (save-excursion | |
2541 (save-restriction | |
2542 (let ((case-fold-search t) | |
2543 (inhibit-point-motion-hooks t)) | |
2544 (nnheader-narrow-to-headers) | |
2545 (message-fetch-field field))))) | |
2546 | |
2547 (defun gnus-goto-colon () | |
2548 (beginning-of-line) | |
2549 (search-forward ":" (gnus-point-at-eol) t)) | |
2550 | |
2551 ;;;###autoload | |
2552 (defun gnus-update-format (var) | |
2553 "Update the format specification near point." | |
2554 (interactive | |
2555 (list | |
2556 (save-excursion | |
2557 (eval-defun nil) | |
2558 ;; Find the end of the current word. | |
2559 (re-search-forward "[ \t\n]" nil t) | |
2560 ;; Search backward. | |
2561 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t) | |
2562 (match-string 1))))) | |
2563 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var) | |
2564 (match-string 1 var)))) | |
2565 (entry (assq type gnus-format-specs)) | |
2566 value spec) | |
2567 (when entry | |
2568 (setq gnus-format-specs (delq entry gnus-format-specs))) | |
2569 (set | |
2570 (intern (format "%s-spec" var)) | |
2571 (gnus-parse-format (setq value (symbol-value (intern var))) | |
2572 (symbol-value (intern (format "%s-alist" var))) | |
2573 (not (string-match "mode" var)))) | |
2574 (setq spec (symbol-value (intern (format "%s-spec" var)))) | |
2575 (push (list type value spec) gnus-format-specs) | |
2576 | |
2577 (pop-to-buffer "*Gnus Format*") | |
2578 (erase-buffer) | |
2579 (lisp-interaction-mode) | |
2580 (insert (pp-to-string spec)))) | |
2581 | |
2582 (defun gnus-update-format-specifications (&optional force) | |
2583 "Update all (necessary) format specifications." | |
2584 ;; Make the indentation array. | |
2585 (gnus-make-thread-indent-array) | |
2586 | |
2587 ;; See whether all the stored info needs to be flushed. | |
2588 (when (or force | |
2589 (not (equal emacs-version | |
2590 (cdr (assq 'version gnus-format-specs))))) | |
2591 (setq gnus-format-specs nil)) | |
2592 | |
2593 ;; Go through all the formats and see whether they need updating. | |
2594 (let ((types '(summary summary-dummy group | |
2595 summary-mode group-mode article-mode)) | |
2596 new-format entry type val) | |
2597 (while (setq type (pop types)) | |
2598 ;; Jump to the proper buffer to find out the value of | |
2599 ;; the variable, if possible. (It may be buffer-local.) | |
2600 (save-excursion | |
2601 (let ((buffer (intern (format "gnus-%s-buffer" type))) | |
2602 val) | |
2603 (when (and (boundp buffer) | |
2604 (setq val (symbol-value buffer)) | |
2605 (get-buffer val) | |
2606 (buffer-name (get-buffer val))) | |
2607 (set-buffer (get-buffer val))) | |
2608 (setq new-format (symbol-value | |
2609 (intern (format "gnus-%s-line-format" type)))))) | |
2610 (setq entry (cdr (assq type gnus-format-specs))) | |
2611 (if (and entry | |
2612 (equal (car entry) new-format)) | |
2613 ;; Use the old format. | |
2614 (set (intern (format "gnus-%s-line-format-spec" type)) | |
2615 (cadr entry)) | |
2616 ;; This is a new format. | |
2617 (setq val | |
2618 (if (not (stringp new-format)) | |
2619 ;; This is a function call or something. | |
2620 new-format | |
2621 ;; This is a "real" format. | |
2622 (gnus-parse-format | |
2623 new-format | |
2624 (symbol-value | |
2625 (intern (format "gnus-%s-line-format-alist" | |
2626 (if (eq type 'article-mode) | |
2627 'summary-mode type)))) | |
2628 (not (string-match "mode$" (symbol-name type)))))) | |
2629 ;; Enter the new format spec into the list. | |
2630 (if entry | |
2631 (progn | |
2632 (setcar (cdr entry) val) | |
2633 (setcar entry new-format)) | |
2634 (push (list type new-format val) gnus-format-specs)) | |
2635 (set (intern (format "gnus-%s-line-format-spec" type)) val)))) | |
2636 | |
2637 (unless (assq 'version gnus-format-specs) | |
2638 (push (cons 'version emacs-version) gnus-format-specs)) | |
2639 | |
2640 (gnus-update-group-mark-positions) | |
2641 (gnus-update-summary-mark-positions)) | |
2642 | |
2643 (defun gnus-update-summary-mark-positions () | |
2644 "Compute where the summary marks are to go." | |
2645 (save-excursion | |
2646 (when (and gnus-summary-buffer | |
2647 (get-buffer gnus-summary-buffer) | |
2648 (buffer-name (get-buffer gnus-summary-buffer))) | |
2649 (set-buffer gnus-summary-buffer)) | |
2650 (let ((gnus-replied-mark 129) | |
2651 (gnus-score-below-mark 130) | |
2652 (gnus-score-over-mark 130) | |
2653 (thread nil) | |
2654 (gnus-visual nil) | |
2655 (spec gnus-summary-line-format-spec) | |
2656 pos) | |
2657 (save-excursion | |
2658 (gnus-set-work-buffer) | |
2659 (let ((gnus-summary-line-format-spec spec)) | |
2660 (gnus-summary-insert-line | |
2661 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1) | |
2662 (goto-char (point-min)) | |
2663 (setq pos (list (cons 'unread (and (search-forward "\200" nil t) | |
2664 (- (point) 2))))) | |
2665 (goto-char (point-min)) | |
2666 (push (cons 'replied (and (search-forward "\201" nil t) | |
2667 (- (point) 2))) | |
2668 pos) | |
2669 (goto-char (point-min)) | |
2670 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2))) | |
2671 pos))) | |
2672 (setq gnus-summary-mark-positions pos)))) | |
2673 | |
2674 (defun gnus-update-group-mark-positions () | |
2675 (save-excursion | |
2676 (let ((gnus-process-mark 128) | |
2677 (gnus-group-marked '("dummy.group")) | |
2678 (gnus-active-hashtb (make-vector 10 0))) | |
2679 (gnus-set-active "dummy.group" '(0 . 0)) | |
2680 (gnus-set-work-buffer) | |
2681 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil) | |
2682 (goto-char (point-min)) | |
2683 (setq gnus-group-mark-positions | |
2684 (list (cons 'process (and (search-forward "\200" nil t) | |
2685 (- (point) 2)))))))) | |
2686 | |
2687 (defvar gnus-mouse-face-0 'highlight) | |
2688 (defvar gnus-mouse-face-1 'highlight) | |
2689 (defvar gnus-mouse-face-2 'highlight) | |
2690 (defvar gnus-mouse-face-3 'highlight) | |
2691 (defvar gnus-mouse-face-4 'highlight) | |
2692 | |
2693 (defun gnus-mouse-face-function (form type) | |
2694 `(gnus-put-text-property | |
2695 (point) (progn ,@form (point)) | |
2696 gnus-mouse-face-prop | |
2697 ,(if (equal type 0) | |
2698 'gnus-mouse-face | |
2699 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type))))))) | |
2700 | |
2701 (defvar gnus-face-0 'bold) | |
2702 (defvar gnus-face-1 'italic) | |
2703 (defvar gnus-face-2 'bold-italic) | |
2704 (defvar gnus-face-3 'bold) | |
2705 (defvar gnus-face-4 'bold) | |
2706 | |
2707 (defun gnus-face-face-function (form type) | |
2708 `(gnus-put-text-property | |
2709 (point) (progn ,@form (point)) | |
2710 'face ',(symbol-value (intern (format "gnus-face-%d" type))))) | |
2711 | |
2712 (defun gnus-max-width-function (el max-width) | |
2713 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width))) | |
2714 (if (symbolp el) | |
2715 `(if (> (length ,el) ,max-width) | |
2716 (substring ,el 0 ,max-width) | |
2717 ,el) | |
2718 `(let ((val (eval ,el))) | |
2719 (if (numberp val) | |
2720 (setq val (int-to-string val))) | |
2721 (if (> (length val) ,max-width) | |
2722 (substring val 0 ,max-width) | |
2723 val)))) | |
2724 | |
2725 (defun gnus-parse-format (format spec-alist &optional insert) | |
2726 ;; This function parses the FORMAT string with the help of the | |
2727 ;; SPEC-ALIST and returns a list that can be eval'ed to return the | |
2728 ;; string. If the FORMAT string contains the specifiers %( and %) | |
2729 ;; the text between them will have the mouse-face text property. | |
2730 (if (string-match | |
2731 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'" | |
2732 format) | |
2733 (gnus-parse-complex-format format spec-alist) | |
2734 ;; This is a simple format. | |
2735 (gnus-parse-simple-format format spec-alist insert))) | |
2736 | |
2737 (defun gnus-parse-complex-format (format spec-alist) | |
2738 (save-excursion | |
2739 (gnus-set-work-buffer) | |
2740 (insert format) | |
2741 (goto-char (point-min)) | |
2742 (while (re-search-forward "\"" nil t) | |
2743 (replace-match "\\\"" nil t)) | |
2744 (goto-char (point-min)) | |
2745 (insert "(\"") | |
2746 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t) | |
2747 (let ((number (if (match-beginning 1) | |
2748 (match-string 1) "0")) | |
2749 (delim (aref (match-string 2) 0))) | |
2750 (if (or (= delim ?\() (= delim ?\{)) | |
2751 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face") | |
2752 " " number " \"")) | |
2753 (replace-match "\")\"")))) | |
2754 (goto-char (point-max)) | |
2755 (insert "\")") | |
2756 (goto-char (point-min)) | |
2757 (let ((form (read (current-buffer)))) | |
2758 (cons 'progn (gnus-complex-form-to-spec form spec-alist))))) | |
2759 | |
2760 (defun gnus-complex-form-to-spec (form spec-alist) | |
2761 (delq nil | |
2762 (mapcar | |
2763 (lambda (sform) | |
2764 (if (stringp sform) | |
2765 (gnus-parse-simple-format sform spec-alist t) | |
2766 (funcall (intern (format "gnus-%s-face-function" (car sform))) | |
2767 (gnus-complex-form-to-spec (cddr sform) spec-alist) | |
2768 (nth 1 sform)))) | |
2769 form))) | |
2770 | |
2771 (defun gnus-parse-simple-format (format spec-alist &optional insert) | |
2772 ;; This function parses the FORMAT string with the help of the | |
2773 ;; SPEC-ALIST and returns a list that can be eval'ed to return a | |
2774 ;; string. | |
2775 (let ((max-width 0) | |
2776 spec flist fstring newspec elem beg result dontinsert) | |
2777 (save-excursion | |
2778 (gnus-set-work-buffer) | |
2779 (insert format) | |
2780 (goto-char (point-min)) | |
2781 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?" | |
2782 nil t) | |
2783 (if (= (setq spec (string-to-char (match-string 2))) ?%) | |
2784 (setq newspec "%" | |
2785 beg (1+ (match-beginning 0))) | |
2786 ;; First check if there are any specs that look anything like | |
2787 ;; "%12,12A", ie. with a "max width specification". These have | |
2788 ;; to be treated specially. | |
2789 (if (setq beg (match-beginning 1)) | |
2790 (setq max-width | |
2791 (string-to-int | |
2792 (buffer-substring | |
2793 (1+ (match-beginning 1)) (match-end 1)))) | |
2794 (setq max-width 0) | |
2795 (setq beg (match-beginning 2))) | |
2796 ;; Find the specification from `spec-alist'. | |
2797 (unless (setq elem (cdr (assq spec spec-alist))) | |
2798 (setq elem '("*" ?s))) | |
2799 ;; Treat user defined format specifiers specially. | |
2800 (when (eq (car elem) 'gnus-tmp-user-defined) | |
2801 (setq elem | |
2802 (list | |
2803 (list (intern (concat "gnus-user-format-function-" | |
2804 (match-string 3))) | |
2805 'gnus-tmp-header) ?s)) | |
2806 (delete-region (match-beginning 3) (match-end 3))) | |
2807 (if (not (zerop max-width)) | |
2808 (let ((el (car elem))) | |
2809 (cond ((= (cadr elem) ?c) | |
2810 (setq el (list 'char-to-string el))) | |
2811 ((= (cadr elem) ?d) | |
2812 (setq el (list 'int-to-string el)))) | |
2813 (setq flist (cons (gnus-max-width-function el max-width) | |
2814 flist)) | |
2815 (setq newspec ?s)) | |
2816 (progn | |
2817 (setq flist (cons (car elem) flist)) | |
2818 (setq newspec (cadr elem))))) | |
2819 ;; Remove the old specification (and possibly a ",12" string). | |
2820 (delete-region beg (match-end 2)) | |
2821 ;; Insert the new specification. | |
2822 (goto-char beg) | |
2823 (insert newspec)) | |
2824 (setq fstring (buffer-substring 1 (point-max)))) | |
2825 ;; Do some postprocessing to increase efficiency. | |
2826 (setq | |
2827 result | |
2828 (cond | |
2829 ;; Emptyness. | |
2830 ((string= fstring "") | |
2831 nil) | |
2832 ;; Not a format string. | |
2833 ((not (string-match "%" fstring)) | |
2834 (list fstring)) | |
2835 ;; A format string with just a single string spec. | |
2836 ((string= fstring "%s") | |
2837 (list (car flist))) | |
2838 ;; A single character. | |
2839 ((string= fstring "%c") | |
2840 (list (car flist))) | |
2841 ;; A single number. | |
2842 ((string= fstring "%d") | |
2843 (setq dontinsert) | |
2844 (if insert | |
2845 (list `(princ ,(car flist))) | |
2846 (list `(int-to-string ,(car flist))))) | |
2847 ;; Just lots of chars and strings. | |
2848 ((string-match "\\`\\(%[cs]\\)+\\'" fstring) | |
2849 (nreverse flist)) | |
2850 ;; A single string spec at the beginning of the spec. | |
2851 ((string-match "\\`%[sc][^%]+\\'" fstring) | |
2852 (list (car flist) (substring fstring 2))) | |
2853 ;; A single string spec in the middle of the spec. | |
2854 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring) | |
2855 (list (match-string 1 fstring) (car flist) (match-string 2 fstring))) | |
2856 ;; A single string spec in the end of the spec. | |
2857 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring) | |
2858 (list (match-string 1 fstring) (car flist))) | |
2859 ;; A more complex spec. | |
2860 (t | |
2861 (list (cons 'format (cons fstring (nreverse flist))))))) | |
2862 | |
2863 (if insert | |
2864 (when result | |
2865 (if dontinsert | |
2866 result | |
2867 (cons 'insert result))) | |
2868 (cond ((stringp result) | |
2869 result) | |
2870 ((consp result) | |
2871 (cons 'concat result)) | |
2872 (t ""))))) | |
2873 | |
2874 (defun gnus-eval-format (format &optional alist props) | |
2875 "Eval the format variable FORMAT, using ALIST. | |
2876 If PROPS, insert the result." | |
2877 (let ((form (gnus-parse-format format alist props))) | |
2878 (if props | |
2879 (gnus-add-text-properties (point) (progn (eval form) (point)) props) | |
2880 (eval form)))) | |
2881 | |
2882 (defun gnus-remove-text-with-property (prop) | |
2883 "Delete all text in the current buffer with text property PROP." | |
2884 (save-excursion | |
2885 (goto-char (point-min)) | |
2886 (while (not (eobp)) | |
2887 (while (get-text-property (point) prop) | |
2888 (delete-char 1)) | |
2889 (goto-char (next-single-property-change (point) prop nil (point-max)))))) | |
2890 | |
2891 (defun gnus-set-work-buffer () | |
2892 (if (get-buffer gnus-work-buffer) | |
2893 (progn | |
2894 (set-buffer gnus-work-buffer) | |
2895 (erase-buffer)) | |
2896 (set-buffer (get-buffer-create gnus-work-buffer)) | |
2897 (kill-all-local-variables) | |
2898 (buffer-disable-undo (current-buffer)) | |
2899 (gnus-add-current-to-buffer-list))) | |
2900 | |
2901 ;; Article file names when saving. | |
2902 | |
2903 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file) | |
2904 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
2905 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num. | |
2906 Otherwise, it is like ~/News/news/group/num." | |
2907 (let ((default | |
2908 (expand-file-name | |
2909 (concat (if (gnus-use-long-file-name 'not-save) | |
2910 (gnus-capitalize-newsgroup newsgroup) | |
2911 (gnus-newsgroup-directory-form newsgroup)) | |
2912 "/" (int-to-string (mail-header-number headers))) | |
2913 gnus-article-save-directory))) | |
2914 (if (and last-file | |
2915 (string-equal (file-name-directory default) | |
2916 (file-name-directory last-file)) | |
2917 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
2918 default | |
2919 (or last-file default)))) | |
2920 | |
2921 (defun gnus-numeric-save-name (newsgroup headers &optional last-file) | |
2922 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
2923 If variable `gnus-use-long-file-name' is non-nil, it is | |
2924 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num." | |
2925 (let ((default | |
2926 (expand-file-name | |
2927 (concat (if (gnus-use-long-file-name 'not-save) | |
2928 newsgroup | |
2929 (gnus-newsgroup-directory-form newsgroup)) | |
2930 "/" (int-to-string (mail-header-number headers))) | |
2931 gnus-article-save-directory))) | |
2932 (if (and last-file | |
2933 (string-equal (file-name-directory default) | |
2934 (file-name-directory last-file)) | |
2935 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
2936 default | |
2937 (or last-file default)))) | |
2938 | |
2939 (defun gnus-Plain-save-name (newsgroup headers &optional last-file) | |
2940 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
2941 If variable `gnus-use-long-file-name' is non-nil, it is | |
2942 ~/News/News.group. Otherwise, it is like ~/News/news/group/news." | |
2943 (or last-file | |
2944 (expand-file-name | |
2945 (if (gnus-use-long-file-name 'not-save) | |
2946 (gnus-capitalize-newsgroup newsgroup) | |
2947 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | |
2948 gnus-article-save-directory))) | |
2949 | |
2950 (defun gnus-plain-save-name (newsgroup headers &optional last-file) | |
2951 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
2952 If variable `gnus-use-long-file-name' is non-nil, it is | |
2953 ~/News/news.group. Otherwise, it is like ~/News/news/group/news." | |
2954 (or last-file | |
2955 (expand-file-name | |
2956 (if (gnus-use-long-file-name 'not-save) | |
2957 newsgroup | |
2958 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | |
2959 gnus-article-save-directory))) | |
2960 | |
2961 ;; For subscribing new newsgroup | |
2962 | |
2963 (defun gnus-subscribe-hierarchical-interactive (groups) | |
2964 (let ((groups (sort groups 'string<)) | |
2965 prefixes prefix start ans group starts) | |
2966 (while groups | |
2967 (setq prefixes (list "^")) | |
2968 (while (and groups prefixes) | |
2969 (while (not (string-match (car prefixes) (car groups))) | |
2970 (setq prefixes (cdr prefixes))) | |
2971 (setq prefix (car prefixes)) | |
2972 (setq start (1- (length prefix))) | |
2973 (if (and (string-match "[^\\.]\\." (car groups) start) | |
2974 (cdr groups) | |
2975 (setq prefix | |
2976 (concat "^" (substring (car groups) 0 (match-end 0)))) | |
2977 (string-match prefix (cadr groups))) | |
2978 (progn | |
2979 (setq prefixes (cons prefix prefixes)) | |
2980 (message "Descend hierarchy %s? ([y]nsq): " | |
2981 (substring prefix 1 (1- (length prefix)))) | |
2982 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q))) | |
2983 (ding) | |
2984 (message "Descend hierarchy %s? ([y]nsq): " | |
2985 (substring prefix 1 (1- (length prefix))))) | |
2986 (cond ((= ans ?n) | |
2987 (while (and groups | |
2988 (string-match prefix | |
2989 (setq group (car groups)))) | |
2990 (setq gnus-killed-list | |
2991 (cons group gnus-killed-list)) | |
2992 (gnus-sethash group group gnus-killed-hashtb) | |
2993 (setq groups (cdr groups))) | |
2994 (setq starts (cdr starts))) | |
2995 ((= ans ?s) | |
2996 (while (and groups | |
2997 (string-match prefix | |
2998 (setq group (car groups)))) | |
2999 (gnus-sethash group group gnus-killed-hashtb) | |
3000 (gnus-subscribe-alphabetically (car groups)) | |
3001 (setq groups (cdr groups))) | |
3002 (setq starts (cdr starts))) | |
3003 ((= ans ?q) | |
3004 (while groups | |
3005 (setq group (car groups)) | |
3006 (setq gnus-killed-list (cons group gnus-killed-list)) | |
3007 (gnus-sethash group group gnus-killed-hashtb) | |
3008 (setq groups (cdr groups)))) | |
3009 (t nil))) | |
3010 (message "Subscribe %s? ([n]yq)" (car groups)) | |
3011 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n))) | |
3012 (ding) | |
3013 (message "Subscribe %s? ([n]yq)" (car groups))) | |
3014 (setq group (car groups)) | |
3015 (cond ((= ans ?y) | |
3016 (gnus-subscribe-alphabetically (car groups)) | |
3017 (gnus-sethash group group gnus-killed-hashtb)) | |
3018 ((= ans ?q) | |
3019 (while groups | |
3020 (setq group (car groups)) | |
3021 (setq gnus-killed-list (cons group gnus-killed-list)) | |
3022 (gnus-sethash group group gnus-killed-hashtb) | |
3023 (setq groups (cdr groups)))) | |
3024 (t | |
3025 (setq gnus-killed-list (cons group gnus-killed-list)) | |
3026 (gnus-sethash group group gnus-killed-hashtb))) | |
3027 (setq groups (cdr groups))))))) | |
3028 | |
3029 (defun gnus-subscribe-randomly (newsgroup) | |
3030 "Subscribe new NEWSGROUP by making it the first newsgroup." | |
3031 (gnus-subscribe-newsgroup newsgroup)) | |
3032 | |
3033 (defun gnus-subscribe-alphabetically (newgroup) | |
3034 "Subscribe new NEWSGROUP and insert it in alphabetical order." | |
3035 (let ((groups (cdr gnus-newsrc-alist)) | |
3036 before) | |
3037 (while (and (not before) groups) | |
3038 (if (string< newgroup (caar groups)) | |
3039 (setq before (caar groups)) | |
3040 (setq groups (cdr groups)))) | |
3041 (gnus-subscribe-newsgroup newgroup before))) | |
3042 | |
3043 (defun gnus-subscribe-hierarchically (newgroup) | |
3044 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order." | |
3045 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams) | |
3046 (save-excursion | |
3047 (set-buffer (find-file-noselect gnus-current-startup-file)) | |
3048 (let ((groupkey newgroup) | |
3049 before) | |
3050 (while (and (not before) groupkey) | |
3051 (goto-char (point-min)) | |
3052 (let ((groupkey-re | |
3053 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]"))) | |
3054 (while (and (re-search-forward groupkey-re nil t) | |
3055 (progn | |
3056 (setq before (match-string 1)) | |
3057 (string< before newgroup))))) | |
3058 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b) | |
3059 (setq groupkey | |
3060 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey) | |
3061 (substring groupkey (match-beginning 1) (match-end 1))))) | |
3062 (gnus-subscribe-newsgroup newgroup before)) | |
3063 (kill-buffer (current-buffer)))) | |
3064 | |
3065 (defun gnus-subscribe-interactively (group) | |
3066 "Subscribe the new GROUP interactively. | |
3067 It is inserted in hierarchical newsgroup order if subscribed. If not, | |
3068 it is killed." | |
3069 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group)) | |
3070 (gnus-subscribe-hierarchically group) | |
3071 (push group gnus-killed-list))) | |
3072 | |
3073 (defun gnus-subscribe-zombies (group) | |
3074 "Make the new GROUP into a zombie group." | |
3075 (push group gnus-zombie-list)) | |
3076 | |
3077 (defun gnus-subscribe-killed (group) | |
3078 "Make the new GROUP a killed group." | |
3079 (push group gnus-killed-list)) | |
3080 | |
3081 (defun gnus-subscribe-newsgroup (newsgroup &optional next) | |
3082 "Subscribe new NEWSGROUP. | |
3083 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made | |
3084 the first newsgroup." | |
3085 (save-excursion | |
3086 (goto-char (point-min)) | |
3087 ;; We subscribe the group by changing its level to `subscribed'. | |
3088 (gnus-group-change-level | |
3089 newsgroup gnus-level-default-subscribed | |
3090 gnus-level-killed (gnus-gethash (or next "dummy.group") | |
3091 gnus-newsrc-hashtb)) | |
3092 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))) | |
3093 | |
3094 ;; For directories | |
3095 | |
3096 (defun gnus-newsgroup-directory-form (newsgroup) | |
3097 "Make hierarchical directory name from NEWSGROUP name." | |
3098 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup)) | |
3099 (len (length newsgroup)) | |
3100 idx) | |
3101 ;; If this is a foreign group, we don't want to translate the | |
3102 ;; entire name. | |
3103 (if (setq idx (string-match ":" newsgroup)) | |
3104 (aset newsgroup idx ?/) | |
3105 (setq idx 0)) | |
3106 ;; Replace all occurrences of `.' with `/'. | |
3107 (while (< idx len) | |
3108 (if (= (aref newsgroup idx) ?.) | |
3109 (aset newsgroup idx ?/)) | |
3110 (setq idx (1+ idx))) | |
3111 newsgroup)) | |
3112 | |
3113 (defun gnus-newsgroup-savable-name (group) | |
3114 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group) | |
3115 ;; with dots. | |
3116 (nnheader-replace-chars-in-string group ?/ ?.)) | |
3117 | |
3118 (defun gnus-make-directory (dir) | |
3119 "Make DIRECTORY recursively." | |
3120 (unless dir | |
3121 (error "No directory to make")) | |
3122 ;; Why don't we use `(make-directory dir 'parents)'? That's just one | |
3123 ;; of the many mysteries of the universe. | |
3124 (let* ((dir (expand-file-name dir default-directory)) | |
3125 dirs err) | |
3126 (if (string-match "/$" dir) | |
3127 (setq dir (substring dir 0 (match-beginning 0)))) | |
3128 ;; First go down the path until we find a directory that exists. | |
3129 (while (not (file-exists-p dir)) | |
3130 (setq dirs (cons dir dirs)) | |
3131 (string-match "/[^/]+$" dir) | |
3132 (setq dir (substring dir 0 (match-beginning 0)))) | |
3133 ;; Then create all the subdirs. | |
3134 (while (and dirs (not err)) | |
3135 (condition-case () | |
3136 (make-directory (car dirs)) | |
3137 (error (setq err t))) | |
3138 (setq dirs (cdr dirs))) | |
3139 ;; We return whether we were successful or not. | |
3140 (not dirs))) | |
3141 | |
3142 (defun gnus-capitalize-newsgroup (newsgroup) | |
3143 "Capitalize NEWSGROUP name." | |
3144 (and (not (zerop (length newsgroup))) | |
3145 (concat (char-to-string (upcase (aref newsgroup 0))) | |
3146 (substring newsgroup 1)))) | |
3147 | |
3148 ;; Various... things. | |
3149 | |
3150 (defun gnus-simplify-subject (subject &optional re-only) | |
3151 "Remove `Re:' and words in parentheses. | |
3152 If RE-ONLY is non-nil, strip leading `Re:'s only." | |
3153 (let ((case-fold-search t)) ;Ignore case. | |
3154 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'. | |
3155 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject) | |
3156 (setq subject (substring subject (match-end 0)))) | |
3157 ;; Remove uninteresting prefixes. | |
3158 (if (and (not re-only) | |
3159 gnus-simplify-ignored-prefixes | |
3160 (string-match gnus-simplify-ignored-prefixes subject)) | |
3161 (setq subject (substring subject (match-end 0)))) | |
3162 ;; Remove words in parentheses from end. | |
3163 (unless re-only | |
3164 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject) | |
3165 (setq subject (substring subject 0 (match-beginning 0))))) | |
3166 ;; Return subject string. | |
3167 subject)) | |
3168 | |
3169 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify | |
3170 ;; all whitespace. | |
3171 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>. | |
3172 (defun gnus-simplify-buffer-fuzzy () | |
3173 (let ((case-fold-search t)) | |
3174 (goto-char (point-min)) | |
3175 (while (search-forward "\t" nil t) | |
3176 (replace-match " " t t)) | |
3177 (goto-char (point-min)) | |
3178 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t) | |
3179 (goto-char (match-beginning 0)) | |
3180 (while (or | |
3181 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *") | |
3182 (looking-at "^[[].*: .*[]]$")) | |
3183 (goto-char (point-min)) | |
3184 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" | |
3185 nil t) | |
3186 (replace-match "" t t)) | |
3187 (goto-char (point-min)) | |
3188 (while (re-search-forward "^[[].*: .*[]]$" nil t) | |
3189 (goto-char (match-end 0)) | |
3190 (delete-char -1) | |
3191 (delete-region | |
3192 (progn (goto-char (match-beginning 0))) | |
3193 (re-search-forward ":")))) | |
3194 (goto-char (point-min)) | |
3195 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t) | |
3196 (replace-match "" t t)) | |
3197 (goto-char (point-min)) | |
3198 (while (re-search-forward " +" nil t) | |
3199 (replace-match " " t t)) | |
3200 (goto-char (point-min)) | |
3201 (while (re-search-forward " $" nil t) | |
3202 (replace-match "" t t)) | |
3203 (goto-char (point-min)) | |
3204 (while (re-search-forward "^ +" nil t) | |
3205 (replace-match "" t t)) | |
3206 (goto-char (point-min)) | |
3207 (when gnus-simplify-subject-fuzzy-regexp | |
3208 (if (listp gnus-simplify-subject-fuzzy-regexp) | |
3209 (let ((list gnus-simplify-subject-fuzzy-regexp)) | |
3210 (while list | |
3211 (goto-char (point-min)) | |
3212 (while (re-search-forward (car list) nil t) | |
3213 (replace-match "" t t)) | |
3214 (setq list (cdr list)))) | |
3215 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t) | |
3216 (replace-match "" t t)))))) | |
3217 | |
3218 (defun gnus-simplify-subject-fuzzy (subject) | |
3219 "Siplify a subject string fuzzily." | |
3220 (save-excursion | |
3221 (gnus-set-work-buffer) | |
3222 (let ((case-fold-search t)) | |
3223 (insert subject) | |
3224 (inline (gnus-simplify-buffer-fuzzy)) | |
3225 (buffer-string)))) | |
3226 | |
3227 ;; Add the current buffer to the list of buffers to be killed on exit. | 1880 ;; Add the current buffer to the list of buffers to be killed on exit. |
3228 (defun gnus-add-current-to-buffer-list () | 1881 (defun gnus-add-current-to-buffer-list () |
3229 (or (memq (current-buffer) gnus-buffer-list) | 1882 (or (memq (current-buffer) gnus-buffer-list) |
3230 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))) | 1883 (push (current-buffer) gnus-buffer-list))) |
3231 | |
3232 (defun gnus-string> (s1 s2) | |
3233 (not (or (string< s1 s2) | |
3234 (string= s1 s2)))) | |
3235 | |
3236 (defun gnus-read-active-file-p () | |
3237 "Say whether the active file has been read from `gnus-select-method'." | |
3238 (memq gnus-select-method gnus-have-read-active-file)) | |
3239 | |
3240 ;;; General various misc type functions. | |
3241 | |
3242 (defun gnus-clear-system () | |
3243 "Clear all variables and buffers." | |
3244 ;; Clear Gnus variables. | |
3245 (let ((variables gnus-variable-list)) | |
3246 (while variables | |
3247 (set (car variables) nil) | |
3248 (setq variables (cdr variables)))) | |
3249 ;; Clear other internal variables. | |
3250 (setq gnus-list-of-killed-groups nil | |
3251 gnus-have-read-active-file nil | |
3252 gnus-newsrc-alist nil | |
3253 gnus-newsrc-hashtb nil | |
3254 gnus-killed-list nil | |
3255 gnus-zombie-list nil | |
3256 gnus-killed-hashtb nil | |
3257 gnus-active-hashtb nil | |
3258 gnus-moderated-list nil | |
3259 gnus-description-hashtb nil | |
3260 gnus-current-headers nil | |
3261 gnus-thread-indent-array nil | |
3262 gnus-newsgroup-headers nil | |
3263 gnus-newsgroup-name nil | |
3264 gnus-server-alist nil | |
3265 gnus-group-list-mode nil | |
3266 gnus-opened-servers nil | |
3267 gnus-group-mark-positions nil | |
3268 gnus-newsgroup-data nil | |
3269 gnus-newsgroup-unreads nil | |
3270 nnoo-state-alist nil | |
3271 gnus-current-select-method nil) | |
3272 (gnus-shutdown 'gnus) | |
3273 ;; Kill the startup file. | |
3274 (and gnus-current-startup-file | |
3275 (get-file-buffer gnus-current-startup-file) | |
3276 (kill-buffer (get-file-buffer gnus-current-startup-file))) | |
3277 ;; Clear the dribble buffer. | |
3278 (gnus-dribble-clear) | |
3279 ;; Kill global KILL file buffer. | |
3280 (when (get-file-buffer (gnus-newsgroup-kill-file nil)) | |
3281 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil)))) | |
3282 (gnus-kill-buffer nntp-server-buffer) | |
3283 ;; Kill Gnus buffers. | |
3284 (while gnus-buffer-list | |
3285 (gnus-kill-buffer (pop gnus-buffer-list))) | |
3286 ;; Remove Gnus frames. | |
3287 (gnus-kill-gnus-frames)) | |
3288 | |
3289 (defun gnus-kill-gnus-frames () | |
3290 "Kill all frames Gnus has created." | |
3291 (while gnus-created-frames | |
3292 (when (frame-live-p (car gnus-created-frames)) | |
3293 ;; We slap a condition-case around this `delete-frame' to ensure | |
3294 ;; against errors if we try do delete the single frame that's left. | |
3295 (condition-case () | |
3296 (delete-frame (car gnus-created-frames)) | |
3297 (error nil))) | |
3298 (pop gnus-created-frames))) | |
3299 | |
3300 (defun gnus-windows-old-to-new (setting) | |
3301 ;; First we take care of the really, really old Gnus 3 actions. | |
3302 (when (symbolp setting) | |
3303 (setq setting | |
3304 ;; Take care of ooold GNUS 3.x values. | |
3305 (cond ((eq setting 'SelectArticle) 'article) | |
3306 ((memq setting '(SelectSubject ExpandSubject)) 'summary) | |
3307 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group) | |
3308 (t setting)))) | |
3309 (if (or (listp setting) | |
3310 (not (and gnus-window-configuration | |
3311 (memq setting '(group summary article))))) | |
3312 setting | |
3313 (let* ((setting (if (eq setting 'group) | |
3314 (if (assq 'newsgroup gnus-window-configuration) | |
3315 'newsgroup | |
3316 'newsgroups) setting)) | |
3317 (elem (cadr (assq setting gnus-window-configuration))) | |
3318 (total (apply '+ elem)) | |
3319 (types '(group summary article)) | |
3320 (pbuf (if (eq setting 'newsgroups) 'group 'summary)) | |
3321 (i 0) | |
3322 perc | |
3323 out) | |
3324 (while (< i 3) | |
3325 (or (not (numberp (nth i elem))) | |
3326 (zerop (nth i elem)) | |
3327 (progn | |
3328 (setq perc (if (= i 2) | |
3329 1.0 | |
3330 (/ (float (nth 0 elem)) total))) | |
3331 (setq out (cons (if (eq pbuf (nth i types)) | |
3332 (list (nth i types) perc 'point) | |
3333 (list (nth i types) perc)) | |
3334 out)))) | |
3335 (setq i (1+ i))) | |
3336 `(vertical 1.0 ,@(nreverse out))))) | |
3337 | |
3338 ;;;###autoload | |
3339 (defun gnus-add-configuration (conf) | |
3340 "Add the window configuration CONF to `gnus-buffer-configuration'." | |
3341 (setq gnus-buffer-configuration | |
3342 (cons conf (delq (assq (car conf) gnus-buffer-configuration) | |
3343 gnus-buffer-configuration)))) | |
3344 | |
3345 (defvar gnus-frame-list nil) | |
3346 | |
3347 (defun gnus-configure-frame (split &optional window) | |
3348 "Split WINDOW according to SPLIT." | |
3349 (unless window | |
3350 (setq window (get-buffer-window (current-buffer)))) | |
3351 (select-window window) | |
3352 ;; This might be an old-stylee buffer config. | |
3353 (when (vectorp split) | |
3354 (setq split (append split nil))) | |
3355 (when (or (consp (car split)) | |
3356 (vectorp (car split))) | |
3357 (push 1.0 split) | |
3358 (push 'vertical split)) | |
3359 ;; The SPLIT might be something that is to be evaled to | |
3360 ;; return a new SPLIT. | |
3361 (while (and (not (assq (car split) gnus-window-to-buffer)) | |
3362 (gnus-functionp (car split))) | |
3363 (setq split (eval split))) | |
3364 (let* ((type (car split)) | |
3365 (subs (cddr split)) | |
3366 (len (if (eq type 'horizontal) (window-width) (window-height))) | |
3367 (total 0) | |
3368 (window-min-width (or gnus-window-min-width window-min-width)) | |
3369 (window-min-height (or gnus-window-min-height window-min-height)) | |
3370 s result new-win rest comp-subs size sub) | |
3371 (cond | |
3372 ;; Nothing to do here. | |
3373 ((null split)) | |
3374 ;; Don't switch buffers. | |
3375 ((null type) | |
3376 (and (memq 'point split) window)) | |
3377 ;; This is a buffer to be selected. | |
3378 ((not (memq type '(frame horizontal vertical))) | |
3379 (let ((buffer (cond ((stringp type) type) | |
3380 (t (cdr (assq type gnus-window-to-buffer))))) | |
3381 buf) | |
3382 (unless buffer | |
3383 (error "Illegal buffer type: %s" type)) | |
3384 (unless (setq buf (get-buffer (if (symbolp buffer) | |
3385 (symbol-value buffer) buffer))) | |
3386 (setq buf (get-buffer-create (if (symbolp buffer) | |
3387 (symbol-value buffer) buffer)))) | |
3388 (switch-to-buffer buf) | |
3389 ;; We return the window if it has the `point' spec. | |
3390 (and (memq 'point split) window))) | |
3391 ;; This is a frame split. | |
3392 ((eq type 'frame) | |
3393 (unless gnus-frame-list | |
3394 (setq gnus-frame-list (list (window-frame | |
3395 (get-buffer-window (current-buffer)))))) | |
3396 (let ((i 0) | |
3397 params frame fresult) | |
3398 (while (< i (length subs)) | |
3399 ;; Frame parameter is gotten from the sub-split. | |
3400 (setq params (cadr (elt subs i))) | |
3401 ;; It should be a list. | |
3402 (unless (listp params) | |
3403 (setq params nil)) | |
3404 ;; Create a new frame? | |
3405 (unless (setq frame (elt gnus-frame-list i)) | |
3406 (nconc gnus-frame-list (list (setq frame (make-frame params)))) | |
3407 (push frame gnus-created-frames)) | |
3408 ;; Is the old frame still alive? | |
3409 (unless (frame-live-p frame) | |
3410 (setcar (nthcdr i gnus-frame-list) | |
3411 (setq frame (make-frame params)))) | |
3412 ;; Select the frame in question and do more splits there. | |
3413 (select-frame frame) | |
3414 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult)) | |
3415 (incf i)) | |
3416 ;; Select the frame that has the selected buffer. | |
3417 (when fresult | |
3418 (select-frame (window-frame fresult))))) | |
3419 ;; This is a normal split. | |
3420 (t | |
3421 (when (> (length subs) 0) | |
3422 ;; First we have to compute the sizes of all new windows. | |
3423 (while subs | |
3424 (setq sub (append (pop subs) nil)) | |
3425 (while (and (not (assq (car sub) gnus-window-to-buffer)) | |
3426 (gnus-functionp (car sub))) | |
3427 (setq sub (eval sub))) | |
3428 (when sub | |
3429 (push sub comp-subs) | |
3430 (setq size (cadar comp-subs)) | |
3431 (cond ((equal size 1.0) | |
3432 (setq rest (car comp-subs)) | |
3433 (setq s 0)) | |
3434 ((floatp size) | |
3435 (setq s (floor (* size len)))) | |
3436 ((integerp size) | |
3437 (setq s size)) | |
3438 (t | |
3439 (error "Illegal size: %s" size))) | |
3440 ;; Try to make sure that we are inside the safe limits. | |
3441 (cond ((zerop s)) | |
3442 ((eq type 'horizontal) | |
3443 (setq s (max s window-min-width))) | |
3444 ((eq type 'vertical) | |
3445 (setq s (max s window-min-height)))) | |
3446 (setcar (cdar comp-subs) s) | |
3447 (incf total s))) | |
3448 ;; Take care of the "1.0" spec. | |
3449 (if rest | |
3450 (setcar (cdr rest) (- len total)) | |
3451 (error "No 1.0 specs in %s" split)) | |
3452 ;; The we do the actual splitting in a nice recursive | |
3453 ;; fashion. | |
3454 (setq comp-subs (nreverse comp-subs)) | |
3455 (while comp-subs | |
3456 (if (null (cdr comp-subs)) | |
3457 (setq new-win window) | |
3458 (setq new-win | |
3459 (split-window window (cadar comp-subs) | |
3460 (eq type 'horizontal)))) | |
3461 (setq result (or (gnus-configure-frame | |
3462 (car comp-subs) window) result)) | |
3463 (select-window new-win) | |
3464 (setq window new-win) | |
3465 (setq comp-subs (cdr comp-subs)))) | |
3466 ;; Return the proper window, if any. | |
3467 (when result | |
3468 (select-window result)))))) | |
3469 | |
3470 (defvar gnus-frame-split-p nil) | |
3471 | |
3472 (defun gnus-configure-windows (setting &optional force) | |
3473 (setq setting (gnus-windows-old-to-new setting)) | |
3474 (let ((split (if (symbolp setting) | |
3475 (cadr (assq setting gnus-buffer-configuration)) | |
3476 setting)) | |
3477 all-visible) | |
3478 | |
3479 (setq gnus-frame-split-p nil) | |
3480 | |
3481 (unless split | |
3482 (error "No such setting: %s" setting)) | |
3483 | |
3484 (if (and (setq all-visible (gnus-all-windows-visible-p split)) | |
3485 (not force)) | |
3486 ;; All the windows mentioned are already visible, so we just | |
3487 ;; put point in the assigned buffer, and do not touch the | |
3488 ;; winconf. | |
3489 (select-window all-visible) | |
3490 | |
3491 ;; Either remove all windows or just remove all Gnus windows. | |
3492 (let ((frame (selected-frame))) | |
3493 (unwind-protect | |
3494 (if gnus-use-full-window | |
3495 ;; We want to remove all other windows. | |
3496 (if (not gnus-frame-split-p) | |
3497 ;; This is not a `frame' split, so we ignore the | |
3498 ;; other frames. | |
3499 (delete-other-windows) | |
3500 ;; This is a `frame' split, so we delete all windows | |
3501 ;; on all frames. | |
3502 (mapcar | |
3503 (lambda (frame) | |
3504 (unless (eq (cdr (assq 'minibuffer | |
3505 (frame-parameters frame))) | |
3506 'only) | |
3507 (select-frame frame) | |
3508 (delete-other-windows))) | |
3509 (frame-list))) | |
3510 ;; Just remove some windows. | |
3511 (gnus-remove-some-windows) | |
3512 (switch-to-buffer nntp-server-buffer)) | |
3513 (select-frame frame))) | |
3514 | |
3515 (switch-to-buffer nntp-server-buffer) | |
3516 (gnus-configure-frame split (get-buffer-window (current-buffer)))))) | |
3517 | |
3518 (defun gnus-all-windows-visible-p (split) | |
3519 "Say whether all buffers in SPLIT are currently visible. | |
3520 In particular, the value returned will be the window that | |
3521 should have point." | |
3522 (let ((stack (list split)) | |
3523 (all-visible t) | |
3524 type buffer win buf) | |
3525 (while (and (setq split (pop stack)) | |
3526 all-visible) | |
3527 ;; Be backwards compatible. | |
3528 (when (vectorp split) | |
3529 (setq split (append split nil))) | |
3530 (when (or (consp (car split)) | |
3531 (vectorp (car split))) | |
3532 (push 1.0 split) | |
3533 (push 'vertical split)) | |
3534 ;; The SPLIT might be something that is to be evaled to | |
3535 ;; return a new SPLIT. | |
3536 (while (and (not (assq (car split) gnus-window-to-buffer)) | |
3537 (gnus-functionp (car split))) | |
3538 (setq split (eval split))) | |
3539 | |
3540 (setq type (elt split 0)) | |
3541 (cond | |
3542 ;; Nothing here. | |
3543 ((null split) t) | |
3544 ;; A buffer. | |
3545 ((not (memq type '(horizontal vertical frame))) | |
3546 (setq buffer (cond ((stringp type) type) | |
3547 (t (cdr (assq type gnus-window-to-buffer))))) | |
3548 (unless buffer | |
3549 (error "Illegal buffer type: %s" type)) | |
3550 (when (setq buf (get-buffer (if (symbolp buffer) | |
3551 (symbol-value buffer) | |
3552 buffer))) | |
3553 (setq win (get-buffer-window buf t))) | |
3554 (if win | |
3555 (when (memq 'point split) | |
3556 (setq all-visible win)) | |
3557 (setq all-visible nil))) | |
3558 (t | |
3559 (when (eq type 'frame) | |
3560 (setq gnus-frame-split-p t)) | |
3561 (setq stack (append (cddr split) stack))))) | |
3562 (unless (eq all-visible t) | |
3563 all-visible))) | |
3564 | |
3565 (defun gnus-window-top-edge (&optional window) | |
3566 (nth 1 (window-edges window))) | |
3567 | |
3568 (defun gnus-remove-some-windows () | |
3569 (let ((buffers gnus-window-to-buffer) | |
3570 buf bufs lowest-buf lowest) | |
3571 (save-excursion | |
3572 ;; Remove windows on all known Gnus buffers. | |
3573 (while buffers | |
3574 (setq buf (cdar buffers)) | |
3575 (if (symbolp buf) | |
3576 (setq buf (and (boundp buf) (symbol-value buf)))) | |
3577 (and buf | |
3578 (get-buffer-window buf) | |
3579 (progn | |
3580 (setq bufs (cons buf bufs)) | |
3581 (pop-to-buffer buf) | |
3582 (if (or (not lowest) | |
3583 (< (gnus-window-top-edge) lowest)) | |
3584 (progn | |
3585 (setq lowest (gnus-window-top-edge)) | |
3586 (setq lowest-buf buf))))) | |
3587 (setq buffers (cdr buffers))) | |
3588 ;; Remove windows on *all* summary buffers. | |
3589 (walk-windows | |
3590 (lambda (win) | |
3591 (let ((buf (window-buffer win))) | |
3592 (if (string-match "^\\*Summary" (buffer-name buf)) | |
3593 (progn | |
3594 (setq bufs (cons buf bufs)) | |
3595 (pop-to-buffer buf) | |
3596 (if (or (not lowest) | |
3597 (< (gnus-window-top-edge) lowest)) | |
3598 (progn | |
3599 (setq lowest-buf buf) | |
3600 (setq lowest (gnus-window-top-edge))))))))) | |
3601 (and lowest-buf | |
3602 (progn | |
3603 (pop-to-buffer lowest-buf) | |
3604 (switch-to-buffer nntp-server-buffer))) | |
3605 (while bufs | |
3606 (and (not (eq (car bufs) lowest-buf)) | |
3607 (delete-windows-on (car bufs))) | |
3608 (setq bufs (cdr bufs)))))) | |
3609 | 1884 |
3610 (defun gnus-version (&optional arg) | 1885 (defun gnus-version (&optional arg) |
3611 "Version number of this version of Gnus. | 1886 "Version number of this version of Gnus. |
3612 If ARG, insert string at point." | 1887 If ARG, insert string at point." |
3613 (interactive "P") | 1888 (interactive "P") |
3625 (setq mess (concat mess "; " (symbol-value meth)))) | 1900 (setq mess (concat mess "; " (symbol-value meth)))) |
3626 (setq methods (cdr methods))) | 1901 (setq methods (cdr methods))) |
3627 (if arg | 1902 (if arg |
3628 (insert (message mess)) | 1903 (insert (message mess)) |
3629 (message mess)))) | 1904 (message mess)))) |
3630 | |
3631 (defun gnus-info-find-node () | |
3632 "Find Info documentation of Gnus." | |
3633 (interactive) | |
3634 ;; Enlarge info window if needed. | |
3635 (let ((mode major-mode) | |
3636 gnus-info-buffer) | |
3637 (Info-goto-node (cadr (assq mode gnus-info-nodes))) | |
3638 (setq gnus-info-buffer (current-buffer)) | |
3639 (gnus-configure-windows 'info))) | |
3640 | |
3641 (defun gnus-days-between (date1 date2) | |
3642 ;; Return the number of days between date1 and date2. | |
3643 (- (gnus-day-number date1) (gnus-day-number date2))) | |
3644 | |
3645 (defun gnus-day-number (date) | |
3646 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) ) | |
3647 (timezone-parse-date date)))) | |
3648 (timezone-absolute-from-gregorian | |
3649 (nth 1 dat) (nth 2 dat) (car dat)))) | |
3650 | |
3651 (defun gnus-encode-date (date) | |
3652 "Convert DATE to internal time." | |
3653 (let* ((parse (timezone-parse-date date)) | |
3654 (date (mapcar (lambda (d) (and d (string-to-int d))) parse)) | |
3655 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3))))) | |
3656 (encode-time (caddr time) (cadr time) (car time) | |
3657 (caddr date) (cadr date) (car date) (nth 4 date)))) | |
3658 | |
3659 (defun gnus-time-minus (t1 t2) | |
3660 "Subtract two internal times." | |
3661 (let ((borrow (< (cadr t1) (cadr t2)))) | |
3662 (list (- (car t1) (car t2) (if borrow 1 0)) | |
3663 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2))))) | |
3664 | |
3665 (defun gnus-file-newer-than (file date) | |
3666 (let ((fdate (nth 5 (file-attributes file)))) | |
3667 (or (> (car fdate) (car date)) | |
3668 (and (= (car fdate) (car date)) | |
3669 (> (nth 1 fdate) (nth 1 date)))))) | |
3670 | |
3671 (defmacro gnus-local-set-keys (&rest plist) | |
3672 "Set the keys in PLIST in the current keymap." | |
3673 `(gnus-define-keys-1 (current-local-map) ',plist)) | |
3674 | |
3675 (defmacro gnus-define-keys (keymap &rest plist) | |
3676 "Define all keys in PLIST in KEYMAP." | |
3677 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist))) | |
3678 | |
3679 (put 'gnus-define-keys 'lisp-indent-function 1) | |
3680 (put 'gnus-define-keys 'lisp-indent-hook 1) | |
3681 (put 'gnus-define-keymap 'lisp-indent-function 1) | |
3682 (put 'gnus-define-keymap 'lisp-indent-hook 1) | |
3683 | |
3684 (defmacro gnus-define-keymap (keymap &rest plist) | |
3685 "Define all keys in PLIST in KEYMAP." | |
3686 `(gnus-define-keys-1 ,keymap (quote ,plist))) | |
3687 | |
3688 (defun gnus-define-keys-1 (keymap plist) | |
3689 (when (null keymap) | |
3690 (error "Can't set keys in a null keymap")) | |
3691 (cond ((symbolp keymap) | |
3692 (setq keymap (symbol-value keymap))) | |
3693 ((keymapp keymap)) | |
3694 ((listp keymap) | |
3695 (set (car keymap) nil) | |
3696 (define-prefix-command (car keymap)) | |
3697 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap)) | |
3698 (setq keymap (symbol-value (car keymap))))) | |
3699 (let (key) | |
3700 (while plist | |
3701 (when (symbolp (setq key (pop plist))) | |
3702 (setq key (symbol-value key))) | |
3703 (define-key keymap key (pop plist))))) | |
3704 | |
3705 (defun gnus-group-read-only-p (&optional group) | |
3706 "Check whether GROUP supports editing or not. | |
3707 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note | |
3708 that that variable is buffer-local to the summary buffers." | |
3709 (let ((group (or group gnus-newsgroup-name))) | |
3710 (not (gnus-check-backend-function 'request-replace-article group)))) | |
3711 | |
3712 (defun gnus-group-total-expirable-p (group) | |
3713 "Check whether GROUP is total-expirable or not." | |
3714 (let ((params (gnus-info-params (gnus-get-info group)))) | |
3715 (or (memq 'total-expire params) | |
3716 (cdr (assq 'total-expire params)) ; (total-expire . t) | |
3717 (and gnus-total-expirable-newsgroups ; Check var. | |
3718 (string-match gnus-total-expirable-newsgroups group))))) | |
3719 | |
3720 (defun gnus-group-auto-expirable-p (group) | |
3721 "Check whether GROUP is total-expirable or not." | |
3722 (let ((params (gnus-info-params (gnus-get-info group)))) | |
3723 (or (memq 'auto-expire params) | |
3724 (cdr (assq 'auto-expire params)) ; (auto-expire . t) | |
3725 (and gnus-auto-expirable-newsgroups ; Check var. | |
3726 (string-match gnus-auto-expirable-newsgroups group))))) | |
3727 | |
3728 (defun gnus-virtual-group-p (group) | |
3729 "Say whether GROUP is virtual or not." | |
3730 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group))) | |
3731 gnus-valid-select-methods))) | |
3732 | |
3733 (defun gnus-news-group-p (group &optional article) | |
3734 "Return non-nil if GROUP (and ARTICLE) come from a news server." | |
3735 (or (gnus-member-of-valid 'post group) ; Ordinary news group. | |
3736 (and (gnus-member-of-valid 'post-mail group) ; Combined group. | |
3737 (eq (gnus-request-type group article) 'news)))) | |
3738 | |
3739 (defsubst gnus-simplify-subject-fully (subject) | |
3740 "Simplify a subject string according to the user's wishes." | |
3741 (cond | |
3742 ((null gnus-summary-gather-subject-limit) | |
3743 (gnus-simplify-subject-re subject)) | |
3744 ((eq gnus-summary-gather-subject-limit 'fuzzy) | |
3745 (gnus-simplify-subject-fuzzy subject)) | |
3746 ((numberp gnus-summary-gather-subject-limit) | |
3747 (gnus-limit-string (gnus-simplify-subject-re subject) | |
3748 gnus-summary-gather-subject-limit)) | |
3749 (t | |
3750 subject))) | |
3751 | |
3752 (defsubst gnus-subject-equal (s1 s2 &optional simple-first) | |
3753 "Check whether two subjects are equal. If optional argument | |
3754 simple-first is t, first argument is already simplified." | |
3755 (cond | |
3756 ((null simple-first) | |
3757 (equal (gnus-simplify-subject-fully s1) | |
3758 (gnus-simplify-subject-fully s2))) | |
3759 (t | |
3760 (equal s1 | |
3761 (gnus-simplify-subject-fully s2))))) | |
3762 | |
3763 ;; Returns a list of writable groups. | |
3764 (defun gnus-writable-groups () | |
3765 (let ((alist gnus-newsrc-alist) | |
3766 groups group) | |
3767 (while (setq group (car (pop alist))) | |
3768 (unless (gnus-group-read-only-p group) | |
3769 (push group groups))) | |
3770 (nreverse groups))) | |
3771 | |
3772 (defun gnus-completing-read (default prompt &rest args) | |
3773 ;; Like `completing-read', except that DEFAULT is the default argument. | |
3774 (let* ((prompt (if default | |
3775 (concat prompt " (default " default ") ") | |
3776 (concat prompt " "))) | |
3777 (answer (apply 'completing-read prompt args))) | |
3778 (if (or (null answer) (zerop (length answer))) | |
3779 default | |
3780 answer))) | |
3781 | |
3782 ;; Two silly functions to ensure that all `y-or-n-p' questions clear | |
3783 ;; the echo area. | |
3784 (defun gnus-y-or-n-p (prompt) | |
3785 (prog1 | |
3786 (y-or-n-p prompt) | |
3787 (message ""))) | |
3788 | |
3789 (defun gnus-yes-or-no-p (prompt) | |
3790 (prog1 | |
3791 (yes-or-no-p prompt) | |
3792 (message ""))) | |
3793 | |
3794 ;; Check whether to use long file names. | |
3795 (defun gnus-use-long-file-name (symbol) | |
3796 ;; The variable has to be set... | |
3797 (and gnus-use-long-file-name | |
3798 ;; If it isn't a list, then we return t. | |
3799 (or (not (listp gnus-use-long-file-name)) | |
3800 ;; If it is a list, and the list contains `symbol', we | |
3801 ;; return nil. | |
3802 (not (memq symbol gnus-use-long-file-name))))) | |
3803 | |
3804 ;; I suspect there's a better way, but I haven't taken the time to do | |
3805 ;; it yet. -erik selberg@cs.washington.edu | |
3806 (defun gnus-dd-mmm (messy-date) | |
3807 "Return a string like DD-MMM from a big messy string" | |
3808 (let ((datevec (condition-case () (timezone-parse-date messy-date) | |
3809 (error nil)))) | |
3810 (if (not datevec) | |
3811 "??-???" | |
3812 (format "%2s-%s" | |
3813 (condition-case () | |
3814 ;; Make sure leading zeroes are stripped. | |
3815 (number-to-string (string-to-number (aref datevec 2))) | |
3816 (error "??")) | |
3817 (capitalize | |
3818 (or (car | |
3819 (nth (1- (string-to-number (aref datevec 1))) | |
3820 timezone-months-assoc)) | |
3821 "???")))))) | |
3822 | |
3823 (defun gnus-mode-string-quote (string) | |
3824 "Quote all \"%\" in STRING." | |
3825 (save-excursion | |
3826 (gnus-set-work-buffer) | |
3827 (insert string) | |
3828 (goto-char (point-min)) | |
3829 (while (search-forward "%" nil t) | |
3830 (insert "%")) | |
3831 (buffer-string))) | |
3832 | |
3833 ;; Make a hash table (default and minimum size is 255). | |
3834 ;; Optional argument HASHSIZE specifies the table size. | |
3835 (defun gnus-make-hashtable (&optional hashsize) | |
3836 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0)) | |
3837 | |
3838 ;; Make a number that is suitable for hashing; bigger than MIN and one | |
3839 ;; less than 2^x. | |
3840 (defun gnus-create-hash-size (min) | |
3841 (let ((i 1)) | |
3842 (while (< i min) | |
3843 (setq i (* 2 i))) | |
3844 (1- i))) | |
3845 | |
3846 ;; Show message if message has a lower level than `gnus-verbose'. | |
3847 ;; Guideline for numbers: | |
3848 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages | |
3849 ;; for things that take a long time, 7 - not very important messages | |
3850 ;; on stuff, 9 - messages inside loops. | |
3851 (defun gnus-message (level &rest args) | |
3852 (if (<= level gnus-verbose) | |
3853 (apply 'message args) | |
3854 ;; We have to do this format thingy here even if the result isn't | |
3855 ;; shown - the return value has to be the same as the return value | |
3856 ;; from `message'. | |
3857 (apply 'format args))) | |
3858 | |
3859 (defun gnus-error (level &rest args) | |
3860 "Beep an error if LEVEL is equal to or less than `gnus-verbose'." | |
3861 (when (<= (floor level) gnus-verbose) | |
3862 (apply 'message args) | |
3863 (ding) | |
3864 (let (duration) | |
3865 (when (and (floatp level) | |
3866 (not (zerop (setq duration (* 10 (- level (floor level))))))) | |
3867 (sit-for duration)))) | |
3868 nil) | |
3869 | |
3870 ;; Generate a unique new group name. | |
3871 (defun gnus-generate-new-group-name (leaf) | |
3872 (let ((name leaf) | |
3873 (num 0)) | |
3874 (while (gnus-gethash name gnus-newsrc-hashtb) | |
3875 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">"))) | |
3876 name)) | |
3877 | |
3878 (defsubst gnus-hide-text (b e props) | |
3879 "Set text PROPS on the B to E region, extending `intangible' 1 past B." | |
3880 (gnus-add-text-properties b e props) | |
3881 (when (memq 'intangible props) | |
3882 (gnus-put-text-property (max (1- b) (point-min)) | |
3883 b 'intangible (cddr (memq 'intangible props))))) | |
3884 | |
3885 (defsubst gnus-unhide-text (b e) | |
3886 "Remove hidden text properties from region between B and E." | |
3887 (remove-text-properties b e gnus-hidden-properties) | |
3888 (when (memq 'intangible gnus-hidden-properties) | |
3889 (gnus-put-text-property (max (1- b) (point-min)) | |
3890 b 'intangible nil))) | |
3891 | |
3892 (defun gnus-hide-text-type (b e type) | |
3893 "Hide text of TYPE between B and E." | |
3894 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties)))) | |
3895 | |
3896 (defun gnus-parent-headers (headers &optional generation) | |
3897 "Return the headers of the GENERATIONeth parent of HEADERS." | |
3898 (unless generation | |
3899 (setq generation 1)) | |
3900 (let (references parent) | |
3901 (while (and headers (not (zerop generation))) | |
3902 (setq references (mail-header-references headers)) | |
3903 (when (and references | |
3904 (setq parent (gnus-parent-id references)) | |
3905 (setq headers (car (gnus-id-to-thread parent)))) | |
3906 (decf generation))) | |
3907 headers)) | |
3908 | |
3909 (defun gnus-parent-id (references) | |
3910 "Return the last Message-ID in REFERENCES." | |
3911 (when (and references | |
3912 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references)) | |
3913 (substring references (match-beginning 1) (match-end 1)))) | |
3914 | |
3915 (defun gnus-split-references (references) | |
3916 "Return a list of Message-IDs in REFERENCES." | |
3917 (let ((beg 0) | |
3918 ids) | |
3919 (while (string-match "<[^>]+>" references beg) | |
3920 (push (substring references (match-beginning 0) (setq beg (match-end 0))) | |
3921 ids)) | |
3922 (nreverse ids))) | |
3923 | |
3924 (defun gnus-buffer-live-p (buffer) | |
3925 "Say whether BUFFER is alive or not." | |
3926 (and buffer | |
3927 (get-buffer buffer) | |
3928 (buffer-name (get-buffer buffer)))) | |
3929 | |
3930 (defun gnus-ephemeral-group-p (group) | |
3931 "Say whether GROUP is ephemeral or not." | |
3932 (gnus-group-get-parameter group 'quit-config)) | |
3933 | |
3934 (defun gnus-group-quit-config (group) | |
3935 "Return the quit-config of GROUP." | |
3936 (gnus-group-get-parameter group 'quit-config)) | |
3937 | |
3938 (defun gnus-simplify-mode-line () | |
3939 "Make mode lines a bit simpler." | |
3940 (setq mode-line-modified "-- ") | |
3941 (when (listp mode-line-format) | |
3942 (make-local-variable 'mode-line-format) | |
3943 (setq mode-line-format (copy-sequence mode-line-format)) | |
3944 (when (equal (nth 3 mode-line-format) " ") | |
3945 (setcar (nthcdr 3 mode-line-format) " ")))) | |
3946 | |
3947 ;;; List and range functions | |
3948 | |
3949 (defun gnus-last-element (list) | |
3950 "Return last element of LIST." | |
3951 (while (cdr list) | |
3952 (setq list (cdr list))) | |
3953 (car list)) | |
3954 | |
3955 (defun gnus-copy-sequence (list) | |
3956 "Do a complete, total copy of a list." | |
3957 (if (and (consp list) (not (consp (cdr list)))) | |
3958 (cons (car list) (cdr list)) | |
3959 (mapcar (lambda (elem) (if (consp elem) | |
3960 (if (consp (cdr elem)) | |
3961 (gnus-copy-sequence elem) | |
3962 (cons (car elem) (cdr elem))) | |
3963 elem)) | |
3964 list))) | |
3965 | |
3966 (defun gnus-set-difference (list1 list2) | |
3967 "Return a list of elements of LIST1 that do not appear in LIST2." | |
3968 (let ((list1 (copy-sequence list1))) | |
3969 (while list2 | |
3970 (setq list1 (delq (car list2) list1)) | |
3971 (setq list2 (cdr list2))) | |
3972 list1)) | |
3973 | |
3974 (defun gnus-sorted-complement (list1 list2) | |
3975 "Return a list of elements of LIST1 that do not appear in LIST2. | |
3976 Both lists have to be sorted over <." | |
3977 (let (out) | |
3978 (if (or (null list1) (null list2)) | |
3979 (or list1 list2) | |
3980 (while (and list1 list2) | |
3981 (cond ((= (car list1) (car list2)) | |
3982 (setq list1 (cdr list1) | |
3983 list2 (cdr list2))) | |
3984 ((< (car list1) (car list2)) | |
3985 (setq out (cons (car list1) out)) | |
3986 (setq list1 (cdr list1))) | |
3987 (t | |
3988 (setq out (cons (car list2) out)) | |
3989 (setq list2 (cdr list2))))) | |
3990 (nconc (nreverse out) (or list1 list2))))) | |
3991 | |
3992 (defun gnus-intersection (list1 list2) | |
3993 (let ((result nil)) | |
3994 (while list2 | |
3995 (if (memq (car list2) list1) | |
3996 (setq result (cons (car list2) result))) | |
3997 (setq list2 (cdr list2))) | |
3998 result)) | |
3999 | |
4000 (defun gnus-sorted-intersection (list1 list2) | |
4001 ;; LIST1 and LIST2 have to be sorted over <. | |
4002 (let (out) | |
4003 (while (and list1 list2) | |
4004 (cond ((= (car list1) (car list2)) | |
4005 (setq out (cons (car list1) out) | |
4006 list1 (cdr list1) | |
4007 list2 (cdr list2))) | |
4008 ((< (car list1) (car list2)) | |
4009 (setq list1 (cdr list1))) | |
4010 (t | |
4011 (setq list2 (cdr list2))))) | |
4012 (nreverse out))) | |
4013 | |
4014 (defun gnus-set-sorted-intersection (list1 list2) | |
4015 ;; LIST1 and LIST2 have to be sorted over <. | |
4016 ;; This function modifies LIST1. | |
4017 (let* ((top (cons nil list1)) | |
4018 (prev top)) | |
4019 (while (and list1 list2) | |
4020 (cond ((= (car list1) (car list2)) | |
4021 (setq prev list1 | |
4022 list1 (cdr list1) | |
4023 list2 (cdr list2))) | |
4024 ((< (car list1) (car list2)) | |
4025 (setcdr prev (cdr list1)) | |
4026 (setq list1 (cdr list1))) | |
4027 (t | |
4028 (setq list2 (cdr list2))))) | |
4029 (setcdr prev nil) | |
4030 (cdr top))) | |
4031 | |
4032 (defun gnus-compress-sequence (numbers &optional always-list) | |
4033 "Convert list of numbers to a list of ranges or a single range. | |
4034 If ALWAYS-LIST is non-nil, this function will always release a list of | |
4035 ranges." | |
4036 (let* ((first (car numbers)) | |
4037 (last (car numbers)) | |
4038 result) | |
4039 (if (null numbers) | |
4040 nil | |
4041 (if (not (listp (cdr numbers))) | |
4042 numbers | |
4043 (while numbers | |
4044 (cond ((= last (car numbers)) nil) ;Omit duplicated number | |
4045 ((= (1+ last) (car numbers)) ;Still in sequence | |
4046 (setq last (car numbers))) | |
4047 (t ;End of one sequence | |
4048 (setq result | |
4049 (cons (if (= first last) first | |
4050 (cons first last)) result)) | |
4051 (setq first (car numbers)) | |
4052 (setq last (car numbers)))) | |
4053 (setq numbers (cdr numbers))) | |
4054 (if (and (not always-list) (null result)) | |
4055 (if (= first last) (list first) (cons first last)) | |
4056 (nreverse (cons (if (= first last) first (cons first last)) | |
4057 result))))))) | |
4058 | |
4059 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range) | |
4060 (defun gnus-uncompress-range (ranges) | |
4061 "Expand a list of ranges into a list of numbers. | |
4062 RANGES is either a single range on the form `(num . num)' or a list of | |
4063 these ranges." | |
4064 (let (first last result) | |
4065 (cond | |
4066 ((null ranges) | |
4067 nil) | |
4068 ((not (listp (cdr ranges))) | |
4069 (setq first (car ranges)) | |
4070 (setq last (cdr ranges)) | |
4071 (while (<= first last) | |
4072 (setq result (cons first result)) | |
4073 (setq first (1+ first))) | |
4074 (nreverse result)) | |
4075 (t | |
4076 (while ranges | |
4077 (if (atom (car ranges)) | |
4078 (if (numberp (car ranges)) | |
4079 (setq result (cons (car ranges) result))) | |
4080 (setq first (caar ranges)) | |
4081 (setq last (cdar ranges)) | |
4082 (while (<= first last) | |
4083 (setq result (cons first result)) | |
4084 (setq first (1+ first)))) | |
4085 (setq ranges (cdr ranges))) | |
4086 (nreverse result))))) | |
4087 | |
4088 (defun gnus-add-to-range (ranges list) | |
4089 "Return a list of ranges that has all articles from both RANGES and LIST. | |
4090 Note: LIST has to be sorted over `<'." | |
4091 (if (not ranges) | |
4092 (gnus-compress-sequence list t) | |
4093 (setq list (copy-sequence list)) | |
4094 (or (listp (cdr ranges)) | |
4095 (setq ranges (list ranges))) | |
4096 (let ((out ranges) | |
4097 ilist lowest highest temp) | |
4098 (while (and ranges list) | |
4099 (setq ilist list) | |
4100 (setq lowest (or (and (atom (car ranges)) (car ranges)) | |
4101 (caar ranges))) | |
4102 (while (and list (cdr list) (< (cadr list) lowest)) | |
4103 (setq list (cdr list))) | |
4104 (if (< (car ilist) lowest) | |
4105 (progn | |
4106 (setq temp list) | |
4107 (setq list (cdr list)) | |
4108 (setcdr temp nil) | |
4109 (setq out (nconc (gnus-compress-sequence ilist t) out)))) | |
4110 (setq highest (or (and (atom (car ranges)) (car ranges)) | |
4111 (cdar ranges))) | |
4112 (while (and list (<= (car list) highest)) | |
4113 (setq list (cdr list))) | |
4114 (setq ranges (cdr ranges))) | |
4115 (if list | |
4116 (setq out (nconc (gnus-compress-sequence list t) out))) | |
4117 (setq out (sort out (lambda (r1 r2) | |
4118 (< (or (and (atom r1) r1) (car r1)) | |
4119 (or (and (atom r2) r2) (car r2)))))) | |
4120 (setq ranges out) | |
4121 (while ranges | |
4122 (if (atom (car ranges)) | |
4123 (if (cdr ranges) | |
4124 (if (atom (cadr ranges)) | |
4125 (if (= (1+ (car ranges)) (cadr ranges)) | |
4126 (progn | |
4127 (setcar ranges (cons (car ranges) | |
4128 (cadr ranges))) | |
4129 (setcdr ranges (cddr ranges)))) | |
4130 (if (= (1+ (car ranges)) (caadr ranges)) | |
4131 (progn | |
4132 (setcar (cadr ranges) (car ranges)) | |
4133 (setcar ranges (cadr ranges)) | |
4134 (setcdr ranges (cddr ranges)))))) | |
4135 (if (cdr ranges) | |
4136 (if (atom (cadr ranges)) | |
4137 (if (= (1+ (cdar ranges)) (cadr ranges)) | |
4138 (progn | |
4139 (setcdr (car ranges) (cadr ranges)) | |
4140 (setcdr ranges (cddr ranges)))) | |
4141 (if (= (1+ (cdar ranges)) (caadr ranges)) | |
4142 (progn | |
4143 (setcdr (car ranges) (cdadr ranges)) | |
4144 (setcdr ranges (cddr ranges))))))) | |
4145 (setq ranges (cdr ranges))) | |
4146 out))) | |
4147 | |
4148 (defun gnus-remove-from-range (ranges list) | |
4149 "Return a list of ranges that has all articles from LIST removed from RANGES. | |
4150 Note: LIST has to be sorted over `<'." | |
4151 ;; !!! This function shouldn't look like this, but I've got a headache. | |
4152 (gnus-compress-sequence | |
4153 (gnus-sorted-complement | |
4154 (gnus-uncompress-range ranges) list))) | |
4155 | |
4156 (defun gnus-member-of-range (number ranges) | |
4157 (if (not (listp (cdr ranges))) | |
4158 (and (>= number (car ranges)) | |
4159 (<= number (cdr ranges))) | |
4160 (let ((not-stop t)) | |
4161 (while (and ranges | |
4162 (if (numberp (car ranges)) | |
4163 (>= number (car ranges)) | |
4164 (>= number (caar ranges))) | |
4165 not-stop) | |
4166 (if (if (numberp (car ranges)) | |
4167 (= number (car ranges)) | |
4168 (and (>= number (caar ranges)) | |
4169 (<= number (cdar ranges)))) | |
4170 (setq not-stop nil)) | |
4171 (setq ranges (cdr ranges))) | |
4172 (not not-stop)))) | |
4173 | |
4174 (defun gnus-range-length (range) | |
4175 "Return the length RANGE would have if uncompressed." | |
4176 (length (gnus-uncompress-range range))) | |
4177 | |
4178 (defun gnus-sublist-p (list sublist) | |
4179 "Test whether all elements in SUBLIST are members of LIST." | |
4180 (let ((sublistp t)) | |
4181 (while sublist | |
4182 (unless (memq (pop sublist) list) | |
4183 (setq sublistp nil | |
4184 sublist nil))) | |
4185 sublistp)) | |
4186 | |
4187 | |
4188 ;;; | |
4189 ;;; Gnus group mode | |
4190 ;;; | |
4191 | |
4192 (defvar gnus-group-mode-map nil) | |
4193 (put 'gnus-group-mode 'mode-class 'special) | |
4194 | |
4195 (unless gnus-group-mode-map | |
4196 (setq gnus-group-mode-map (make-keymap)) | |
4197 (suppress-keymap gnus-group-mode-map) | |
4198 | |
4199 (gnus-define-keys gnus-group-mode-map | |
4200 " " gnus-group-read-group | |
4201 "=" gnus-group-select-group | |
4202 "\r" gnus-group-select-group | |
4203 "\M-\r" gnus-group-quick-select-group | |
4204 "j" gnus-group-jump-to-group | |
4205 "n" gnus-group-next-unread-group | |
4206 "p" gnus-group-prev-unread-group | |
4207 "\177" gnus-group-prev-unread-group | |
4208 [delete] gnus-group-prev-unread-group | |
4209 "N" gnus-group-next-group | |
4210 "P" gnus-group-prev-group | |
4211 "\M-n" gnus-group-next-unread-group-same-level | |
4212 "\M-p" gnus-group-prev-unread-group-same-level | |
4213 "," gnus-group-best-unread-group | |
4214 "." gnus-group-first-unread-group | |
4215 "u" gnus-group-unsubscribe-current-group | |
4216 "U" gnus-group-unsubscribe-group | |
4217 "c" gnus-group-catchup-current | |
4218 "C" gnus-group-catchup-current-all | |
4219 "l" gnus-group-list-groups | |
4220 "L" gnus-group-list-all-groups | |
4221 "m" gnus-group-mail | |
4222 "g" gnus-group-get-new-news | |
4223 "\M-g" gnus-group-get-new-news-this-group | |
4224 "R" gnus-group-restart | |
4225 "r" gnus-group-read-init-file | |
4226 "B" gnus-group-browse-foreign-server | |
4227 "b" gnus-group-check-bogus-groups | |
4228 "F" gnus-find-new-newsgroups | |
4229 "\C-c\C-d" gnus-group-describe-group | |
4230 "\M-d" gnus-group-describe-all-groups | |
4231 "\C-c\C-a" gnus-group-apropos | |
4232 "\C-c\M-\C-a" gnus-group-description-apropos | |
4233 "a" gnus-group-post-news | |
4234 "\ek" gnus-group-edit-local-kill | |
4235 "\eK" gnus-group-edit-global-kill | |
4236 "\C-k" gnus-group-kill-group | |
4237 "\C-y" gnus-group-yank-group | |
4238 "\C-w" gnus-group-kill-region | |
4239 "\C-x\C-t" gnus-group-transpose-groups | |
4240 "\C-c\C-l" gnus-group-list-killed | |
4241 "\C-c\C-x" gnus-group-expire-articles | |
4242 "\C-c\M-\C-x" gnus-group-expire-all-groups | |
4243 "V" gnus-version | |
4244 "s" gnus-group-save-newsrc | |
4245 "z" gnus-group-suspend | |
4246 ; "Z" gnus-group-clear-dribble | |
4247 "q" gnus-group-exit | |
4248 "Q" gnus-group-quit | |
4249 "?" gnus-group-describe-briefly | |
4250 "\C-c\C-i" gnus-info-find-node | |
4251 "\M-e" gnus-group-edit-group-method | |
4252 "^" gnus-group-enter-server-mode | |
4253 gnus-mouse-2 gnus-mouse-pick-group | |
4254 "<" beginning-of-buffer | |
4255 ">" end-of-buffer | |
4256 "\C-c\C-b" gnus-bug | |
4257 "\C-c\C-s" gnus-group-sort-groups | |
4258 "t" gnus-topic-mode | |
4259 "\C-c\M-g" gnus-activate-all-groups | |
4260 "\M-&" gnus-group-universal-argument | |
4261 "#" gnus-group-mark-group | |
4262 "\M-#" gnus-group-unmark-group) | |
4263 | |
4264 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map) | |
4265 "m" gnus-group-mark-group | |
4266 "u" gnus-group-unmark-group | |
4267 "w" gnus-group-mark-region | |
4268 "m" gnus-group-mark-buffer | |
4269 "r" gnus-group-mark-regexp | |
4270 "U" gnus-group-unmark-all-groups) | |
4271 | |
4272 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map) | |
4273 "d" gnus-group-make-directory-group | |
4274 "h" gnus-group-make-help-group | |
4275 "a" gnus-group-make-archive-group | |
4276 "k" gnus-group-make-kiboze-group | |
4277 "m" gnus-group-make-group | |
4278 "E" gnus-group-edit-group | |
4279 "e" gnus-group-edit-group-method | |
4280 "p" gnus-group-edit-group-parameters | |
4281 "v" gnus-group-add-to-virtual | |
4282 "V" gnus-group-make-empty-virtual | |
4283 "D" gnus-group-enter-directory | |
4284 "f" gnus-group-make-doc-group | |
4285 "r" gnus-group-rename-group | |
4286 "\177" gnus-group-delete-group | |
4287 [delete] gnus-group-delete-group) | |
4288 | |
4289 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map) | |
4290 "b" gnus-group-brew-soup | |
4291 "w" gnus-soup-save-areas | |
4292 "s" gnus-soup-send-replies | |
4293 "p" gnus-soup-pack-packet | |
4294 "r" nnsoup-pack-replies) | |
4295 | |
4296 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map) | |
4297 "s" gnus-group-sort-groups | |
4298 "a" gnus-group-sort-groups-by-alphabet | |
4299 "u" gnus-group-sort-groups-by-unread | |
4300 "l" gnus-group-sort-groups-by-level | |
4301 "v" gnus-group-sort-groups-by-score | |
4302 "r" gnus-group-sort-groups-by-rank | |
4303 "m" gnus-group-sort-groups-by-method) | |
4304 | |
4305 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map) | |
4306 "k" gnus-group-list-killed | |
4307 "z" gnus-group-list-zombies | |
4308 "s" gnus-group-list-groups | |
4309 "u" gnus-group-list-all-groups | |
4310 "A" gnus-group-list-active | |
4311 "a" gnus-group-apropos | |
4312 "d" gnus-group-description-apropos | |
4313 "m" gnus-group-list-matching | |
4314 "M" gnus-group-list-all-matching | |
4315 "l" gnus-group-list-level) | |
4316 | |
4317 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map) | |
4318 "f" gnus-score-flush-cache) | |
4319 | |
4320 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map) | |
4321 "f" gnus-group-fetch-faq) | |
4322 | |
4323 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map) | |
4324 "l" gnus-group-set-current-level | |
4325 "t" gnus-group-unsubscribe-current-group | |
4326 "s" gnus-group-unsubscribe-group | |
4327 "k" gnus-group-kill-group | |
4328 "y" gnus-group-yank-group | |
4329 "w" gnus-group-kill-region | |
4330 "\C-k" gnus-group-kill-level | |
4331 "z" gnus-group-kill-all-zombies)) | |
4332 | |
4333 (defun gnus-group-mode () | |
4334 "Major mode for reading news. | |
4335 | |
4336 All normal editing commands are switched off. | |
4337 \\<gnus-group-mode-map> | |
4338 The group buffer lists (some of) the groups available. For instance, | |
4339 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]' | |
4340 lists all zombie groups. | |
4341 | |
4342 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe | |
4343 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'. | |
4344 | |
4345 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]'). | |
4346 | |
4347 The following commands are available: | |
4348 | |
4349 \\{gnus-group-mode-map}" | |
4350 (interactive) | |
4351 (when (and menu-bar-mode | |
4352 (gnus-visual-p 'group-menu 'menu)) | |
4353 (gnus-group-make-menu-bar)) | |
4354 (kill-all-local-variables) | |
4355 (gnus-simplify-mode-line) | |
4356 (setq major-mode 'gnus-group-mode) | |
4357 (setq mode-name "Group") | |
4358 (gnus-group-set-mode-line) | |
4359 (setq mode-line-process nil) | |
4360 (use-local-map gnus-group-mode-map) | |
4361 (buffer-disable-undo (current-buffer)) | |
4362 (setq truncate-lines t) | |
4363 (setq buffer-read-only t) | |
4364 (gnus-make-local-hook 'post-command-hook) | |
4365 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t) | |
4366 (run-hooks 'gnus-group-mode-hook)) | |
4367 | |
4368 (defun gnus-clear-inboxes-moved () | |
4369 (setq nnmail-moved-inboxes nil)) | |
4370 | |
4371 (defun gnus-mouse-pick-group (e) | |
4372 "Enter the group under the mouse pointer." | |
4373 (interactive "e") | |
4374 (mouse-set-point e) | |
4375 (gnus-group-read-group nil)) | |
4376 | |
4377 ;; Look at LEVEL and find out what the level is really supposed to be. | |
4378 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens | |
4379 ;; will depend on whether `gnus-group-use-permanent-levels' is used. | |
4380 (defun gnus-group-default-level (&optional level number-or-nil) | |
4381 (cond | |
4382 (gnus-group-use-permanent-levels | |
4383 (or (setq gnus-group-use-permanent-levels | |
4384 (or level (if (numberp gnus-group-use-permanent-levels) | |
4385 gnus-group-use-permanent-levels | |
4386 (or gnus-group-default-list-level | |
4387 gnus-level-subscribed)))) | |
4388 gnus-group-default-list-level gnus-level-subscribed)) | |
4389 (number-or-nil | |
4390 level) | |
4391 (t | |
4392 (or level gnus-group-default-list-level gnus-level-subscribed)))) | |
4393 | |
4394 ;;;###autoload | |
4395 (defun gnus-slave-no-server (&optional arg) | |
4396 "Read network news as a slave, without connecting to local server" | |
4397 (interactive "P") | |
4398 (gnus-no-server arg t)) | |
4399 | |
4400 ;;;###autoload | |
4401 (defun gnus-no-server (&optional arg slave) | |
4402 "Read network news. | |
4403 If ARG is a positive number, Gnus will use that as the | |
4404 startup level. If ARG is nil, Gnus will be started at level 2. | |
4405 If ARG is non-nil and not a positive number, Gnus will | |
4406 prompt the user for the name of an NNTP server to use. | |
4407 As opposed to `gnus', this command will not connect to the local server." | |
4408 (interactive "P") | |
4409 (let ((val (or arg (1- gnus-level-default-subscribed)))) | |
4410 (gnus val t slave) | |
4411 (make-local-variable 'gnus-group-use-permanent-levels) | |
4412 (setq gnus-group-use-permanent-levels val))) | |
4413 | |
4414 ;;;###autoload | |
4415 (defun gnus-slave (&optional arg) | |
4416 "Read news as a slave." | |
4417 (interactive "P") | |
4418 (gnus arg nil 'slave)) | |
4419 | |
4420 ;;;###autoload | |
4421 (defun gnus-other-frame (&optional arg) | |
4422 "Pop up a frame to read news." | |
4423 (interactive "P") | |
4424 (if (get-buffer gnus-group-buffer) | |
4425 (let ((pop-up-frames t)) | |
4426 (gnus arg)) | |
4427 (select-frame (make-frame)) | |
4428 (gnus arg))) | |
4429 | |
4430 ;;;###autoload | |
4431 (defun gnus (&optional arg dont-connect slave) | |
4432 "Read network news. | |
4433 If ARG is non-nil and a positive number, Gnus will use that as the | |
4434 startup level. If ARG is non-nil and not a positive number, Gnus will | |
4435 prompt the user for the name of an NNTP server to use." | |
4436 (interactive "P") | |
4437 | |
4438 (if (get-buffer gnus-group-buffer) | |
4439 (progn | |
4440 (switch-to-buffer gnus-group-buffer) | |
4441 (gnus-group-get-new-news)) | |
4442 | |
4443 (gnus-clear-system) | |
4444 (nnheader-init-server-buffer) | |
4445 (gnus-read-init-file) | |
4446 (setq gnus-slave slave) | |
4447 | |
4448 (gnus-group-setup-buffer) | |
4449 (let ((buffer-read-only nil)) | |
4450 (erase-buffer) | |
4451 (if (not gnus-inhibit-startup-message) | |
4452 (progn | |
4453 (gnus-group-startup-message) | |
4454 (sit-for 0)))) | |
4455 | |
4456 (let ((level (and (numberp arg) (> arg 0) arg)) | |
4457 did-connect) | |
4458 (unwind-protect | |
4459 (progn | |
4460 (or dont-connect | |
4461 (setq did-connect | |
4462 (gnus-start-news-server (and arg (not level)))))) | |
4463 (if (and (not dont-connect) | |
4464 (not did-connect)) | |
4465 (gnus-group-quit) | |
4466 (run-hooks 'gnus-startup-hook) | |
4467 ;; NNTP server is successfully open. | |
4468 | |
4469 ;; Find the current startup file name. | |
4470 (setq gnus-current-startup-file | |
4471 (gnus-make-newsrc-file gnus-startup-file)) | |
4472 | |
4473 ;; Read the dribble file. | |
4474 (when (or gnus-slave gnus-use-dribble-file) | |
4475 (gnus-dribble-read-file)) | |
4476 | |
4477 ;; Allow using GroupLens predictions. | |
4478 (when gnus-use-grouplens | |
4479 (bbb-login) | |
4480 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode)) | |
4481 | |
4482 (gnus-summary-make-display-table) | |
4483 ;; Do the actual startup. | |
4484 (gnus-setup-news nil level dont-connect) | |
4485 ;; Generate the group buffer. | |
4486 (gnus-group-list-groups level) | |
4487 (gnus-group-first-unread-group) | |
4488 (gnus-configure-windows 'group) | |
4489 (gnus-group-set-mode-line)))))) | |
4490 | |
4491 (defun gnus-unload () | |
4492 "Unload all Gnus features." | |
4493 (interactive) | |
4494 (or (boundp 'load-history) | |
4495 (error "Sorry, `gnus-unload' is not implemented in this Emacs version.")) | |
4496 (let ((history load-history) | |
4497 feature) | |
4498 (while history | |
4499 (and (string-match "^\\(gnus\\|nn\\)" (caar history)) | |
4500 (setq feature (cdr (assq 'provide (car history)))) | |
4501 (unload-feature feature 'force)) | |
4502 (setq history (cdr history))))) | |
4503 | |
4504 (defun gnus-compile () | |
4505 "Byte-compile the user-defined format specs." | |
4506 (interactive) | |
4507 (let ((entries gnus-format-specs) | |
4508 entry gnus-tmp-func) | |
4509 (save-excursion | |
4510 (gnus-message 7 "Compiling format specs...") | |
4511 | |
4512 (while entries | |
4513 (setq entry (pop entries)) | |
4514 (if (eq (car entry) 'version) | |
4515 (setq gnus-format-specs (delq entry gnus-format-specs)) | |
4516 (when (and (listp (caddr entry)) | |
4517 (not (eq 'byte-code (caaddr entry)))) | |
4518 (fset 'gnus-tmp-func | |
4519 `(lambda () ,(caddr entry))) | |
4520 (byte-compile 'gnus-tmp-func) | |
4521 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func))))) | |
4522 | |
4523 (push (cons 'version emacs-version) gnus-format-specs) | |
4524 ;; Mark the .newsrc.eld file as "dirty". | |
4525 (gnus-dribble-enter " ") | |
4526 (gnus-message 7 "Compiling user specs...done")))) | |
4527 | |
4528 (defun gnus-indent-rigidly (start end arg) | |
4529 "Indent rigidly using only spaces and no tabs." | |
4530 (save-excursion | |
4531 (save-restriction | |
4532 (narrow-to-region start end) | |
4533 (indent-rigidly start end arg) | |
4534 (goto-char (point-min)) | |
4535 (while (search-forward "\t" nil t) | |
4536 (replace-match " " t t))))) | |
4537 | |
4538 (defun gnus-group-startup-message (&optional x y) | |
4539 "Insert startup message in current buffer." | |
4540 ;; Insert the message. | |
4541 (erase-buffer) | |
4542 (insert | |
4543 (format " %s | |
4544 _ ___ _ _ | |
4545 _ ___ __ ___ __ _ ___ | |
4546 __ _ ___ __ ___ | |
4547 _ ___ _ | |
4548 _ _ __ _ | |
4549 ___ __ _ | |
4550 __ _ | |
4551 _ _ _ | |
4552 _ _ _ | |
4553 _ _ _ | |
4554 __ ___ | |
4555 _ _ _ _ | |
4556 _ _ | |
4557 _ _ | |
4558 _ _ | |
4559 _ | |
4560 __ | |
4561 | |
4562 " | |
4563 "")) | |
4564 ;; And then hack it. | |
4565 (gnus-indent-rigidly (point-min) (point-max) | |
4566 (/ (max (- (window-width) (or x 46)) 0) 2)) | |
4567 (goto-char (point-min)) | |
4568 (forward-line 1) | |
4569 (let* ((pheight (count-lines (point-min) (point-max))) | |
4570 (wheight (window-height)) | |
4571 (rest (- wheight pheight))) | |
4572 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))) | |
4573 ;; Fontify some. | |
4574 (goto-char (point-min)) | |
4575 (and (search-forward "Praxis" nil t) | |
4576 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold)) | |
4577 (goto-char (point-min)) | |
4578 (let* ((mode-string (gnus-group-set-mode-line))) | |
4579 (setq mode-line-buffer-identification | |
4580 (list (concat gnus-version (substring (car mode-string) 4)))) | |
4581 (set-buffer-modified-p t))) | |
4582 | |
4583 (defun gnus-group-setup-buffer () | |
4584 (or (get-buffer gnus-group-buffer) | |
4585 (progn | |
4586 (switch-to-buffer gnus-group-buffer) | |
4587 (gnus-add-current-to-buffer-list) | |
4588 (gnus-group-mode) | |
4589 (and gnus-carpal (gnus-carpal-setup-buffer 'group))))) | |
4590 | |
4591 (defun gnus-group-list-groups (&optional level unread lowest) | |
4592 "List newsgroups with level LEVEL or lower that have unread articles. | |
4593 Default is all subscribed groups. | |
4594 If argument UNREAD is non-nil, groups with no unread articles are also | |
4595 listed." | |
4596 (interactive (list (if current-prefix-arg | |
4597 (prefix-numeric-value current-prefix-arg) | |
4598 (or | |
4599 (gnus-group-default-level nil t) | |
4600 gnus-group-default-list-level | |
4601 gnus-level-subscribed)))) | |
4602 (or level | |
4603 (setq level (car gnus-group-list-mode) | |
4604 unread (cdr gnus-group-list-mode))) | |
4605 (setq level (gnus-group-default-level level)) | |
4606 (gnus-group-setup-buffer) ;May call from out of group buffer | |
4607 (gnus-update-format-specifications) | |
4608 (let ((case-fold-search nil) | |
4609 (props (text-properties-at (gnus-point-at-bol))) | |
4610 (group (gnus-group-group-name))) | |
4611 (set-buffer gnus-group-buffer) | |
4612 (funcall gnus-group-prepare-function level unread lowest) | |
4613 (if (zerop (buffer-size)) | |
4614 (gnus-message 5 gnus-no-groups-message) | |
4615 (goto-char (point-max)) | |
4616 (when (or (not gnus-group-goto-next-group-function) | |
4617 (not (funcall gnus-group-goto-next-group-function | |
4618 group props))) | |
4619 (if (not group) | |
4620 ;; Go to the first group with unread articles. | |
4621 (gnus-group-search-forward t) | |
4622 ;; Find the right group to put point on. If the current group | |
4623 ;; has disappeared in the new listing, try to find the next | |
4624 ;; one. If no next one can be found, just leave point at the | |
4625 ;; first newsgroup in the buffer. | |
4626 (if (not (gnus-goto-char | |
4627 (text-property-any | |
4628 (point-min) (point-max) | |
4629 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))) | |
4630 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb)))) | |
4631 (while (and newsrc | |
4632 (not (gnus-goto-char | |
4633 (text-property-any | |
4634 (point-min) (point-max) 'gnus-group | |
4635 (gnus-intern-safe | |
4636 (caar newsrc) gnus-active-hashtb))))) | |
4637 (setq newsrc (cdr newsrc))) | |
4638 (or newsrc (progn (goto-char (point-max)) | |
4639 (forward-line -1))))))) | |
4640 ;; Adjust cursor point. | |
4641 (gnus-group-position-point)))) | |
4642 | |
4643 (defun gnus-group-list-level (level &optional all) | |
4644 "List groups on LEVEL. | |
4645 If ALL (the prefix), also list groups that have no unread articles." | |
4646 (interactive "nList groups on level: \nP") | |
4647 (gnus-group-list-groups level all level)) | |
4648 | |
4649 (defun gnus-group-prepare-flat (level &optional all lowest regexp) | |
4650 "List all newsgroups with unread articles of level LEVEL or lower. | |
4651 If ALL is non-nil, list groups that have no unread articles. | |
4652 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher. | |
4653 If REGEXP, only list groups matching REGEXP." | |
4654 (set-buffer gnus-group-buffer) | |
4655 (let ((buffer-read-only nil) | |
4656 (newsrc (cdr gnus-newsrc-alist)) | |
4657 (lowest (or lowest 1)) | |
4658 info clevel unread group params) | |
4659 (erase-buffer) | |
4660 (if (< lowest gnus-level-zombie) | |
4661 ;; List living groups. | |
4662 (while newsrc | |
4663 (setq info (car newsrc) | |
4664 group (gnus-info-group info) | |
4665 params (gnus-info-params info) | |
4666 newsrc (cdr newsrc) | |
4667 unread (car (gnus-gethash group gnus-newsrc-hashtb))) | |
4668 (and unread ; This group might be bogus | |
4669 (or (not regexp) | |
4670 (string-match regexp group)) | |
4671 (<= (setq clevel (gnus-info-level info)) level) | |
4672 (>= clevel lowest) | |
4673 (or all ; We list all groups? | |
4674 (if (eq unread t) ; Unactivated? | |
4675 gnus-group-list-inactive-groups ; We list unactivated | |
4676 (> unread 0)) ; We list groups with unread articles | |
4677 (and gnus-list-groups-with-ticked-articles | |
4678 (cdr (assq 'tick (gnus-info-marks info)))) | |
4679 ; And groups with tickeds | |
4680 ;; Check for permanent visibility. | |
4681 (and gnus-permanently-visible-groups | |
4682 (string-match gnus-permanently-visible-groups | |
4683 group)) | |
4684 (memq 'visible params) | |
4685 (cdr (assq 'visible params))) | |
4686 (gnus-group-insert-group-line | |
4687 group (gnus-info-level info) | |
4688 (gnus-info-marks info) unread (gnus-info-method info))))) | |
4689 | |
4690 ;; List dead groups. | |
4691 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie) | |
4692 (gnus-group-prepare-flat-list-dead | |
4693 (setq gnus-zombie-list (sort gnus-zombie-list 'string<)) | |
4694 gnus-level-zombie ?Z | |
4695 regexp)) | |
4696 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed) | |
4697 (gnus-group-prepare-flat-list-dead | |
4698 (setq gnus-killed-list (sort gnus-killed-list 'string<)) | |
4699 gnus-level-killed ?K regexp)) | |
4700 | |
4701 (gnus-group-set-mode-line) | |
4702 (setq gnus-group-list-mode (cons level all)) | |
4703 (run-hooks 'gnus-group-prepare-hook))) | |
4704 | |
4705 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp) | |
4706 ;; List zombies and killed lists somewhat faster, which was | |
4707 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does | |
4708 ;; this by ignoring the group format specification altogether. | |
4709 (let (group) | |
4710 (if regexp | |
4711 ;; This loop is used when listing groups that match some | |
4712 ;; regexp. | |
4713 (while groups | |
4714 (setq group (pop groups)) | |
4715 (when (string-match regexp group) | |
4716 (gnus-add-text-properties | |
4717 (point) (prog1 (1+ (point)) | |
4718 (insert " " mark " *: " group "\n")) | |
4719 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb) | |
4720 'gnus-unread t | |
4721 'gnus-level level)))) | |
4722 ;; This loop is used when listing all groups. | |
4723 (while groups | |
4724 (gnus-add-text-properties | |
4725 (point) (prog1 (1+ (point)) | |
4726 (insert " " mark " *: " | |
4727 (setq group (pop groups)) "\n")) | |
4728 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb) | |
4729 'gnus-unread t | |
4730 'gnus-level level)))))) | |
4731 | |
4732 (defmacro gnus-group-real-name (group) | |
4733 "Find the real name of a foreign newsgroup." | |
4734 `(let ((gname ,group)) | |
4735 (if (string-match ":[^:]+$" gname) | |
4736 (substring gname (1+ (match-beginning 0))) | |
4737 gname))) | |
4738 | |
4739 (defsubst gnus-server-add-address (method) | |
4740 (let ((method-name (symbol-name (car method)))) | |
4741 (if (and (memq 'address (assoc method-name gnus-valid-select-methods)) | |
4742 (not (assq (intern (concat method-name "-address")) method))) | |
4743 (append method (list (list (intern (concat method-name "-address")) | |
4744 (nth 1 method)))) | |
4745 method))) | |
4746 | |
4747 (defsubst gnus-server-get-method (group method) | |
4748 ;; Input either a server name, and extended server name, or a | |
4749 ;; select method, and return a select method. | |
4750 (cond ((stringp method) | |
4751 (gnus-server-to-method method)) | |
4752 ((equal method gnus-select-method) | |
4753 gnus-select-method) | |
4754 ((and (stringp (car method)) group) | |
4755 (gnus-server-extend-method group method)) | |
4756 ((and method (not group) | |
4757 (equal (cadr method) "")) | |
4758 method) | |
4759 (t | |
4760 (gnus-server-add-address method)))) | |
4761 | |
4762 (defun gnus-server-to-method (server) | |
4763 "Map virtual server names to select methods." | |
4764 (or | |
4765 ;; Is this a method, perhaps? | |
4766 (and server (listp server) server) | |
4767 ;; Perhaps this is the native server? | |
4768 (and (equal server "native") gnus-select-method) | |
4769 ;; It should be in the server alist. | |
4770 (cdr (assoc server gnus-server-alist)) | |
4771 ;; If not, we look through all the opened server | |
4772 ;; to see whether we can find it there. | |
4773 (let ((opened gnus-opened-servers)) | |
4774 (while (and opened | |
4775 (not (equal server (format "%s:%s" (caaar opened) | |
4776 (cadaar opened))))) | |
4777 (pop opened)) | |
4778 (caar opened)))) | |
4779 | |
4780 (defmacro gnus-method-equal (ss1 ss2) | |
4781 "Say whether two servers are equal." | |
4782 `(let ((s1 ,ss1) | |
4783 (s2 ,ss2)) | |
4784 (or (equal s1 s2) | |
4785 (and (= (length s1) (length s2)) | |
4786 (progn | |
4787 (while (and s1 (member (car s1) s2)) | |
4788 (setq s1 (cdr s1))) | |
4789 (null s1)))))) | |
4790 | |
4791 (defun gnus-server-equal (m1 m2) | |
4792 "Say whether two methods are equal." | |
4793 (let ((m1 (cond ((null m1) gnus-select-method) | |
4794 ((stringp m1) (gnus-server-to-method m1)) | |
4795 (t m1))) | |
4796 (m2 (cond ((null m2) gnus-select-method) | |
4797 ((stringp m2) (gnus-server-to-method m2)) | |
4798 (t m2)))) | |
4799 (gnus-method-equal m1 m2))) | |
4800 | |
4801 (defun gnus-servers-using-backend (backend) | |
4802 "Return a list of known servers using BACKEND." | |
4803 (let ((opened gnus-opened-servers) | |
4804 out) | |
4805 (while opened | |
4806 (when (eq backend (caaar opened)) | |
4807 (push (caar opened) out)) | |
4808 (pop opened)) | |
4809 out)) | |
4810 | |
4811 (defun gnus-archive-server-wanted-p () | |
4812 "Say whether the user wants to use the archive server." | |
4813 (cond | |
4814 ((or (not gnus-message-archive-method) | |
4815 (not gnus-message-archive-group)) | |
4816 nil) | |
4817 ((and gnus-message-archive-method gnus-message-archive-group) | |
4818 t) | |
4819 (t | |
4820 (let ((active (cadr (assq 'nnfolder-active-file | |
4821 gnus-message-archive-method)))) | |
4822 (and active | |
4823 (file-exists-p active)))))) | |
4824 | |
4825 (defun gnus-group-prefixed-name (group method) | |
4826 "Return the whole name from GROUP and METHOD." | |
4827 (and (stringp method) (setq method (gnus-server-to-method method))) | |
4828 (if (not method) | |
4829 group | |
4830 (concat (format "%s" (car method)) | |
4831 (if (and | |
4832 (or (assoc (format "%s" (car method)) | |
4833 (gnus-methods-using 'address)) | |
4834 (gnus-server-equal method gnus-message-archive-method)) | |
4835 (nth 1 method) | |
4836 (not (string= (nth 1 method) ""))) | |
4837 (concat "+" (nth 1 method))) | |
4838 ":" group))) | |
4839 | |
4840 (defun gnus-group-real-prefix (group) | |
4841 "Return the prefix of the current group name." | |
4842 (if (string-match "^[^:]+:" group) | |
4843 (substring group 0 (match-end 0)) | |
4844 "")) | |
4845 | |
4846 (defun gnus-group-method (group) | |
4847 "Return the server or method used for selecting GROUP." | |
4848 (let ((prefix (gnus-group-real-prefix group))) | |
4849 (if (equal prefix "") | |
4850 gnus-select-method | |
4851 (let ((servers gnus-opened-servers) | |
4852 (server "") | |
4853 backend possible found) | |
4854 (if (string-match "^[^\\+]+\\+" prefix) | |
4855 (setq backend (intern (substring prefix 0 (1- (match-end 0)))) | |
4856 server (substring prefix (match-end 0) (1- (length prefix)))) | |
4857 (setq backend (intern (substring prefix 0 (1- (length prefix)))))) | |
4858 (while servers | |
4859 (when (eq (caaar servers) backend) | |
4860 (setq possible (caar servers)) | |
4861 (when (equal (cadaar servers) server) | |
4862 (setq found (caar servers)))) | |
4863 (pop servers)) | |
4864 (or (car (rassoc found gnus-server-alist)) | |
4865 found | |
4866 (car (rassoc possible gnus-server-alist)) | |
4867 possible | |
4868 (list backend server)))))) | |
4869 | |
4870 (defsubst gnus-secondary-method-p (method) | |
4871 "Return whether METHOD is a secondary select method." | |
4872 (let ((methods gnus-secondary-select-methods) | |
4873 (gmethod (gnus-server-get-method nil method))) | |
4874 (while (and methods | |
4875 (not (equal (gnus-server-get-method nil (car methods)) | |
4876 gmethod))) | |
4877 (setq methods (cdr methods))) | |
4878 methods)) | |
4879 | |
4880 (defun gnus-group-foreign-p (group) | |
4881 "Say whether a group is foreign or not." | |
4882 (and (not (gnus-group-native-p group)) | |
4883 (not (gnus-group-secondary-p group)))) | |
4884 | |
4885 (defun gnus-group-native-p (group) | |
4886 "Say whether the group is native or not." | |
4887 (not (string-match ":" group))) | |
4888 | |
4889 (defun gnus-group-secondary-p (group) | |
4890 "Say whether the group is secondary or not." | |
4891 (gnus-secondary-method-p (gnus-find-method-for-group group))) | |
4892 | |
4893 (defun gnus-group-get-parameter (group &optional symbol) | |
4894 "Returns the group parameters for GROUP. | |
4895 If SYMBOL, return the value of that symbol in the group parameters." | |
4896 (let ((params (gnus-info-params (gnus-get-info group)))) | |
4897 (if symbol | |
4898 (gnus-group-parameter-value params symbol) | |
4899 params))) | |
4900 | |
4901 (defun gnus-group-parameter-value (params symbol) | |
4902 "Return the value of SYMBOL in group PARAMS." | |
4903 (or (car (memq symbol params)) ; It's either a simple symbol | |
4904 (cdr (assq symbol params)))) ; or a cons. | |
4905 | |
4906 (defun gnus-group-add-parameter (group param) | |
4907 "Add parameter PARAM to GROUP." | |
4908 (let ((info (gnus-get-info group))) | |
4909 (if (not info) | |
4910 () ; This is a dead group. We just ignore it. | |
4911 ;; Cons the new param to the old one and update. | |
4912 (gnus-group-set-info (cons param (gnus-info-params info)) | |
4913 group 'params)))) | |
4914 | |
4915 (defun gnus-group-set-parameter (group name value) | |
4916 "Set parameter NAME to VALUE in GROUP." | |
4917 (let ((info (gnus-get-info group))) | |
4918 (if (not info) | |
4919 () ; This is a dead group. We just ignore it. | |
4920 (let ((old-params (gnus-info-params info)) | |
4921 (new-params (list (cons name value)))) | |
4922 (while old-params | |
4923 (if (or (not (listp (car old-params))) | |
4924 (not (eq (caar old-params) name))) | |
4925 (setq new-params (append new-params (list (car old-params))))) | |
4926 (setq old-params (cdr old-params))) | |
4927 (gnus-group-set-info new-params group 'params))))) | |
4928 | |
4929 (defun gnus-group-add-score (group &optional score) | |
4930 "Add SCORE to the GROUP score. | |
4931 If SCORE is nil, add 1 to the score of GROUP." | |
4932 (let ((info (gnus-get-info group))) | |
4933 (when info | |
4934 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1)))))) | |
4935 | |
4936 (defun gnus-summary-bubble-group () | |
4937 "Increase the score of the current group. | |
4938 This is a handy function to add to `gnus-summary-exit-hook' to | |
4939 increase the score of each group you read." | |
4940 (gnus-group-add-score gnus-newsgroup-name)) | |
4941 | |
4942 (defun gnus-group-set-info (info &optional method-only-group part) | |
4943 (let* ((entry (gnus-gethash | |
4944 (or method-only-group (gnus-info-group info)) | |
4945 gnus-newsrc-hashtb)) | |
4946 (part-info info) | |
4947 (info (if method-only-group (nth 2 entry) info)) | |
4948 method) | |
4949 (when method-only-group | |
4950 (unless entry | |
4951 (error "Trying to change non-existent group %s" method-only-group)) | |
4952 ;; We have received parts of the actual group info - either the | |
4953 ;; select method or the group parameters. We first check | |
4954 ;; whether we have to extend the info, and if so, do that. | |
4955 (let ((len (length info)) | |
4956 (total (if (eq part 'method) 5 6))) | |
4957 (when (< len total) | |
4958 (setcdr (nthcdr (1- len) info) | |
4959 (make-list (- total len) nil))) | |
4960 ;; Then we enter the new info. | |
4961 (setcar (nthcdr (1- total) info) part-info))) | |
4962 (unless entry | |
4963 ;; This is a new group, so we just create it. | |
4964 (save-excursion | |
4965 (set-buffer gnus-group-buffer) | |
4966 (setq method (gnus-info-method info)) | |
4967 (when (gnus-server-equal method "native") | |
4968 (setq method nil)) | |
4969 (save-excursion | |
4970 (set-buffer gnus-group-buffer) | |
4971 (if method | |
4972 ;; It's a foreign group... | |
4973 (gnus-group-make-group | |
4974 (gnus-group-real-name (gnus-info-group info)) | |
4975 (if (stringp method) method | |
4976 (prin1-to-string (car method))) | |
4977 (and (consp method) | |
4978 (nth 1 (gnus-info-method info)))) | |
4979 ;; It's a native group. | |
4980 (gnus-group-make-group (gnus-info-group info)))) | |
4981 (gnus-message 6 "Note: New group created") | |
4982 (setq entry | |
4983 (gnus-gethash (gnus-group-prefixed-name | |
4984 (gnus-group-real-name (gnus-info-group info)) | |
4985 (or (gnus-info-method info) gnus-select-method)) | |
4986 gnus-newsrc-hashtb)))) | |
4987 ;; Whether it was a new group or not, we now have the entry, so we | |
4988 ;; can do the update. | |
4989 (if entry | |
4990 (progn | |
4991 (setcar (nthcdr 2 entry) info) | |
4992 (when (and (not (eq (car entry) t)) | |
4993 (gnus-active (gnus-info-group info))) | |
4994 (setcar entry (length (gnus-list-of-unread-articles (car info)))))) | |
4995 (error "No such group: %s" (gnus-info-group info))))) | |
4996 | |
4997 (defun gnus-group-set-method-info (group select-method) | |
4998 (gnus-group-set-info select-method group 'method)) | |
4999 | |
5000 (defun gnus-group-set-params-info (group params) | |
5001 (gnus-group-set-info params group 'params)) | |
5002 | |
5003 (defun gnus-group-update-group-line () | |
5004 "Update the current line in the group buffer." | |
5005 (let* ((buffer-read-only nil) | |
5006 (group (gnus-group-group-name)) | |
5007 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))) | |
5008 gnus-group-indentation) | |
5009 (when group | |
5010 (and entry | |
5011 (not (gnus-ephemeral-group-p group)) | |
5012 (gnus-dribble-enter | |
5013 (concat "(gnus-group-set-info '" | |
5014 (prin1-to-string (nth 2 entry)) ")"))) | |
5015 (setq gnus-group-indentation (gnus-group-group-indentation)) | |
5016 (gnus-delete-line) | |
5017 (gnus-group-insert-group-line-info group) | |
5018 (forward-line -1) | |
5019 (gnus-group-position-point)))) | |
5020 | |
5021 (defun gnus-group-insert-group-line-info (group) | |
5022 "Insert GROUP on the current line." | |
5023 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
5024 active info) | |
5025 (if entry | |
5026 (progn | |
5027 ;; (Un)subscribed group. | |
5028 (setq info (nth 2 entry)) | |
5029 (gnus-group-insert-group-line | |
5030 group (gnus-info-level info) (gnus-info-marks info) | |
5031 (or (car entry) t) (gnus-info-method info))) | |
5032 ;; This group is dead. | |
5033 (gnus-group-insert-group-line | |
5034 group | |
5035 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed) | |
5036 nil | |
5037 (if (setq active (gnus-active group)) | |
5038 (- (1+ (cdr active)) (car active)) 0) | |
5039 nil)))) | |
5040 | |
5041 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level | |
5042 gnus-tmp-marked number | |
5043 gnus-tmp-method) | |
5044 "Insert a group line in the group buffer." | |
5045 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group)) | |
5046 (gnus-tmp-number-total | |
5047 (if gnus-tmp-active | |
5048 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active))) | |
5049 0)) | |
5050 (gnus-tmp-number-of-unread | |
5051 (if (numberp number) (int-to-string (max 0 number)) | |
5052 "*")) | |
5053 (gnus-tmp-number-of-read | |
5054 (if (numberp number) | |
5055 (int-to-string (max 0 (- gnus-tmp-number-total number))) | |
5056 "*")) | |
5057 (gnus-tmp-subscribed | |
5058 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? ) | |
5059 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U) | |
5060 ((= gnus-tmp-level gnus-level-zombie) ?Z) | |
5061 (t ?K))) | |
5062 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group)) | |
5063 (gnus-tmp-newsgroup-description | |
5064 (if gnus-description-hashtb | |
5065 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "") | |
5066 "")) | |
5067 (gnus-tmp-moderated | |
5068 (if (member gnus-tmp-group gnus-moderated-list) ?m ? )) | |
5069 (gnus-tmp-moderated-string | |
5070 (if (eq gnus-tmp-moderated ?m) "(m)" "")) | |
5071 (gnus-tmp-method | |
5072 (gnus-server-get-method gnus-tmp-group gnus-tmp-method)) | |
5073 (gnus-tmp-news-server (or (cadr gnus-tmp-method) "")) | |
5074 (gnus-tmp-news-method (or (car gnus-tmp-method) "")) | |
5075 (gnus-tmp-news-method-string | |
5076 (if gnus-tmp-method | |
5077 (format "(%s:%s)" (car gnus-tmp-method) | |
5078 (cadr gnus-tmp-method)) "")) | |
5079 (gnus-tmp-marked-mark | |
5080 (if (and (numberp number) | |
5081 (zerop number) | |
5082 (cdr (assq 'tick gnus-tmp-marked))) | |
5083 ?* ? )) | |
5084 (gnus-tmp-process-marked | |
5085 (if (member gnus-tmp-group gnus-group-marked) | |
5086 gnus-process-mark ? )) | |
5087 (gnus-tmp-grouplens | |
5088 (or (and gnus-use-grouplens | |
5089 (bbb-grouplens-group-p gnus-tmp-group)) | |
5090 "")) | |
5091 (buffer-read-only nil) | |
5092 header gnus-tmp-header) ; passed as parameter to user-funcs. | |
5093 (beginning-of-line) | |
5094 (gnus-add-text-properties | |
5095 (point) | |
5096 (prog1 (1+ (point)) | |
5097 ;; Insert the text. | |
5098 (eval gnus-group-line-format-spec)) | |
5099 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb) | |
5100 gnus-unread ,(if (numberp number) | |
5101 (string-to-int gnus-tmp-number-of-unread) | |
5102 t) | |
5103 gnus-marked ,gnus-tmp-marked-mark | |
5104 gnus-indentation ,gnus-group-indentation | |
5105 gnus-level ,gnus-tmp-level)) | |
5106 (when (inline (gnus-visual-p 'group-highlight 'highlight)) | |
5107 (forward-line -1) | |
5108 (run-hooks 'gnus-group-update-hook) | |
5109 (forward-line)) | |
5110 ;; Allow XEmacs to remove front-sticky text properties. | |
5111 (gnus-group-remove-excess-properties))) | |
5112 | |
5113 (defun gnus-group-update-group (group &optional visible-only) | |
5114 "Update all lines where GROUP appear. | |
5115 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't | |
5116 already." | |
5117 (save-excursion | |
5118 (set-buffer gnus-group-buffer) | |
5119 ;; The buffer may be narrowed. | |
5120 (save-restriction | |
5121 (widen) | |
5122 (let ((ident (gnus-intern-safe group gnus-active-hashtb)) | |
5123 (loc (point-min)) | |
5124 found buffer-read-only) | |
5125 ;; Enter the current status into the dribble buffer. | |
5126 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))) | |
5127 (if (and entry (not (gnus-ephemeral-group-p group))) | |
5128 (gnus-dribble-enter | |
5129 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry)) | |
5130 ")")))) | |
5131 ;; Find all group instances. If topics are in use, each group | |
5132 ;; may be listed in more than once. | |
5133 (while (setq loc (text-property-any | |
5134 loc (point-max) 'gnus-group ident)) | |
5135 (setq found t) | |
5136 (goto-char loc) | |
5137 (let ((gnus-group-indentation (gnus-group-group-indentation))) | |
5138 (gnus-delete-line) | |
5139 (gnus-group-insert-group-line-info group) | |
5140 (save-excursion | |
5141 (forward-line -1) | |
5142 (run-hooks 'gnus-group-update-group-hook))) | |
5143 (setq loc (1+ loc))) | |
5144 (unless (or found visible-only) | |
5145 ;; No such line in the buffer, find out where it's supposed to | |
5146 ;; go, and insert it there (or at the end of the buffer). | |
5147 (if gnus-goto-missing-group-function | |
5148 (funcall gnus-goto-missing-group-function group) | |
5149 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb)))) | |
5150 (while (and entry (car entry) | |
5151 (not | |
5152 (gnus-goto-char | |
5153 (text-property-any | |
5154 (point-min) (point-max) | |
5155 'gnus-group (gnus-intern-safe | |
5156 (caar entry) gnus-active-hashtb))))) | |
5157 (setq entry (cdr entry))) | |
5158 (or entry (goto-char (point-max))))) | |
5159 ;; Finally insert the line. | |
5160 (let ((gnus-group-indentation (gnus-group-group-indentation))) | |
5161 (gnus-group-insert-group-line-info group) | |
5162 (save-excursion | |
5163 (forward-line -1) | |
5164 (run-hooks 'gnus-group-update-group-hook)))) | |
5165 (gnus-group-set-mode-line))))) | |
5166 | |
5167 (defun gnus-group-set-mode-line () | |
5168 "Update the mode line in the group buffer." | |
5169 (when (memq 'group gnus-updated-mode-lines) | |
5170 ;; Yes, we want to keep this mode line updated. | |
5171 (save-excursion | |
5172 (set-buffer gnus-group-buffer) | |
5173 (let* ((gformat (or gnus-group-mode-line-format-spec | |
5174 (setq gnus-group-mode-line-format-spec | |
5175 (gnus-parse-format | |
5176 gnus-group-mode-line-format | |
5177 gnus-group-mode-line-format-alist)))) | |
5178 (gnus-tmp-news-server (cadr gnus-select-method)) | |
5179 (gnus-tmp-news-method (car gnus-select-method)) | |
5180 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":")) | |
5181 (max-len 60) | |
5182 gnus-tmp-header ;Dummy binding for user-defined formats | |
5183 ;; Get the resulting string. | |
5184 (modified | |
5185 (and gnus-dribble-buffer | |
5186 (buffer-name gnus-dribble-buffer) | |
5187 (buffer-modified-p gnus-dribble-buffer) | |
5188 (save-excursion | |
5189 (set-buffer gnus-dribble-buffer) | |
5190 (not (zerop (buffer-size)))))) | |
5191 (mode-string (eval gformat))) | |
5192 ;; Say whether the dribble buffer has been modified. | |
5193 (setq mode-line-modified | |
5194 (if modified "---*- " "----- ")) | |
5195 ;; If the line is too long, we chop it off. | |
5196 (when (> (length mode-string) max-len) | |
5197 (setq mode-string (substring mode-string 0 (- max-len 4)))) | |
5198 (prog1 | |
5199 (setq mode-line-buffer-identification | |
5200 (gnus-mode-line-buffer-identification | |
5201 (list mode-string))) | |
5202 (set-buffer-modified-p modified)))))) | |
5203 | |
5204 (defun gnus-group-group-name () | |
5205 "Get the name of the newsgroup on the current line." | |
5206 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group))) | |
5207 (and group (symbol-name group)))) | |
5208 | |
5209 (defun gnus-group-group-level () | |
5210 "Get the level of the newsgroup on the current line." | |
5211 (get-text-property (gnus-point-at-bol) 'gnus-level)) | |
5212 | |
5213 (defun gnus-group-group-indentation () | |
5214 "Get the indentation of the newsgroup on the current line." | |
5215 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation) | |
5216 (and gnus-group-indentation-function | |
5217 (funcall gnus-group-indentation-function)) | |
5218 "")) | |
5219 | |
5220 (defun gnus-group-group-unread () | |
5221 "Get the number of unread articles of the newsgroup on the current line." | |
5222 (get-text-property (gnus-point-at-bol) 'gnus-unread)) | |
5223 | |
5224 (defun gnus-group-search-forward (&optional backward all level first-too) | |
5225 "Find the next newsgroup with unread articles. | |
5226 If BACKWARD is non-nil, find the previous newsgroup instead. | |
5227 If ALL is non-nil, just find any newsgroup. | |
5228 If LEVEL is non-nil, find group with level LEVEL, or higher if no such | |
5229 group exists. | |
5230 If FIRST-TOO, the current line is also eligible as a target." | |
5231 (let ((way (if backward -1 1)) | |
5232 (low gnus-level-killed) | |
5233 (beg (point)) | |
5234 pos found lev) | |
5235 (if (and backward (progn (beginning-of-line)) (bobp)) | |
5236 nil | |
5237 (or first-too (forward-line way)) | |
5238 (while (and | |
5239 (not (eobp)) | |
5240 (not (setq | |
5241 found | |
5242 (and (or all | |
5243 (and | |
5244 (let ((unread | |
5245 (get-text-property (point) 'gnus-unread))) | |
5246 (and (numberp unread) (> unread 0))) | |
5247 (setq lev (get-text-property (point) | |
5248 'gnus-level)) | |
5249 (<= lev gnus-level-subscribed))) | |
5250 (or (not level) | |
5251 (and (setq lev (get-text-property (point) | |
5252 'gnus-level)) | |
5253 (or (= lev level) | |
5254 (and (< lev low) | |
5255 (< level lev) | |
5256 (progn | |
5257 (setq low lev) | |
5258 (setq pos (point)) | |
5259 nil)))))))) | |
5260 (zerop (forward-line way))))) | |
5261 (if found | |
5262 (progn (gnus-group-position-point) t) | |
5263 (goto-char (or pos beg)) | |
5264 (and pos t)))) | |
5265 | |
5266 ;;; Gnus group mode commands | |
5267 | |
5268 ;; Group marking. | |
5269 | |
5270 (defun gnus-group-mark-group (n &optional unmark no-advance) | |
5271 "Mark the current group." | |
5272 (interactive "p") | |
5273 (let ((buffer-read-only nil) | |
5274 group) | |
5275 (while (and (> n 0) | |
5276 (not (eobp))) | |
5277 (when (setq group (gnus-group-group-name)) | |
5278 ;; Update the mark. | |
5279 (beginning-of-line) | |
5280 (forward-char | |
5281 (or (cdr (assq 'process gnus-group-mark-positions)) 2)) | |
5282 (delete-char 1) | |
5283 (if unmark | |
5284 (progn | |
5285 (insert " ") | |
5286 (setq gnus-group-marked (delete group gnus-group-marked))) | |
5287 (insert "#") | |
5288 (setq gnus-group-marked | |
5289 (cons group (delete group gnus-group-marked))))) | |
5290 (or no-advance (gnus-group-next-group 1)) | |
5291 (decf n)) | |
5292 (gnus-summary-position-point) | |
5293 n)) | |
5294 | |
5295 (defun gnus-group-unmark-group (n) | |
5296 "Remove the mark from the current group." | |
5297 (interactive "p") | |
5298 (gnus-group-mark-group n 'unmark) | |
5299 (gnus-group-position-point)) | |
5300 | |
5301 (defun gnus-group-unmark-all-groups () | |
5302 "Unmark all groups." | |
5303 (interactive) | |
5304 (let ((groups gnus-group-marked)) | |
5305 (save-excursion | |
5306 (while groups | |
5307 (gnus-group-remove-mark (pop groups))))) | |
5308 (gnus-group-position-point)) | |
5309 | |
5310 (defun gnus-group-mark-region (unmark beg end) | |
5311 "Mark all groups between point and mark. | |
5312 If UNMARK, remove the mark instead." | |
5313 (interactive "P\nr") | |
5314 (let ((num (count-lines beg end))) | |
5315 (save-excursion | |
5316 (goto-char beg) | |
5317 (- num (gnus-group-mark-group num unmark))))) | |
5318 | |
5319 (defun gnus-group-mark-buffer (&optional unmark) | |
5320 "Mark all groups in the buffer. | |
5321 If UNMARK, remove the mark instead." | |
5322 (interactive "P") | |
5323 (gnus-group-mark-region unmark (point-min) (point-max))) | |
5324 | |
5325 (defun gnus-group-mark-regexp (regexp) | |
5326 "Mark all groups that match some regexp." | |
5327 (interactive "sMark (regexp): ") | |
5328 (let ((alist (cdr gnus-newsrc-alist)) | |
5329 group) | |
5330 (while alist | |
5331 (when (string-match regexp (setq group (gnus-info-group (pop alist)))) | |
5332 (gnus-group-set-mark group)))) | |
5333 (gnus-group-position-point)) | |
5334 | |
5335 (defun gnus-group-remove-mark (group) | |
5336 "Remove the process mark from GROUP and move point there. | |
5337 Return nil if the group isn't displayed." | |
5338 (if (gnus-group-goto-group group) | |
5339 (save-excursion | |
5340 (gnus-group-mark-group 1 'unmark t) | |
5341 t) | |
5342 (setq gnus-group-marked | |
5343 (delete group gnus-group-marked)) | |
5344 nil)) | |
5345 | |
5346 (defun gnus-group-set-mark (group) | |
5347 "Set the process mark on GROUP." | |
5348 (if (gnus-group-goto-group group) | |
5349 (save-excursion | |
5350 (gnus-group-mark-group 1 nil t)) | |
5351 (setq gnus-group-marked (cons group (delete group gnus-group-marked))))) | |
5352 | |
5353 (defun gnus-group-universal-argument (arg &optional groups func) | |
5354 "Perform any command on all groups accoring to the process/prefix convention." | |
5355 (interactive "P") | |
5356 (let ((groups (or groups (gnus-group-process-prefix arg))) | |
5357 group func) | |
5358 (if (eq (setq func (or func | |
5359 (key-binding | |
5360 (read-key-sequence | |
5361 (substitute-command-keys | |
5362 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]"))))) | |
5363 'undefined) | |
5364 (gnus-error 1 "Undefined key") | |
5365 (while groups | |
5366 (gnus-group-remove-mark (setq group (pop groups))) | |
5367 (command-execute func)))) | |
5368 (gnus-group-position-point)) | |
5369 | |
5370 (defun gnus-group-process-prefix (n) | |
5371 "Return a list of groups to work on. | |
5372 Take into consideration N (the prefix) and the list of marked groups." | |
5373 (cond | |
5374 (n | |
5375 (setq n (prefix-numeric-value n)) | |
5376 ;; There is a prefix, so we return a list of the N next | |
5377 ;; groups. | |
5378 (let ((way (if (< n 0) -1 1)) | |
5379 (n (abs n)) | |
5380 group groups) | |
5381 (save-excursion | |
5382 (while (and (> n 0) | |
5383 (setq group (gnus-group-group-name))) | |
5384 (setq groups (cons group groups)) | |
5385 (setq n (1- n)) | |
5386 (gnus-group-next-group way))) | |
5387 (nreverse groups))) | |
5388 ((and (boundp 'transient-mark-mode) | |
5389 transient-mark-mode | |
5390 (boundp 'mark-active) | |
5391 mark-active) | |
5392 ;; Work on the region between point and mark. | |
5393 (let ((max (max (point) (mark))) | |
5394 groups) | |
5395 (save-excursion | |
5396 (goto-char (min (point) (mark))) | |
5397 (while | |
5398 (and | |
5399 (push (gnus-group-group-name) groups) | |
5400 (zerop (gnus-group-next-group 1)) | |
5401 (< (point) max))) | |
5402 (nreverse groups)))) | |
5403 (gnus-group-marked | |
5404 ;; No prefix, but a list of marked articles. | |
5405 (reverse gnus-group-marked)) | |
5406 (t | |
5407 ;; Neither marked articles or a prefix, so we return the | |
5408 ;; current group. | |
5409 (let ((group (gnus-group-group-name))) | |
5410 (and group (list group)))))) | |
5411 | |
5412 ;; Selecting groups. | |
5413 | |
5414 (defun gnus-group-read-group (&optional all no-article group) | |
5415 "Read news in this newsgroup. | |
5416 If the prefix argument ALL is non-nil, already read articles become | |
5417 readable. IF ALL is a number, fetch this number of articles. If the | |
5418 optional argument NO-ARTICLE is non-nil, no article will be | |
5419 auto-selected upon group entry. If GROUP is non-nil, fetch that | |
5420 group." | |
5421 (interactive "P") | |
5422 (let ((group (or group (gnus-group-group-name))) | |
5423 number active marked entry) | |
5424 (or group (error "No group on current line")) | |
5425 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash | |
5426 group gnus-newsrc-hashtb))))) | |
5427 ;; This group might be a dead group. In that case we have to get | |
5428 ;; the number of unread articles from `gnus-active-hashtb'. | |
5429 (setq number | |
5430 (cond ((numberp all) all) | |
5431 (entry (car entry)) | |
5432 ((setq active (gnus-active group)) | |
5433 (- (1+ (cdr active)) (car active))))) | |
5434 (gnus-summary-read-group | |
5435 group (or all (and (numberp number) | |
5436 (zerop (+ number (gnus-range-length | |
5437 (cdr (assq 'tick marked))) | |
5438 (gnus-range-length | |
5439 (cdr (assq 'dormant marked))))))) | |
5440 no-article))) | |
5441 | |
5442 (defun gnus-group-select-group (&optional all) | |
5443 "Select this newsgroup. | |
5444 No article is selected automatically. | |
5445 If ALL is non-nil, already read articles become readable. | |
5446 If ALL is a number, fetch this number of articles." | |
5447 (interactive "P") | |
5448 (gnus-group-read-group all t)) | |
5449 | |
5450 (defun gnus-group-quick-select-group (&optional all) | |
5451 "Select the current group \"quickly\". | |
5452 This means that no highlighting or scoring will be performed." | |
5453 (interactive "P") | |
5454 (let (gnus-visual | |
5455 gnus-score-find-score-files-function | |
5456 gnus-apply-kill-hook | |
5457 gnus-summary-expunge-below) | |
5458 (gnus-group-read-group all t))) | |
5459 | |
5460 (defun gnus-group-visible-select-group (&optional all) | |
5461 "Select the current group without hiding any articles." | |
5462 (interactive "P") | |
5463 (let ((gnus-inhibit-limiting t)) | |
5464 (gnus-group-read-group all t))) | |
5465 | |
5466 ;;;###autoload | |
5467 (defun gnus-fetch-group (group) | |
5468 "Start Gnus if necessary and enter GROUP. | |
5469 Returns whether the fetching was successful or not." | |
5470 (interactive "sGroup name: ") | |
5471 (or (get-buffer gnus-group-buffer) | |
5472 (gnus)) | |
5473 (gnus-group-read-group nil nil group)) | |
5474 | |
5475 ;; Enter a group that is not in the group buffer. Non-nil is returned | |
5476 ;; if selection was successful. | |
5477 (defun gnus-group-read-ephemeral-group | |
5478 (group method &optional activate quit-config) | |
5479 (let ((group (if (gnus-group-foreign-p group) group | |
5480 (gnus-group-prefixed-name group method)))) | |
5481 (gnus-sethash | |
5482 group | |
5483 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method | |
5484 ((quit-config . ,(if quit-config quit-config | |
5485 (cons (current-buffer) 'summary)))))) | |
5486 gnus-newsrc-hashtb) | |
5487 (set-buffer gnus-group-buffer) | |
5488 (or (gnus-check-server method) | |
5489 (error "Unable to contact server: %s" (gnus-status-message method))) | |
5490 (if activate (or (gnus-request-group group) | |
5491 (error "Couldn't request group"))) | |
5492 (condition-case () | |
5493 (gnus-group-read-group t t group) | |
5494 (error nil) | |
5495 (quit nil)))) | |
5496 | |
5497 (defun gnus-group-jump-to-group (group) | |
5498 "Jump to newsgroup GROUP." | |
5499 (interactive | |
5500 (list (completing-read | |
5501 "Group: " gnus-active-hashtb nil | |
5502 (gnus-read-active-file-p) | |
5503 nil | |
5504 'gnus-group-history))) | |
5505 | |
5506 (when (equal group "") | |
5507 (error "Empty group name")) | |
5508 | |
5509 (when (string-match "[\000-\032]" group) | |
5510 (error "Control characters in group: %s" group)) | |
5511 | |
5512 (let ((b (text-property-any | |
5513 (point-min) (point-max) | |
5514 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))) | |
5515 (unless (gnus-ephemeral-group-p group) | |
5516 (if b | |
5517 ;; Either go to the line in the group buffer... | |
5518 (goto-char b) | |
5519 ;; ... or insert the line. | |
5520 (or | |
5521 t ;; Don't activate group. | |
5522 (gnus-active group) | |
5523 (gnus-activate-group group) | |
5524 (error "%s error: %s" group (gnus-status-message group))) | |
5525 | |
5526 (gnus-group-update-group group) | |
5527 (goto-char (text-property-any | |
5528 (point-min) (point-max) | |
5529 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))) | |
5530 ;; Adjust cursor point. | |
5531 (gnus-group-position-point))) | |
5532 | |
5533 (defun gnus-group-goto-group (group) | |
5534 "Goto to newsgroup GROUP." | |
5535 (when group | |
5536 ;; It's quite likely that we are on the right line, so | |
5537 ;; we check the current line first. | |
5538 (beginning-of-line) | |
5539 (if (eq (get-text-property (point) 'gnus-group) | |
5540 (gnus-intern-safe group gnus-active-hashtb)) | |
5541 (point) | |
5542 ;; Search through the entire buffer. | |
5543 (let ((b (text-property-any | |
5544 (point-min) (point-max) | |
5545 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))) | |
5546 (when b | |
5547 (goto-char b)))))) | |
5548 | |
5549 (defun gnus-group-next-group (n &optional silent) | |
5550 "Go to next N'th newsgroup. | |
5551 If N is negative, search backward instead. | |
5552 Returns the difference between N and the number of skips actually | |
5553 done." | |
5554 (interactive "p") | |
5555 (gnus-group-next-unread-group n t nil silent)) | |
5556 | |
5557 (defun gnus-group-next-unread-group (n &optional all level silent) | |
5558 "Go to next N'th unread newsgroup. | |
5559 If N is negative, search backward instead. | |
5560 If ALL is non-nil, choose any newsgroup, unread or not. | |
5561 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no | |
5562 such group can be found, the next group with a level higher than | |
5563 LEVEL. | |
5564 Returns the difference between N and the number of skips actually | |
5565 made." | |
5566 (interactive "p") | |
5567 (let ((backward (< n 0)) | |
5568 (n (abs n))) | |
5569 (while (and (> n 0) | |
5570 (gnus-group-search-forward | |
5571 backward (or (not gnus-group-goto-unread) all) level)) | |
5572 (setq n (1- n))) | |
5573 (when (and (/= 0 n) | |
5574 (not silent)) | |
5575 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread") | |
5576 (if level " on this level or higher" ""))) | |
5577 n)) | |
5578 | |
5579 (defun gnus-group-prev-group (n) | |
5580 "Go to previous N'th newsgroup. | |
5581 Returns the difference between N and the number of skips actually | |
5582 done." | |
5583 (interactive "p") | |
5584 (gnus-group-next-unread-group (- n) t)) | |
5585 | |
5586 (defun gnus-group-prev-unread-group (n) | |
5587 "Go to previous N'th unread newsgroup. | |
5588 Returns the difference between N and the number of skips actually | |
5589 done." | |
5590 (interactive "p") | |
5591 (gnus-group-next-unread-group (- n))) | |
5592 | |
5593 (defun gnus-group-next-unread-group-same-level (n) | |
5594 "Go to next N'th unread newsgroup on the same level. | |
5595 If N is negative, search backward instead. | |
5596 Returns the difference between N and the number of skips actually | |
5597 done." | |
5598 (interactive "p") | |
5599 (gnus-group-next-unread-group n t (gnus-group-group-level)) | |
5600 (gnus-group-position-point)) | |
5601 | |
5602 (defun gnus-group-prev-unread-group-same-level (n) | |
5603 "Go to next N'th unread newsgroup on the same level. | |
5604 Returns the difference between N and the number of skips actually | |
5605 done." | |
5606 (interactive "p") | |
5607 (gnus-group-next-unread-group (- n) t (gnus-group-group-level)) | |
5608 (gnus-group-position-point)) | |
5609 | |
5610 (defun gnus-group-best-unread-group (&optional exclude-group) | |
5611 "Go to the group with the highest level. | |
5612 If EXCLUDE-GROUP, do not go to that group." | |
5613 (interactive) | |
5614 (goto-char (point-min)) | |
5615 (let ((best 100000) | |
5616 unread best-point) | |
5617 (while (not (eobp)) | |
5618 (setq unread (get-text-property (point) 'gnus-unread)) | |
5619 (if (and (numberp unread) (> unread 0)) | |
5620 (progn | |
5621 (if (and (get-text-property (point) 'gnus-level) | |
5622 (< (get-text-property (point) 'gnus-level) best) | |
5623 (or (not exclude-group) | |
5624 (not (equal exclude-group (gnus-group-group-name))))) | |
5625 (progn | |
5626 (setq best (get-text-property (point) 'gnus-level)) | |
5627 (setq best-point (point)))))) | |
5628 (forward-line 1)) | |
5629 (if best-point (goto-char best-point)) | |
5630 (gnus-summary-position-point) | |
5631 (and best-point (gnus-group-group-name)))) | |
5632 | |
5633 (defun gnus-group-first-unread-group () | |
5634 "Go to the first group with unread articles." | |
5635 (interactive) | |
5636 (prog1 | |
5637 (let ((opoint (point)) | |
5638 unread) | |
5639 (goto-char (point-min)) | |
5640 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active. | |
5641 (and (numberp unread) ; Not a topic. | |
5642 (not (zerop unread))) ; Has unread articles. | |
5643 (zerop (gnus-group-next-unread-group 1))) ; Next unread group. | |
5644 (point) ; Success. | |
5645 (goto-char opoint) | |
5646 nil)) ; Not success. | |
5647 (gnus-group-position-point))) | |
5648 | |
5649 (defun gnus-group-enter-server-mode () | |
5650 "Jump to the server buffer." | |
5651 (interactive) | |
5652 (gnus-enter-server-buffer)) | |
5653 | |
5654 (defun gnus-group-make-group (name &optional method address) | |
5655 "Add a new newsgroup. | |
5656 The user will be prompted for a NAME, for a select METHOD, and an | |
5657 ADDRESS." | |
5658 (interactive | |
5659 (cons | |
5660 (read-string "Group name: ") | |
5661 (let ((method | |
5662 (completing-read | |
5663 "Method: " (append gnus-valid-select-methods gnus-server-alist) | |
5664 nil t nil 'gnus-method-history))) | |
5665 (cond | |
5666 ((equal method "") | |
5667 (setq method gnus-select-method)) | |
5668 ((assoc method gnus-valid-select-methods) | |
5669 (list method | |
5670 (if (memq 'prompt-address | |
5671 (assoc method gnus-valid-select-methods)) | |
5672 (read-string "Address: ") | |
5673 ""))) | |
5674 ((assoc method gnus-server-alist) | |
5675 (list method)) | |
5676 (t | |
5677 (list method "")))))) | |
5678 | |
5679 (let* ((meth (when (and method | |
5680 (not (gnus-server-equal method gnus-select-method))) | |
5681 (if address (list (intern method) address) | |
5682 method))) | |
5683 (nname (if method (gnus-group-prefixed-name name meth) name)) | |
5684 backend info) | |
5685 (when (gnus-gethash nname gnus-newsrc-hashtb) | |
5686 (error "Group %s already exists" nname)) | |
5687 ;; Subscribe to the new group. | |
5688 (gnus-group-change-level | |
5689 (setq info (list t nname gnus-level-default-subscribed nil nil meth)) | |
5690 gnus-level-default-subscribed gnus-level-killed | |
5691 (and (gnus-group-group-name) | |
5692 (gnus-gethash (gnus-group-group-name) | |
5693 gnus-newsrc-hashtb)) | |
5694 t) | |
5695 ;; Make it active. | |
5696 (gnus-set-active nname (cons 1 0)) | |
5697 (or (gnus-ephemeral-group-p name) | |
5698 (gnus-dribble-enter | |
5699 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))) | |
5700 ;; Insert the line. | |
5701 (gnus-group-insert-group-line-info nname) | |
5702 (forward-line -1) | |
5703 (gnus-group-position-point) | |
5704 | |
5705 ;; Load the backend and try to make the backend create | |
5706 ;; the group as well. | |
5707 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method | |
5708 nil meth)))) | |
5709 gnus-valid-select-methods) | |
5710 (require backend)) | |
5711 (gnus-check-server meth) | |
5712 (and (gnus-check-backend-function 'request-create-group nname) | |
5713 (gnus-request-create-group nname)) | |
5714 t)) | |
5715 | |
5716 (defun gnus-group-delete-group (group &optional force) | |
5717 "Delete the current group. Only meaningful with mail groups. | |
5718 If FORCE (the prefix) is non-nil, all the articles in the group will | |
5719 be deleted. This is \"deleted\" as in \"removed forever from the face | |
5720 of the Earth\". There is no undo. The user will be prompted before | |
5721 doing the deletion." | |
5722 (interactive | |
5723 (list (gnus-group-group-name) | |
5724 current-prefix-arg)) | |
5725 (or group (error "No group to rename")) | |
5726 (or (gnus-check-backend-function 'request-delete-group group) | |
5727 (error "This backend does not support group deletion")) | |
5728 (prog1 | |
5729 (if (not (gnus-yes-or-no-p | |
5730 (format | |
5731 "Do you really want to delete %s%s? " | |
5732 group (if force " and all its contents" "")))) | |
5733 () ; Whew! | |
5734 (gnus-message 6 "Deleting group %s..." group) | |
5735 (if (not (gnus-request-delete-group group force)) | |
5736 (gnus-error 3 "Couldn't delete group %s" group) | |
5737 (gnus-message 6 "Deleting group %s...done" group) | |
5738 (gnus-group-goto-group group) | |
5739 (gnus-group-kill-group 1 t) | |
5740 (gnus-sethash group nil gnus-active-hashtb) | |
5741 t)) | |
5742 (gnus-group-position-point))) | |
5743 | |
5744 (defun gnus-group-rename-group (group new-name) | |
5745 (interactive | |
5746 (list | |
5747 (gnus-group-group-name) | |
5748 (progn | |
5749 (or (gnus-check-backend-function | |
5750 'request-rename-group (gnus-group-group-name)) | |
5751 (error "This backend does not support renaming groups")) | |
5752 (read-string "New group name: ")))) | |
5753 | |
5754 (or (gnus-check-backend-function 'request-rename-group group) | |
5755 (error "This backend does not support renaming groups")) | |
5756 | |
5757 (or group (error "No group to rename")) | |
5758 (and (string-match "^[ \t]*$" new-name) | |
5759 (error "Not a valid group name")) | |
5760 | |
5761 ;; We find the proper prefixed name. | |
5762 (setq new-name | |
5763 (if (equal (gnus-group-real-name new-name) new-name) | |
5764 ;; Native group. | |
5765 new-name | |
5766 ;; Foreign group. | |
5767 (gnus-group-prefixed-name | |
5768 (gnus-group-real-name new-name) | |
5769 (gnus-info-method (gnus-get-info group))))) | |
5770 | |
5771 (gnus-message 6 "Renaming group %s to %s..." group new-name) | |
5772 (prog1 | |
5773 (if (not (gnus-request-rename-group group new-name)) | |
5774 (gnus-error 3 "Couldn't rename group %s to %s" group new-name) | |
5775 ;; We rename the group internally by killing it... | |
5776 (gnus-group-goto-group group) | |
5777 (gnus-group-kill-group) | |
5778 ;; ... changing its name ... | |
5779 (setcar (cdar gnus-list-of-killed-groups) new-name) | |
5780 ;; ... and then yanking it. Magic! | |
5781 (gnus-group-yank-group) | |
5782 (gnus-set-active new-name (gnus-active group)) | |
5783 (gnus-message 6 "Renaming group %s to %s...done" group new-name) | |
5784 new-name) | |
5785 (gnus-group-position-point))) | |
5786 | |
5787 (defun gnus-group-edit-group (group &optional part) | |
5788 "Edit the group on the current line." | |
5789 (interactive (list (gnus-group-group-name))) | |
5790 (let* ((part (or part 'info)) | |
5791 (done-func `(lambda () | |
5792 "Exit editing mode and update the information." | |
5793 (interactive) | |
5794 (gnus-group-edit-group-done ',part ,group))) | |
5795 (winconf (current-window-configuration)) | |
5796 info) | |
5797 (or group (error "No group on current line")) | |
5798 (or (setq info (gnus-get-info group)) | |
5799 (error "Killed group; can't be edited")) | |
5800 (set-buffer (setq gnus-group-edit-buffer | |
5801 (get-buffer-create | |
5802 (format "*Gnus edit %s*" group)))) | |
5803 (gnus-configure-windows 'edit-group) | |
5804 (gnus-add-current-to-buffer-list) | |
5805 (emacs-lisp-mode) | |
5806 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
5807 (use-local-map (copy-keymap emacs-lisp-mode-map)) | |
5808 (local-set-key "\C-c\C-c" done-func) | |
5809 (make-local-variable 'gnus-prev-winconf) | |
5810 (setq gnus-prev-winconf winconf) | |
5811 (erase-buffer) | |
5812 (insert | |
5813 (cond | |
5814 ((eq part 'method) | |
5815 ";; Type `C-c C-c' after editing the select method.\n\n") | |
5816 ((eq part 'params) | |
5817 ";; Type `C-c C-c' after editing the group parameters.\n\n") | |
5818 ((eq part 'info) | |
5819 ";; Type `C-c C-c' after editing the group info.\n\n"))) | |
5820 (insert | |
5821 (pp-to-string | |
5822 (cond ((eq part 'method) | |
5823 (or (gnus-info-method info) "native")) | |
5824 ((eq part 'params) | |
5825 (gnus-info-params info)) | |
5826 (t info))) | |
5827 "\n"))) | |
5828 | |
5829 (defun gnus-group-edit-group-method (group) | |
5830 "Edit the select method of GROUP." | |
5831 (interactive (list (gnus-group-group-name))) | |
5832 (gnus-group-edit-group group 'method)) | |
5833 | |
5834 (defun gnus-group-edit-group-parameters (group) | |
5835 "Edit the group parameters of GROUP." | |
5836 (interactive (list (gnus-group-group-name))) | |
5837 (gnus-group-edit-group group 'params)) | |
5838 | |
5839 (defun gnus-group-edit-group-done (part group) | |
5840 "Get info from buffer, update variables and jump to the group buffer." | |
5841 (when (and gnus-group-edit-buffer | |
5842 (buffer-name gnus-group-edit-buffer)) | |
5843 (set-buffer gnus-group-edit-buffer) | |
5844 (goto-char (point-min)) | |
5845 (let* ((form (read (current-buffer))) | |
5846 (winconf gnus-prev-winconf) | |
5847 (method (cond ((eq part 'info) (nth 4 form)) | |
5848 ((eq part 'method) form) | |
5849 (t nil))) | |
5850 (info (cond ((eq part 'info) form) | |
5851 ((eq part 'method) (gnus-get-info group)) | |
5852 (t nil))) | |
5853 (new-group (if info | |
5854 (if (or (not method) | |
5855 (gnus-server-equal | |
5856 gnus-select-method method)) | |
5857 (gnus-group-real-name (car info)) | |
5858 (gnus-group-prefixed-name | |
5859 (gnus-group-real-name (car info)) method)) | |
5860 nil))) | |
5861 (when (and new-group | |
5862 (not (equal new-group group))) | |
5863 (when (gnus-group-goto-group group) | |
5864 (gnus-group-kill-group 1)) | |
5865 (gnus-activate-group new-group)) | |
5866 ;; Set the info. | |
5867 (if (and info new-group) | |
5868 (progn | |
5869 (setq info (gnus-copy-sequence info)) | |
5870 (setcar info new-group) | |
5871 (unless (gnus-server-equal method "native") | |
5872 (unless (nthcdr 3 info) | |
5873 (nconc info (list nil nil))) | |
5874 (unless (nthcdr 4 info) | |
5875 (nconc info (list nil))) | |
5876 (gnus-info-set-method info method)) | |
5877 (gnus-group-set-info info)) | |
5878 (gnus-group-set-info form (or new-group group) part)) | |
5879 (kill-buffer (current-buffer)) | |
5880 (and winconf (set-window-configuration winconf)) | |
5881 (set-buffer gnus-group-buffer) | |
5882 (gnus-group-update-group (or new-group group)) | |
5883 (gnus-group-position-point)))) | |
5884 | |
5885 (defun gnus-group-make-help-group () | |
5886 "Create the Gnus documentation group." | |
5887 (interactive) | |
5888 (let ((path load-path) | |
5889 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help"))) | |
5890 file dir) | |
5891 (and (gnus-gethash name gnus-newsrc-hashtb) | |
5892 (error "Documentation group already exists")) | |
5893 (while path | |
5894 (setq dir (file-name-as-directory (expand-file-name (pop path))) | |
5895 file nil) | |
5896 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt"))) | |
5897 (file-exists-p | |
5898 (setq file (concat (file-name-directory | |
5899 (directory-file-name dir)) | |
5900 "etc/gnus-tut.txt")))) | |
5901 (setq path nil))) | |
5902 (if (not file) | |
5903 (gnus-message 1 "Couldn't find doc group") | |
5904 (gnus-group-make-group | |
5905 (gnus-group-real-name name) | |
5906 (list 'nndoc "gnus-help" | |
5907 (list 'nndoc-address file) | |
5908 (list 'nndoc-article-type 'mbox))))) | |
5909 (gnus-group-position-point)) | |
5910 | |
5911 (defun gnus-group-make-doc-group (file type) | |
5912 "Create a group that uses a single file as the source." | |
5913 (interactive | |
5914 (list (read-file-name "File name: ") | |
5915 (and current-prefix-arg 'ask))) | |
5916 (when (eq type 'ask) | |
5917 (let ((err "") | |
5918 char found) | |
5919 (while (not found) | |
5920 (message | |
5921 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: " | |
5922 err) | |
5923 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox) | |
5924 ((= char ?b) 'babyl) | |
5925 ((= char ?d) 'digest) | |
5926 ((= char ?f) 'forward) | |
5927 ((= char ?a) 'mmfd) | |
5928 (t (setq err (format "%c unknown. " char)) | |
5929 nil)))) | |
5930 (setq type found))) | |
5931 (let* ((file (expand-file-name file)) | |
5932 (name (gnus-generate-new-group-name | |
5933 (gnus-group-prefixed-name | |
5934 (file-name-nondirectory file) '(nndoc ""))))) | |
5935 (gnus-group-make-group | |
5936 (gnus-group-real-name name) | |
5937 (list 'nndoc (file-name-nondirectory file) | |
5938 (list 'nndoc-address file) | |
5939 (list 'nndoc-article-type (or type 'guess)))))) | |
5940 | |
5941 (defun gnus-group-make-archive-group (&optional all) | |
5942 "Create the (ding) Gnus archive group of the most recent articles. | |
5943 Given a prefix, create a full group." | |
5944 (interactive "P") | |
5945 (let ((group (gnus-group-prefixed-name | |
5946 (if all "ding.archives" "ding.recent") '(nndir "")))) | |
5947 (when (gnus-gethash group gnus-newsrc-hashtb) | |
5948 (error "Archive group already exists")) | |
5949 (gnus-group-make-group | |
5950 (gnus-group-real-name group) | |
5951 (list 'nndir (if all "hpc" "edu") | |
5952 (list 'nndir-directory | |
5953 (if all gnus-group-archive-directory | |
5954 gnus-group-recent-archive-directory)))) | |
5955 (gnus-group-add-parameter group (cons 'to-address "ding@ifi.uio.no")))) | |
5956 | |
5957 (defun gnus-group-make-directory-group (dir) | |
5958 "Create an nndir group. | |
5959 The user will be prompted for a directory. The contents of this | |
5960 directory will be used as a newsgroup. The directory should contain | |
5961 mail messages or news articles in files that have numeric names." | |
5962 (interactive | |
5963 (list (read-file-name "Create group from directory: "))) | |
5964 (or (file-exists-p dir) (error "No such directory")) | |
5965 (or (file-directory-p dir) (error "Not a directory")) | |
5966 (let ((ext "") | |
5967 (i 0) | |
5968 group) | |
5969 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb)) | |
5970 (setq group | |
5971 (gnus-group-prefixed-name | |
5972 (concat (file-name-as-directory (directory-file-name dir)) | |
5973 ext) | |
5974 '(nndir ""))) | |
5975 (setq ext (format "<%d>" (setq i (1+ i))))) | |
5976 (gnus-group-make-group | |
5977 (gnus-group-real-name group) | |
5978 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir))))) | |
5979 | |
5980 (defun gnus-group-make-kiboze-group (group address scores) | |
5981 "Create an nnkiboze group. | |
5982 The user will be prompted for a name, a regexp to match groups, and | |
5983 score file entries for articles to include in the group." | |
5984 (interactive | |
5985 (list | |
5986 (read-string "nnkiboze group name: ") | |
5987 (read-string "Source groups (regexp): ") | |
5988 (let ((headers (mapcar (lambda (group) (list group)) | |
5989 '("subject" "from" "number" "date" "message-id" | |
5990 "references" "chars" "lines" "xref" | |
5991 "followup" "all" "body" "head"))) | |
5992 scores header regexp regexps) | |
5993 (while (not (equal "" (setq header (completing-read | |
5994 "Match on header: " headers nil t)))) | |
5995 (setq regexps nil) | |
5996 (while (not (equal "" (setq regexp (read-string | |
5997 (format "Match on %s (string): " | |
5998 header))))) | |
5999 (setq regexps (cons (list regexp nil nil 'r) regexps))) | |
6000 (setq scores (cons (cons header regexps) scores))) | |
6001 scores))) | |
6002 (gnus-group-make-group group "nnkiboze" address) | |
6003 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group)) | |
6004 (let (emacs-lisp-mode-hook) | |
6005 (pp scores (current-buffer))))) | |
6006 | |
6007 (defun gnus-group-add-to-virtual (n vgroup) | |
6008 "Add the current group to a virtual group." | |
6009 (interactive | |
6010 (list current-prefix-arg | |
6011 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t | |
6012 "nnvirtual:"))) | |
6013 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual) | |
6014 (error "%s is not an nnvirtual group" vgroup)) | |
6015 (let* ((groups (gnus-group-process-prefix n)) | |
6016 (method (gnus-info-method (gnus-get-info vgroup)))) | |
6017 (setcar (cdr method) | |
6018 (concat | |
6019 (nth 1 method) "\\|" | |
6020 (mapconcat | |
6021 (lambda (s) | |
6022 (gnus-group-remove-mark s) | |
6023 (concat "\\(^" (regexp-quote s) "$\\)")) | |
6024 groups "\\|")))) | |
6025 (gnus-group-position-point)) | |
6026 | |
6027 (defun gnus-group-make-empty-virtual (group) | |
6028 "Create a new, fresh, empty virtual group." | |
6029 (interactive "sCreate new, empty virtual group: ") | |
6030 (let* ((method (list 'nnvirtual "^$")) | |
6031 (pgroup (gnus-group-prefixed-name group method))) | |
6032 ;; Check whether it exists already. | |
6033 (and (gnus-gethash pgroup gnus-newsrc-hashtb) | |
6034 (error "Group %s already exists." pgroup)) | |
6035 ;; Subscribe the new group after the group on the current line. | |
6036 (gnus-subscribe-group pgroup (gnus-group-group-name) method) | |
6037 (gnus-group-update-group pgroup) | |
6038 (forward-line -1) | |
6039 (gnus-group-position-point))) | |
6040 | |
6041 (defun gnus-group-enter-directory (dir) | |
6042 "Enter an ephemeral nneething group." | |
6043 (interactive "DDirectory to read: ") | |
6044 (let* ((method (list 'nneething dir '(nneething-read-only t))) | |
6045 (leaf (gnus-group-prefixed-name | |
6046 (file-name-nondirectory (directory-file-name dir)) | |
6047 method)) | |
6048 (name (gnus-generate-new-group-name leaf))) | |
6049 (unless (gnus-group-read-ephemeral-group | |
6050 name method t | |
6051 (cons (current-buffer) | |
6052 (if (eq major-mode 'gnus-summary-mode) | |
6053 'summary 'group))) | |
6054 (error "Couldn't enter %s" dir)))) | |
6055 | |
6056 ;; Group sorting commands | |
6057 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>. | |
6058 | |
6059 (defun gnus-group-sort-groups (func &optional reverse) | |
6060 "Sort the group buffer according to FUNC. | |
6061 If REVERSE, reverse the sorting order." | |
6062 (interactive (list gnus-group-sort-function | |
6063 current-prefix-arg)) | |
6064 (let ((func (cond | |
6065 ((not (listp func)) func) | |
6066 ((null func) func) | |
6067 ((= 1 (length func)) (car func)) | |
6068 (t `(lambda (t1 t2) | |
6069 ,(gnus-make-sort-function | |
6070 (reverse func))))))) | |
6071 ;; We peel off the dummy group from the alist. | |
6072 (when func | |
6073 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group") | |
6074 (pop gnus-newsrc-alist)) | |
6075 ;; Do the sorting. | |
6076 (setq gnus-newsrc-alist | |
6077 (sort gnus-newsrc-alist func)) | |
6078 (when reverse | |
6079 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))) | |
6080 ;; Regenerate the hash table. | |
6081 (gnus-make-hashtable-from-newsrc-alist) | |
6082 (gnus-group-list-groups)))) | |
6083 | |
6084 (defun gnus-group-sort-groups-by-alphabet (&optional reverse) | |
6085 "Sort the group buffer alphabetically by group name. | |
6086 If REVERSE, sort in reverse order." | |
6087 (interactive "P") | |
6088 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse)) | |
6089 | |
6090 (defun gnus-group-sort-groups-by-unread (&optional reverse) | |
6091 "Sort the group buffer by number of unread articles. | |
6092 If REVERSE, sort in reverse order." | |
6093 (interactive "P") | |
6094 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse)) | |
6095 | |
6096 (defun gnus-group-sort-groups-by-level (&optional reverse) | |
6097 "Sort the group buffer by group level. | |
6098 If REVERSE, sort in reverse order." | |
6099 (interactive "P") | |
6100 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse)) | |
6101 | |
6102 (defun gnus-group-sort-groups-by-score (&optional reverse) | |
6103 "Sort the group buffer by group score. | |
6104 If REVERSE, sort in reverse order." | |
6105 (interactive "P") | |
6106 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse)) | |
6107 | |
6108 (defun gnus-group-sort-groups-by-rank (&optional reverse) | |
6109 "Sort the group buffer by group rank. | |
6110 If REVERSE, sort in reverse order." | |
6111 (interactive "P") | |
6112 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse)) | |
6113 | |
6114 (defun gnus-group-sort-groups-by-method (&optional reverse) | |
6115 "Sort the group buffer alphabetically by backend name. | |
6116 If REVERSE, sort in reverse order." | |
6117 (interactive "P") | |
6118 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse)) | |
6119 | |
6120 (defun gnus-group-sort-by-alphabet (info1 info2) | |
6121 "Sort alphabetically." | |
6122 (string< (gnus-info-group info1) (gnus-info-group info2))) | |
6123 | |
6124 (defun gnus-group-sort-by-unread (info1 info2) | |
6125 "Sort by number of unread articles." | |
6126 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb))) | |
6127 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb)))) | |
6128 (< (or (and (numberp n1) n1) 0) | |
6129 (or (and (numberp n2) n2) 0)))) | |
6130 | |
6131 (defun gnus-group-sort-by-level (info1 info2) | |
6132 "Sort by level." | |
6133 (< (gnus-info-level info1) (gnus-info-level info2))) | |
6134 | |
6135 (defun gnus-group-sort-by-method (info1 info2) | |
6136 "Sort alphabetically by backend name." | |
6137 (string< (symbol-name (car (gnus-find-method-for-group | |
6138 (gnus-info-group info1) info1))) | |
6139 (symbol-name (car (gnus-find-method-for-group | |
6140 (gnus-info-group info2) info2))))) | |
6141 | |
6142 (defun gnus-group-sort-by-score (info1 info2) | |
6143 "Sort by group score." | |
6144 (< (gnus-info-score info1) (gnus-info-score info2))) | |
6145 | |
6146 (defun gnus-group-sort-by-rank (info1 info2) | |
6147 "Sort by level and score." | |
6148 (let ((level1 (gnus-info-level info1)) | |
6149 (level2 (gnus-info-level info2))) | |
6150 (or (< level1 level2) | |
6151 (and (= level1 level2) | |
6152 (> (gnus-info-score info1) (gnus-info-score info2)))))) | |
6153 | |
6154 ;; Group catching up. | |
6155 | |
6156 (defun gnus-group-clear-data (n) | |
6157 "Clear all marks and read ranges from the current group." | |
6158 (interactive "P") | |
6159 (let ((groups (gnus-group-process-prefix n)) | |
6160 group info) | |
6161 (while (setq group (pop groups)) | |
6162 (setq info (gnus-get-info group)) | |
6163 (gnus-info-set-read info nil) | |
6164 (when (gnus-info-marks info) | |
6165 (gnus-info-set-marks info nil)) | |
6166 (gnus-get-unread-articles-in-group info (gnus-active group) t) | |
6167 (when (gnus-group-goto-group group) | |
6168 (gnus-group-remove-mark group) | |
6169 (gnus-group-update-group-line))))) | |
6170 | |
6171 (defun gnus-group-catchup-current (&optional n all) | |
6172 "Mark all articles not marked as unread in current newsgroup as read. | |
6173 If prefix argument N is numeric, the ARG next newsgroups will be | |
6174 caught up. If ALL is non-nil, marked articles will also be marked as | |
6175 read. Cross references (Xref: header) of articles are ignored. | |
6176 The difference between N and actual number of newsgroups that were | |
6177 caught up is returned." | |
6178 (interactive "P") | |
6179 (unless (gnus-group-group-name) | |
6180 (error "No group on the current line")) | |
6181 (if (not (or (not gnus-interactive-catchup) ;Without confirmation? | |
6182 gnus-expert-user | |
6183 (gnus-y-or-n-p | |
6184 (if all | |
6185 "Do you really want to mark all articles as read? " | |
6186 "Mark all unread articles as read? ")))) | |
6187 n | |
6188 (let ((groups (gnus-group-process-prefix n)) | |
6189 (ret 0)) | |
6190 (while groups | |
6191 ;; Virtual groups have to be given special treatment. | |
6192 (let ((method (gnus-find-method-for-group (car groups)))) | |
6193 (if (eq 'nnvirtual (car method)) | |
6194 (nnvirtual-catchup-group | |
6195 (gnus-group-real-name (car groups)) (nth 1 method) all))) | |
6196 (gnus-group-remove-mark (car groups)) | |
6197 (if (>= (gnus-group-group-level) gnus-level-zombie) | |
6198 (gnus-message 2 "Dead groups can't be caught up") | |
6199 (if (prog1 | |
6200 (gnus-group-goto-group (car groups)) | |
6201 (gnus-group-catchup (car groups) all)) | |
6202 (gnus-group-update-group-line) | |
6203 (setq ret (1+ ret)))) | |
6204 (setq groups (cdr groups))) | |
6205 (gnus-group-next-unread-group 1) | |
6206 ret))) | |
6207 | |
6208 (defun gnus-group-catchup-current-all (&optional n) | |
6209 "Mark all articles in current newsgroup as read. | |
6210 Cross references (Xref: header) of articles are ignored." | |
6211 (interactive "P") | |
6212 (gnus-group-catchup-current n 'all)) | |
6213 | |
6214 (defun gnus-group-catchup (group &optional all) | |
6215 "Mark all articles in GROUP as read. | |
6216 If ALL is non-nil, all articles are marked as read. | |
6217 The return value is the number of articles that were marked as read, | |
6218 or nil if no action could be taken." | |
6219 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
6220 (num (car entry))) | |
6221 ;; Do the updating only if the newsgroup isn't killed. | |
6222 (if (not (numberp (car entry))) | |
6223 (gnus-message 1 "Can't catch up; non-active group") | |
6224 ;; Do auto-expirable marks if that's required. | |
6225 (when (gnus-group-auto-expirable-p group) | |
6226 (gnus-add-marked-articles | |
6227 group 'expire (gnus-list-of-unread-articles group)) | |
6228 (when all | |
6229 (let ((marks (nth 3 (nth 2 entry)))) | |
6230 (gnus-add-marked-articles | |
6231 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))) | |
6232 (gnus-add-marked-articles | |
6233 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))))) | |
6234 (when entry | |
6235 (gnus-update-read-articles group nil) | |
6236 ;; Also nix out the lists of marks and dormants. | |
6237 (when all | |
6238 (gnus-add-marked-articles group 'tick nil nil 'force) | |
6239 (gnus-add-marked-articles group 'dormant nil nil 'force)) | |
6240 (run-hooks 'gnus-group-catchup-group-hook) | |
6241 num)))) | |
6242 | |
6243 (defun gnus-group-expire-articles (&optional n) | |
6244 "Expire all expirable articles in the current newsgroup." | |
6245 (interactive "P") | |
6246 (let ((groups (gnus-group-process-prefix n)) | |
6247 group) | |
6248 (unless groups | |
6249 (error "No groups to expire")) | |
6250 (while (setq group (pop groups)) | |
6251 (gnus-group-remove-mark group) | |
6252 (when (gnus-check-backend-function 'request-expire-articles group) | |
6253 (gnus-message 6 "Expiring articles in %s..." group) | |
6254 (let* ((info (gnus-get-info group)) | |
6255 (expirable (if (gnus-group-total-expirable-p group) | |
6256 (cons nil (gnus-list-of-read-articles group)) | |
6257 (assq 'expire (gnus-info-marks info)))) | |
6258 (expiry-wait (gnus-group-get-parameter group 'expiry-wait))) | |
6259 (when expirable | |
6260 (setcdr | |
6261 expirable | |
6262 (gnus-compress-sequence | |
6263 (if expiry-wait | |
6264 ;; We set the expiry variables to the groupp | |
6265 ;; parameter. | |
6266 (let ((nnmail-expiry-wait-function nil) | |
6267 (nnmail-expiry-wait expiry-wait)) | |
6268 (gnus-request-expire-articles | |
6269 (gnus-uncompress-sequence (cdr expirable)) group)) | |
6270 ;; Just expire using the normal expiry values. | |
6271 (gnus-request-expire-articles | |
6272 (gnus-uncompress-sequence (cdr expirable)) group)))) | |
6273 (gnus-close-group group)) | |
6274 (gnus-message 6 "Expiring articles in %s...done" group))) | |
6275 (gnus-group-position-point)))) | |
6276 | |
6277 (defun gnus-group-expire-all-groups () | |
6278 "Expire all expirable articles in all newsgroups." | |
6279 (interactive) | |
6280 (save-excursion | |
6281 (gnus-message 5 "Expiring...") | |
6282 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info)) | |
6283 (cdr gnus-newsrc-alist)))) | |
6284 (gnus-group-expire-articles nil))) | |
6285 (gnus-group-position-point) | |
6286 (gnus-message 5 "Expiring...done")) | |
6287 | |
6288 (defun gnus-group-set-current-level (n level) | |
6289 "Set the level of the next N groups to LEVEL." | |
6290 (interactive | |
6291 (list | |
6292 current-prefix-arg | |
6293 (string-to-int | |
6294 (let ((s (read-string | |
6295 (format "Level (default %s): " | |
6296 (or (gnus-group-group-level) | |
6297 gnus-level-default-subscribed))))) | |
6298 (if (string-match "^\\s-*$" s) | |
6299 (int-to-string (or (gnus-group-group-level) | |
6300 gnus-level-default-subscribed)) | |
6301 s))))) | |
6302 (or (and (>= level 1) (<= level gnus-level-killed)) | |
6303 (error "Illegal level: %d" level)) | |
6304 (let ((groups (gnus-group-process-prefix n)) | |
6305 group) | |
6306 (while (setq group (pop groups)) | |
6307 (gnus-group-remove-mark group) | |
6308 (gnus-message 6 "Changed level of %s from %d to %d" | |
6309 group (or (gnus-group-group-level) gnus-level-killed) | |
6310 level) | |
6311 (gnus-group-change-level | |
6312 group level (or (gnus-group-group-level) gnus-level-killed)) | |
6313 (gnus-group-update-group-line))) | |
6314 (gnus-group-position-point)) | |
6315 | |
6316 (defun gnus-group-unsubscribe-current-group (&optional n) | |
6317 "Toggle subscription of the current group. | |
6318 If given numerical prefix, toggle the N next groups." | |
6319 (interactive "P") | |
6320 (let ((groups (gnus-group-process-prefix n)) | |
6321 group) | |
6322 (while groups | |
6323 (setq group (car groups) | |
6324 groups (cdr groups)) | |
6325 (gnus-group-remove-mark group) | |
6326 (gnus-group-unsubscribe-group | |
6327 group (if (<= (gnus-group-group-level) gnus-level-subscribed) | |
6328 gnus-level-default-unsubscribed | |
6329 gnus-level-default-subscribed) t) | |
6330 (gnus-group-update-group-line)) | |
6331 (gnus-group-next-group 1))) | |
6332 | |
6333 (defun gnus-group-unsubscribe-group (group &optional level silent) | |
6334 "Toggle subscription to GROUP. | |
6335 Killed newsgroups are subscribed. If SILENT, don't try to update the | |
6336 group line." | |
6337 (interactive | |
6338 (list (completing-read | |
6339 "Group: " gnus-active-hashtb nil | |
6340 (gnus-read-active-file-p) | |
6341 nil | |
6342 'gnus-group-history))) | |
6343 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb))) | |
6344 (cond | |
6345 ((string-match "^[ \t]$" group) | |
6346 (error "Empty group name")) | |
6347 (newsrc | |
6348 ;; Toggle subscription flag. | |
6349 (gnus-group-change-level | |
6350 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc)) | |
6351 gnus-level-subscribed) | |
6352 (1+ gnus-level-subscribed) | |
6353 gnus-level-default-subscribed))) | |
6354 (unless silent | |
6355 (gnus-group-update-group group))) | |
6356 ((and (stringp group) | |
6357 (or (not (gnus-read-active-file-p)) | |
6358 (gnus-active group))) | |
6359 ;; Add new newsgroup. | |
6360 (gnus-group-change-level | |
6361 group | |
6362 (if level level gnus-level-default-subscribed) | |
6363 (or (and (member group gnus-zombie-list) | |
6364 gnus-level-zombie) | |
6365 gnus-level-killed) | |
6366 (and (gnus-group-group-name) | |
6367 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb))) | |
6368 (unless silent | |
6369 (gnus-group-update-group group))) | |
6370 (t (error "No such newsgroup: %s" group))) | |
6371 (gnus-group-position-point))) | |
6372 | |
6373 (defun gnus-group-transpose-groups (n) | |
6374 "Move the current newsgroup up N places. | |
6375 If given a negative prefix, move down instead. The difference between | |
6376 N and the number of steps taken is returned." | |
6377 (interactive "p") | |
6378 (or (gnus-group-group-name) | |
6379 (error "No group on current line")) | |
6380 (gnus-group-kill-group 1) | |
6381 (prog1 | |
6382 (forward-line (- n)) | |
6383 (gnus-group-yank-group) | |
6384 (gnus-group-position-point))) | |
6385 | |
6386 (defun gnus-group-kill-all-zombies () | |
6387 "Kill all zombie newsgroups." | |
6388 (interactive) | |
6389 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list)) | |
6390 (setq gnus-zombie-list nil) | |
6391 (gnus-group-list-groups)) | |
6392 | |
6393 (defun gnus-group-kill-region (begin end) | |
6394 "Kill newsgroups in current region (excluding current point). | |
6395 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]." | |
6396 (interactive "r") | |
6397 (let ((lines | |
6398 ;; Count lines. | |
6399 (save-excursion | |
6400 (count-lines | |
6401 (progn | |
6402 (goto-char begin) | |
6403 (beginning-of-line) | |
6404 (point)) | |
6405 (progn | |
6406 (goto-char end) | |
6407 (beginning-of-line) | |
6408 (point)))))) | |
6409 (goto-char begin) | |
6410 (beginning-of-line) ;Important when LINES < 1 | |
6411 (gnus-group-kill-group lines))) | |
6412 | |
6413 (defun gnus-group-kill-group (&optional n discard) | |
6414 "Kill the next N groups. | |
6415 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]. | |
6416 However, only groups that were alive can be yanked; already killed | |
6417 groups or zombie groups can't be yanked. | |
6418 The return value is the name of the group that was killed, or a list | |
6419 of groups killed." | |
6420 (interactive "P") | |
6421 (let ((buffer-read-only nil) | |
6422 (groups (gnus-group-process-prefix n)) | |
6423 group entry level out) | |
6424 (if (< (length groups) 10) | |
6425 ;; This is faster when there are few groups. | |
6426 (while groups | |
6427 (push (setq group (pop groups)) out) | |
6428 (gnus-group-remove-mark group) | |
6429 (setq level (gnus-group-group-level)) | |
6430 (gnus-delete-line) | |
6431 (when (and (not discard) | |
6432 (setq entry (gnus-gethash group gnus-newsrc-hashtb))) | |
6433 (push (cons (car entry) (nth 2 entry)) | |
6434 gnus-list-of-killed-groups)) | |
6435 (gnus-group-change-level | |
6436 (if entry entry group) gnus-level-killed (if entry nil level))) | |
6437 ;; If there are lots and lots of groups to be killed, we use | |
6438 ;; this thing instead. | |
6439 (let (entry) | |
6440 (setq groups (nreverse groups)) | |
6441 (while groups | |
6442 (gnus-group-remove-mark (setq group (pop groups))) | |
6443 (gnus-delete-line) | |
6444 (push group gnus-killed-list) | |
6445 (setq gnus-newsrc-alist | |
6446 (delq (assoc group gnus-newsrc-alist) | |
6447 gnus-newsrc-alist)) | |
6448 (when gnus-group-change-level-function | |
6449 (funcall gnus-group-change-level-function group 9 3)) | |
6450 (cond | |
6451 ((setq entry (gnus-gethash group gnus-newsrc-hashtb)) | |
6452 (push (cons (car entry) (nth 2 entry)) | |
6453 gnus-list-of-killed-groups) | |
6454 (setcdr (cdr entry) (cdddr entry))) | |
6455 ((member group gnus-zombie-list) | |
6456 (setq gnus-zombie-list (delete group gnus-zombie-list))))) | |
6457 (gnus-make-hashtable-from-newsrc-alist))) | |
6458 | |
6459 (gnus-group-position-point) | |
6460 (if (< (length out) 2) (car out) (nreverse out)))) | |
6461 | |
6462 (defun gnus-group-yank-group (&optional arg) | |
6463 "Yank the last newsgroups killed with \\[gnus-group-kill-group], | |
6464 inserting it before the current newsgroup. The numeric ARG specifies | |
6465 how many newsgroups are to be yanked. The name of the newsgroup yanked | |
6466 is returned, or (if several groups are yanked) a list of yanked groups | |
6467 is returned." | |
6468 (interactive "p") | |
6469 (setq arg (or arg 1)) | |
6470 (let (info group prev out) | |
6471 (while (>= (decf arg) 0) | |
6472 (if (not (setq info (pop gnus-list-of-killed-groups))) | |
6473 (error "No more newsgroups to yank")) | |
6474 (push (setq group (nth 1 info)) out) | |
6475 ;; Find which newsgroup to insert this one before - search | |
6476 ;; backward until something suitable is found. If there are no | |
6477 ;; other newsgroups in this buffer, just make this newsgroup the | |
6478 ;; first newsgroup. | |
6479 (setq prev (gnus-group-group-name)) | |
6480 (gnus-group-change-level | |
6481 info (gnus-info-level (cdr info)) gnus-level-killed | |
6482 (and prev (gnus-gethash prev gnus-newsrc-hashtb)) | |
6483 t) | |
6484 (gnus-group-insert-group-line-info group)) | |
6485 (forward-line -1) | |
6486 (gnus-group-position-point) | |
6487 (if (< (length out) 2) (car out) (nreverse out)))) | |
6488 | |
6489 (defun gnus-group-kill-level (level) | |
6490 "Kill all groups that is on a certain LEVEL." | |
6491 (interactive "nKill all groups on level: ") | |
6492 (cond | |
6493 ((= level gnus-level-zombie) | |
6494 (setq gnus-killed-list | |
6495 (nconc gnus-zombie-list gnus-killed-list)) | |
6496 (setq gnus-zombie-list nil)) | |
6497 ((and (< level gnus-level-zombie) | |
6498 (> level 0) | |
6499 (or gnus-expert-user | |
6500 (gnus-yes-or-no-p | |
6501 (format | |
6502 "Do you really want to kill all groups on level %d? " | |
6503 level)))) | |
6504 (let* ((prev gnus-newsrc-alist) | |
6505 (alist (cdr prev))) | |
6506 (while alist | |
6507 (if (= (gnus-info-level (car alist)) level) | |
6508 (progn | |
6509 (push (gnus-info-group (car alist)) gnus-killed-list) | |
6510 (setcdr prev (cdr alist))) | |
6511 (setq prev alist)) | |
6512 (setq alist (cdr alist))) | |
6513 (gnus-make-hashtable-from-newsrc-alist) | |
6514 (gnus-group-list-groups))) | |
6515 (t | |
6516 (error "Can't kill; illegal level: %d" level)))) | |
6517 | |
6518 (defun gnus-group-list-all-groups (&optional arg) | |
6519 "List all newsgroups with level ARG or lower. | |
6520 Default is gnus-level-unsubscribed, which lists all subscribed and most | |
6521 unsubscribed groups." | |
6522 (interactive "P") | |
6523 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t)) | |
6524 | |
6525 ;; Redefine this to list ALL killed groups if prefix arg used. | |
6526 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom). | |
6527 (defun gnus-group-list-killed (&optional arg) | |
6528 "List all killed newsgroups in the group buffer. | |
6529 If ARG is non-nil, list ALL killed groups known to Gnus. This may | |
6530 entail asking the server for the groups." | |
6531 (interactive "P") | |
6532 ;; Find all possible killed newsgroups if arg. | |
6533 (when arg | |
6534 (gnus-get-killed-groups)) | |
6535 (if (not gnus-killed-list) | |
6536 (gnus-message 6 "No killed groups") | |
6537 (let (gnus-group-list-mode) | |
6538 (funcall gnus-group-prepare-function | |
6539 gnus-level-killed t gnus-level-killed)) | |
6540 (goto-char (point-min))) | |
6541 (gnus-group-position-point)) | |
6542 | |
6543 (defun gnus-group-list-zombies () | |
6544 "List all zombie newsgroups in the group buffer." | |
6545 (interactive) | |
6546 (if (not gnus-zombie-list) | |
6547 (gnus-message 6 "No zombie groups") | |
6548 (let (gnus-group-list-mode) | |
6549 (funcall gnus-group-prepare-function | |
6550 gnus-level-zombie t gnus-level-zombie)) | |
6551 (goto-char (point-min))) | |
6552 (gnus-group-position-point)) | |
6553 | |
6554 (defun gnus-group-list-active () | |
6555 "List all groups that are available from the server(s)." | |
6556 (interactive) | |
6557 ;; First we make sure that we have really read the active file. | |
6558 (unless (gnus-read-active-file-p) | |
6559 (let ((gnus-read-active-file t)) | |
6560 (gnus-read-active-file))) | |
6561 ;; Find all groups and sort them. | |
6562 (let ((groups | |
6563 (sort | |
6564 (let (list) | |
6565 (mapatoms | |
6566 (lambda (sym) | |
6567 (and (boundp sym) | |
6568 (symbol-value sym) | |
6569 (setq list (cons (symbol-name sym) list)))) | |
6570 gnus-active-hashtb) | |
6571 list) | |
6572 'string<)) | |
6573 (buffer-read-only nil)) | |
6574 (erase-buffer) | |
6575 (while groups | |
6576 (gnus-group-insert-group-line-info (pop groups))) | |
6577 (goto-char (point-min)))) | |
6578 | |
6579 (defun gnus-activate-all-groups (level) | |
6580 "Activate absolutely all groups." | |
6581 (interactive (list 7)) | |
6582 (let ((gnus-activate-level level) | |
6583 (gnus-activate-foreign-newsgroups level)) | |
6584 (gnus-group-get-new-news))) | |
6585 | |
6586 (defun gnus-group-get-new-news (&optional arg) | |
6587 "Get newly arrived articles. | |
6588 If ARG is a number, it specifies which levels you are interested in | |
6589 re-scanning. If ARG is non-nil and not a number, this will force | |
6590 \"hard\" re-reading of the active files from all servers." | |
6591 (interactive "P") | |
6592 (run-hooks 'gnus-get-new-news-hook) | |
6593 ;; We might read in new NoCeM messages here. | |
6594 (when (and gnus-use-nocem | |
6595 (null arg)) | |
6596 (gnus-nocem-scan-groups)) | |
6597 ;; If ARG is not a number, then we read the active file. | |
6598 (when (and arg (not (numberp arg))) | |
6599 (let ((gnus-read-active-file t)) | |
6600 (gnus-read-active-file)) | |
6601 (setq arg nil)) | |
6602 | |
6603 (setq arg (gnus-group-default-level arg t)) | |
6604 (if (and gnus-read-active-file (not arg)) | |
6605 (progn | |
6606 (gnus-read-active-file) | |
6607 (gnus-get-unread-articles arg)) | |
6608 (let ((gnus-read-active-file (if arg nil gnus-read-active-file))) | |
6609 (gnus-get-unread-articles arg))) | |
6610 (run-hooks 'gnus-after-getting-new-news-hook) | |
6611 (gnus-group-list-groups)) | |
6612 | |
6613 (defun gnus-group-get-new-news-this-group (&optional n) | |
6614 "Check for newly arrived news in the current group (and the N-1 next groups). | |
6615 The difference between N and the number of newsgroup checked is returned. | |
6616 If N is negative, this group and the N-1 previous groups will be checked." | |
6617 (interactive "P") | |
6618 (let* ((groups (gnus-group-process-prefix n)) | |
6619 (ret (if (numberp n) (- n (length groups)) 0)) | |
6620 (beg (unless n (point))) | |
6621 group) | |
6622 (while (setq group (pop groups)) | |
6623 (gnus-group-remove-mark group) | |
6624 (if (gnus-activate-group group 'scan) | |
6625 (progn | |
6626 (gnus-get-unread-articles-in-group | |
6627 (gnus-get-info group) (gnus-active group) t) | |
6628 (unless (gnus-virtual-group-p group) | |
6629 (gnus-close-group group)) | |
6630 (gnus-group-update-group group)) | |
6631 (if (eq (gnus-server-status (gnus-find-method-for-group group)) | |
6632 'denied) | |
6633 (gnus-error 3 "Server denied access") | |
6634 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))) | |
6635 (when beg (goto-char beg)) | |
6636 (when gnus-goto-next-group-when-activating | |
6637 (gnus-group-next-unread-group 1 t)) | |
6638 (gnus-summary-position-point) | |
6639 ret)) | |
6640 | |
6641 (defun gnus-group-fetch-faq (group &optional faq-dir) | |
6642 "Fetch the FAQ for the current group." | |
6643 (interactive | |
6644 (list | |
6645 (and (gnus-group-group-name) | |
6646 (gnus-group-real-name (gnus-group-group-name))) | |
6647 (cond (current-prefix-arg | |
6648 (completing-read | |
6649 "Faq dir: " (and (listp gnus-group-faq-directory) | |
6650 (mapcar (lambda (file) (list file)) | |
6651 gnus-group-faq-directory))))))) | |
6652 (or faq-dir | |
6653 (setq faq-dir (if (listp gnus-group-faq-directory) | |
6654 (car gnus-group-faq-directory) | |
6655 gnus-group-faq-directory))) | |
6656 (or group (error "No group name given")) | |
6657 (let ((file (concat (file-name-as-directory faq-dir) | |
6658 (gnus-group-real-name group)))) | |
6659 (if (not (file-exists-p file)) | |
6660 (error "No such file: %s" file) | |
6661 (find-file file)))) | |
6662 | |
6663 (defun gnus-group-describe-group (force &optional group) | |
6664 "Display a description of the current newsgroup." | |
6665 (interactive (list current-prefix-arg (gnus-group-group-name))) | |
6666 (let* ((method (gnus-find-method-for-group group)) | |
6667 (mname (gnus-group-prefixed-name "" method)) | |
6668 desc) | |
6669 (when (and force | |
6670 gnus-description-hashtb) | |
6671 (gnus-sethash mname nil gnus-description-hashtb)) | |
6672 (or group (error "No group name given")) | |
6673 (and (or (and gnus-description-hashtb | |
6674 ;; We check whether this group's method has been | |
6675 ;; queried for a description file. | |
6676 (gnus-gethash mname gnus-description-hashtb)) | |
6677 (setq desc (gnus-group-get-description group)) | |
6678 (gnus-read-descriptions-file method)) | |
6679 (gnus-message 1 | |
6680 (or desc (gnus-gethash group gnus-description-hashtb) | |
6681 "No description available"))))) | |
6682 | |
6683 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
6684 (defun gnus-group-describe-all-groups (&optional force) | |
6685 "Pop up a buffer with descriptions of all newsgroups." | |
6686 (interactive "P") | |
6687 (and force (setq gnus-description-hashtb nil)) | |
6688 (if (not (or gnus-description-hashtb | |
6689 (gnus-read-all-descriptions-files))) | |
6690 (error "Couldn't request descriptions file")) | |
6691 (let ((buffer-read-only nil) | |
6692 b) | |
6693 (erase-buffer) | |
6694 (mapatoms | |
6695 (lambda (group) | |
6696 (setq b (point)) | |
6697 (insert (format " *: %-20s %s\n" (symbol-name group) | |
6698 (symbol-value group))) | |
6699 (gnus-add-text-properties | |
6700 b (1+ b) (list 'gnus-group group | |
6701 'gnus-unread t 'gnus-marked nil | |
6702 'gnus-level (1+ gnus-level-subscribed)))) | |
6703 gnus-description-hashtb) | |
6704 (goto-char (point-min)) | |
6705 (gnus-group-position-point))) | |
6706 | |
6707 ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
6708 (defun gnus-group-apropos (regexp &optional search-description) | |
6709 "List all newsgroups that have names that match a regexp." | |
6710 (interactive "sGnus apropos (regexp): ") | |
6711 (let ((prev "") | |
6712 (obuf (current-buffer)) | |
6713 groups des) | |
6714 ;; Go through all newsgroups that are known to Gnus. | |
6715 (mapatoms | |
6716 (lambda (group) | |
6717 (and (symbol-name group) | |
6718 (string-match regexp (symbol-name group)) | |
6719 (setq groups (cons (symbol-name group) groups)))) | |
6720 gnus-active-hashtb) | |
6721 ;; Also go through all descriptions that are known to Gnus. | |
6722 (when search-description | |
6723 (mapatoms | |
6724 (lambda (group) | |
6725 (and (string-match regexp (symbol-value group)) | |
6726 (gnus-active (symbol-name group)) | |
6727 (setq groups (cons (symbol-name group) groups)))) | |
6728 gnus-description-hashtb)) | |
6729 (if (not groups) | |
6730 (gnus-message 3 "No groups matched \"%s\"." regexp) | |
6731 ;; Print out all the groups. | |
6732 (save-excursion | |
6733 (pop-to-buffer "*Gnus Help*") | |
6734 (buffer-disable-undo (current-buffer)) | |
6735 (erase-buffer) | |
6736 (setq groups (sort groups 'string<)) | |
6737 (while groups | |
6738 ;; Groups may be entered twice into the list of groups. | |
6739 (if (not (string= (car groups) prev)) | |
6740 (progn | |
6741 (insert (setq prev (car groups)) "\n") | |
6742 (if (and gnus-description-hashtb | |
6743 (setq des (gnus-gethash (car groups) | |
6744 gnus-description-hashtb))) | |
6745 (insert " " des "\n")))) | |
6746 (setq groups (cdr groups))) | |
6747 (goto-char (point-min)))) | |
6748 (pop-to-buffer obuf))) | |
6749 | |
6750 (defun gnus-group-description-apropos (regexp) | |
6751 "List all newsgroups that have names or descriptions that match a regexp." | |
6752 (interactive "sGnus description apropos (regexp): ") | |
6753 (if (not (or gnus-description-hashtb | |
6754 (gnus-read-all-descriptions-files))) | |
6755 (error "Couldn't request descriptions file")) | |
6756 (gnus-group-apropos regexp t)) | |
6757 | |
6758 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
6759 (defun gnus-group-list-matching (level regexp &optional all lowest) | |
6760 "List all groups with unread articles that match REGEXP. | |
6761 If the prefix LEVEL is non-nil, it should be a number that says which | |
6762 level to cut off listing groups. | |
6763 If ALL, also list groups with no unread articles. | |
6764 If LOWEST, don't list groups with level lower than LOWEST. | |
6765 | |
6766 This command may read the active file." | |
6767 (interactive "P\nsList newsgroups matching: ") | |
6768 ;; First make sure active file has been read. | |
6769 (when (and level | |
6770 (> (prefix-numeric-value level) gnus-level-killed)) | |
6771 (gnus-get-killed-groups)) | |
6772 (gnus-group-prepare-flat (or level gnus-level-subscribed) | |
6773 all (or lowest 1) regexp) | |
6774 (goto-char (point-min)) | |
6775 (gnus-group-position-point)) | |
6776 | |
6777 (defun gnus-group-list-all-matching (level regexp &optional lowest) | |
6778 "List all groups that match REGEXP. | |
6779 If the prefix LEVEL is non-nil, it should be a number that says which | |
6780 level to cut off listing groups. | |
6781 If LOWEST, don't list groups with level lower than LOWEST." | |
6782 (interactive "P\nsList newsgroups matching: ") | |
6783 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest)) | |
6784 | |
6785 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. | |
6786 (defun gnus-group-save-newsrc (&optional force) | |
6787 "Save the Gnus startup files. | |
6788 If FORCE, force saving whether it is necessary or not." | |
6789 (interactive "P") | |
6790 (gnus-save-newsrc-file force)) | |
6791 | |
6792 (defun gnus-group-restart (&optional arg) | |
6793 "Force Gnus to read the .newsrc file." | |
6794 (interactive "P") | |
6795 (when (gnus-yes-or-no-p | |
6796 (format "Are you sure you want to read %s? " | |
6797 gnus-current-startup-file)) | |
6798 (gnus-save-newsrc-file) | |
6799 (gnus-setup-news 'force) | |
6800 (gnus-group-list-groups arg))) | |
6801 | |
6802 (defun gnus-group-read-init-file () | |
6803 "Read the Gnus elisp init file." | |
6804 (interactive) | |
6805 (gnus-read-init-file)) | |
6806 | |
6807 (defun gnus-group-check-bogus-groups (&optional silent) | |
6808 "Check bogus newsgroups. | |
6809 If given a prefix, don't ask for confirmation before removing a bogus | |
6810 group." | |
6811 (interactive "P") | |
6812 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user))) | |
6813 (gnus-group-list-groups)) | |
6814 | |
6815 (defun gnus-group-edit-global-kill (&optional article group) | |
6816 "Edit the global kill file. | |
6817 If GROUP, edit that local kill file instead." | |
6818 (interactive "P") | |
6819 (setq gnus-current-kill-article article) | |
6820 (gnus-kill-file-edit-file group) | |
6821 (gnus-message | |
6822 6 | |
6823 (substitute-command-keys | |
6824 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)" | |
6825 (if group "local" "global"))))) | |
6826 | |
6827 (defun gnus-group-edit-local-kill (article group) | |
6828 "Edit a local kill file." | |
6829 (interactive (list nil (gnus-group-group-name))) | |
6830 (gnus-group-edit-global-kill article group)) | |
6831 | |
6832 (defun gnus-group-force-update () | |
6833 "Update `.newsrc' file." | |
6834 (interactive) | |
6835 (gnus-save-newsrc-file)) | |
6836 | |
6837 (defun gnus-group-suspend () | |
6838 "Suspend the current Gnus session. | |
6839 In fact, cleanup buffers except for group mode buffer. | |
6840 The hook gnus-suspend-gnus-hook is called before actually suspending." | |
6841 (interactive) | |
6842 (run-hooks 'gnus-suspend-gnus-hook) | |
6843 ;; Kill Gnus buffers except for group mode buffer. | |
6844 (let* ((group-buf (get-buffer gnus-group-buffer)) | |
6845 ;; Do this on a separate list in case the user does a ^G before we finish | |
6846 (gnus-buffer-list | |
6847 (delete group-buf (delete gnus-dribble-buffer | |
6848 (append gnus-buffer-list nil))))) | |
6849 (while gnus-buffer-list | |
6850 (gnus-kill-buffer (pop gnus-buffer-list))) | |
6851 (gnus-kill-gnus-frames) | |
6852 (when group-buf | |
6853 (setq gnus-buffer-list (list group-buf)) | |
6854 (bury-buffer group-buf) | |
6855 (delete-windows-on group-buf t)))) | |
6856 | |
6857 (defun gnus-group-clear-dribble () | |
6858 "Clear all information from the dribble buffer." | |
6859 (interactive) | |
6860 (gnus-dribble-clear) | |
6861 (gnus-message 7 "Cleared dribble buffer")) | |
6862 | |
6863 (defun gnus-group-exit () | |
6864 "Quit reading news after updating .newsrc.eld and .newsrc. | |
6865 The hook `gnus-exit-gnus-hook' is called before actually exiting." | |
6866 (interactive) | |
6867 (when | |
6868 (or noninteractive ;For gnus-batch-kill | |
6869 (not gnus-interactive-exit) ;Without confirmation | |
6870 gnus-expert-user | |
6871 (gnus-y-or-n-p "Are you sure you want to quit reading news? ")) | |
6872 (run-hooks 'gnus-exit-gnus-hook) | |
6873 ;; Offer to save data from non-quitted summary buffers. | |
6874 (gnus-offer-save-summaries) | |
6875 ;; Save the newsrc file(s). | |
6876 (gnus-save-newsrc-file) | |
6877 ;; Kill-em-all. | |
6878 (gnus-close-backends) | |
6879 ;; Reset everything. | |
6880 (gnus-clear-system) | |
6881 ;; Allow the user to do things after cleaning up. | |
6882 (run-hooks 'gnus-after-exiting-gnus-hook))) | |
6883 | |
6884 (defun gnus-close-backends () | |
6885 ;; Send a close request to all backends that support such a request. | |
6886 (let ((methods gnus-valid-select-methods) | |
6887 func) | |
6888 (while methods | |
6889 (if (fboundp (setq func (intern (concat (caar methods) | |
6890 "-request-close")))) | |
6891 (funcall func)) | |
6892 (setq methods (cdr methods))))) | |
6893 | |
6894 (defun gnus-group-quit () | |
6895 "Quit reading news without updating .newsrc.eld or .newsrc. | |
6896 The hook `gnus-exit-gnus-hook' is called before actually exiting." | |
6897 (interactive) | |
6898 (when (or noninteractive ;For gnus-batch-kill | |
6899 (zerop (buffer-size)) | |
6900 (not (gnus-server-opened gnus-select-method)) | |
6901 gnus-expert-user | |
6902 (not gnus-current-startup-file) | |
6903 (gnus-yes-or-no-p | |
6904 (format "Quit reading news without saving %s? " | |
6905 (file-name-nondirectory gnus-current-startup-file)))) | |
6906 (run-hooks 'gnus-exit-gnus-hook) | |
6907 (if gnus-use-full-window | |
6908 (delete-other-windows) | |
6909 (gnus-remove-some-windows)) | |
6910 (gnus-dribble-save) | |
6911 (gnus-close-backends) | |
6912 (gnus-clear-system) | |
6913 ;; Allow the user to do things after cleaning up. | |
6914 (run-hooks 'gnus-after-exiting-gnus-hook))) | |
6915 | |
6916 (defun gnus-offer-save-summaries () | |
6917 "Offer to save all active summary buffers." | |
6918 (save-excursion | |
6919 (let ((buflist (buffer-list)) | |
6920 buffers bufname) | |
6921 ;; Go through all buffers and find all summaries. | |
6922 (while buflist | |
6923 (and (setq bufname (buffer-name (car buflist))) | |
6924 (string-match "Summary" bufname) | |
6925 (save-excursion | |
6926 (set-buffer bufname) | |
6927 ;; We check that this is, indeed, a summary buffer. | |
6928 (and (eq major-mode 'gnus-summary-mode) | |
6929 ;; Also make sure this isn't bogus. | |
6930 gnus-newsgroup-prepared)) | |
6931 (push bufname buffers)) | |
6932 (setq buflist (cdr buflist))) | |
6933 ;; Go through all these summary buffers and offer to save them. | |
6934 (when buffers | |
6935 (map-y-or-n-p | |
6936 "Update summary buffer %s? " | |
6937 (lambda (buf) (set-buffer buf) (gnus-summary-exit)) | |
6938 buffers))))) | |
6939 | |
6940 (defun gnus-group-describe-briefly () | |
6941 "Give a one line description of the group mode commands." | |
6942 (interactive) | |
6943 (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"))) | |
6944 | |
6945 (defun gnus-group-browse-foreign-server (method) | |
6946 "Browse a foreign news server. | |
6947 If called interactively, this function will ask for a select method | |
6948 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where). | |
6949 If not, METHOD should be a list where the first element is the method | |
6950 and the second element is the address." | |
6951 (interactive | |
6952 (list (let ((how (completing-read | |
6953 "Which backend: " | |
6954 (append gnus-valid-select-methods gnus-server-alist) | |
6955 nil t (cons "nntp" 0) 'gnus-method-history))) | |
6956 ;; We either got a backend name or a virtual server name. | |
6957 ;; If the first, we also need an address. | |
6958 (if (assoc how gnus-valid-select-methods) | |
6959 (list (intern how) | |
6960 ;; Suggested by mapjph@bath.ac.uk. | |
6961 (completing-read | |
6962 "Address: " | |
6963 (mapcar (lambda (server) (list server)) | |
6964 gnus-secondary-servers))) | |
6965 ;; We got a server name, so we find the method. | |
6966 (gnus-server-to-method how))))) | |
6967 (gnus-browse-foreign-server method)) | |
6968 | |
6969 | |
6970 ;;; | |
6971 ;;; Gnus summary mode | |
6972 ;;; | |
6973 | |
6974 (defvar gnus-summary-mode-map nil) | |
6975 | |
6976 (put 'gnus-summary-mode 'mode-class 'special) | |
6977 | |
6978 (unless gnus-summary-mode-map | |
6979 (setq gnus-summary-mode-map (make-keymap)) | |
6980 (suppress-keymap gnus-summary-mode-map) | |
6981 | |
6982 ;; Non-orthogonal keys | |
6983 | |
6984 (gnus-define-keys gnus-summary-mode-map | |
6985 " " gnus-summary-next-page | |
6986 "\177" gnus-summary-prev-page | |
6987 [delete] gnus-summary-prev-page | |
6988 "\r" gnus-summary-scroll-up | |
6989 "n" gnus-summary-next-unread-article | |
6990 "p" gnus-summary-prev-unread-article | |
6991 "N" gnus-summary-next-article | |
6992 "P" gnus-summary-prev-article | |
6993 "\M-\C-n" gnus-summary-next-same-subject | |
6994 "\M-\C-p" gnus-summary-prev-same-subject | |
6995 "\M-n" gnus-summary-next-unread-subject | |
6996 "\M-p" gnus-summary-prev-unread-subject | |
6997 "." gnus-summary-first-unread-article | |
6998 "," gnus-summary-best-unread-article | |
6999 "\M-s" gnus-summary-search-article-forward | |
7000 "\M-r" gnus-summary-search-article-backward | |
7001 "<" gnus-summary-beginning-of-article | |
7002 ">" gnus-summary-end-of-article | |
7003 "j" gnus-summary-goto-article | |
7004 "^" gnus-summary-refer-parent-article | |
7005 "\M-^" gnus-summary-refer-article | |
7006 "u" gnus-summary-tick-article-forward | |
7007 "!" gnus-summary-tick-article-forward | |
7008 "U" gnus-summary-tick-article-backward | |
7009 "d" gnus-summary-mark-as-read-forward | |
7010 "D" gnus-summary-mark-as-read-backward | |
7011 "E" gnus-summary-mark-as-expirable | |
7012 "\M-u" gnus-summary-clear-mark-forward | |
7013 "\M-U" gnus-summary-clear-mark-backward | |
7014 "k" gnus-summary-kill-same-subject-and-select | |
7015 "\C-k" gnus-summary-kill-same-subject | |
7016 "\M-\C-k" gnus-summary-kill-thread | |
7017 "\M-\C-l" gnus-summary-lower-thread | |
7018 "e" gnus-summary-edit-article | |
7019 "#" gnus-summary-mark-as-processable | |
7020 "\M-#" gnus-summary-unmark-as-processable | |
7021 "\M-\C-t" gnus-summary-toggle-threads | |
7022 "\M-\C-s" gnus-summary-show-thread | |
7023 "\M-\C-h" gnus-summary-hide-thread | |
7024 "\M-\C-f" gnus-summary-next-thread | |
7025 "\M-\C-b" gnus-summary-prev-thread | |
7026 "\M-\C-u" gnus-summary-up-thread | |
7027 "\M-\C-d" gnus-summary-down-thread | |
7028 "&" gnus-summary-execute-command | |
7029 "c" gnus-summary-catchup-and-exit | |
7030 "\C-w" gnus-summary-mark-region-as-read | |
7031 "\C-t" gnus-summary-toggle-truncation | |
7032 "?" gnus-summary-mark-as-dormant | |
7033 "\C-c\M-\C-s" gnus-summary-limit-include-expunged | |
7034 "\C-c\C-s\C-n" gnus-summary-sort-by-number | |
7035 "\C-c\C-s\C-a" gnus-summary-sort-by-author | |
7036 "\C-c\C-s\C-s" gnus-summary-sort-by-subject | |
7037 "\C-c\C-s\C-d" gnus-summary-sort-by-date | |
7038 "\C-c\C-s\C-i" gnus-summary-sort-by-score | |
7039 "=" gnus-summary-expand-window | |
7040 "\C-x\C-s" gnus-summary-reselect-current-group | |
7041 "\M-g" gnus-summary-rescan-group | |
7042 "w" gnus-summary-stop-page-breaking | |
7043 "\C-c\C-r" gnus-summary-caesar-message | |
7044 "\M-t" gnus-summary-toggle-mime | |
7045 "f" gnus-summary-followup | |
7046 "F" gnus-summary-followup-with-original | |
7047 "C" gnus-summary-cancel-article | |
7048 "r" gnus-summary-reply | |
7049 "R" gnus-summary-reply-with-original | |
7050 "\C-c\C-f" gnus-summary-mail-forward | |
7051 "o" gnus-summary-save-article | |
7052 "\C-o" gnus-summary-save-article-mail | |
7053 "|" gnus-summary-pipe-output | |
7054 "\M-k" gnus-summary-edit-local-kill | |
7055 "\M-K" gnus-summary-edit-global-kill | |
7056 "V" gnus-version | |
7057 "\C-c\C-d" gnus-summary-describe-group | |
7058 "q" gnus-summary-exit | |
7059 "Q" gnus-summary-exit-no-update | |
7060 "\C-c\C-i" gnus-info-find-node | |
7061 gnus-mouse-2 gnus-mouse-pick-article | |
7062 "m" gnus-summary-mail-other-window | |
7063 "a" gnus-summary-post-news | |
7064 "x" gnus-summary-limit-to-unread | |
7065 "s" gnus-summary-isearch-article | |
7066 "t" gnus-article-hide-headers | |
7067 "g" gnus-summary-show-article | |
7068 "l" gnus-summary-goto-last-article | |
7069 "\C-c\C-v\C-v" gnus-uu-decode-uu-view | |
7070 "\C-d" gnus-summary-enter-digest-group | |
7071 "\C-c\C-b" gnus-bug | |
7072 "*" gnus-cache-enter-article | |
7073 "\M-*" gnus-cache-remove-article | |
7074 "\M-&" gnus-summary-universal-argument | |
7075 "\C-l" gnus-recenter | |
7076 "I" gnus-summary-increase-score | |
7077 "L" gnus-summary-lower-score | |
7078 | |
7079 "V" gnus-summary-score-map | |
7080 "X" gnus-uu-extract-map | |
7081 "S" gnus-summary-send-map) | |
7082 | |
7083 ;; Sort of orthogonal keymap | |
7084 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map) | |
7085 "t" gnus-summary-tick-article-forward | |
7086 "!" gnus-summary-tick-article-forward | |
7087 "d" gnus-summary-mark-as-read-forward | |
7088 "r" gnus-summary-mark-as-read-forward | |
7089 "c" gnus-summary-clear-mark-forward | |
7090 " " gnus-summary-clear-mark-forward | |
7091 "e" gnus-summary-mark-as-expirable | |
7092 "x" gnus-summary-mark-as-expirable | |
7093 "?" gnus-summary-mark-as-dormant | |
7094 "b" gnus-summary-set-bookmark | |
7095 "B" gnus-summary-remove-bookmark | |
7096 "#" gnus-summary-mark-as-processable | |
7097 "\M-#" gnus-summary-unmark-as-processable | |
7098 "S" gnus-summary-limit-include-expunged | |
7099 "C" gnus-summary-catchup | |
7100 "H" gnus-summary-catchup-to-here | |
7101 "\C-c" gnus-summary-catchup-all | |
7102 "k" gnus-summary-kill-same-subject-and-select | |
7103 "K" gnus-summary-kill-same-subject | |
7104 "P" gnus-uu-mark-map) | |
7105 | |
7106 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map) | |
7107 "c" gnus-summary-clear-above | |
7108 "u" gnus-summary-tick-above | |
7109 "m" gnus-summary-mark-above | |
7110 "k" gnus-summary-kill-below) | |
7111 | |
7112 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map) | |
7113 "/" gnus-summary-limit-to-subject | |
7114 "n" gnus-summary-limit-to-articles | |
7115 "w" gnus-summary-pop-limit | |
7116 "s" gnus-summary-limit-to-subject | |
7117 "a" gnus-summary-limit-to-author | |
7118 "u" gnus-summary-limit-to-unread | |
7119 "m" gnus-summary-limit-to-marks | |
7120 "v" gnus-summary-limit-to-score | |
7121 "D" gnus-summary-limit-include-dormant | |
7122 "d" gnus-summary-limit-exclude-dormant | |
7123 ;; "t" gnus-summary-limit-exclude-thread | |
7124 "E" gnus-summary-limit-include-expunged | |
7125 "c" gnus-summary-limit-exclude-childless-dormant | |
7126 "C" gnus-summary-limit-mark-excluded-as-read) | |
7127 | |
7128 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map) | |
7129 "n" gnus-summary-next-unread-article | |
7130 "p" gnus-summary-prev-unread-article | |
7131 "N" gnus-summary-next-article | |
7132 "P" gnus-summary-prev-article | |
7133 "\C-n" gnus-summary-next-same-subject | |
7134 "\C-p" gnus-summary-prev-same-subject | |
7135 "\M-n" gnus-summary-next-unread-subject | |
7136 "\M-p" gnus-summary-prev-unread-subject | |
7137 "f" gnus-summary-first-unread-article | |
7138 "b" gnus-summary-best-unread-article | |
7139 "j" gnus-summary-goto-article | |
7140 "g" gnus-summary-goto-subject | |
7141 "l" gnus-summary-goto-last-article | |
7142 "p" gnus-summary-pop-article) | |
7143 | |
7144 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map) | |
7145 "k" gnus-summary-kill-thread | |
7146 "l" gnus-summary-lower-thread | |
7147 "i" gnus-summary-raise-thread | |
7148 "T" gnus-summary-toggle-threads | |
7149 "t" gnus-summary-rethread-current | |
7150 "^" gnus-summary-reparent-thread | |
7151 "s" gnus-summary-show-thread | |
7152 "S" gnus-summary-show-all-threads | |
7153 "h" gnus-summary-hide-thread | |
7154 "H" gnus-summary-hide-all-threads | |
7155 "n" gnus-summary-next-thread | |
7156 "p" gnus-summary-prev-thread | |
7157 "u" gnus-summary-up-thread | |
7158 "o" gnus-summary-top-thread | |
7159 "d" gnus-summary-down-thread | |
7160 "#" gnus-uu-mark-thread | |
7161 "\M-#" gnus-uu-unmark-thread) | |
7162 | |
7163 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map) | |
7164 "c" gnus-summary-catchup-and-exit | |
7165 "C" gnus-summary-catchup-all-and-exit | |
7166 "E" gnus-summary-exit-no-update | |
7167 "Q" gnus-summary-exit | |
7168 "Z" gnus-summary-exit | |
7169 "n" gnus-summary-catchup-and-goto-next-group | |
7170 "R" gnus-summary-reselect-current-group | |
7171 "G" gnus-summary-rescan-group | |
7172 "N" gnus-summary-next-group | |
7173 "P" gnus-summary-prev-group) | |
7174 | |
7175 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map) | |
7176 " " gnus-summary-next-page | |
7177 "n" gnus-summary-next-page | |
7178 "\177" gnus-summary-prev-page | |
7179 [delete] gnus-summary-prev-page | |
7180 "p" gnus-summary-prev-page | |
7181 "\r" gnus-summary-scroll-up | |
7182 "<" gnus-summary-beginning-of-article | |
7183 ">" gnus-summary-end-of-article | |
7184 "b" gnus-summary-beginning-of-article | |
7185 "e" gnus-summary-end-of-article | |
7186 "^" gnus-summary-refer-parent-article | |
7187 "r" gnus-summary-refer-parent-article | |
7188 "R" gnus-summary-refer-references | |
7189 "g" gnus-summary-show-article | |
7190 "s" gnus-summary-isearch-article) | |
7191 | |
7192 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map) | |
7193 "b" gnus-article-add-buttons | |
7194 "B" gnus-article-add-buttons-to-head | |
7195 "o" gnus-article-treat-overstrike | |
7196 ;; "w" gnus-article-word-wrap | |
7197 "w" gnus-article-fill-cited-article | |
7198 "c" gnus-article-remove-cr | |
7199 "L" gnus-article-remove-trailing-blank-lines | |
7200 "q" gnus-article-de-quoted-unreadable | |
7201 "f" gnus-article-display-x-face | |
7202 "l" gnus-summary-stop-page-breaking | |
7203 "r" gnus-summary-caesar-message | |
7204 "t" gnus-article-hide-headers | |
7205 "v" gnus-summary-verbose-headers | |
7206 "m" gnus-summary-toggle-mime) | |
7207 | |
7208 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map) | |
7209 "a" gnus-article-hide | |
7210 "h" gnus-article-hide-headers | |
7211 "b" gnus-article-hide-boring-headers | |
7212 "s" gnus-article-hide-signature | |
7213 "c" gnus-article-hide-citation | |
7214 "p" gnus-article-hide-pgp | |
7215 "P" gnus-article-hide-pem | |
7216 "\C-c" gnus-article-hide-citation-maybe) | |
7217 | |
7218 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map) | |
7219 "a" gnus-article-highlight | |
7220 "h" gnus-article-highlight-headers | |
7221 "c" gnus-article-highlight-citation | |
7222 "s" gnus-article-highlight-signature) | |
7223 | |
7224 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map) | |
7225 "z" gnus-article-date-ut | |
7226 "u" gnus-article-date-ut | |
7227 "l" gnus-article-date-local | |
7228 "e" gnus-article-date-lapsed | |
7229 "o" gnus-article-date-original) | |
7230 | |
7231 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map) | |
7232 "v" gnus-version | |
7233 "f" gnus-summary-fetch-faq | |
7234 "d" gnus-summary-describe-group | |
7235 "h" gnus-summary-describe-briefly | |
7236 "i" gnus-info-find-node) | |
7237 | |
7238 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map) | |
7239 "e" gnus-summary-expire-articles | |
7240 "\M-\C-e" gnus-summary-expire-articles-now | |
7241 "\177" gnus-summary-delete-article | |
7242 [delete] gnus-summary-delete-article | |
7243 "m" gnus-summary-move-article | |
7244 "r" gnus-summary-respool-article | |
7245 "w" gnus-summary-edit-article | |
7246 "c" gnus-summary-copy-article | |
7247 "B" gnus-summary-crosspost-article | |
7248 "q" gnus-summary-respool-query | |
7249 "i" gnus-summary-import-article) | |
7250 | |
7251 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map) | |
7252 "o" gnus-summary-save-article | |
7253 "m" gnus-summary-save-article-mail | |
7254 "r" gnus-summary-save-article-rmail | |
7255 "f" gnus-summary-save-article-file | |
7256 "b" gnus-summary-save-article-body-file | |
7257 "h" gnus-summary-save-article-folder | |
7258 "v" gnus-summary-save-article-vm | |
7259 "p" gnus-summary-pipe-output | |
7260 "s" gnus-soup-add-article) | |
7261 ) | |
7262 | |
7263 | |
7264 | |
7265 (defun gnus-summary-mode (&optional group) | |
7266 "Major mode for reading articles. | |
7267 | |
7268 All normal editing commands are switched off. | |
7269 \\<gnus-summary-mode-map> | |
7270 Each line in this buffer represents one article. To read an | |
7271 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards | |
7272 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]', | |
7273 respectively. | |
7274 | |
7275 You can also post articles and send mail from this buffer. To | |
7276 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author | |
7277 of an article, type `\\[gnus-summary-reply]'. | |
7278 | |
7279 There are approx. one gazillion commands you can execute in this | |
7280 buffer; read the info pages for more information (`\\[gnus-info-find-node]'). | |
7281 | |
7282 The following commands are available: | |
7283 | |
7284 \\{gnus-summary-mode-map}" | |
7285 (interactive) | |
7286 (when (and menu-bar-mode | |
7287 (gnus-visual-p 'summary-menu 'menu)) | |
7288 (gnus-summary-make-menu-bar)) | |
7289 (kill-all-local-variables) | |
7290 (gnus-summary-make-local-variables) | |
7291 (gnus-make-thread-indent-array) | |
7292 (gnus-simplify-mode-line) | |
7293 (setq major-mode 'gnus-summary-mode) | |
7294 (setq mode-name "Summary") | |
7295 (make-local-variable 'minor-mode-alist) | |
7296 (use-local-map gnus-summary-mode-map) | |
7297 (buffer-disable-undo (current-buffer)) | |
7298 (setq buffer-read-only t) ;Disable modification | |
7299 (setq truncate-lines t) | |
7300 (setq selective-display t) | |
7301 (setq selective-display-ellipses t) ;Display `...' | |
7302 (setq buffer-display-table gnus-summary-display-table) | |
7303 (setq gnus-newsgroup-name group) | |
7304 (make-local-variable 'gnus-summary-line-format) | |
7305 (make-local-variable 'gnus-summary-line-format-spec) | |
7306 (make-local-variable 'gnus-summary-mark-positions) | |
7307 (gnus-make-local-hook 'post-command-hook) | |
7308 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t) | |
7309 (run-hooks 'gnus-summary-mode-hook)) | |
7310 | |
7311 (defun gnus-summary-make-local-variables () | |
7312 "Make all the local summary buffer variables." | |
7313 (let ((locals gnus-summary-local-variables) | |
7314 global local) | |
7315 (while (setq local (pop locals)) | |
7316 (if (consp local) | |
7317 (progn | |
7318 (if (eq (cdr local) 'global) | |
7319 ;; Copy the global value of the variable. | |
7320 (setq global (symbol-value (car local))) | |
7321 ;; Use the value from the list. | |
7322 (setq global (eval (cdr local)))) | |
7323 (make-local-variable (car local)) | |
7324 (set (car local) global)) | |
7325 ;; Simple nil-valued local variable. | |
7326 (make-local-variable local) | |
7327 (set local nil))))) | |
7328 | |
7329 (defun gnus-summary-make-display-table () | |
7330 ;; Change the display table. Odd characters have a tendency to mess | |
7331 ;; up nicely formatted displays - we make all possible glyphs | |
7332 ;; display only a single character. | |
7333 | |
7334 ;; We start from the standard display table, if any. | |
7335 (setq gnus-summary-display-table | |
7336 (or (copy-sequence standard-display-table) | |
7337 (make-display-table))) | |
7338 ;; Nix out all the control chars... | |
7339 (let ((i 32)) | |
7340 (while (>= (setq i (1- i)) 0) | |
7341 (aset gnus-summary-display-table i [??]))) | |
7342 ;; ... but not newline and cr, of course. (cr is necessary for the | |
7343 ;; selective display). | |
7344 (aset gnus-summary-display-table ?\n nil) | |
7345 (aset gnus-summary-display-table ?\r nil) | |
7346 ;; We nix out any glyphs over 126 that are not set already. | |
7347 (let ((i 256)) | |
7348 (while (>= (setq i (1- i)) 127) | |
7349 ;; Only modify if the entry is nil. | |
7350 (or (aref gnus-summary-display-table i) | |
7351 (aset gnus-summary-display-table i [??]))))) | |
7352 | |
7353 (defun gnus-summary-clear-local-variables () | |
7354 (let ((locals gnus-summary-local-variables)) | |
7355 (while locals | |
7356 (if (consp (car locals)) | |
7357 (and (vectorp (caar locals)) | |
7358 (set (caar locals) nil)) | |
7359 (and (vectorp (car locals)) | |
7360 (set (car locals) nil))) | |
7361 (setq locals (cdr locals))))) | |
7362 | |
7363 ;; Summary data functions. | |
7364 | |
7365 (defmacro gnus-data-number (data) | |
7366 `(car ,data)) | |
7367 | |
7368 (defmacro gnus-data-set-number (data number) | |
7369 `(setcar ,data ,number)) | |
7370 | |
7371 (defmacro gnus-data-mark (data) | |
7372 `(nth 1 ,data)) | |
7373 | |
7374 (defmacro gnus-data-set-mark (data mark) | |
7375 `(setcar (nthcdr 1 ,data) ,mark)) | |
7376 | |
7377 (defmacro gnus-data-pos (data) | |
7378 `(nth 2 ,data)) | |
7379 | |
7380 (defmacro gnus-data-set-pos (data pos) | |
7381 `(setcar (nthcdr 2 ,data) ,pos)) | |
7382 | |
7383 (defmacro gnus-data-header (data) | |
7384 `(nth 3 ,data)) | |
7385 | |
7386 (defmacro gnus-data-level (data) | |
7387 `(nth 4 ,data)) | |
7388 | |
7389 (defmacro gnus-data-unread-p (data) | |
7390 `(= (nth 1 ,data) gnus-unread-mark)) | |
7391 | |
7392 (defmacro gnus-data-pseudo-p (data) | |
7393 `(consp (nth 3 ,data))) | |
7394 | |
7395 (defmacro gnus-data-find (number) | |
7396 `(assq ,number gnus-newsgroup-data)) | |
7397 | |
7398 (defmacro gnus-data-find-list (number &optional data) | |
7399 `(let ((bdata ,(or data 'gnus-newsgroup-data))) | |
7400 (memq (assq ,number bdata) | |
7401 bdata))) | |
7402 | |
7403 (defmacro gnus-data-make (number mark pos header level) | |
7404 `(list ,number ,mark ,pos ,header ,level)) | |
7405 | |
7406 (defun gnus-data-enter (after-article number mark pos header level offset) | |
7407 (let ((data (gnus-data-find-list after-article))) | |
7408 (or data (error "No such article: %d" after-article)) | |
7409 (setcdr data (cons (gnus-data-make number mark pos header level) | |
7410 (cdr data))) | |
7411 (setq gnus-newsgroup-data-reverse nil) | |
7412 (gnus-data-update-list (cddr data) offset))) | |
7413 | |
7414 (defun gnus-data-enter-list (after-article list &optional offset) | |
7415 (when list | |
7416 (let ((data (and after-article (gnus-data-find-list after-article))) | |
7417 (ilist list)) | |
7418 (or data (not after-article) (error "No such article: %d" after-article)) | |
7419 ;; Find the last element in the list to be spliced into the main | |
7420 ;; list. | |
7421 (while (cdr list) | |
7422 (setq list (cdr list))) | |
7423 (if (not data) | |
7424 (progn | |
7425 (setcdr list gnus-newsgroup-data) | |
7426 (setq gnus-newsgroup-data ilist) | |
7427 (and offset (gnus-data-update-list (cdr list) offset))) | |
7428 (setcdr list (cdr data)) | |
7429 (setcdr data ilist) | |
7430 (and offset (gnus-data-update-list (cdr data) offset))) | |
7431 (setq gnus-newsgroup-data-reverse nil)))) | |
7432 | |
7433 (defun gnus-data-remove (article &optional offset) | |
7434 (let ((data gnus-newsgroup-data)) | |
7435 (if (= (gnus-data-number (car data)) article) | |
7436 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data) | |
7437 gnus-newsgroup-data-reverse nil) | |
7438 (while (cdr data) | |
7439 (and (= (gnus-data-number (cadr data)) article) | |
7440 (progn | |
7441 (setcdr data (cddr data)) | |
7442 (and offset (gnus-data-update-list (cdr data) offset)) | |
7443 (setq data nil | |
7444 gnus-newsgroup-data-reverse nil))) | |
7445 (setq data (cdr data)))))) | |
7446 | |
7447 (defmacro gnus-data-list (backward) | |
7448 `(if ,backward | |
7449 (or gnus-newsgroup-data-reverse | |
7450 (setq gnus-newsgroup-data-reverse | |
7451 (reverse gnus-newsgroup-data))) | |
7452 gnus-newsgroup-data)) | |
7453 | |
7454 (defun gnus-data-update-list (data offset) | |
7455 "Add OFFSET to the POS of all data entries in DATA." | |
7456 (while data | |
7457 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data)))) | |
7458 (setq data (cdr data)))) | |
7459 | |
7460 (defun gnus-data-compute-positions () | |
7461 "Compute the positions of all articles." | |
7462 (let ((data gnus-newsgroup-data) | |
7463 pos) | |
7464 (while data | |
7465 (when (setq pos (text-property-any | |
7466 (point-min) (point-max) | |
7467 'gnus-number (gnus-data-number (car data)))) | |
7468 (gnus-data-set-pos (car data) (+ pos 3))) | |
7469 (setq data (cdr data))))) | |
7470 | |
7471 (defun gnus-summary-article-pseudo-p (article) | |
7472 "Say whether this article is a pseudo article or not." | |
7473 (not (vectorp (gnus-data-header (gnus-data-find article))))) | |
7474 | |
7475 (defun gnus-article-parent-p (number) | |
7476 "Say whether this article is a parent or not." | |
7477 (let ((data (gnus-data-find-list number))) | |
7478 (and (cdr data) ; There has to be an article after... | |
7479 (< (gnus-data-level (car data)) ; And it has to have a higher level. | |
7480 (gnus-data-level (nth 1 data)))))) | |
7481 | |
7482 (defun gnus-article-children (number) | |
7483 "Return a list of all children to NUMBER." | |
7484 (let* ((data (gnus-data-find-list number)) | |
7485 (level (gnus-data-level (car data))) | |
7486 children) | |
7487 (setq data (cdr data)) | |
7488 (while (and data | |
7489 (= (gnus-data-level (car data)) (1+ level))) | |
7490 (push (gnus-data-number (car data)) children) | |
7491 (setq data (cdr data))) | |
7492 children)) | |
7493 | |
7494 (defmacro gnus-summary-skip-intangible () | |
7495 "If the current article is intangible, then jump to a different article." | |
7496 '(let ((to (get-text-property (point) 'gnus-intangible))) | |
7497 (and to (gnus-summary-goto-subject to)))) | |
7498 | |
7499 (defmacro gnus-summary-article-intangible-p () | |
7500 "Say whether this article is intangible or not." | |
7501 '(get-text-property (point) 'gnus-intangible)) | |
7502 | |
7503 ;; Some summary mode macros. | |
7504 | |
7505 (defmacro gnus-summary-article-number () | |
7506 "The article number of the article on the current line. | |
7507 If there isn's an article number here, then we return the current | |
7508 article number." | |
7509 '(progn | |
7510 (gnus-summary-skip-intangible) | |
7511 (or (get-text-property (point) 'gnus-number) | |
7512 (gnus-summary-last-subject)))) | |
7513 | |
7514 (defmacro gnus-summary-article-header (&optional number) | |
7515 `(gnus-data-header (gnus-data-find | |
7516 ,(or number '(gnus-summary-article-number))))) | |
7517 | |
7518 (defmacro gnus-summary-thread-level (&optional number) | |
7519 `(if (and (eq gnus-summary-make-false-root 'dummy) | |
7520 (get-text-property (point) 'gnus-intangible)) | |
7521 0 | |
7522 (gnus-data-level (gnus-data-find | |
7523 ,(or number '(gnus-summary-article-number)))))) | |
7524 | |
7525 (defmacro gnus-summary-article-mark (&optional number) | |
7526 `(gnus-data-mark (gnus-data-find | |
7527 ,(or number '(gnus-summary-article-number))))) | |
7528 | |
7529 (defmacro gnus-summary-article-pos (&optional number) | |
7530 `(gnus-data-pos (gnus-data-find | |
7531 ,(or number '(gnus-summary-article-number))))) | |
7532 | |
7533 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject) | |
7534 (defmacro gnus-summary-article-subject (&optional number) | |
7535 "Return current subject string or nil if nothing." | |
7536 `(let ((headers | |
7537 ,(if number | |
7538 `(gnus-data-header (assq ,number gnus-newsgroup-data)) | |
7539 '(gnus-data-header (assq (gnus-summary-article-number) | |
7540 gnus-newsgroup-data))))) | |
7541 (and headers | |
7542 (vectorp headers) | |
7543 (mail-header-subject headers)))) | |
7544 | |
7545 (defmacro gnus-summary-article-score (&optional number) | |
7546 "Return current article score." | |
7547 `(or (cdr (assq ,(or number '(gnus-summary-article-number)) | |
7548 gnus-newsgroup-scored)) | |
7549 gnus-summary-default-score 0)) | |
7550 | |
7551 (defun gnus-summary-article-children (&optional number) | |
7552 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number)))) | |
7553 (level (gnus-data-level (car data))) | |
7554 l children) | |
7555 (while (and (setq data (cdr data)) | |
7556 (> (setq l (gnus-data-level (car data))) level)) | |
7557 (and (= (1+ level) l) | |
7558 (setq children (cons (gnus-data-number (car data)) | |
7559 children)))) | |
7560 (nreverse children))) | |
7561 | |
7562 (defun gnus-summary-article-parent (&optional number) | |
7563 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number)) | |
7564 (gnus-data-list t))) | |
7565 (level (gnus-data-level (car data)))) | |
7566 (if (zerop level) | |
7567 () ; This is a root. | |
7568 ;; We search until we find an article with a level less than | |
7569 ;; this one. That function has to be the parent. | |
7570 (while (and (setq data (cdr data)) | |
7571 (not (< (gnus-data-level (car data)) level)))) | |
7572 (and data (gnus-data-number (car data)))))) | |
7573 | |
7574 (defun gnus-unread-mark-p (mark) | |
7575 "Say whether MARK is the unread mark." | |
7576 (= mark gnus-unread-mark)) | |
7577 | |
7578 (defun gnus-read-mark-p (mark) | |
7579 "Say whether MARK is one of the marks that mark as read. | |
7580 This is all marks except unread, ticked, dormant, and expirable." | |
7581 (not (or (= mark gnus-unread-mark) | |
7582 (= mark gnus-ticked-mark) | |
7583 (= mark gnus-dormant-mark) | |
7584 (= mark gnus-expirable-mark)))) | |
7585 | |
7586 ;; Saving hidden threads. | |
7587 | |
7588 (put 'gnus-save-hidden-threads 'lisp-indent-function 0) | |
7589 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0) | |
7590 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body)) | |
7591 | |
7592 (defmacro gnus-save-hidden-threads (&rest forms) | |
7593 "Save hidden threads, eval FORMS, and restore the hidden threads." | |
7594 (let ((config (make-symbol "config"))) | |
7595 `(let ((,config (gnus-hidden-threads-configuration))) | |
7596 (unwind-protect | |
7597 (progn | |
7598 ,@forms) | |
7599 (gnus-restore-hidden-threads-configuration ,config))))) | |
7600 | |
7601 (defun gnus-hidden-threads-configuration () | |
7602 "Return the current hidden threads configuration." | |
7603 (save-excursion | |
7604 (let (config) | |
7605 (goto-char (point-min)) | |
7606 (while (search-forward "\r" nil t) | |
7607 (push (1- (point)) config)) | |
7608 config))) | |
7609 | |
7610 (defun gnus-restore-hidden-threads-configuration (config) | |
7611 "Restore hidden threads configuration from CONFIG." | |
7612 (let (point buffer-read-only) | |
7613 (while (setq point (pop config)) | |
7614 (when (and (< point (point-max)) | |
7615 (goto-char point) | |
7616 (= (following-char) ?\n)) | |
7617 (subst-char-in-region point (1+ point) ?\n ?\r))))) | |
7618 | |
7619 ;; Various summary mode internalish functions. | |
7620 | |
7621 (defun gnus-mouse-pick-article (e) | |
7622 (interactive "e") | |
7623 (mouse-set-point e) | |
7624 (gnus-summary-next-page nil t)) | |
7625 | |
7626 (defun gnus-summary-setup-buffer (group) | |
7627 "Initialize summary buffer." | |
7628 (let ((buffer (concat "*Summary " group "*"))) | |
7629 (if (get-buffer buffer) | |
7630 (progn | |
7631 (set-buffer buffer) | |
7632 (setq gnus-summary-buffer (current-buffer)) | |
7633 (not gnus-newsgroup-prepared)) | |
7634 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu> | |
7635 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer))) | |
7636 (gnus-add-current-to-buffer-list) | |
7637 (gnus-summary-mode group) | |
7638 (when gnus-carpal | |
7639 (gnus-carpal-setup-buffer 'summary)) | |
7640 (unless gnus-single-article-buffer | |
7641 (make-local-variable 'gnus-article-buffer) | |
7642 (make-local-variable 'gnus-article-current) | |
7643 (make-local-variable 'gnus-original-article-buffer)) | |
7644 (setq gnus-newsgroup-name group) | |
7645 t))) | |
7646 | |
7647 (defun gnus-set-global-variables () | |
7648 ;; Set the global equivalents of the summary buffer-local variables | |
7649 ;; to the latest values they had. These reflect the summary buffer | |
7650 ;; that was in action when the last article was fetched. | |
7651 (when (eq major-mode 'gnus-summary-mode) | |
7652 (setq gnus-summary-buffer (current-buffer)) | |
7653 (let ((name gnus-newsgroup-name) | |
7654 (marked gnus-newsgroup-marked) | |
7655 (unread gnus-newsgroup-unreads) | |
7656 (headers gnus-current-headers) | |
7657 (data gnus-newsgroup-data) | |
7658 (summary gnus-summary-buffer) | |
7659 (article-buffer gnus-article-buffer) | |
7660 (original gnus-original-article-buffer) | |
7661 (gac gnus-article-current) | |
7662 (reffed gnus-reffed-article-number) | |
7663 (score-file gnus-current-score-file)) | |
7664 (save-excursion | |
7665 (set-buffer gnus-group-buffer) | |
7666 (setq gnus-newsgroup-name name) | |
7667 (setq gnus-newsgroup-marked marked) | |
7668 (setq gnus-newsgroup-unreads unread) | |
7669 (setq gnus-current-headers headers) | |
7670 (setq gnus-newsgroup-data data) | |
7671 (setq gnus-article-current gac) | |
7672 (setq gnus-summary-buffer summary) | |
7673 (setq gnus-article-buffer article-buffer) | |
7674 (setq gnus-original-article-buffer original) | |
7675 (setq gnus-reffed-article-number reffed) | |
7676 (setq gnus-current-score-file score-file))))) | |
7677 | |
7678 (defun gnus-summary-last-article-p (&optional article) | |
7679 "Return whether ARTICLE is the last article in the buffer." | |
7680 (if (not (setq article (or article (gnus-summary-article-number)))) | |
7681 t ; All non-existant numbers are the last article. :-) | |
7682 (not (cdr (gnus-data-find-list article))))) | |
7683 | |
7684 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number) | |
7685 "Insert a dummy root in the summary buffer." | |
7686 (beginning-of-line) | |
7687 (gnus-add-text-properties | |
7688 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point)) | |
7689 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number))) | |
7690 | |
7691 (defun gnus-make-thread-indent-array () | |
7692 (let ((n 200)) | |
7693 (unless (and gnus-thread-indent-array | |
7694 (= gnus-thread-indent-level gnus-thread-indent-array-level)) | |
7695 (setq gnus-thread-indent-array (make-vector 201 "") | |
7696 gnus-thread-indent-array-level gnus-thread-indent-level) | |
7697 (while (>= n 0) | |
7698 (aset gnus-thread-indent-array n | |
7699 (make-string (* n gnus-thread-indent-level) ? )) | |
7700 (setq n (1- n)))))) | |
7701 | |
7702 (defun gnus-summary-insert-line | |
7703 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread | |
7704 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil | |
7705 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process) | |
7706 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level)) | |
7707 (gnus-tmp-lines (mail-header-lines gnus-tmp-header)) | |
7708 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0)) | |
7709 (gnus-tmp-score-char | |
7710 (if (or (null gnus-summary-default-score) | |
7711 (<= (abs (- gnus-tmp-score gnus-summary-default-score)) | |
7712 gnus-summary-zcore-fuzz)) ? | |
7713 (if (< gnus-tmp-score gnus-summary-default-score) | |
7714 gnus-score-below-mark gnus-score-over-mark))) | |
7715 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark) | |
7716 ((memq gnus-tmp-current gnus-newsgroup-cached) | |
7717 gnus-cached-mark) | |
7718 (gnus-tmp-replied gnus-replied-mark) | |
7719 ((memq gnus-tmp-current gnus-newsgroup-saved) | |
7720 gnus-saved-mark) | |
7721 (t gnus-unread-mark))) | |
7722 (gnus-tmp-from (mail-header-from gnus-tmp-header)) | |
7723 (gnus-tmp-name | |
7724 (cond | |
7725 ((string-match "(.+)" gnus-tmp-from) | |
7726 (substring gnus-tmp-from | |
7727 (1+ (match-beginning 0)) (1- (match-end 0)))) | |
7728 ((string-match "<[^>]+> *$" gnus-tmp-from) | |
7729 (let ((beg (match-beginning 0))) | |
7730 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from) | |
7731 (substring gnus-tmp-from (1+ (match-beginning 0)) | |
7732 (1- (match-end 0)))) | |
7733 (substring gnus-tmp-from 0 beg)))) | |
7734 (t gnus-tmp-from))) | |
7735 (gnus-tmp-subject (mail-header-subject gnus-tmp-header)) | |
7736 (gnus-tmp-number (mail-header-number gnus-tmp-header)) | |
7737 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[)) | |
7738 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\])) | |
7739 (buffer-read-only nil)) | |
7740 (when (string= gnus-tmp-name "") | |
7741 (setq gnus-tmp-name gnus-tmp-from)) | |
7742 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0)) | |
7743 (gnus-put-text-property | |
7744 (point) | |
7745 (progn (eval gnus-summary-line-format-spec) (point)) | |
7746 'gnus-number gnus-tmp-number) | |
7747 (when (gnus-visual-p 'summary-highlight 'highlight) | |
7748 (forward-line -1) | |
7749 (run-hooks 'gnus-summary-update-hook) | |
7750 (forward-line 1)))) | |
7751 | |
7752 (defun gnus-summary-update-line (&optional dont-update) | |
7753 ;; Update summary line after change. | |
7754 (when (and gnus-summary-default-score | |
7755 (not gnus-summary-inhibit-highlight)) | |
7756 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion. | |
7757 (article (gnus-summary-article-number)) | |
7758 (score (gnus-summary-article-score article))) | |
7759 (unless dont-update | |
7760 (if (and gnus-summary-mark-below | |
7761 (< (gnus-summary-article-score) | |
7762 gnus-summary-mark-below)) | |
7763 ;; This article has a low score, so we mark it as read. | |
7764 (when (memq article gnus-newsgroup-unreads) | |
7765 (gnus-summary-mark-article-as-read gnus-low-score-mark)) | |
7766 (when (eq (gnus-summary-article-mark) gnus-low-score-mark) | |
7767 ;; This article was previously marked as read on account | |
7768 ;; of a low score, but now it has risen, so we mark it as | |
7769 ;; unread. | |
7770 (gnus-summary-mark-article-as-unread gnus-unread-mark))) | |
7771 (gnus-summary-update-mark | |
7772 (if (or (null gnus-summary-default-score) | |
7773 (<= (abs (- score gnus-summary-default-score)) | |
7774 gnus-summary-zcore-fuzz)) ? | |
7775 (if (< score gnus-summary-default-score) | |
7776 gnus-score-below-mark gnus-score-over-mark)) 'score)) | |
7777 ;; Do visual highlighting. | |
7778 (when (gnus-visual-p 'summary-highlight 'highlight) | |
7779 (run-hooks 'gnus-summary-update-hook))))) | |
7780 | |
7781 (defvar gnus-tmp-new-adopts nil) | |
7782 | |
7783 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char) | |
7784 ;; Sum up all elements (and sub-elements) in a list. | |
7785 (let* ((number | |
7786 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>. | |
7787 (cond | |
7788 ((and (consp thread) (cdr thread)) | |
7789 (apply | |
7790 '+ 1 (mapcar | |
7791 'gnus-summary-number-of-articles-in-thread (cdr thread)))) | |
7792 ((null thread) | |
7793 1) | |
7794 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit) | |
7795 1) | |
7796 (t 0)))) | |
7797 (when (and level (zerop level) gnus-tmp-new-adopts) | |
7798 (incf number | |
7799 (apply '+ (mapcar | |
7800 'gnus-summary-number-of-articles-in-thread | |
7801 gnus-tmp-new-adopts)))) | |
7802 (if char | |
7803 (if (> number 1) gnus-not-empty-thread-mark | |
7804 gnus-empty-thread-mark) | |
7805 number))) | |
7806 | |
7807 (defun gnus-summary-set-local-parameters (group) | |
7808 "Go through the local params of GROUP and set all variable specs in that list." | |
7809 (let ((params (gnus-info-params (gnus-get-info group))) | |
7810 elem) | |
7811 (while params | |
7812 (setq elem (car params) | |
7813 params (cdr params)) | |
7814 (and (consp elem) ; Has to be a cons. | |
7815 (consp (cdr elem)) ; The cdr has to be a list. | |
7816 (symbolp (car elem)) ; Has to be a symbol in there. | |
7817 (not (memq (car elem) | |
7818 '(quit-config to-address to-list to-group))) | |
7819 (progn ; So we set it. | |
7820 (make-local-variable (car elem)) | |
7821 (set (car elem) (eval (nth 1 elem)))))))) | |
7822 | |
7823 (defun gnus-summary-read-group (group &optional show-all no-article | |
7824 kill-buffer no-display) | |
7825 "Start reading news in newsgroup GROUP. | |
7826 If SHOW-ALL is non-nil, already read articles are also listed. | |
7827 If NO-ARTICLE is non-nil, no article is selected initially. | |
7828 If NO-DISPLAY, don't generate a summary buffer." | |
7829 (gnus-message 5 "Retrieving newsgroup: %s..." group) | |
7830 (let* ((new-group (gnus-summary-setup-buffer group)) | |
7831 (quit-config (gnus-group-quit-config group)) | |
7832 (did-select (and new-group (gnus-select-newsgroup group show-all)))) | |
7833 (cond | |
7834 ;; This summary buffer exists already, so we just select it. | |
7835 ((not new-group) | |
7836 (gnus-set-global-variables) | |
7837 (when kill-buffer | |
7838 (gnus-kill-or-deaden-summary kill-buffer)) | |
7839 (gnus-configure-windows 'summary 'force) | |
7840 (gnus-set-mode-line 'summary) | |
7841 (gnus-summary-position-point) | |
7842 (message "") | |
7843 t) | |
7844 ;; We couldn't select this group. | |
7845 ((null did-select) | |
7846 (when (and (eq major-mode 'gnus-summary-mode) | |
7847 (not (equal (current-buffer) kill-buffer))) | |
7848 (kill-buffer (current-buffer)) | |
7849 (if (not quit-config) | |
7850 (progn | |
7851 (set-buffer gnus-group-buffer) | |
7852 (gnus-group-jump-to-group group) | |
7853 (gnus-group-next-unread-group 1)) | |
7854 (if (not (buffer-name (car quit-config))) | |
7855 (gnus-configure-windows 'group 'force) | |
7856 (set-buffer (car quit-config)) | |
7857 (and (eq major-mode 'gnus-summary-mode) | |
7858 (gnus-set-global-variables)) | |
7859 (gnus-configure-windows (cdr quit-config))))) | |
7860 (gnus-message 3 "Can't select group") | |
7861 nil) | |
7862 ;; The user did a `C-g' while prompting for number of articles, | |
7863 ;; so we exit this group. | |
7864 ((eq did-select 'quit) | |
7865 (and (eq major-mode 'gnus-summary-mode) | |
7866 (not (equal (current-buffer) kill-buffer)) | |
7867 (kill-buffer (current-buffer))) | |
7868 (when kill-buffer | |
7869 (gnus-kill-or-deaden-summary kill-buffer)) | |
7870 (if (not quit-config) | |
7871 (progn | |
7872 (set-buffer gnus-group-buffer) | |
7873 (gnus-group-jump-to-group group) | |
7874 (gnus-group-next-unread-group 1) | |
7875 (gnus-configure-windows 'group 'force)) | |
7876 (if (not (buffer-name (car quit-config))) | |
7877 (gnus-configure-windows 'group 'force) | |
7878 (set-buffer (car quit-config)) | |
7879 (and (eq major-mode 'gnus-summary-mode) | |
7880 (gnus-set-global-variables)) | |
7881 (gnus-configure-windows (cdr quit-config)))) | |
7882 ;; Finally signal the quit. | |
7883 (signal 'quit nil)) | |
7884 ;; The group was successfully selected. | |
7885 (t | |
7886 (gnus-set-global-variables) | |
7887 ;; Save the active value in effect when the group was entered. | |
7888 (setq gnus-newsgroup-active | |
7889 (gnus-copy-sequence | |
7890 (gnus-active gnus-newsgroup-name))) | |
7891 ;; You can change the summary buffer in some way with this hook. | |
7892 (run-hooks 'gnus-select-group-hook) | |
7893 ;; Set any local variables in the group parameters. | |
7894 (gnus-summary-set-local-parameters gnus-newsgroup-name) | |
7895 (gnus-update-format-specifications) | |
7896 ;; Do score processing. | |
7897 (when gnus-use-scoring | |
7898 (gnus-possibly-score-headers)) | |
7899 ;; Check whether to fill in the gaps in the threads. | |
7900 (when gnus-build-sparse-threads | |
7901 (gnus-build-sparse-threads)) | |
7902 ;; Find the initial limit. | |
7903 (if gnus-show-threads | |
7904 (if show-all | |
7905 (let ((gnus-newsgroup-dormant nil)) | |
7906 (gnus-summary-initial-limit show-all)) | |
7907 (gnus-summary-initial-limit show-all)) | |
7908 (setq gnus-newsgroup-limit | |
7909 (mapcar | |
7910 (lambda (header) (mail-header-number header)) | |
7911 gnus-newsgroup-headers))) | |
7912 ;; Generate the summary buffer. | |
7913 (unless no-display | |
7914 (gnus-summary-prepare)) | |
7915 (when gnus-use-trees | |
7916 (gnus-tree-open group) | |
7917 (setq gnus-summary-highlight-line-function | |
7918 'gnus-tree-highlight-article)) | |
7919 ;; If the summary buffer is empty, but there are some low-scored | |
7920 ;; articles or some excluded dormants, we include these in the | |
7921 ;; buffer. | |
7922 (when (and (zerop (buffer-size)) | |
7923 (not no-display)) | |
7924 (cond (gnus-newsgroup-dormant | |
7925 (gnus-summary-limit-include-dormant)) | |
7926 ((and gnus-newsgroup-scored show-all) | |
7927 (gnus-summary-limit-include-expunged t)))) | |
7928 ;; Function `gnus-apply-kill-file' must be called in this hook. | |
7929 (run-hooks 'gnus-apply-kill-hook) | |
7930 (if (and (zerop (buffer-size)) | |
7931 (not no-display)) | |
7932 (progn | |
7933 ;; This newsgroup is empty. | |
7934 (gnus-summary-catchup-and-exit nil t) ;Without confirmations. | |
7935 (gnus-message 6 "No unread news") | |
7936 (when kill-buffer | |
7937 (gnus-kill-or-deaden-summary kill-buffer)) | |
7938 ;; Return nil from this function. | |
7939 nil) | |
7940 ;; Hide conversation thread subtrees. We cannot do this in | |
7941 ;; gnus-summary-prepare-hook since kill processing may not | |
7942 ;; work with hidden articles. | |
7943 (and gnus-show-threads | |
7944 gnus-thread-hide-subtree | |
7945 (gnus-summary-hide-all-threads)) | |
7946 ;; Show first unread article if requested. | |
7947 (if (and (not no-article) | |
7948 (not no-display) | |
7949 gnus-newsgroup-unreads | |
7950 gnus-auto-select-first) | |
7951 (unless (if (eq gnus-auto-select-first 'best) | |
7952 (gnus-summary-best-unread-article) | |
7953 (gnus-summary-first-unread-article)) | |
7954 (gnus-configure-windows 'summary)) | |
7955 ;; Don't select any articles, just move point to the first | |
7956 ;; article in the group. | |
7957 (goto-char (point-min)) | |
7958 (gnus-summary-position-point) | |
7959 (gnus-set-mode-line 'summary) | |
7960 (gnus-configure-windows 'summary 'force)) | |
7961 ;; If we are in async mode, we send some info to the backend. | |
7962 (when gnus-newsgroup-async | |
7963 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data)) | |
7964 (when kill-buffer | |
7965 (gnus-kill-or-deaden-summary kill-buffer)) | |
7966 (when (get-buffer-window gnus-group-buffer t) | |
7967 ;; Gotta use windows, because recenter does wierd stuff if | |
7968 ;; the current buffer ain't the displayed window. | |
7969 (let ((owin (selected-window))) | |
7970 (select-window (get-buffer-window gnus-group-buffer t)) | |
7971 (when (gnus-group-goto-group group) | |
7972 (recenter)) | |
7973 (select-window owin)))) | |
7974 ;; Mark this buffer as "prepared". | |
7975 (setq gnus-newsgroup-prepared t) | |
7976 t)))) | |
7977 | |
7978 (defun gnus-summary-prepare () | |
7979 "Generate the summary buffer." | |
7980 (let ((buffer-read-only nil)) | |
7981 (erase-buffer) | |
7982 (setq gnus-newsgroup-data nil | |
7983 gnus-newsgroup-data-reverse nil) | |
7984 (run-hooks 'gnus-summary-generate-hook) | |
7985 ;; Generate the buffer, either with threads or without. | |
7986 (when gnus-newsgroup-headers | |
7987 (gnus-summary-prepare-threads | |
7988 (if gnus-show-threads | |
7989 (gnus-sort-gathered-threads | |
7990 (funcall gnus-summary-thread-gathering-function | |
7991 (gnus-sort-threads | |
7992 (gnus-cut-threads (gnus-make-threads))))) | |
7993 ;; Unthreaded display. | |
7994 (gnus-sort-articles gnus-newsgroup-headers)))) | |
7995 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data)) | |
7996 ;; Call hooks for modifying summary buffer. | |
7997 (goto-char (point-min)) | |
7998 (run-hooks 'gnus-summary-prepare-hook))) | |
7999 | |
8000 (defun gnus-gather-threads-by-subject (threads) | |
8001 "Gather threads by looking at Subject headers." | |
8002 (if (not gnus-summary-make-false-root) | |
8003 threads | |
8004 (let ((hashtb (gnus-make-hashtable 1023)) | |
8005 (prev threads) | |
8006 (result threads) | |
8007 subject hthread whole-subject) | |
8008 (while threads | |
8009 (setq whole-subject (mail-header-subject (caar threads))) | |
8010 (setq subject | |
8011 (cond | |
8012 ;; Truncate the subject. | |
8013 ((numberp gnus-summary-gather-subject-limit) | |
8014 (setq subject (gnus-simplify-subject-re whole-subject)) | |
8015 (if (> (length subject) gnus-summary-gather-subject-limit) | |
8016 (substring subject 0 gnus-summary-gather-subject-limit) | |
8017 subject)) | |
8018 ;; Fuzzily simplify it. | |
8019 ((eq 'fuzzy gnus-summary-gather-subject-limit) | |
8020 (gnus-simplify-subject-fuzzy whole-subject)) | |
8021 ;; Just remove the leading "Re:". | |
8022 (t | |
8023 (gnus-simplify-subject-re whole-subject)))) | |
8024 | |
8025 (if (and gnus-summary-gather-exclude-subject | |
8026 (string-match gnus-summary-gather-exclude-subject | |
8027 subject)) | |
8028 () ; We don't want to do anything with this article. | |
8029 ;; We simplify the subject before looking it up in the | |
8030 ;; hash table. | |
8031 | |
8032 (if (setq hthread (gnus-gethash subject hashtb)) | |
8033 (progn | |
8034 ;; We enter a dummy root into the thread, if we | |
8035 ;; haven't done that already. | |
8036 (unless (stringp (caar hthread)) | |
8037 (setcar hthread (list whole-subject (car hthread)))) | |
8038 ;; We add this new gathered thread to this gathered | |
8039 ;; thread. | |
8040 (setcdr (car hthread) | |
8041 (nconc (cdar hthread) (list (car threads)))) | |
8042 ;; Remove it from the list of threads. | |
8043 (setcdr prev (cdr threads)) | |
8044 (setq threads prev)) | |
8045 ;; Enter this thread into the hash table. | |
8046 (gnus-sethash subject threads hashtb))) | |
8047 (setq prev threads) | |
8048 (setq threads (cdr threads))) | |
8049 result))) | |
8050 | |
8051 (defun gnus-gather-threads-by-references (threads) | |
8052 "Gather threads by looking at References headers." | |
8053 (let ((idhashtb (gnus-make-hashtable 1023)) | |
8054 (thhashtb (gnus-make-hashtable 1023)) | |
8055 (prev threads) | |
8056 (result threads) | |
8057 ids references id gthread gid entered) | |
8058 (while threads | |
8059 (when (setq references (mail-header-references (caar threads))) | |
8060 (setq id (mail-header-id (caar threads))) | |
8061 (setq ids (gnus-split-references references)) | |
8062 (setq entered nil) | |
8063 (while ids | |
8064 (if (not (setq gid (gnus-gethash (car ids) idhashtb))) | |
8065 (progn | |
8066 (gnus-sethash (car ids) id idhashtb) | |
8067 (gnus-sethash id threads thhashtb)) | |
8068 (setq gthread (gnus-gethash gid thhashtb)) | |
8069 (unless entered | |
8070 ;; We enter a dummy root into the thread, if we | |
8071 ;; haven't done that already. | |
8072 (unless (stringp (caar gthread)) | |
8073 (setcar gthread (list (mail-header-subject (caar gthread)) | |
8074 (car gthread)))) | |
8075 ;; We add this new gathered thread to this gathered | |
8076 ;; thread. | |
8077 (setcdr (car gthread) | |
8078 (nconc (cdar gthread) (list (car threads))))) | |
8079 ;; Add it into the thread hash table. | |
8080 (gnus-sethash id gthread thhashtb) | |
8081 (setq entered t) | |
8082 ;; Remove it from the list of threads. | |
8083 (setcdr prev (cdr threads)) | |
8084 (setq threads prev)) | |
8085 (setq ids (cdr ids)))) | |
8086 (setq prev threads) | |
8087 (setq threads (cdr threads))) | |
8088 result)) | |
8089 | |
8090 (defun gnus-sort-gathered-threads (threads) | |
8091 "Sort subtreads inside each gathered thread by article number." | |
8092 (let ((result threads)) | |
8093 (while threads | |
8094 (when (stringp (caar threads)) | |
8095 (setcdr (car threads) | |
8096 (sort (cdar threads) 'gnus-thread-sort-by-number))) | |
8097 (setq threads (cdr threads))) | |
8098 result)) | |
8099 | |
8100 (defun gnus-make-threads () | |
8101 "Go through the dependency hashtb and find the roots. Return all threads." | |
8102 (let (threads) | |
8103 (mapatoms | |
8104 (lambda (refs) | |
8105 (unless (car (symbol-value refs)) | |
8106 ;; These threads do not refer back to any other articles, | |
8107 ;; so they're roots. | |
8108 (setq threads (append (cdr (symbol-value refs)) threads)))) | |
8109 gnus-newsgroup-dependencies) | |
8110 threads)) | |
8111 | |
8112 (defun gnus-build-sparse-threads () | |
8113 (let ((headers gnus-newsgroup-headers) | |
8114 (deps gnus-newsgroup-dependencies) | |
8115 header references generation relations | |
8116 cthread subject child end pthread relation) | |
8117 ;; First we create an alist of generations/relations, where | |
8118 ;; generations is how much we trust the ralation, and the relation | |
8119 ;; is parent/child. | |
8120 (gnus-message 7 "Making sparse threads...") | |
8121 (save-excursion | |
8122 (nnheader-set-temp-buffer " *gnus sparse threads*") | |
8123 (while (setq header (pop headers)) | |
8124 (when (and (setq references (mail-header-references header)) | |
8125 (not (string= references ""))) | |
8126 (insert references) | |
8127 (setq child (mail-header-id header) | |
8128 subject (mail-header-subject header)) | |
8129 (setq generation 0) | |
8130 (while (search-backward ">" nil t) | |
8131 (setq end (1+ (point))) | |
8132 (when (search-backward "<" nil t) | |
8133 (push (list (incf generation) | |
8134 child (setq child (buffer-substring (point) end)) | |
8135 subject) | |
8136 relations))) | |
8137 (push (list (1+ generation) child nil subject) relations) | |
8138 (erase-buffer))) | |
8139 (kill-buffer (current-buffer))) | |
8140 ;; Sort over trustworthiness. | |
8141 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2))))) | |
8142 (while (setq relation (pop relations)) | |
8143 (when (if (boundp (setq cthread (intern (cadr relation) deps))) | |
8144 (unless (car (symbol-value cthread)) | |
8145 ;; Make this article the parent of these threads. | |
8146 (setcar (symbol-value cthread) | |
8147 (vector gnus-reffed-article-number | |
8148 (cadddr relation) | |
8149 "" "" | |
8150 (cadr relation) | |
8151 (or (caddr relation) "") 0 0 ""))) | |
8152 (set cthread (list (vector gnus-reffed-article-number | |
8153 (cadddr relation) | |
8154 "" "" (cadr relation) | |
8155 (or (caddr relation) "") 0 0 "")))) | |
8156 (push gnus-reffed-article-number gnus-newsgroup-limit) | |
8157 (push gnus-reffed-article-number gnus-newsgroup-sparse) | |
8158 (push (cons gnus-reffed-article-number gnus-sparse-mark) | |
8159 gnus-newsgroup-reads) | |
8160 (decf gnus-reffed-article-number) | |
8161 ;; Make this new thread the child of its parent. | |
8162 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps))) | |
8163 (setcdr (symbol-value pthread) | |
8164 (nconc (cdr (symbol-value pthread)) | |
8165 (list (symbol-value cthread)))) | |
8166 (set pthread (list nil (symbol-value cthread)))))) | |
8167 (gnus-message 7 "Making sparse threads...done"))) | |
8168 | |
8169 (defun gnus-build-old-threads () | |
8170 ;; Look at all the articles that refer back to old articles, and | |
8171 ;; fetch the headers for the articles that aren't there. This will | |
8172 ;; build complete threads - if the roots haven't been expired by the | |
8173 ;; server, that is. | |
8174 (let (id heads) | |
8175 (mapatoms | |
8176 (lambda (refs) | |
8177 (when (not (car (symbol-value refs))) | |
8178 (setq heads (cdr (symbol-value refs))) | |
8179 (while heads | |
8180 (if (memq (mail-header-number (caar heads)) | |
8181 gnus-newsgroup-dormant) | |
8182 (setq heads (cdr heads)) | |
8183 (setq id (symbol-name refs)) | |
8184 (while (and (setq id (gnus-build-get-header id)) | |
8185 (not (car (gnus-gethash | |
8186 id gnus-newsgroup-dependencies))))) | |
8187 (setq heads nil))))) | |
8188 gnus-newsgroup-dependencies))) | |
8189 | |
8190 (defun gnus-build-get-header (id) | |
8191 ;; Look through the buffer of NOV lines and find the header to | |
8192 ;; ID. Enter this line into the dependencies hash table, and return | |
8193 ;; the id of the parent article (if any). | |
8194 (let ((deps gnus-newsgroup-dependencies) | |
8195 found header) | |
8196 (prog1 | |
8197 (save-excursion | |
8198 (set-buffer nntp-server-buffer) | |
8199 (goto-char (point-min)) | |
8200 (while (and (not found) (search-forward id nil t)) | |
8201 (beginning-of-line) | |
8202 (setq found (looking-at | |
8203 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s" | |
8204 (regexp-quote id)))) | |
8205 (or found (beginning-of-line 2))) | |
8206 (when found | |
8207 (beginning-of-line) | |
8208 (and | |
8209 (setq header (gnus-nov-parse-line | |
8210 (read (current-buffer)) deps)) | |
8211 (gnus-parent-id (mail-header-references header))))) | |
8212 (when header | |
8213 (let ((number (mail-header-number header))) | |
8214 (push number gnus-newsgroup-limit) | |
8215 (push header gnus-newsgroup-headers) | |
8216 (if (memq number gnus-newsgroup-unselected) | |
8217 (progn | |
8218 (push number gnus-newsgroup-unreads) | |
8219 (setq gnus-newsgroup-unselected | |
8220 (delq number gnus-newsgroup-unselected))) | |
8221 (push number gnus-newsgroup-ancient))))))) | |
8222 | |
8223 (defun gnus-summary-update-article (article &optional iheader) | |
8224 "Update ARTICLE in the summary buffer." | |
8225 (set-buffer gnus-summary-buffer) | |
8226 (let* ((header (or iheader (gnus-summary-article-header article))) | |
8227 (id (mail-header-id header)) | |
8228 (data (gnus-data-find article)) | |
8229 (thread (gnus-id-to-thread id)) | |
8230 (references (mail-header-references header)) | |
8231 (parent | |
8232 (gnus-id-to-thread | |
8233 (or (gnus-parent-id | |
8234 (if (and references | |
8235 (not (equal "" references))) | |
8236 references)) | |
8237 "none"))) | |
8238 (buffer-read-only nil) | |
8239 (old (car thread)) | |
8240 (number (mail-header-number header)) | |
8241 pos) | |
8242 (when thread | |
8243 ;; !!! Should this be in or not? | |
8244 (unless iheader | |
8245 (setcar thread nil)) | |
8246 (when parent | |
8247 (delq thread parent)) | |
8248 (if (gnus-summary-insert-subject id header iheader) | |
8249 ;; Set the (possibly) new article number in the data structure. | |
8250 (gnus-data-set-number data (gnus-id-to-article id)) | |
8251 (setcar thread old) | |
8252 nil)))) | |
8253 | |
8254 (defun gnus-rebuild-thread (id) | |
8255 "Rebuild the thread containing ID." | |
8256 (let ((buffer-read-only nil) | |
8257 current thread data) | |
8258 (if (not gnus-show-threads) | |
8259 (setq thread (list (car (gnus-id-to-thread id)))) | |
8260 ;; Get the thread this article is part of. | |
8261 (setq thread (gnus-remove-thread id))) | |
8262 (setq current (save-excursion | |
8263 (and (zerop (forward-line -1)) | |
8264 (gnus-summary-article-number)))) | |
8265 ;; If this is a gathered thread, we have to go some re-gathering. | |
8266 (when (stringp (car thread)) | |
8267 (let ((subject (car thread)) | |
8268 roots thr) | |
8269 (setq thread (cdr thread)) | |
8270 (while thread | |
8271 (unless (memq (setq thr (gnus-id-to-thread | |
8272 (gnus-root-id | |
8273 (mail-header-id (caar thread))))) | |
8274 roots) | |
8275 (push thr roots)) | |
8276 (setq thread (cdr thread))) | |
8277 ;; We now have all (unique) roots. | |
8278 (if (= (length roots) 1) | |
8279 ;; All the loose roots are now one solid root. | |
8280 (setq thread (car roots)) | |
8281 (setq thread (cons subject (gnus-sort-threads roots)))))) | |
8282 (let (threads) | |
8283 ;; We then insert this thread into the summary buffer. | |
8284 (let (gnus-newsgroup-data gnus-newsgroup-threads) | |
8285 (gnus-summary-prepare-threads (gnus-cut-threads (list thread))) | |
8286 (setq data (nreverse gnus-newsgroup-data)) | |
8287 (setq threads gnus-newsgroup-threads)) | |
8288 ;; We splice the new data into the data structure. | |
8289 (gnus-data-enter-list current data) | |
8290 (gnus-data-compute-positions) | |
8291 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads))))) | |
8292 | |
8293 (defun gnus-number-to-header (number) | |
8294 "Return the header for article NUMBER." | |
8295 (let ((headers gnus-newsgroup-headers)) | |
8296 (while (and headers | |
8297 (not (= number (mail-header-number (car headers))))) | |
8298 (pop headers)) | |
8299 (when headers | |
8300 (car headers)))) | |
8301 | |
8302 (defun gnus-id-to-thread (id) | |
8303 "Return the (sub-)thread where ID appears." | |
8304 (gnus-gethash id gnus-newsgroup-dependencies)) | |
8305 | |
8306 (defun gnus-id-to-article (id) | |
8307 "Return the article number of ID." | |
8308 (let ((thread (gnus-id-to-thread id))) | |
8309 (when (and thread | |
8310 (car thread)) | |
8311 (mail-header-number (car thread))))) | |
8312 | |
8313 (defun gnus-id-to-header (id) | |
8314 "Return the article headers of ID." | |
8315 (car (gnus-id-to-thread id))) | |
8316 | |
8317 (defun gnus-article-displayed-root-p (article) | |
8318 "Say whether ARTICLE is a root(ish) article." | |
8319 (let ((level (gnus-summary-thread-level article)) | |
8320 (refs (mail-header-references (gnus-summary-article-header article))) | |
8321 particle) | |
8322 (cond | |
8323 ((null level) nil) | |
8324 ((zerop level) t) | |
8325 ((null refs) t) | |
8326 ((null (gnus-parent-id refs)) t) | |
8327 ((and (= 1 level) | |
8328 (null (setq particle (gnus-id-to-article | |
8329 (gnus-parent-id refs)))) | |
8330 (null (gnus-summary-thread-level particle))))))) | |
8331 | |
8332 (defun gnus-root-id (id) | |
8333 "Return the id of the root of the thread where ID appears." | |
8334 (let (last-id prev) | |
8335 (while (and id (setq prev (car (gnus-gethash | |
8336 id gnus-newsgroup-dependencies)))) | |
8337 (setq last-id id | |
8338 id (gnus-parent-id (mail-header-references prev)))) | |
8339 last-id)) | |
8340 | |
8341 (defun gnus-remove-thread (id &optional dont-remove) | |
8342 "Remove the thread that has ID in it." | |
8343 (let ((dep gnus-newsgroup-dependencies) | |
8344 headers thread last-id) | |
8345 ;; First go up in this thread until we find the root. | |
8346 (setq last-id (gnus-root-id id)) | |
8347 (setq headers (list (car (gnus-id-to-thread last-id)) | |
8348 (caadr (gnus-id-to-thread last-id)))) | |
8349 ;; We have now found the real root of this thread. It might have | |
8350 ;; been gathered into some loose thread, so we have to search | |
8351 ;; through the threads to find the thread we wanted. | |
8352 (let ((threads gnus-newsgroup-threads) | |
8353 sub) | |
8354 (while threads | |
8355 (setq sub (car threads)) | |
8356 (if (stringp (car sub)) | |
8357 ;; This is a gathered thread, so we look at the roots | |
8358 ;; below it to find whether this article is in this | |
8359 ;; gathered root. | |
8360 (progn | |
8361 (setq sub (cdr sub)) | |
8362 (while sub | |
8363 (when (member (caar sub) headers) | |
8364 (setq thread (car threads) | |
8365 threads nil | |
8366 sub nil)) | |
8367 (setq sub (cdr sub)))) | |
8368 ;; It's an ordinary thread, so we check it. | |
8369 (when (eq (car sub) (car headers)) | |
8370 (setq thread sub | |
8371 threads nil))) | |
8372 (setq threads (cdr threads))) | |
8373 ;; If this article is in no thread, then it's a root. | |
8374 (if thread | |
8375 (unless dont-remove | |
8376 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads))) | |
8377 (setq thread (gnus-gethash last-id dep))) | |
8378 (when thread | |
8379 (prog1 | |
8380 thread ; We return this thread. | |
8381 (unless dont-remove | |
8382 (if (stringp (car thread)) | |
8383 (progn | |
8384 ;; If we use dummy roots, then we have to remove the | |
8385 ;; dummy root as well. | |
8386 (when (eq gnus-summary-make-false-root 'dummy) | |
8387 ;; Uhm. | |
8388 ) | |
8389 (setq thread (cdr thread)) | |
8390 (while thread | |
8391 (gnus-remove-thread-1 (car thread)) | |
8392 (setq thread (cdr thread)))) | |
8393 (gnus-remove-thread-1 thread)))))))) | |
8394 | |
8395 (defun gnus-remove-thread-1 (thread) | |
8396 "Remove the thread THREAD recursively." | |
8397 (let ((number (mail-header-number (car thread))) | |
8398 pos) | |
8399 (when (setq pos (text-property-any | |
8400 (point-min) (point-max) 'gnus-number number)) | |
8401 (goto-char pos) | |
8402 (gnus-delete-line) | |
8403 (gnus-data-remove number)) | |
8404 (setq thread (cdr thread)) | |
8405 (while thread | |
8406 (gnus-remove-thread-1 (pop thread))))) | |
8407 | |
8408 (defun gnus-sort-threads (threads) | |
8409 "Sort THREADS." | |
8410 (if (not gnus-thread-sort-functions) | |
8411 threads | |
8412 (let ((func (if (= 1 (length gnus-thread-sort-functions)) | |
8413 (car gnus-thread-sort-functions) | |
8414 `(lambda (t1 t2) | |
8415 ,(gnus-make-sort-function | |
8416 (reverse gnus-thread-sort-functions)))))) | |
8417 (gnus-message 7 "Sorting threads...") | |
8418 (prog1 | |
8419 (sort threads func) | |
8420 (gnus-message 7 "Sorting threads...done"))))) | |
8421 | |
8422 (defun gnus-sort-articles (articles) | |
8423 "Sort ARTICLES." | |
8424 (when gnus-article-sort-functions | |
8425 (let ((func (if (= 1 (length gnus-article-sort-functions)) | |
8426 (car gnus-article-sort-functions) | |
8427 `(lambda (t1 t2) | |
8428 ,(gnus-make-sort-function | |
8429 (reverse gnus-article-sort-functions)))))) | |
8430 (gnus-message 7 "Sorting articles...") | |
8431 (prog1 | |
8432 (setq gnus-newsgroup-headers (sort articles func)) | |
8433 (gnus-message 7 "Sorting articles...done"))))) | |
8434 | |
8435 (defun gnus-make-sort-function (funs) | |
8436 "Return a composite sort condition based on the functions in FUNC." | |
8437 (if (cdr funs) | |
8438 `(or (,(car funs) t1 t2) | |
8439 (and (not (,(car funs) t2 t1)) | |
8440 ,(gnus-make-sort-function (cdr funs)))) | |
8441 `(,(car funs) t1 t2))) | |
8442 | |
8443 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
8444 (defmacro gnus-thread-header (thread) | |
8445 ;; Return header of first article in THREAD. | |
8446 ;; Note that THREAD must never, ever be anything else than a variable - | |
8447 ;; using some other form will lead to serious barfage. | |
8448 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread))) | |
8449 ;; (8% speedup to gnus-summary-prepare, just for fun :-) | |
8450 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ; | |
8451 (vector thread) 2)) | |
8452 | |
8453 (defsubst gnus-article-sort-by-number (h1 h2) | |
8454 "Sort articles by article number." | |
8455 (< (mail-header-number h1) | |
8456 (mail-header-number h2))) | |
8457 | |
8458 (defun gnus-thread-sort-by-number (h1 h2) | |
8459 "Sort threads by root article number." | |
8460 (gnus-article-sort-by-number | |
8461 (gnus-thread-header h1) (gnus-thread-header h2))) | |
8462 | |
8463 (defsubst gnus-article-sort-by-author (h1 h2) | |
8464 "Sort articles by root author." | |
8465 (string-lessp | |
8466 (let ((extract (funcall | |
8467 gnus-extract-address-components | |
8468 (mail-header-from h1)))) | |
8469 (or (car extract) (cdr extract))) | |
8470 (let ((extract (funcall | |
8471 gnus-extract-address-components | |
8472 (mail-header-from h2)))) | |
8473 (or (car extract) (cdr extract))))) | |
8474 | |
8475 (defun gnus-thread-sort-by-author (h1 h2) | |
8476 "Sort threads by root author." | |
8477 (gnus-article-sort-by-author | |
8478 (gnus-thread-header h1) (gnus-thread-header h2))) | |
8479 | |
8480 (defsubst gnus-article-sort-by-subject (h1 h2) | |
8481 "Sort articles by root subject." | |
8482 (string-lessp | |
8483 (downcase (gnus-simplify-subject-re (mail-header-subject h1))) | |
8484 (downcase (gnus-simplify-subject-re (mail-header-subject h2))))) | |
8485 | |
8486 (defun gnus-thread-sort-by-subject (h1 h2) | |
8487 "Sort threads by root subject." | |
8488 (gnus-article-sort-by-subject | |
8489 (gnus-thread-header h1) (gnus-thread-header h2))) | |
8490 | |
8491 (defsubst gnus-article-sort-by-date (h1 h2) | |
8492 "Sort articles by root article date." | |
8493 (string-lessp | |
8494 (inline (gnus-sortable-date (mail-header-date h1))) | |
8495 (inline (gnus-sortable-date (mail-header-date h2))))) | |
8496 | |
8497 (defun gnus-thread-sort-by-date (h1 h2) | |
8498 "Sort threads by root article date." | |
8499 (gnus-article-sort-by-date | |
8500 (gnus-thread-header h1) (gnus-thread-header h2))) | |
8501 | |
8502 (defsubst gnus-article-sort-by-score (h1 h2) | |
8503 "Sort articles by root article score. | |
8504 Unscored articles will be counted as having a score of zero." | |
8505 (> (or (cdr (assq (mail-header-number h1) | |
8506 gnus-newsgroup-scored)) | |
8507 gnus-summary-default-score 0) | |
8508 (or (cdr (assq (mail-header-number h2) | |
8509 gnus-newsgroup-scored)) | |
8510 gnus-summary-default-score 0))) | |
8511 | |
8512 (defun gnus-thread-sort-by-score (h1 h2) | |
8513 "Sort threads by root article score." | |
8514 (gnus-article-sort-by-score | |
8515 (gnus-thread-header h1) (gnus-thread-header h2))) | |
8516 | |
8517 (defun gnus-thread-sort-by-total-score (h1 h2) | |
8518 "Sort threads by the sum of all scores in the thread. | |
8519 Unscored articles will be counted as having a score of zero." | |
8520 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2))) | |
8521 | |
8522 (defun gnus-thread-total-score (thread) | |
8523 ;; This function find the total score of THREAD. | |
8524 (cond ((null thread) | |
8525 0) | |
8526 ((consp thread) | |
8527 (if (stringp (car thread)) | |
8528 (apply gnus-thread-score-function 0 | |
8529 (mapcar 'gnus-thread-total-score-1 (cdr thread))) | |
8530 (gnus-thread-total-score-1 thread))) | |
8531 (t | |
8532 (gnus-thread-total-score-1 (list thread))))) | |
8533 | |
8534 (defun gnus-thread-total-score-1 (root) | |
8535 ;; This function find the total score of the thread below ROOT. | |
8536 (setq root (car root)) | |
8537 (apply gnus-thread-score-function | |
8538 (or (append | |
8539 (mapcar 'gnus-thread-total-score | |
8540 (cdr (gnus-gethash (mail-header-id root) | |
8541 gnus-newsgroup-dependencies))) | |
8542 (if (> (mail-header-number root) 0) | |
8543 (list (or (cdr (assq (mail-header-number root) | |
8544 gnus-newsgroup-scored)) | |
8545 gnus-summary-default-score 0)))) | |
8546 (list gnus-summary-default-score) | |
8547 '(0)))) | |
8548 | |
8549 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. | |
8550 (defvar gnus-tmp-prev-subject nil) | |
8551 (defvar gnus-tmp-false-parent nil) | |
8552 (defvar gnus-tmp-root-expunged nil) | |
8553 (defvar gnus-tmp-dummy-line nil) | |
8554 | |
8555 (defun gnus-summary-prepare-threads (threads) | |
8556 "Prepare summary buffer from THREADS and indentation LEVEL. | |
8557 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])' | |
8558 or a straight list of headers." | |
8559 (gnus-message 7 "Generating summary...") | |
8560 | |
8561 (setq gnus-newsgroup-threads threads) | |
8562 (beginning-of-line) | |
8563 | |
8564 (let ((gnus-tmp-level 0) | |
8565 (default-score (or gnus-summary-default-score 0)) | |
8566 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight)) | |
8567 thread number subject stack state gnus-tmp-gathered beg-match | |
8568 new-roots gnus-tmp-new-adopts thread-end | |
8569 gnus-tmp-header gnus-tmp-unread | |
8570 gnus-tmp-replied gnus-tmp-subject-or-nil | |
8571 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score | |
8572 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name | |
8573 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket) | |
8574 | |
8575 (setq gnus-tmp-prev-subject nil) | |
8576 | |
8577 (if (vectorp (car threads)) | |
8578 ;; If this is a straight (sic) list of headers, then a | |
8579 ;; threaded summary display isn't required, so we just create | |
8580 ;; an unthreaded one. | |
8581 (gnus-summary-prepare-unthreaded threads) | |
8582 | |
8583 ;; Do the threaded display. | |
8584 | |
8585 (while (or threads stack gnus-tmp-new-adopts new-roots) | |
8586 | |
8587 (if (and (= gnus-tmp-level 0) | |
8588 (not (setq gnus-tmp-dummy-line nil)) | |
8589 (or (not stack) | |
8590 (= (caar stack) 0)) | |
8591 (not gnus-tmp-false-parent) | |
8592 (or gnus-tmp-new-adopts new-roots)) | |
8593 (if gnus-tmp-new-adopts | |
8594 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1) | |
8595 thread (list (car gnus-tmp-new-adopts)) | |
8596 gnus-tmp-header (caar thread) | |
8597 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts)) | |
8598 (if new-roots | |
8599 (setq thread (list (car new-roots)) | |
8600 gnus-tmp-header (caar thread) | |
8601 new-roots (cdr new-roots)))) | |
8602 | |
8603 (if threads | |
8604 ;; If there are some threads, we do them before the | |
8605 ;; threads on the stack. | |
8606 (setq thread threads | |
8607 gnus-tmp-header (caar thread)) | |
8608 ;; There were no current threads, so we pop something off | |
8609 ;; the stack. | |
8610 (setq state (car stack) | |
8611 gnus-tmp-level (car state) | |
8612 thread (cdr state) | |
8613 stack (cdr stack) | |
8614 gnus-tmp-header (caar thread)))) | |
8615 | |
8616 (setq gnus-tmp-false-parent nil) | |
8617 (setq gnus-tmp-root-expunged nil) | |
8618 (setq thread-end nil) | |
8619 | |
8620 (if (stringp gnus-tmp-header) | |
8621 ;; The header is a dummy root. | |
8622 (cond | |
8623 ((eq gnus-summary-make-false-root 'adopt) | |
8624 ;; We let the first article adopt the rest. | |
8625 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts | |
8626 (cddar thread))) | |
8627 (setq gnus-tmp-gathered | |
8628 (nconc (mapcar | |
8629 (lambda (h) (mail-header-number (car h))) | |
8630 (cddar thread)) | |
8631 gnus-tmp-gathered)) | |
8632 (setq thread (cons (list (caar thread) | |
8633 (cadar thread)) | |
8634 (cdr thread))) | |
8635 (setq gnus-tmp-level -1 | |
8636 gnus-tmp-false-parent t)) | |
8637 ((eq gnus-summary-make-false-root 'empty) | |
8638 ;; We print adopted articles with empty subject fields. | |
8639 (setq gnus-tmp-gathered | |
8640 (nconc (mapcar | |
8641 (lambda (h) (mail-header-number (car h))) | |
8642 (cddar thread)) | |
8643 gnus-tmp-gathered)) | |
8644 (setq gnus-tmp-level -1)) | |
8645 ((eq gnus-summary-make-false-root 'dummy) | |
8646 ;; We remember that we probably want to output a dummy | |
8647 ;; root. | |
8648 (setq gnus-tmp-dummy-line gnus-tmp-header) | |
8649 (setq gnus-tmp-prev-subject gnus-tmp-header)) | |
8650 (t | |
8651 ;; We do not make a root for the gathered | |
8652 ;; sub-threads at all. | |
8653 (setq gnus-tmp-level -1))) | |
8654 | |
8655 (setq number (mail-header-number gnus-tmp-header) | |
8656 subject (mail-header-subject gnus-tmp-header)) | |
8657 | |
8658 (cond | |
8659 ;; If the thread has changed subject, we might want to make | |
8660 ;; this subthread into a root. | |
8661 ((and (null gnus-thread-ignore-subject) | |
8662 (not (zerop gnus-tmp-level)) | |
8663 gnus-tmp-prev-subject | |
8664 (not (inline | |
8665 (gnus-subject-equal gnus-tmp-prev-subject subject)))) | |
8666 (setq new-roots (nconc new-roots (list (car thread))) | |
8667 thread-end t | |
8668 gnus-tmp-header nil)) | |
8669 ;; If the article lies outside the current limit, | |
8670 ;; then we do not display it. | |
8671 ((and (not (memq number gnus-newsgroup-limit)) | |
8672 (not gnus-tmp-dummy-line)) | |
8673 (setq gnus-tmp-gathered | |
8674 (nconc (mapcar | |
8675 (lambda (h) (mail-header-number (car h))) | |
8676 (cdar thread)) | |
8677 gnus-tmp-gathered)) | |
8678 (setq gnus-tmp-new-adopts (if (cdar thread) | |
8679 (append gnus-tmp-new-adopts | |
8680 (cdar thread)) | |
8681 gnus-tmp-new-adopts) | |
8682 thread-end t | |
8683 gnus-tmp-header nil) | |
8684 (when (zerop gnus-tmp-level) | |
8685 (setq gnus-tmp-root-expunged t))) | |
8686 ;; Perhaps this article is to be marked as read? | |
8687 ((and gnus-summary-mark-below | |
8688 (< (or (cdr (assq number gnus-newsgroup-scored)) | |
8689 default-score) | |
8690 gnus-summary-mark-below) | |
8691 ;; Don't touch sparse articles. | |
8692 (not (memq number gnus-newsgroup-sparse)) | |
8693 (not (memq number gnus-newsgroup-ancient))) | |
8694 (setq gnus-newsgroup-unreads | |
8695 (delq number gnus-newsgroup-unreads)) | |
8696 (if gnus-newsgroup-auto-expire | |
8697 (push number gnus-newsgroup-expirable) | |
8698 (push (cons number gnus-low-score-mark) | |
8699 gnus-newsgroup-reads)))) | |
8700 | |
8701 (when gnus-tmp-header | |
8702 ;; We may have an old dummy line to output before this | |
8703 ;; article. | |
8704 (when gnus-tmp-dummy-line | |
8705 (gnus-summary-insert-dummy-line | |
8706 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header)) | |
8707 (setq gnus-tmp-dummy-line nil)) | |
8708 | |
8709 ;; Compute the mark. | |
8710 (setq | |
8711 gnus-tmp-unread | |
8712 (cond | |
8713 ((memq number gnus-newsgroup-unreads) gnus-unread-mark) | |
8714 ((memq number gnus-newsgroup-marked) gnus-ticked-mark) | |
8715 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark) | |
8716 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark) | |
8717 (t (or (cdr (assq number gnus-newsgroup-reads)) | |
8718 gnus-ancient-mark)))) | |
8719 | |
8720 (push (gnus-data-make number gnus-tmp-unread (1+ (point)) | |
8721 gnus-tmp-header gnus-tmp-level) | |
8722 gnus-newsgroup-data) | |
8723 | |
8724 ;; Actually insert the line. | |
8725 (setq | |
8726 gnus-tmp-subject-or-nil | |
8727 (cond | |
8728 ((and gnus-thread-ignore-subject | |
8729 gnus-tmp-prev-subject | |
8730 (not (inline (gnus-subject-equal | |
8731 gnus-tmp-prev-subject subject)))) | |
8732 subject) | |
8733 ((zerop gnus-tmp-level) | |
8734 (if (and (eq gnus-summary-make-false-root 'empty) | |
8735 (memq number gnus-tmp-gathered) | |
8736 gnus-tmp-prev-subject | |
8737 (inline (gnus-subject-equal | |
8738 gnus-tmp-prev-subject subject))) | |
8739 gnus-summary-same-subject | |
8740 subject)) | |
8741 (t gnus-summary-same-subject))) | |
8742 (if (and (eq gnus-summary-make-false-root 'adopt) | |
8743 (= gnus-tmp-level 1) | |
8744 (memq number gnus-tmp-gathered)) | |
8745 (setq gnus-tmp-opening-bracket ?\< | |
8746 gnus-tmp-closing-bracket ?\>) | |
8747 (setq gnus-tmp-opening-bracket ?\[ | |
8748 gnus-tmp-closing-bracket ?\])) | |
8749 (setq | |
8750 gnus-tmp-indentation | |
8751 (aref gnus-thread-indent-array gnus-tmp-level) | |
8752 gnus-tmp-lines (mail-header-lines gnus-tmp-header) | |
8753 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored)) | |
8754 gnus-summary-default-score 0) | |
8755 gnus-tmp-score-char | |
8756 (if (or (null gnus-summary-default-score) | |
8757 (<= (abs (- gnus-tmp-score gnus-summary-default-score)) | |
8758 gnus-summary-zcore-fuzz)) ? | |
8759 (if (< gnus-tmp-score gnus-summary-default-score) | |
8760 gnus-score-below-mark gnus-score-over-mark)) | |
8761 gnus-tmp-replied | |
8762 (cond ((memq number gnus-newsgroup-processable) | |
8763 gnus-process-mark) | |
8764 ((memq number gnus-newsgroup-cached) | |
8765 gnus-cached-mark) | |
8766 ((memq number gnus-newsgroup-replied) | |
8767 gnus-replied-mark) | |
8768 ((memq number gnus-newsgroup-saved) | |
8769 gnus-saved-mark) | |
8770 (t gnus-unread-mark)) | |
8771 gnus-tmp-from (mail-header-from gnus-tmp-header) | |
8772 gnus-tmp-name | |
8773 (cond | |
8774 ((string-match "(.+)" gnus-tmp-from) | |
8775 (substring gnus-tmp-from | |
8776 (1+ (match-beginning 0)) (1- (match-end 0)))) | |
8777 ((string-match "<[^>]+> *$" gnus-tmp-from) | |
8778 (setq beg-match (match-beginning 0)) | |
8779 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from) | |
8780 (substring gnus-tmp-from (1+ (match-beginning 0)) | |
8781 (1- (match-end 0)))) | |
8782 (substring gnus-tmp-from 0 beg-match))) | |
8783 (t gnus-tmp-from))) | |
8784 (when (string= gnus-tmp-name "") | |
8785 (setq gnus-tmp-name gnus-tmp-from)) | |
8786 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0)) | |
8787 (gnus-put-text-property | |
8788 (point) | |
8789 (progn (eval gnus-summary-line-format-spec) (point)) | |
8790 'gnus-number number) | |
8791 (when gnus-visual-p | |
8792 (forward-line -1) | |
8793 (run-hooks 'gnus-summary-update-hook) | |
8794 (forward-line 1)) | |
8795 | |
8796 (setq gnus-tmp-prev-subject subject))) | |
8797 | |
8798 (when (nth 1 thread) | |
8799 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack)) | |
8800 (incf gnus-tmp-level) | |
8801 (setq threads (if thread-end nil (cdar thread))) | |
8802 (unless threads | |
8803 (setq gnus-tmp-level 0))))) | |
8804 (gnus-message 7 "Generating summary...done")) | |
8805 | |
8806 (defun gnus-summary-prepare-unthreaded (headers) | |
8807 "Generate an unthreaded summary buffer based on HEADERS." | |
8808 (let (header number mark) | |
8809 | |
8810 (while headers | |
8811 ;; We may have to root out some bad articles... | |
8812 (when (memq (setq number (mail-header-number | |
8813 (setq header (pop headers)))) | |
8814 gnus-newsgroup-limit) | |
8815 ;; Mark article as read when it has a low score. | |
8816 (when (and gnus-summary-mark-below | |
8817 (< (or (cdr (assq number gnus-newsgroup-scored)) | |
8818 gnus-summary-default-score 0) | |
8819 gnus-summary-mark-below) | |
8820 (not (memq number gnus-newsgroup-ancient))) | |
8821 (setq gnus-newsgroup-unreads | |
8822 (delq number gnus-newsgroup-unreads)) | |
8823 (if gnus-newsgroup-auto-expire | |
8824 (push number gnus-newsgroup-expirable) | |
8825 (push (cons number gnus-low-score-mark) | |
8826 gnus-newsgroup-reads))) | |
8827 | |
8828 (setq mark | |
8829 (cond | |
8830 ((memq number gnus-newsgroup-marked) gnus-ticked-mark) | |
8831 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark) | |
8832 ((memq number gnus-newsgroup-unreads) gnus-unread-mark) | |
8833 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark) | |
8834 (t (or (cdr (assq number gnus-newsgroup-reads)) | |
8835 gnus-ancient-mark)))) | |
8836 (setq gnus-newsgroup-data | |
8837 (cons (gnus-data-make number mark (1+ (point)) header 0) | |
8838 gnus-newsgroup-data)) | |
8839 (gnus-summary-insert-line | |
8840 header 0 nil mark (memq number gnus-newsgroup-replied) | |
8841 (memq number gnus-newsgroup-expirable) | |
8842 (mail-header-subject header) nil | |
8843 (cdr (assq number gnus-newsgroup-scored)) | |
8844 (memq number gnus-newsgroup-processable)))))) | |
8845 | |
8846 (defun gnus-select-newsgroup (group &optional read-all) | |
8847 "Select newsgroup GROUP. | |
8848 If READ-ALL is non-nil, all articles in the group are selected." | |
8849 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
8850 (info (nth 2 entry)) | |
8851 articles fetched-articles cached) | |
8852 | |
8853 (or (gnus-check-server | |
8854 (setq gnus-current-select-method (gnus-find-method-for-group group))) | |
8855 (error "Couldn't open server")) | |
8856 | |
8857 (or (and entry (not (eq (car entry) t))) ; Either it's active... | |
8858 (gnus-activate-group group) ; Or we can activate it... | |
8859 (progn ; Or we bug out. | |
8860 (when (equal major-mode 'gnus-summary-mode) | |
8861 (kill-buffer (current-buffer))) | |
8862 (error "Couldn't request group %s: %s" | |
8863 group (gnus-status-message group)))) | |
8864 | |
8865 (unless (gnus-request-group group t) | |
8866 (when (equal major-mode 'gnus-summary-mode) | |
8867 (kill-buffer (current-buffer))) | |
8868 (error "Couldn't request group %s: %s" | |
8869 group (gnus-status-message group))) | |
8870 | |
8871 (setq gnus-newsgroup-name group) | |
8872 (setq gnus-newsgroup-unselected nil) | |
8873 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group)) | |
8874 | |
8875 (and gnus-asynchronous | |
8876 (gnus-check-backend-function | |
8877 'request-asynchronous gnus-newsgroup-name) | |
8878 (setq gnus-newsgroup-async | |
8879 (gnus-request-asynchronous gnus-newsgroup-name))) | |
8880 | |
8881 ;; Adjust and set lists of article marks. | |
8882 (when info | |
8883 (gnus-adjust-marked-articles info)) | |
8884 | |
8885 ;; Kludge to avoid having cached articles nixed out in virtual groups. | |
8886 (when (gnus-virtual-group-p group) | |
8887 (setq cached gnus-newsgroup-cached)) | |
8888 | |
8889 (setq gnus-newsgroup-unreads | |
8890 (gnus-set-difference | |
8891 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked) | |
8892 gnus-newsgroup-dormant)) | |
8893 | |
8894 (setq gnus-newsgroup-processable nil) | |
8895 | |
8896 (setq articles (gnus-articles-to-read group read-all)) | |
8897 | |
8898 (cond | |
8899 ((null articles) | |
8900 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display") | |
8901 'quit) | |
8902 ((eq articles 0) nil) | |
8903 (t | |
8904 ;; Init the dependencies hash table. | |
8905 (setq gnus-newsgroup-dependencies | |
8906 (gnus-make-hashtable (length articles))) | |
8907 ;; Retrieve the headers and read them in. | |
8908 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name) | |
8909 (setq gnus-newsgroup-headers | |
8910 (if (eq 'nov | |
8911 (setq gnus-headers-retrieved-by | |
8912 (gnus-retrieve-headers | |
8913 articles gnus-newsgroup-name | |
8914 ;; We might want to fetch old headers, but | |
8915 ;; not if there is only 1 article. | |
8916 (and gnus-fetch-old-headers | |
8917 (or (and | |
8918 (not (eq gnus-fetch-old-headers 'some)) | |
8919 (not (numberp gnus-fetch-old-headers))) | |
8920 (> (length articles) 1)))))) | |
8921 (gnus-get-newsgroup-headers-xover articles) | |
8922 (gnus-get-newsgroup-headers))) | |
8923 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name) | |
8924 | |
8925 ;; Kludge to avoid having cached articles nixed out in virtual groups. | |
8926 (when cached | |
8927 (setq gnus-newsgroup-cached cached)) | |
8928 | |
8929 ;; Set the initial limit. | |
8930 (setq gnus-newsgroup-limit (copy-sequence articles)) | |
8931 ;; Remove canceled articles from the list of unread articles. | |
8932 (setq gnus-newsgroup-unreads | |
8933 (gnus-set-sorted-intersection | |
8934 gnus-newsgroup-unreads | |
8935 (setq fetched-articles | |
8936 (mapcar (lambda (headers) (mail-header-number headers)) | |
8937 gnus-newsgroup-headers)))) | |
8938 ;; Removed marked articles that do not exist. | |
8939 (gnus-update-missing-marks | |
8940 (gnus-sorted-complement fetched-articles articles)) | |
8941 ;; We might want to build some more threads first. | |
8942 (and gnus-fetch-old-headers | |
8943 (eq gnus-headers-retrieved-by 'nov) | |
8944 (gnus-build-old-threads)) | |
8945 ;; Check whether auto-expire is to be done in this group. | |
8946 (setq gnus-newsgroup-auto-expire | |
8947 (gnus-group-auto-expirable-p group)) | |
8948 ;; Set up the article buffer now, if necessary. | |
8949 (unless gnus-single-article-buffer | |
8950 (gnus-article-setup-buffer)) | |
8951 ;; First and last article in this newsgroup. | |
8952 (when gnus-newsgroup-headers | |
8953 (setq gnus-newsgroup-begin | |
8954 (mail-header-number (car gnus-newsgroup-headers)) | |
8955 gnus-newsgroup-end | |
8956 (mail-header-number | |
8957 (gnus-last-element gnus-newsgroup-headers)))) | |
8958 ;; GROUP is successfully selected. | |
8959 (or gnus-newsgroup-headers t))))) | |
8960 | |
8961 (defun gnus-articles-to-read (group read-all) | |
8962 ;; Find out what articles the user wants to read. | |
8963 (let* ((articles | |
8964 ;; Select all articles if `read-all' is non-nil, or if there | |
8965 ;; are no unread articles. | |
8966 (if (or read-all | |
8967 (and (zerop (length gnus-newsgroup-marked)) | |
8968 (zerop (length gnus-newsgroup-unreads)))) | |
8969 (gnus-uncompress-range (gnus-active group)) | |
8970 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked | |
8971 (copy-sequence gnus-newsgroup-unreads)) | |
8972 '<))) | |
8973 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles)) | |
8974 (scored (length scored-list)) | |
8975 (number (length articles)) | |
8976 (marked (+ (length gnus-newsgroup-marked) | |
8977 (length gnus-newsgroup-dormant))) | |
8978 (select | |
8979 (cond | |
8980 ((numberp read-all) | |
8981 read-all) | |
8982 (t | |
8983 (condition-case () | |
8984 (cond | |
8985 ((and (or (<= scored marked) (= scored number)) | |
8986 (numberp gnus-large-newsgroup) | |
8987 (> number gnus-large-newsgroup)) | |
8988 (let ((input | |
8989 (read-string | |
8990 (format | |
8991 "How many articles from %s (default %d): " | |
8992 gnus-newsgroup-name number)))) | |
8993 (if (string-match "^[ \t]*$" input) number input))) | |
8994 ((and (> scored marked) (< scored number) | |
8995 (> (- scored number) 20)) | |
8996 (let ((input | |
8997 (read-string | |
8998 (format "%s %s (%d scored, %d total): " | |
8999 "How many articles from" | |
9000 group scored number)))) | |
9001 (if (string-match "^[ \t]*$" input) | |
9002 number input))) | |
9003 (t number)) | |
9004 (quit nil)))))) | |
9005 (setq select (if (stringp select) (string-to-number select) select)) | |
9006 (if (or (null select) (zerop select)) | |
9007 select | |
9008 (if (and (not (zerop scored)) (<= (abs select) scored)) | |
9009 (progn | |
9010 (setq articles (sort scored-list '<)) | |
9011 (setq number (length articles))) | |
9012 (setq articles (copy-sequence articles))) | |
9013 | |
9014 (if (< (abs select) number) | |
9015 (if (< select 0) | |
9016 ;; Select the N oldest articles. | |
9017 (setcdr (nthcdr (1- (abs select)) articles) nil) | |
9018 ;; Select the N most recent articles. | |
9019 (setq articles (nthcdr (- number select) articles)))) | |
9020 (setq gnus-newsgroup-unselected | |
9021 (gnus-sorted-intersection | |
9022 gnus-newsgroup-unreads | |
9023 (gnus-sorted-complement gnus-newsgroup-unreads articles))) | |
9024 articles))) | |
9025 | |
9026 (defun gnus-killed-articles (killed articles) | |
9027 (let (out) | |
9028 (while articles | |
9029 (if (inline (gnus-member-of-range (car articles) killed)) | |
9030 (setq out (cons (car articles) out))) | |
9031 (setq articles (cdr articles))) | |
9032 out)) | |
9033 | |
9034 (defun gnus-uncompress-marks (marks) | |
9035 "Uncompress the mark ranges in MARKS." | |
9036 (let ((uncompressed '(score bookmark)) | |
9037 out) | |
9038 (while marks | |
9039 (if (memq (caar marks) uncompressed) | |
9040 (push (car marks) out) | |
9041 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out)) | |
9042 (setq marks (cdr marks))) | |
9043 out)) | |
9044 | |
9045 (defun gnus-adjust-marked-articles (info) | |
9046 "Set all article lists and remove all marks that are no longer legal." | |
9047 (let* ((marked-lists (gnus-info-marks info)) | |
9048 (active (gnus-active (gnus-info-group info))) | |
9049 (min (car active)) | |
9050 (max (cdr active)) | |
9051 (types gnus-article-mark-lists) | |
9052 (uncompressed '(score bookmark killed)) | |
9053 marks var articles article mark) | |
9054 | |
9055 (while marked-lists | |
9056 (setq marks (pop marked-lists)) | |
9057 (set (setq var (intern (format "gnus-newsgroup-%s" | |
9058 (car (rassq (setq mark (car marks)) | |
9059 types))))) | |
9060 (if (memq (car marks) uncompressed) (cdr marks) | |
9061 (gnus-uncompress-range (cdr marks)))) | |
9062 | |
9063 (setq articles (symbol-value var)) | |
9064 | |
9065 ;; All articles have to be subsets of the active articles. | |
9066 (cond | |
9067 ;; Adjust "simple" lists. | |
9068 ((memq mark '(tick dormant expirable reply save)) | |
9069 (while articles | |
9070 (when (or (< (setq article (pop articles)) min) (> article max)) | |
9071 (set var (delq article (symbol-value var)))))) | |
9072 ;; Adjust assocs. | |
9073 ((memq mark uncompressed) | |
9074 (while articles | |
9075 (when (or (not (consp (setq article (pop articles)))) | |
9076 (< (car article) min) | |
9077 (> (car article) max)) | |
9078 (set var (delq article (symbol-value var)))))))))) | |
9079 | |
9080 (defun gnus-update-missing-marks (missing) | |
9081 "Go through the list of MISSING articles and remove them mark lists." | |
9082 (when missing | |
9083 (let ((types gnus-article-mark-lists) | |
9084 var m) | |
9085 ;; Go through all types. | |
9086 (while types | |
9087 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types))))) | |
9088 (when (symbol-value var) | |
9089 ;; This list has articles. So we delete all missing articles | |
9090 ;; from it. | |
9091 (setq m missing) | |
9092 (while m | |
9093 (set var (delq (pop m) (symbol-value var))))))))) | |
9094 | |
9095 (defun gnus-update-marks () | |
9096 "Enter the various lists of marked articles into the newsgroup info list." | |
9097 (let ((types gnus-article-mark-lists) | |
9098 (info (gnus-get-info gnus-newsgroup-name)) | |
9099 (uncompressed '(score bookmark killed)) | |
9100 type list newmarked symbol) | |
9101 (when info | |
9102 ;; Add all marks lists that are non-nil to the list of marks lists. | |
9103 (while types | |
9104 (setq type (pop types)) | |
9105 (when (setq list (symbol-value | |
9106 (setq symbol | |
9107 (intern (format "gnus-newsgroup-%s" | |
9108 (car type)))))) | |
9109 (push (cons (cdr type) | |
9110 (if (memq (cdr type) uncompressed) list | |
9111 (gnus-compress-sequence | |
9112 (set symbol (sort list '<)) t))) | |
9113 newmarked))) | |
9114 | |
9115 ;; Enter these new marks into the info of the group. | |
9116 (if (nthcdr 3 info) | |
9117 (setcar (nthcdr 3 info) newmarked) | |
9118 ;; Add the marks lists to the end of the info. | |
9119 (when newmarked | |
9120 (setcdr (nthcdr 2 info) (list newmarked)))) | |
9121 | |
9122 ;; Cut off the end of the info if there's nothing else there. | |
9123 (let ((i 5)) | |
9124 (while (and (> i 2) | |
9125 (not (nth i info))) | |
9126 (when (nthcdr (decf i) info) | |
9127 (setcdr (nthcdr i info) nil))))))) | |
9128 | |
9129 (defun gnus-add-marked-articles (group type articles &optional info force) | |
9130 ;; Add ARTICLES of TYPE to the info of GROUP. | |
9131 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't | |
9132 ;; add, but replace marked articles of TYPE with ARTICLES. | |
9133 (let ((info (or info (gnus-get-info group))) | |
9134 (uncompressed '(score bookmark killed)) | |
9135 marked m) | |
9136 (or (not info) | |
9137 (and (not (setq marked (nthcdr 3 info))) | |
9138 (or (null articles) | |
9139 (setcdr (nthcdr 2 info) | |
9140 (list (list (cons type (gnus-compress-sequence | |
9141 articles t))))))) | |
9142 (and (not (setq m (assq type (car marked)))) | |
9143 (or (null articles) | |
9144 (setcar marked | |
9145 (cons (cons type (gnus-compress-sequence articles t) ) | |
9146 (car marked))))) | |
9147 (if force | |
9148 (if (null articles) | |
9149 (setcar (nthcdr 3 info) | |
9150 (delq (assq type (car marked)) (car marked))) | |
9151 (setcdr m (gnus-compress-sequence articles t))) | |
9152 (setcdr m (gnus-compress-sequence | |
9153 (sort (nconc (gnus-uncompress-range (cdr m)) | |
9154 (copy-sequence articles)) '<) t)))))) | |
9155 | |
9156 (defun gnus-set-mode-line (where) | |
9157 "This function sets the mode line of the article or summary buffers. | |
9158 If WHERE is `summary', the summary mode line format will be used." | |
9159 ;; Is this mode line one we keep updated? | |
9160 (when (memq where gnus-updated-mode-lines) | |
9161 (let (mode-string) | |
9162 (save-excursion | |
9163 ;; We evaluate this in the summary buffer since these | |
9164 ;; variables are buffer-local to that buffer. | |
9165 (set-buffer gnus-summary-buffer) | |
9166 ;; We bind all these variables that are used in the `eval' form | |
9167 ;; below. | |
9168 (let* ((mformat (symbol-value | |
9169 (intern | |
9170 (format "gnus-%s-mode-line-format-spec" where)))) | |
9171 (gnus-tmp-group-name gnus-newsgroup-name) | |
9172 (gnus-tmp-article-number (or gnus-current-article 0)) | |
9173 (gnus-tmp-unread gnus-newsgroup-unreads) | |
9174 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads)) | |
9175 (gnus-tmp-unselected (length gnus-newsgroup-unselected)) | |
9176 (gnus-tmp-unread-and-unselected | |
9177 (cond ((and (zerop gnus-tmp-unread-and-unticked) | |
9178 (zerop gnus-tmp-unselected)) "") | |
9179 ((zerop gnus-tmp-unselected) | |
9180 (format "{%d more}" gnus-tmp-unread-and-unticked)) | |
9181 (t (format "{%d(+%d) more}" | |
9182 gnus-tmp-unread-and-unticked | |
9183 gnus-tmp-unselected)))) | |
9184 (gnus-tmp-subject | |
9185 (if (and gnus-current-headers | |
9186 (vectorp gnus-current-headers)) | |
9187 (gnus-mode-string-quote | |
9188 (mail-header-subject gnus-current-headers)) "")) | |
9189 max-len | |
9190 gnus-tmp-header);; passed as argument to any user-format-funcs | |
9191 (setq mode-string (eval mformat)) | |
9192 (setq max-len (max 4 (if gnus-mode-non-string-length | |
9193 (- (window-width) | |
9194 gnus-mode-non-string-length) | |
9195 (length mode-string)))) | |
9196 ;; We might have to chop a bit of the string off... | |
9197 (when (> (length mode-string) max-len) | |
9198 (setq mode-string | |
9199 (concat (gnus-truncate-string mode-string (- max-len 3)) | |
9200 "..."))) | |
9201 ;; Pad the mode string a bit. | |
9202 (setq mode-string (format (format "%%-%ds" max-len) mode-string)))) | |
9203 ;; Update the mode line. | |
9204 (setq mode-line-buffer-identification | |
9205 (gnus-mode-line-buffer-identification | |
9206 (list mode-string))) | |
9207 (set-buffer-modified-p t)))) | |
9208 | |
9209 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads) | |
9210 "Go through the HEADERS list and add all Xrefs to a hash table. | |
9211 The resulting hash table is returned, or nil if no Xrefs were found." | |
9212 (let* ((virtual (gnus-virtual-group-p from-newsgroup)) | |
9213 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup))) | |
9214 (xref-hashtb (make-vector 63 0)) | |
9215 start group entry number xrefs header) | |
9216 (while headers | |
9217 (setq header (pop headers)) | |
9218 (when (and (setq xrefs (mail-header-xref header)) | |
9219 (not (memq (setq number (mail-header-number header)) | |
9220 unreads))) | |
9221 (setq start 0) | |
9222 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start) | |
9223 (setq start (match-end 0)) | |
9224 (setq group (if prefix | |
9225 (concat prefix (substring xrefs (match-beginning 1) | |
9226 (match-end 1))) | |
9227 (substring xrefs (match-beginning 1) (match-end 1)))) | |
9228 (setq number | |
9229 (string-to-int (substring xrefs (match-beginning 2) | |
9230 (match-end 2)))) | |
9231 (if (setq entry (gnus-gethash group xref-hashtb)) | |
9232 (setcdr entry (cons number (cdr entry))) | |
9233 (gnus-sethash group (cons number nil) xref-hashtb))))) | |
9234 (and start xref-hashtb))) | |
9235 | |
9236 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads) | |
9237 "Look through all the headers and mark the Xrefs as read." | |
9238 (let ((virtual (gnus-virtual-group-p from-newsgroup)) | |
9239 name entry info xref-hashtb idlist method nth4) | |
9240 (save-excursion | |
9241 (set-buffer gnus-group-buffer) | |
9242 (when (setq xref-hashtb | |
9243 (gnus-create-xref-hashtb from-newsgroup headers unreads)) | |
9244 (mapatoms | |
9245 (lambda (group) | |
9246 (unless (string= from-newsgroup (setq name (symbol-name group))) | |
9247 (setq idlist (symbol-value group)) | |
9248 ;; Dead groups are not updated. | |
9249 (and (prog1 | |
9250 (setq entry (gnus-gethash name gnus-newsrc-hashtb) | |
9251 info (nth 2 entry)) | |
9252 (if (stringp (setq nth4 (gnus-info-method info))) | |
9253 (setq nth4 (gnus-server-to-method nth4)))) | |
9254 ;; Only do the xrefs if the group has the same | |
9255 ;; select method as the group we have just read. | |
9256 (or (gnus-methods-equal-p | |
9257 nth4 (gnus-find-method-for-group from-newsgroup)) | |
9258 virtual | |
9259 (equal nth4 (setq method (gnus-find-method-for-group | |
9260 from-newsgroup))) | |
9261 (and (equal (car nth4) (car method)) | |
9262 (equal (nth 1 nth4) (nth 1 method)))) | |
9263 gnus-use-cross-reference | |
9264 (or (not (eq gnus-use-cross-reference t)) | |
9265 virtual | |
9266 ;; Only do cross-references on subscribed | |
9267 ;; groups, if that is what is wanted. | |
9268 (<= (gnus-info-level info) gnus-level-subscribed)) | |
9269 (gnus-group-make-articles-read name idlist)))) | |
9270 xref-hashtb))))) | |
9271 | |
9272 (defun gnus-group-make-articles-read (group articles) | |
9273 (let* ((num 0) | |
9274 (entry (gnus-gethash group gnus-newsrc-hashtb)) | |
9275 (info (nth 2 entry)) | |
9276 (active (gnus-active group)) | |
9277 range) | |
9278 ;; First peel off all illegal article numbers. | |
9279 (when active | |
9280 (let ((ids articles) | |
9281 id first) | |
9282 (while (setq id (pop ids)) | |
9283 (when (and first (> id (cdr active))) | |
9284 ;; We'll end up in this situation in one particular | |
9285 ;; obscure situation. If you re-scan a group and get | |
9286 ;; a new article that is cross-posted to a different | |
9287 ;; group that has not been re-scanned, you might get | |
9288 ;; crossposted article that has a higher number than | |
9289 ;; Gnus believes possible. So we re-activate this | |
9290 ;; group as well. This might mean doing the | |
9291 ;; crossposting thingy will *increase* the number | |
9292 ;; of articles in some groups. Tsk, tsk. | |
9293 (setq active (or (gnus-activate-group group) active))) | |
9294 (when (or (> id (cdr active)) | |
9295 (< id (car active))) | |
9296 (setq articles (delq id articles)))))) | |
9297 ;; If the read list is nil, we init it. | |
9298 (and active | |
9299 (null (gnus-info-read info)) | |
9300 (> (car active) 1) | |
9301 (gnus-info-set-read info (cons 1 (1- (car active))))) | |
9302 ;; Then we add the read articles to the range. | |
9303 (gnus-info-set-read | |
9304 info | |
9305 (setq range | |
9306 (gnus-add-to-range | |
9307 (gnus-info-read info) (setq articles (sort articles '<))))) | |
9308 ;; Then we have to re-compute how many unread | |
9309 ;; articles there are in this group. | |
9310 (if active | |
9311 (progn | |
9312 (cond | |
9313 ((not range) | |
9314 (setq num (- (1+ (cdr active)) (car active)))) | |
9315 ((not (listp (cdr range))) | |
9316 (setq num (- (cdr active) (- (1+ (cdr range)) | |
9317 (car range))))) | |
9318 (t | |
9319 (while range | |
9320 (if (numberp (car range)) | |
9321 (setq num (1+ num)) | |
9322 (setq num (+ num (- (1+ (cdar range)) (caar range))))) | |
9323 (setq range (cdr range))) | |
9324 (setq num (- (cdr active) num)))) | |
9325 ;; Update the number of unread articles. | |
9326 (setcar entry num) | |
9327 ;; Update the group buffer. | |
9328 (gnus-group-update-group group t))))) | |
9329 | |
9330 (defun gnus-methods-equal-p (m1 m2) | |
9331 (let ((m1 (or m1 gnus-select-method)) | |
9332 (m2 (or m2 gnus-select-method))) | |
9333 (or (equal m1 m2) | |
9334 (and (eq (car m1) (car m2)) | |
9335 (or (not (memq 'address (assoc (symbol-name (car m1)) | |
9336 gnus-valid-select-methods))) | |
9337 (equal (nth 1 m1) (nth 1 m2))))))) | |
9338 | |
9339 (defsubst gnus-header-value () | |
9340 (buffer-substring (match-end 0) (gnus-point-at-eol))) | |
9341 | |
9342 (defvar gnus-newsgroup-none-id 0) | |
9343 | |
9344 (defun gnus-get-newsgroup-headers (&optional dependencies force-new) | |
9345 (let ((cur nntp-server-buffer) | |
9346 (dependencies | |
9347 (or dependencies | |
9348 (save-excursion (set-buffer gnus-summary-buffer) | |
9349 gnus-newsgroup-dependencies))) | |
9350 headers id id-dep ref-dep end ref) | |
9351 (save-excursion | |
9352 (set-buffer nntp-server-buffer) | |
9353 (run-hooks 'gnus-parse-headers-hook) | |
9354 (let ((case-fold-search t) | |
9355 in-reply-to header p lines) | |
9356 (goto-char (point-min)) | |
9357 ;; Search to the beginning of the next header. Error messages | |
9358 ;; do not begin with 2 or 3. | |
9359 (while (re-search-forward "^[23][0-9]+ " nil t) | |
9360 (setq id nil | |
9361 ref nil) | |
9362 ;; This implementation of this function, with nine | |
9363 ;; search-forwards instead of the one re-search-forward and | |
9364 ;; a case (which basically was the old function) is actually | |
9365 ;; about twice as fast, even though it looks messier. You | |
9366 ;; can't have everything, I guess. Speed and elegance | |
9367 ;; doesn't always go hand in hand. | |
9368 (setq | |
9369 header | |
9370 (vector | |
9371 ;; Number. | |
9372 (prog1 | |
9373 (read cur) | |
9374 (end-of-line) | |
9375 (setq p (point)) | |
9376 (narrow-to-region (point) | |
9377 (or (and (search-forward "\n.\n" nil t) | |
9378 (- (point) 2)) | |
9379 (point)))) | |
9380 ;; Subject. | |
9381 (progn | |
9382 (goto-char p) | |
9383 (if (search-forward "\nsubject: " nil t) | |
9384 (gnus-header-value) "(none)")) | |
9385 ;; From. | |
9386 (progn | |
9387 (goto-char p) | |
9388 (if (search-forward "\nfrom: " nil t) | |
9389 (gnus-header-value) "(nobody)")) | |
9390 ;; Date. | |
9391 (progn | |
9392 (goto-char p) | |
9393 (if (search-forward "\ndate: " nil t) | |
9394 (gnus-header-value) "")) | |
9395 ;; Message-ID. | |
9396 (progn | |
9397 (goto-char p) | |
9398 (if (search-forward "\nmessage-id: " nil t) | |
9399 (setq id (gnus-header-value)) | |
9400 ;; If there was no message-id, we just fake one to make | |
9401 ;; subsequent routines simpler. | |
9402 (setq id (concat "none+" | |
9403 (int-to-string | |
9404 (setq gnus-newsgroup-none-id | |
9405 (1+ gnus-newsgroup-none-id))))))) | |
9406 ;; References. | |
9407 (progn | |
9408 (goto-char p) | |
9409 (if (search-forward "\nreferences: " nil t) | |
9410 (progn | |
9411 (setq end (point)) | |
9412 (prog1 | |
9413 (gnus-header-value) | |
9414 (setq ref | |
9415 (buffer-substring | |
9416 (progn | |
9417 (end-of-line) | |
9418 (search-backward ">" end t) | |
9419 (1+ (point))) | |
9420 (progn | |
9421 (search-backward "<" end t) | |
9422 (point)))))) | |
9423 ;; Get the references from the in-reply-to header if there | |
9424 ;; were no references and the in-reply-to header looks | |
9425 ;; promising. | |
9426 (if (and (search-forward "\nin-reply-to: " nil t) | |
9427 (setq in-reply-to (gnus-header-value)) | |
9428 (string-match "<[^>]+>" in-reply-to)) | |
9429 (setq ref (substring in-reply-to (match-beginning 0) | |
9430 (match-end 0))) | |
9431 (setq ref "")))) | |
9432 ;; Chars. | |
9433 0 | |
9434 ;; Lines. | |
9435 (progn | |
9436 (goto-char p) | |
9437 (if (search-forward "\nlines: " nil t) | |
9438 (if (numberp (setq lines (read cur))) | |
9439 lines 0) | |
9440 0)) | |
9441 ;; Xref. | |
9442 (progn | |
9443 (goto-char p) | |
9444 (and (search-forward "\nxref: " nil t) | |
9445 (gnus-header-value))))) | |
9446 ;; We do the threading while we read the headers. The | |
9447 ;; message-id and the last reference are both entered into | |
9448 ;; the same hash table. Some tippy-toeing around has to be | |
9449 ;; done in case an article has arrived before the article | |
9450 ;; which it refers to. | |
9451 (if (boundp (setq id-dep (intern id dependencies))) | |
9452 (if (and (car (symbol-value id-dep)) | |
9453 (not force-new)) | |
9454 ;; An article with this Message-ID has already | |
9455 ;; been seen, so we ignore this one, except we add | |
9456 ;; any additional Xrefs (in case the two articles | |
9457 ;; came from different servers). | |
9458 (progn | |
9459 (mail-header-set-xref | |
9460 (car (symbol-value id-dep)) | |
9461 (concat (or (mail-header-xref | |
9462 (car (symbol-value id-dep))) "") | |
9463 (or (mail-header-xref header) ""))) | |
9464 (setq header nil)) | |
9465 (setcar (symbol-value id-dep) header)) | |
9466 (set id-dep (list header))) | |
9467 (when header | |
9468 (if (boundp (setq ref-dep (intern ref dependencies))) | |
9469 (setcdr (symbol-value ref-dep) | |
9470 (nconc (cdr (symbol-value ref-dep)) | |
9471 (list (symbol-value id-dep)))) | |
9472 (set ref-dep (list nil (symbol-value id-dep)))) | |
9473 (setq headers (cons header headers))) | |
9474 (goto-char (point-max)) | |
9475 (widen)) | |
9476 (nreverse headers))))) | |
9477 | |
9478 ;; The following macros and functions were written by Felix Lee | |
9479 ;; <flee@cse.psu.edu>. | |
9480 | |
9481 (defmacro gnus-nov-read-integer () | |
9482 '(prog1 | |
9483 (if (= (following-char) ?\t) | |
9484 0 | |
9485 (let ((num (condition-case nil (read buffer) (error nil)))) | |
9486 (if (numberp num) num 0))) | |
9487 (or (eobp) (forward-char 1)))) | |
9488 | |
9489 (defmacro gnus-nov-skip-field () | |
9490 '(search-forward "\t" eol 'move)) | |
9491 | |
9492 (defmacro gnus-nov-field () | |
9493 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol))) | |
9494 | |
9495 ;; Goes through the xover lines and returns a list of vectors | |
9496 (defun gnus-get-newsgroup-headers-xover (sequence &optional | |
9497 force-new dependencies) | |
9498 "Parse the news overview data in the server buffer, and return a | |
9499 list of headers that match SEQUENCE (see `nntp-retrieve-headers')." | |
9500 ;; Get the Xref when the users reads the articles since most/some | |
9501 ;; NNTP servers do not include Xrefs when using XOVER. | |
9502 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs)) | |
9503 (let ((cur nntp-server-buffer) | |
9504 (dependencies (or dependencies gnus-newsgroup-dependencies)) | |
9505 number headers header) | |
9506 (save-excursion | |
9507 (set-buffer nntp-server-buffer) | |
9508 ;; Allow the user to mangle the headers before parsing them. | |
9509 (run-hooks 'gnus-parse-headers-hook) | |
9510 (goto-char (point-min)) | |
9511 (while (and sequence (not (eobp))) | |
9512 (setq number (read cur)) | |
9513 (while (and sequence (< (car sequence) number)) | |
9514 (setq sequence (cdr sequence))) | |
9515 (and sequence | |
9516 (eq number (car sequence)) | |
9517 (progn | |
9518 (setq sequence (cdr sequence)) | |
9519 (if (setq header | |
9520 (inline (gnus-nov-parse-line | |
9521 number dependencies force-new))) | |
9522 (setq headers (cons header headers))))) | |
9523 (forward-line 1)) | |
9524 (setq headers (nreverse headers))) | |
9525 headers)) | |
9526 | |
9527 ;; This function has to be called with point after the article number | |
9528 ;; on the beginning of the line. | |
9529 (defun gnus-nov-parse-line (number dependencies &optional force-new) | |
9530 (let ((none 0) | |
9531 (eol (gnus-point-at-eol)) | |
9532 (buffer (current-buffer)) | |
9533 header ref id id-dep ref-dep) | |
9534 | |
9535 ;; overview: [num subject from date id refs chars lines misc] | |
9536 (narrow-to-region (point) eol) | |
9537 (or (eobp) (forward-char)) | |
9538 | |
9539 (condition-case nil | |
9540 (setq header | |
9541 (vector | |
9542 number ; number | |
9543 (gnus-nov-field) ; subject | |
9544 (gnus-nov-field) ; from | |
9545 (gnus-nov-field) ; date | |
9546 (setq id (or (gnus-nov-field) | |
9547 (concat "none+" | |
9548 (int-to-string | |
9549 (setq none (1+ none)))))) ; id | |
9550 (progn | |
9551 (save-excursion | |
9552 (let ((beg (point))) | |
9553 (search-forward "\t" eol) | |
9554 (if (search-backward ">" beg t) | |
9555 (setq ref | |
9556 (buffer-substring | |
9557 (1+ (point)) | |
9558 (search-backward "<" beg t))) | |
9559 (setq ref nil)))) | |
9560 (gnus-nov-field)) ; refs | |
9561 (gnus-nov-read-integer) ; chars | |
9562 (gnus-nov-read-integer) ; lines | |
9563 (if (= (following-char) ?\n) | |
9564 nil | |
9565 (gnus-nov-field)) ; misc | |
9566 )) | |
9567 (error (progn | |
9568 (gnus-error 4 "Strange nov line") | |
9569 (setq header nil) | |
9570 (goto-char eol)))) | |
9571 | |
9572 (widen) | |
9573 | |
9574 ;; We build the thread tree. | |
9575 (when header | |
9576 (if (boundp (setq id-dep (intern id dependencies))) | |
9577 (if (and (car (symbol-value id-dep)) | |
9578 (not force-new)) | |
9579 ;; An article with this Message-ID has already been seen, | |
9580 ;; so we ignore this one, except we add any additional | |
9581 ;; Xrefs (in case the two articles came from different | |
9582 ;; servers. | |
9583 (progn | |
9584 (mail-header-set-xref | |
9585 (car (symbol-value id-dep)) | |
9586 (concat (or (mail-header-xref | |
9587 (car (symbol-value id-dep))) "") | |
9588 (or (mail-header-xref header) ""))) | |
9589 (setq header nil)) | |
9590 (setcar (symbol-value id-dep) header)) | |
9591 (set id-dep (list header)))) | |
9592 (when header | |
9593 (if (boundp (setq ref-dep (intern (or ref "none") dependencies))) | |
9594 (setcdr (symbol-value ref-dep) | |
9595 (nconc (cdr (symbol-value ref-dep)) | |
9596 (list (symbol-value id-dep)))) | |
9597 (set ref-dep (list nil (symbol-value id-dep))))) | |
9598 header)) | |
9599 | |
9600 (defun gnus-article-get-xrefs () | |
9601 "Fill in the Xref value in `gnus-current-headers', if necessary. | |
9602 This is meant to be called in `gnus-article-internal-prepare-hook'." | |
9603 (let ((headers (save-excursion (set-buffer gnus-summary-buffer) | |
9604 gnus-current-headers))) | |
9605 (or (not gnus-use-cross-reference) | |
9606 (not headers) | |
9607 (and (mail-header-xref headers) | |
9608 (not (string= (mail-header-xref headers) ""))) | |
9609 (let ((case-fold-search t) | |
9610 xref) | |
9611 (save-restriction | |
9612 (nnheader-narrow-to-headers) | |
9613 (goto-char (point-min)) | |
9614 (if (or (and (eq (downcase (following-char)) ?x) | |
9615 (looking-at "Xref:")) | |
9616 (search-forward "\nXref:" nil t)) | |
9617 (progn | |
9618 (goto-char (1+ (match-end 0))) | |
9619 (setq xref (buffer-substring (point) | |
9620 (progn (end-of-line) (point)))) | |
9621 (mail-header-set-xref headers xref)))))))) | |
9622 | |
9623 (defun gnus-summary-insert-subject (id &optional old-header use-old-header) | |
9624 "Find article ID and insert the summary line for that article." | |
9625 (let ((header (if (and old-header use-old-header) | |
9626 old-header (gnus-read-header id))) | |
9627 (number (and (numberp id) id)) | |
9628 pos) | |
9629 (when header | |
9630 ;; Rebuild the thread that this article is part of and go to the | |
9631 ;; article we have fetched. | |
9632 (when (and (not gnus-show-threads) | |
9633 old-header) | |
9634 (when (setq pos (text-property-any | |
9635 (point-min) (point-max) 'gnus-number | |
9636 (mail-header-number old-header))) | |
9637 (goto-char pos) | |
9638 (gnus-delete-line) | |
9639 (gnus-data-remove (mail-header-number old-header)))) | |
9640 (when old-header | |
9641 (mail-header-set-number header (mail-header-number old-header))) | |
9642 (setq gnus-newsgroup-sparse | |
9643 (delq (setq number (mail-header-number header)) | |
9644 gnus-newsgroup-sparse)) | |
9645 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient)) | |
9646 (gnus-rebuild-thread (mail-header-id header)) | |
9647 (gnus-summary-goto-subject number nil t)) | |
9648 (when (and (numberp number) | |
9649 (> number 0)) | |
9650 ;; We have to update the boundaries even if we can't fetch the | |
9651 ;; article if ID is a number -- so that the next `P' or `N' | |
9652 ;; command will fetch the previous (or next) article even | |
9653 ;; if the one we tried to fetch this time has been canceled. | |
9654 (and (> number gnus-newsgroup-end) | |
9655 (setq gnus-newsgroup-end number)) | |
9656 (and (< number gnus-newsgroup-begin) | |
9657 (setq gnus-newsgroup-begin number)) | |
9658 (setq gnus-newsgroup-unselected | |
9659 (delq number gnus-newsgroup-unselected))) | |
9660 ;; Report back a success? | |
9661 (and header (mail-header-number header)))) | |
9662 | |
9663 (defun gnus-summary-work-articles (n) | |
9664 "Return a list of articles to be worked upon. The prefix argument, | |
9665 the list of process marked articles, and the current article will be | |
9666 taken into consideration." | |
9667 (cond | |
9668 (n | |
9669 ;; A numerical prefix has been given. | |
9670 (let ((backward (< n 0)) | |
9671 (n (abs (prefix-numeric-value n))) | |
9672 articles article) | |
9673 (save-excursion | |
9674 (while | |
9675 (and (> n 0) | |
9676 (push (setq article (gnus-summary-article-number)) | |
9677 articles) | |
9678 (if backward | |
9679 (gnus-summary-find-prev nil article) | |
9680 (gnus-summary-find-next nil article))) | |
9681 (decf n))) | |
9682 (nreverse articles))) | |
9683 ((and (boundp 'transient-mark-mode) | |
9684 transient-mark-mode | |
9685 mark-active) | |
9686 ;; Work on the region between point and mark. | |
9687 (let ((max (max (point) (mark))) | |
9688 articles article) | |
9689 (save-excursion | |
9690 (goto-char (min (point) (mark))) | |
9691 (while | |
9692 (and | |
9693 (push (setq article (gnus-summary-article-number)) articles) | |
9694 (gnus-summary-find-next nil article) | |
9695 (< (point) max))) | |
9696 (nreverse articles)))) | |
9697 (gnus-newsgroup-processable | |
9698 ;; There are process-marked articles present. | |
9699 (reverse gnus-newsgroup-processable)) | |
9700 (t | |
9701 ;; Just return the current article. | |
9702 (list (gnus-summary-article-number))))) | |
9703 | |
9704 (defun gnus-summary-search-group (&optional backward use-level) | |
9705 "Search for next unread newsgroup. | |
9706 If optional argument BACKWARD is non-nil, search backward instead." | |
9707 (save-excursion | |
9708 (set-buffer gnus-group-buffer) | |
9709 (if (gnus-group-search-forward | |
9710 backward nil (if use-level (gnus-group-group-level) nil)) | |
9711 (gnus-group-group-name)))) | |
9712 | |
9713 (defun gnus-summary-best-group (&optional exclude-group) | |
9714 "Find the name of the best unread group. | |
9715 If EXCLUDE-GROUP, do not go to this group." | |
9716 (save-excursion | |
9717 (set-buffer gnus-group-buffer) | |
9718 (save-excursion | |
9719 (gnus-group-best-unread-group exclude-group)))) | |
9720 | |
9721 (defun gnus-summary-find-next (&optional unread article backward) | |
9722 (if backward (gnus-summary-find-prev) | |
9723 (let* ((dummy (gnus-summary-article-intangible-p)) | |
9724 (article (or article (gnus-summary-article-number))) | |
9725 (arts (gnus-data-find-list article)) | |
9726 result) | |
9727 (when (and (not dummy) | |
9728 (or (not gnus-summary-check-current) | |
9729 (not unread) | |
9730 (not (gnus-data-unread-p (car arts))))) | |
9731 (setq arts (cdr arts))) | |
9732 (when (setq result | |
9733 (if unread | |
9734 (progn | |
9735 (while arts | |
9736 (when (gnus-data-unread-p (car arts)) | |
9737 (setq result (car arts) | |
9738 arts nil)) | |
9739 (setq arts (cdr arts))) | |
9740 result) | |
9741 (car arts))) | |
9742 (goto-char (gnus-data-pos result)) | |
9743 (gnus-data-number result))))) | |
9744 | |
9745 (defun gnus-summary-find-prev (&optional unread article) | |
9746 (let* ((eobp (eobp)) | |
9747 (article (or article (gnus-summary-article-number))) | |
9748 (arts (gnus-data-find-list article (gnus-data-list 'rev))) | |
9749 result) | |
9750 (when (and (not eobp) | |
9751 (or (not gnus-summary-check-current) | |
9752 (not unread) | |
9753 (not (gnus-data-unread-p (car arts))))) | |
9754 (setq arts (cdr arts))) | |
9755 (if (setq result | |
9756 (if unread | |
9757 (progn | |
9758 (while arts | |
9759 (and (gnus-data-unread-p (car arts)) | |
9760 (setq result (car arts) | |
9761 arts nil)) | |
9762 (setq arts (cdr arts))) | |
9763 result) | |
9764 (car arts))) | |
9765 (progn | |
9766 (goto-char (gnus-data-pos result)) | |
9767 (gnus-data-number result))))) | |
9768 | |
9769 (defun gnus-summary-find-subject (subject &optional unread backward article) | |
9770 (let* ((simp-subject (gnus-simplify-subject-fully subject)) | |
9771 (article (or article (gnus-summary-article-number))) | |
9772 (articles (gnus-data-list backward)) | |
9773 (arts (gnus-data-find-list article articles)) | |
9774 result) | |
9775 (when (or (not gnus-summary-check-current) | |
9776 (not unread) | |
9777 (not (gnus-data-unread-p (car arts)))) | |
9778 (setq arts (cdr arts))) | |
9779 (while arts | |
9780 (and (or (not unread) | |
9781 (gnus-data-unread-p (car arts))) | |
9782 (vectorp (gnus-data-header (car arts))) | |
9783 (gnus-subject-equal | |
9784 simp-subject (mail-header-subject (gnus-data-header (car arts))) t) | |
9785 (setq result (car arts) | |
9786 arts nil)) | |
9787 (setq arts (cdr arts))) | |
9788 (and result | |
9789 (goto-char (gnus-data-pos result)) | |
9790 (gnus-data-number result)))) | |
9791 | |
9792 (defun gnus-summary-search-forward (&optional unread subject backward) | |
9793 "Search forward for an article. | |
9794 If UNREAD, look for unread articles. If SUBJECT, look for | |
9795 articles with that subject. If BACKWARD, search backward instead." | |
9796 (cond (subject (gnus-summary-find-subject subject unread backward)) | |
9797 (backward (gnus-summary-find-prev unread)) | |
9798 (t (gnus-summary-find-next unread)))) | |
9799 | |
9800 (defun gnus-recenter (&optional n) | |
9801 "Center point in window and redisplay frame. | |
9802 Also do horizontal recentering." | |
9803 (interactive "P") | |
9804 (when (and gnus-auto-center-summary | |
9805 (not (eq gnus-auto-center-summary 'vertical))) | |
9806 (gnus-horizontal-recenter)) | |
9807 (recenter n)) | |
9808 | |
9809 (defun gnus-summary-recenter () | |
9810 "Center point in the summary window. | |
9811 If `gnus-auto-center-summary' is nil, or the article buffer isn't | |
9812 displayed, no centering will be performed." | |
9813 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle). | |
9814 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu. | |
9815 (let* ((top (cond ((< (window-height) 4) 0) | |
9816 ((< (window-height) 7) 1) | |
9817 (t 2))) | |
9818 (height (1- (window-height))) | |
9819 (bottom (save-excursion (goto-char (point-max)) | |
9820 (forward-line (- height)) | |
9821 (point))) | |
9822 (window (get-buffer-window (current-buffer)))) | |
9823 ;; The user has to want it. | |
9824 (when gnus-auto-center-summary | |
9825 (when (get-buffer-window gnus-article-buffer) | |
9826 ;; Only do recentering when the article buffer is displayed, | |
9827 ;; Set the window start to either `bottom', which is the biggest | |
9828 ;; possible valid number, or the second line from the top, | |
9829 ;; whichever is the least. | |
9830 (set-window-start | |
9831 window (min bottom (save-excursion | |
9832 (forward-line (- top)) (point))))) | |
9833 ;; Do horizontal recentering while we're at it. | |
9834 (when (and (get-buffer-window (current-buffer) t) | |
9835 (not (eq gnus-auto-center-summary 'vertical))) | |
9836 (let ((selected (selected-window))) | |
9837 (select-window (get-buffer-window (current-buffer) t)) | |
9838 (gnus-summary-position-point) | |
9839 (gnus-horizontal-recenter) | |
9840 (select-window selected)))))) | |
9841 | |
9842 (defun gnus-horizontal-recenter () | |
9843 "Recenter the current buffer horizontally." | |
9844 (if (< (current-column) (/ (window-width) 2)) | |
9845 (set-window-hscroll (get-buffer-window (current-buffer) t) 0) | |
9846 (let* ((orig (point)) | |
9847 (end (window-end (get-buffer-window (current-buffer) t))) | |
9848 (max 0)) | |
9849 ;; Find the longest line currently displayed in the window. | |
9850 (goto-char (window-start)) | |
9851 (while (and (not (eobp)) | |
9852 (< (point) end)) | |
9853 (end-of-line) | |
9854 (setq max (max max (current-column))) | |
9855 (forward-line 1)) | |
9856 (goto-char orig) | |
9857 ;; Scroll horizontally to center (sort of) the point. | |
9858 (if (> max (window-width)) | |
9859 (set-window-hscroll | |
9860 (get-buffer-window (current-buffer) t) | |
9861 (min (- (current-column) (/ (window-width) 3)) | |
9862 (+ 2 (- max (window-width))))) | |
9863 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)) | |
9864 max))) | |
9865 | |
9866 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>. | |
9867 (defun gnus-short-group-name (group &optional levels) | |
9868 "Collapse GROUP name LEVELS." | |
9869 (let* ((name "") | |
9870 (foreign "") | |
9871 (depth 0) | |
9872 (skip 1) | |
9873 (levels (or levels | |
9874 (progn | |
9875 (while (string-match "\\." group skip) | |
9876 (setq skip (match-end 0) | |
9877 depth (+ depth 1))) | |
9878 depth)))) | |
9879 (if (string-match ":" group) | |
9880 (setq foreign (substring group 0 (match-end 0)) | |
9881 group (substring group (match-end 0)))) | |
9882 (while group | |
9883 (if (and (string-match "\\." group) | |
9884 (> levels (- gnus-group-uncollapsed-levels 1))) | |
9885 (setq name (concat name (substring group 0 1)) | |
9886 group (substring group (match-end 0)) | |
9887 levels (- levels 1) | |
9888 name (concat name ".")) | |
9889 (setq name (concat foreign name group) | |
9890 group nil))) | |
9891 name)) | |
9892 | |
9893 (defun gnus-summary-jump-to-group (newsgroup) | |
9894 "Move point to NEWSGROUP in group mode buffer." | |
9895 ;; Keep update point of group mode buffer if visible. | |
9896 (if (eq (current-buffer) (get-buffer gnus-group-buffer)) | |
9897 (save-window-excursion | |
9898 ;; Take care of tree window mode. | |
9899 (if (get-buffer-window gnus-group-buffer) | |
9900 (pop-to-buffer gnus-group-buffer)) | |
9901 (gnus-group-jump-to-group newsgroup)) | |
9902 (save-excursion | |
9903 ;; Take care of tree window mode. | |
9904 (if (get-buffer-window gnus-group-buffer) | |
9905 (pop-to-buffer gnus-group-buffer) | |
9906 (set-buffer gnus-group-buffer)) | |
9907 (gnus-group-jump-to-group newsgroup)))) | |
9908 | |
9909 ;; This function returns a list of article numbers based on the | |
9910 ;; difference between the ranges of read articles in this group and | |
9911 ;; the range of active articles. | |
9912 (defun gnus-list-of-unread-articles (group) | |
9913 (let* ((read (gnus-info-read (gnus-get-info group))) | |
9914 (active (gnus-active group)) | |
9915 (last (cdr active)) | |
9916 first nlast unread) | |
9917 ;; If none are read, then all are unread. | |
9918 (if (not read) | |
9919 (setq first (car active)) | |
9920 ;; If the range of read articles is a single range, then the | |
9921 ;; first unread article is the article after the last read | |
9922 ;; article. Sounds logical, doesn't it? | |
9923 (if (not (listp (cdr read))) | |
9924 (setq first (1+ (cdr read))) | |
9925 ;; `read' is a list of ranges. | |
9926 (if (/= (setq nlast (or (and (numberp (car read)) (car read)) | |
9927 (caar read))) 1) | |
9928 (setq first 1)) | |
9929 (while read | |
9930 (if first | |
9931 (while (< first nlast) | |
9932 (setq unread (cons first unread)) | |
9933 (setq first (1+ first)))) | |
9934 (setq first (1+ (if (atom (car read)) (car read) (cdar read)))) | |
9935 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read))) | |
9936 (setq read (cdr read))))) | |
9937 ;; And add the last unread articles. | |
9938 (while (<= first last) | |
9939 (setq unread (cons first unread)) | |
9940 (setq first (1+ first))) | |
9941 ;; Return the list of unread articles. | |
9942 (nreverse unread))) | |
9943 | |
9944 (defun gnus-list-of-read-articles (group) | |
9945 "Return a list of unread, unticked and non-dormant articles." | |
9946 (let* ((info (gnus-get-info group)) | |
9947 (marked (gnus-info-marks info)) | |
9948 (active (gnus-active group))) | |
9949 (and info active | |
9950 (gnus-set-difference | |
9951 (gnus-sorted-complement | |
9952 (gnus-uncompress-range active) | |
9953 (gnus-list-of-unread-articles group)) | |
9954 (append | |
9955 (gnus-uncompress-range (cdr (assq 'dormant marked))) | |
9956 (gnus-uncompress-range (cdr (assq 'tick marked)))))))) | |
9957 | |
9958 ;; Various summary commands | |
9959 | |
9960 (defun gnus-summary-universal-argument (arg) | |
9961 "Perform any operation on all articles that are process/prefixed." | |
9962 (interactive "P") | |
9963 (gnus-set-global-variables) | |
9964 (let ((articles (gnus-summary-work-articles arg)) | |
9965 func article) | |
9966 (if (eq | |
9967 (setq | |
9968 func | |
9969 (key-binding | |
9970 (read-key-sequence | |
9971 (substitute-command-keys | |
9972 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]" | |
9973 )))) | |
9974 'undefined) | |
9975 (gnus-error 1 "Undefined key") | |
9976 (save-excursion | |
9977 (while articles | |
9978 (gnus-summary-goto-subject (setq article (pop articles))) | |
9979 (command-execute func) | |
9980 (gnus-summary-remove-process-mark article))))) | |
9981 (gnus-summary-position-point)) | |
9982 | |
9983 (defun gnus-summary-toggle-truncation (&optional arg) | |
9984 "Toggle truncation of summary lines. | |
9985 With arg, turn line truncation on iff arg is positive." | |
9986 (interactive "P") | |
9987 (setq truncate-lines | |
9988 (if (null arg) (not truncate-lines) | |
9989 (> (prefix-numeric-value arg) 0))) | |
9990 (redraw-display)) | |
9991 | |
9992 (defun gnus-summary-reselect-current-group (&optional all rescan) | |
9993 "Exit and then reselect the current newsgroup. | |
9994 The prefix argument ALL means to select all articles." | |
9995 (interactive "P") | |
9996 (gnus-set-global-variables) | |
9997 (when (gnus-ephemeral-group-p gnus-newsgroup-name) | |
9998 (error "Ephemeral groups can't be reselected")) | |
9999 (let ((current-subject (gnus-summary-article-number)) | |
10000 (group gnus-newsgroup-name)) | |
10001 (setq gnus-newsgroup-begin nil) | |
10002 (gnus-summary-exit) | |
10003 ;; We have to adjust the point of group mode buffer because the | |
10004 ;; current point was moved to the next unread newsgroup by | |
10005 ;; exiting. | |
10006 (gnus-summary-jump-to-group group) | |
10007 (when rescan | |
10008 (save-excursion | |
10009 (gnus-group-get-new-news-this-group 1))) | |
10010 (gnus-group-read-group all t) | |
10011 (gnus-summary-goto-subject current-subject nil t))) | |
10012 | |
10013 (defun gnus-summary-rescan-group (&optional all) | |
10014 "Exit the newsgroup, ask for new articles, and select the newsgroup." | |
10015 (interactive "P") | |
10016 (gnus-summary-reselect-current-group all t)) | |
10017 | |
10018 (defun gnus-summary-update-info () | |
10019 (let* ((group gnus-newsgroup-name)) | |
10020 (when gnus-newsgroup-kill-headers | |
10021 (setq gnus-newsgroup-killed | |
10022 (gnus-compress-sequence | |
10023 (nconc | |
10024 (gnus-set-sorted-intersection | |
10025 (gnus-uncompress-range gnus-newsgroup-killed) | |
10026 (setq gnus-newsgroup-unselected | |
10027 (sort gnus-newsgroup-unselected '<))) | |
10028 (setq gnus-newsgroup-unreads | |
10029 (sort gnus-newsgroup-unreads '<))) t))) | |
10030 (unless (listp (cdr gnus-newsgroup-killed)) | |
10031 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed))) | |
10032 (let ((headers gnus-newsgroup-headers)) | |
10033 (run-hooks 'gnus-exit-group-hook) | |
10034 (unless gnus-save-score | |
10035 (setq gnus-newsgroup-scored nil)) | |
10036 ;; Set the new ranges of read articles. | |
10037 (gnus-update-read-articles | |
10038 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected)) | |
10039 ;; Set the current article marks. | |
10040 (gnus-update-marks) | |
10041 ;; Do the cross-ref thing. | |
10042 (when gnus-use-cross-reference | |
10043 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads)) | |
10044 ;; Do adaptive scoring, and possibly save score files. | |
10045 (when gnus-newsgroup-adaptive | |
10046 (gnus-score-adaptive)) | |
10047 (when gnus-use-scoring | |
10048 (gnus-score-save)) | |
10049 ;; Do not switch windows but change the buffer to work. | |
10050 (set-buffer gnus-group-buffer) | |
10051 (or (gnus-ephemeral-group-p gnus-newsgroup-name) | |
10052 (gnus-group-update-group group))))) | |
10053 | |
10054 (defun gnus-summary-exit (&optional temporary) | |
10055 "Exit reading current newsgroup, and then return to group selection mode. | |
10056 gnus-exit-group-hook is called with no arguments if that value is non-nil." | |
10057 (interactive) | |
10058 (gnus-set-global-variables) | |
10059 (gnus-kill-save-kill-buffer) | |
10060 (let* ((group gnus-newsgroup-name) | |
10061 (quit-config (gnus-group-quit-config gnus-newsgroup-name)) | |
10062 (mode major-mode) | |
10063 (buf (current-buffer))) | |
10064 (run-hooks 'gnus-summary-prepare-exit-hook) | |
10065 ;; If we have several article buffers, we kill them at exit. | |
10066 (unless gnus-single-article-buffer | |
10067 (gnus-kill-buffer gnus-original-article-buffer) | |
10068 (setq gnus-article-current nil)) | |
10069 (when gnus-use-cache | |
10070 (gnus-cache-possibly-remove-articles) | |
10071 (gnus-cache-save-buffers)) | |
10072 (when gnus-use-trees | |
10073 (gnus-tree-close group)) | |
10074 ;; Make all changes in this group permanent. | |
10075 (unless quit-config | |
10076 (gnus-summary-update-info)) | |
10077 (gnus-close-group group) | |
10078 ;; Make sure where I was, and go to next newsgroup. | |
10079 (set-buffer gnus-group-buffer) | |
10080 (unless quit-config | |
10081 (gnus-group-jump-to-group group)) | |
10082 (run-hooks 'gnus-summary-exit-hook) | |
10083 (unless quit-config | |
10084 (gnus-group-next-unread-group 1)) | |
10085 (if temporary | |
10086 nil ;Nothing to do. | |
10087 ;; If we have several article buffers, we kill them at exit. | |
10088 (unless gnus-single-article-buffer | |
10089 (gnus-kill-buffer gnus-article-buffer) | |
10090 (gnus-kill-buffer gnus-original-article-buffer) | |
10091 (setq gnus-article-current nil)) | |
10092 (set-buffer buf) | |
10093 (if (not gnus-kill-summary-on-exit) | |
10094 (gnus-deaden-summary) | |
10095 ;; We set all buffer-local variables to nil. It is unclear why | |
10096 ;; this is needed, but if we don't, buffer-local variables are | |
10097 ;; not garbage-collected, it seems. This would the lead to en | |
10098 ;; ever-growing Emacs. | |
10099 (gnus-summary-clear-local-variables) | |
10100 (when (get-buffer gnus-article-buffer) | |
10101 (bury-buffer gnus-article-buffer)) | |
10102 ;; We clear the global counterparts of the buffer-local | |
10103 ;; variables as well, just to be on the safe side. | |
10104 (gnus-configure-windows 'group 'force) | |
10105 (gnus-summary-clear-local-variables) | |
10106 ;; Return to group mode buffer. | |
10107 (if (eq mode 'gnus-summary-mode) | |
10108 (gnus-kill-buffer buf))) | |
10109 (setq gnus-current-select-method gnus-select-method) | |
10110 (pop-to-buffer gnus-group-buffer) | |
10111 ;; Clear the current group name. | |
10112 (if (not quit-config) | |
10113 (progn | |
10114 (gnus-group-jump-to-group group) | |
10115 (gnus-group-next-unread-group 1) | |
10116 (gnus-configure-windows 'group 'force)) | |
10117 (if (not (buffer-name (car quit-config))) | |
10118 (gnus-configure-windows 'group 'force) | |
10119 (set-buffer (car quit-config)) | |
10120 (and (eq major-mode 'gnus-summary-mode) | |
10121 (gnus-set-global-variables)) | |
10122 (gnus-configure-windows (cdr quit-config)))) | |
10123 (unless quit-config | |
10124 (setq gnus-newsgroup-name nil))))) | |
10125 | |
10126 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update) | |
10127 (defun gnus-summary-exit-no-update (&optional no-questions) | |
10128 "Quit reading current newsgroup without updating read article info." | |
10129 (interactive) | |
10130 (gnus-set-global-variables) | |
10131 (let* ((group gnus-newsgroup-name) | |
10132 (quit-config (gnus-group-quit-config group))) | |
10133 (when (or no-questions | |
10134 gnus-expert-user | |
10135 (gnus-y-or-n-p "Do you really wanna quit reading this group? ")) | |
10136 ;; If we have several article buffers, we kill them at exit. | |
10137 (unless gnus-single-article-buffer | |
10138 (gnus-kill-buffer gnus-article-buffer) | |
10139 (gnus-kill-buffer gnus-original-article-buffer) | |
10140 (setq gnus-article-current nil)) | |
10141 (if (not gnus-kill-summary-on-exit) | |
10142 (gnus-deaden-summary) | |
10143 (gnus-close-group group) | |
10144 (gnus-summary-clear-local-variables) | |
10145 (set-buffer gnus-group-buffer) | |
10146 (gnus-summary-clear-local-variables) | |
10147 (when (get-buffer gnus-summary-buffer) | |
10148 (kill-buffer gnus-summary-buffer))) | |
10149 (unless gnus-single-article-buffer | |
10150 (setq gnus-article-current nil)) | |
10151 (when gnus-use-trees | |
10152 (gnus-tree-close group)) | |
10153 (when (get-buffer gnus-article-buffer) | |
10154 (bury-buffer gnus-article-buffer)) | |
10155 ;; Return to the group buffer. | |
10156 (gnus-configure-windows 'group 'force) | |
10157 ;; Clear the current group name. | |
10158 (setq gnus-newsgroup-name nil) | |
10159 (when (equal (gnus-group-group-name) group) | |
10160 (gnus-group-next-unread-group 1)) | |
10161 (when quit-config | |
10162 (if (not (buffer-name (car quit-config))) | |
10163 (gnus-configure-windows 'group 'force) | |
10164 (set-buffer (car quit-config)) | |
10165 (when (eq major-mode 'gnus-summary-mode) | |
10166 (gnus-set-global-variables)) | |
10167 (gnus-configure-windows (cdr quit-config))))))) | |
10168 | |
10169 ;;; Dead summaries. | |
10170 | |
10171 (defvar gnus-dead-summary-mode-map nil) | |
10172 | |
10173 (if gnus-dead-summary-mode-map | |
10174 nil | |
10175 (setq gnus-dead-summary-mode-map (make-keymap)) | |
10176 (suppress-keymap gnus-dead-summary-mode-map) | |
10177 (substitute-key-definition | |
10178 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map) | |
10179 (let ((keys '("\C-d" "\r" "\177"))) | |
10180 (while keys | |
10181 (define-key gnus-dead-summary-mode-map | |
10182 (pop keys) 'gnus-summary-wake-up-the-dead)))) | |
10183 | |
10184 (defvar gnus-dead-summary-mode nil | |
10185 "Minor mode for Gnus summary buffers.") | |
10186 | |
10187 (defun gnus-dead-summary-mode (&optional arg) | |
10188 "Minor mode for Gnus summary buffers." | |
10189 (interactive "P") | |
10190 (when (eq major-mode 'gnus-summary-mode) | |
10191 (make-local-variable 'gnus-dead-summary-mode) | |
10192 (setq gnus-dead-summary-mode | |
10193 (if (null arg) (not gnus-dead-summary-mode) | |
10194 (> (prefix-numeric-value arg) 0))) | |
10195 (when gnus-dead-summary-mode | |
10196 (unless (assq 'gnus-dead-summary-mode minor-mode-alist) | |
10197 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist)) | |
10198 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist) | |
10199 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map) | |
10200 minor-mode-map-alist))))) | |
10201 | |
10202 (defun gnus-deaden-summary () | |
10203 "Make the current summary buffer into a dead summary buffer." | |
10204 ;; Kill any previous dead summary buffer. | |
10205 (when (and gnus-dead-summary | |
10206 (buffer-name gnus-dead-summary)) | |
10207 (save-excursion | |
10208 (set-buffer gnus-dead-summary) | |
10209 (when gnus-dead-summary-mode | |
10210 (kill-buffer (current-buffer))))) | |
10211 ;; Make this the current dead summary. | |
10212 (setq gnus-dead-summary (current-buffer)) | |
10213 (gnus-dead-summary-mode 1) | |
10214 (let ((name (buffer-name))) | |
10215 (when (string-match "Summary" name) | |
10216 (rename-buffer | |
10217 (concat (substring name 0 (match-beginning 0)) "Dead " | |
10218 (substring name (match-beginning 0))) t)))) | |
10219 | |
10220 (defun gnus-kill-or-deaden-summary (buffer) | |
10221 "Kill or deaden the summary BUFFER." | |
10222 (when (and (buffer-name buffer) | |
10223 (not gnus-single-article-buffer)) | |
10224 (save-excursion | |
10225 (set-buffer buffer) | |
10226 (gnus-kill-buffer gnus-article-buffer) | |
10227 (gnus-kill-buffer gnus-original-article-buffer))) | |
10228 (cond (gnus-kill-summary-on-exit | |
10229 (when (and gnus-use-trees | |
10230 (and (get-buffer buffer) | |
10231 (buffer-name (get-buffer buffer)))) | |
10232 (save-excursion | |
10233 (set-buffer (get-buffer buffer)) | |
10234 (gnus-tree-close gnus-newsgroup-name))) | |
10235 (gnus-kill-buffer buffer)) | |
10236 ((and (get-buffer buffer) | |
10237 (buffer-name (get-buffer buffer))) | |
10238 (save-excursion | |
10239 (set-buffer buffer) | |
10240 (gnus-deaden-summary))))) | |
10241 | |
10242 (defun gnus-summary-wake-up-the-dead (&rest args) | |
10243 "Wake up the dead summary buffer." | |
10244 (interactive) | |
10245 (gnus-dead-summary-mode -1) | |
10246 (let ((name (buffer-name))) | |
10247 (when (string-match "Dead " name) | |
10248 (rename-buffer | |
10249 (concat (substring name 0 (match-beginning 0)) | |
10250 (substring name (match-end 0))) t))) | |
10251 (gnus-message 3 "This dead summary is now alive again")) | |
10252 | |
10253 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>. | |
10254 (defun gnus-summary-fetch-faq (&optional faq-dir) | |
10255 "Fetch the FAQ for the current group. | |
10256 If FAQ-DIR (the prefix), prompt for a directory to search for the faq | |
10257 in." | |
10258 (interactive | |
10259 (list | |
10260 (if current-prefix-arg | |
10261 (completing-read | |
10262 "Faq dir: " (and (listp gnus-group-faq-directory) | |
10263 gnus-group-faq-directory))))) | |
10264 (let (gnus-faq-buffer) | |
10265 (and (setq gnus-faq-buffer | |
10266 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir)) | |
10267 (gnus-configure-windows 'summary-faq)))) | |
10268 | |
10269 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
10270 (defun gnus-summary-describe-group (&optional force) | |
10271 "Describe the current newsgroup." | |
10272 (interactive "P") | |
10273 (gnus-group-describe-group force gnus-newsgroup-name)) | |
10274 | |
10275 (defun gnus-summary-describe-briefly () | |
10276 "Describe summary mode commands briefly." | |
10277 (interactive) | |
10278 (gnus-message 6 | |
10279 (substitute-command-keys "\\<gnus-summary-mode-map>\\[gnus-summary-next-page]:Select \\[gnus-summary-next-unread-article]:Forward \\[gnus-summary-prev-unread-article]:Backward \\[gnus-summary-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-summary-describe-briefly]:This help"))) | |
10280 | |
10281 ;; Walking around group mode buffer from summary mode. | |
10282 | |
10283 (defun gnus-summary-next-group (&optional no-article target-group backward) | |
10284 "Exit current newsgroup and then select next unread newsgroup. | |
10285 If prefix argument NO-ARTICLE is non-nil, no article is selected | |
10286 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to | |
10287 previous group instead." | |
10288 (interactive "P") | |
10289 (gnus-set-global-variables) | |
10290 (let ((current-group gnus-newsgroup-name) | |
10291 (current-buffer (current-buffer)) | |
10292 entered) | |
10293 ;; First we semi-exit this group to update Xrefs and all variables. | |
10294 ;; We can't do a real exit, because the window conf must remain | |
10295 ;; the same in case the user is prompted for info, and we don't | |
10296 ;; want the window conf to change before that... | |
10297 (gnus-summary-exit t) | |
10298 (while (not entered) | |
10299 ;; Then we find what group we are supposed to enter. | |
10300 (set-buffer gnus-group-buffer) | |
10301 (gnus-group-jump-to-group current-group) | |
10302 (setq target-group | |
10303 (or target-group | |
10304 (if (eq gnus-keep-same-level 'best) | |
10305 (gnus-summary-best-group gnus-newsgroup-name) | |
10306 (gnus-summary-search-group backward gnus-keep-same-level)))) | |
10307 (if (not target-group) | |
10308 ;; There are no further groups, so we return to the group | |
10309 ;; buffer. | |
10310 (progn | |
10311 (gnus-message 5 "Returning to the group buffer") | |
10312 (setq entered t) | |
10313 (set-buffer current-buffer) | |
10314 (gnus-summary-exit)) | |
10315 ;; We try to enter the target group. | |
10316 (gnus-group-jump-to-group target-group) | |
10317 (let ((unreads (gnus-group-group-unread))) | |
10318 (if (and (or (eq t unreads) | |
10319 (and unreads (not (zerop unreads)))) | |
10320 (gnus-summary-read-group | |
10321 target-group nil no-article current-buffer)) | |
10322 (setq entered t) | |
10323 (setq current-group target-group | |
10324 target-group nil))))))) | |
10325 | |
10326 (defun gnus-summary-prev-group (&optional no-article) | |
10327 "Exit current newsgroup and then select previous unread newsgroup. | |
10328 If prefix argument NO-ARTICLE is non-nil, no article is selected initially." | |
10329 (interactive "P") | |
10330 (gnus-summary-next-group no-article nil t)) | |
10331 | |
10332 ;; Walking around summary lines. | |
10333 | |
10334 (defun gnus-summary-first-subject (&optional unread) | |
10335 "Go to the first unread subject. | |
10336 If UNREAD is non-nil, go to the first unread article. | |
10337 Returns the article selected or nil if there are no unread articles." | |
10338 (interactive "P") | |
10339 (prog1 | |
10340 (cond | |
10341 ;; Empty summary. | |
10342 ((null gnus-newsgroup-data) | |
10343 (gnus-message 3 "No articles in the group") | |
10344 nil) | |
10345 ;; Pick the first article. | |
10346 ((not unread) | |
10347 (goto-char (gnus-data-pos (car gnus-newsgroup-data))) | |
10348 (gnus-data-number (car gnus-newsgroup-data))) | |
10349 ;; No unread articles. | |
10350 ((null gnus-newsgroup-unreads) | |
10351 (gnus-message 3 "No more unread articles") | |
10352 nil) | |
10353 ;; Find the first unread article. | |
10354 (t | |
10355 (let ((data gnus-newsgroup-data)) | |
10356 (while (and data | |
10357 (not (gnus-data-unread-p (car data)))) | |
10358 (setq data (cdr data))) | |
10359 (if data | |
10360 (progn | |
10361 (goto-char (gnus-data-pos (car data))) | |
10362 (gnus-data-number (car data))))))) | |
10363 (gnus-summary-position-point))) | |
10364 | |
10365 (defun gnus-summary-next-subject (n &optional unread dont-display) | |
10366 "Go to next N'th summary line. | |
10367 If N is negative, go to the previous N'th subject line. | |
10368 If UNREAD is non-nil, only unread articles are selected. | |
10369 The difference between N and the actual number of steps taken is | |
10370 returned." | |
10371 (interactive "p") | |
10372 (let ((backward (< n 0)) | |
10373 (n (abs n))) | |
10374 (while (and (> n 0) | |
10375 (if backward | |
10376 (gnus-summary-find-prev unread) | |
10377 (gnus-summary-find-next unread))) | |
10378 (setq n (1- n))) | |
10379 (if (/= 0 n) (gnus-message 7 "No more%s articles" | |
10380 (if unread " unread" ""))) | |
10381 (unless dont-display | |
10382 (gnus-summary-recenter) | |
10383 (gnus-summary-position-point)) | |
10384 n)) | |
10385 | |
10386 (defun gnus-summary-next-unread-subject (n) | |
10387 "Go to next N'th unread summary line." | |
10388 (interactive "p") | |
10389 (gnus-summary-next-subject n t)) | |
10390 | |
10391 (defun gnus-summary-prev-subject (n &optional unread) | |
10392 "Go to previous N'th summary line. | |
10393 If optional argument UNREAD is non-nil, only unread article is selected." | |
10394 (interactive "p") | |
10395 (gnus-summary-next-subject (- n) unread)) | |
10396 | |
10397 (defun gnus-summary-prev-unread-subject (n) | |
10398 "Go to previous N'th unread summary line." | |
10399 (interactive "p") | |
10400 (gnus-summary-next-subject (- n) t)) | |
10401 | |
10402 (defun gnus-summary-goto-subject (article &optional force silent) | |
10403 "Go the subject line of ARTICLE. | |
10404 If FORCE, also allow jumping to articles not currently shown." | |
10405 (let ((b (point)) | |
10406 (data (gnus-data-find article))) | |
10407 ;; We read in the article if we have to. | |
10408 (and (not data) | |
10409 force | |
10410 (gnus-summary-insert-subject article (and (vectorp force) force) t) | |
10411 (setq data (gnus-data-find article))) | |
10412 (goto-char b) | |
10413 (if (not data) | |
10414 (progn | |
10415 (unless silent | |
10416 (gnus-message 3 "Can't find article %d" article)) | |
10417 nil) | |
10418 (goto-char (gnus-data-pos data)) | |
10419 article))) | |
10420 | |
10421 ;; Walking around summary lines with displaying articles. | |
10422 | |
10423 (defun gnus-summary-expand-window (&optional arg) | |
10424 "Make the summary buffer take up the entire Emacs frame. | |
10425 Given a prefix, will force an `article' buffer configuration." | |
10426 (interactive "P") | |
10427 (gnus-set-global-variables) | |
10428 (if arg | |
10429 (gnus-configure-windows 'article 'force) | |
10430 (gnus-configure-windows 'summary 'force))) | |
10431 | |
10432 (defun gnus-summary-display-article (article &optional all-header) | |
10433 "Display ARTICLE in article buffer." | |
10434 (gnus-set-global-variables) | |
10435 (if (null article) | |
10436 nil | |
10437 (prog1 | |
10438 (if gnus-summary-display-article-function | |
10439 (funcall gnus-summary-display-article-function article all-header) | |
10440 (gnus-article-prepare article all-header)) | |
10441 (run-hooks 'gnus-select-article-hook) | |
10442 (unless (zerop gnus-current-article) | |
10443 (gnus-summary-goto-subject gnus-current-article)) | |
10444 (gnus-summary-recenter) | |
10445 (when gnus-use-trees | |
10446 (gnus-possibly-generate-tree article) | |
10447 (gnus-highlight-selected-tree article)) | |
10448 ;; Successfully display article. | |
10449 (gnus-article-set-window-start | |
10450 (cdr (assq article gnus-newsgroup-bookmarks)))))) | |
10451 | |
10452 (defun gnus-summary-select-article (&optional all-headers force pseudo article) | |
10453 "Select the current article. | |
10454 If ALL-HEADERS is non-nil, show all header fields. If FORCE is | |
10455 non-nil, the article will be re-fetched even if it already present in | |
10456 the article buffer. If PSEUDO is non-nil, pseudo-articles will also | |
10457 be displayed." | |
10458 ;; Make sure we are in the summary buffer to work around bbdb bug. | |
10459 (unless (eq major-mode 'gnus-summary-mode) | |
10460 (set-buffer gnus-summary-buffer)) | |
10461 (let ((article (or article (gnus-summary-article-number))) | |
10462 (all-headers (not (not all-headers))) ;Must be T or NIL. | |
10463 gnus-summary-display-article-function | |
10464 did) | |
10465 (and (not pseudo) | |
10466 (gnus-summary-article-pseudo-p article) | |
10467 (error "This is a pseudo-article.")) | |
10468 (prog1 | |
10469 (save-excursion | |
10470 (set-buffer gnus-summary-buffer) | |
10471 (if (or (and gnus-single-article-buffer | |
10472 (or (null gnus-current-article) | |
10473 (null gnus-article-current) | |
10474 (null (get-buffer gnus-article-buffer)) | |
10475 (not (eq article (cdr gnus-article-current))) | |
10476 (not (equal (car gnus-article-current) | |
10477 gnus-newsgroup-name)))) | |
10478 (and (not gnus-single-article-buffer) | |
10479 (or (null gnus-current-article) | |
10480 (not (eq gnus-current-article article)))) | |
10481 force) | |
10482 ;; The requested article is different from the current article. | |
10483 (prog1 | |
10484 (gnus-summary-display-article article all-headers) | |
10485 (setq did article)) | |
10486 (if (or all-headers gnus-show-all-headers) | |
10487 (gnus-article-show-all-headers)) | |
10488 'old)) | |
10489 (if did | |
10490 (gnus-article-set-window-start | |
10491 (cdr (assq article gnus-newsgroup-bookmarks))))))) | |
10492 | |
10493 (defun gnus-summary-set-current-mark (&optional current-mark) | |
10494 "Obsolete function." | |
10495 nil) | |
10496 | |
10497 (defun gnus-summary-next-article (&optional unread subject backward push) | |
10498 "Select the next article. | |
10499 If UNREAD, only unread articles are selected. | |
10500 If SUBJECT, only articles with SUBJECT are selected. | |
10501 If BACKWARD, the previous article is selected instead of the next." | |
10502 (interactive "P") | |
10503 (gnus-set-global-variables) | |
10504 (cond | |
10505 ;; Is there such an article? | |
10506 ((and (gnus-summary-search-forward unread subject backward) | |
10507 (or (gnus-summary-display-article (gnus-summary-article-number)) | |
10508 (eq (gnus-summary-article-mark) gnus-canceled-mark))) | |
10509 (gnus-summary-position-point)) | |
10510 ;; If not, we try the first unread, if that is wanted. | |
10511 ((and subject | |
10512 gnus-auto-select-same | |
10513 (gnus-summary-first-unread-article)) | |
10514 (gnus-summary-position-point) | |
10515 (gnus-message 6 "Wrapped")) | |
10516 ;; Try to get next/previous article not displayed in this group. | |
10517 ((and gnus-auto-extend-newsgroup | |
10518 (not unread) (not subject)) | |
10519 (gnus-summary-goto-article | |
10520 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end)) | |
10521 nil t)) | |
10522 ;; Go to next/previous group. | |
10523 (t | |
10524 (or (gnus-ephemeral-group-p gnus-newsgroup-name) | |
10525 (gnus-summary-jump-to-group gnus-newsgroup-name)) | |
10526 (let ((cmd last-command-char) | |
10527 (group | |
10528 (if (eq gnus-keep-same-level 'best) | |
10529 (gnus-summary-best-group gnus-newsgroup-name) | |
10530 (gnus-summary-search-group backward gnus-keep-same-level)))) | |
10531 ;; For some reason, the group window gets selected. We change | |
10532 ;; it back. | |
10533 (select-window (get-buffer-window (current-buffer))) | |
10534 ;; Select next unread newsgroup automagically. | |
10535 (cond | |
10536 ((or (not gnus-auto-select-next) | |
10537 (not cmd)) | |
10538 (gnus-message 7 "No more%s articles" (if unread " unread" ""))) | |
10539 ((or (eq gnus-auto-select-next 'quietly) | |
10540 (and (eq gnus-auto-select-next 'slightly-quietly) | |
10541 push) | |
10542 (and (eq gnus-auto-select-next 'almost-quietly) | |
10543 (gnus-summary-last-article-p))) | |
10544 ;; Select quietly. | |
10545 (if (gnus-ephemeral-group-p gnus-newsgroup-name) | |
10546 (gnus-summary-exit) | |
10547 (gnus-message 7 "No more%s articles (%s)..." | |
10548 (if unread " unread" "") | |
10549 (if group (concat "selecting " group) | |
10550 "exiting")) | |
10551 (gnus-summary-next-group nil group backward))) | |
10552 (t | |
10553 (gnus-summary-walk-group-buffer | |
10554 gnus-newsgroup-name cmd unread backward))))))) | |
10555 | |
10556 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward) | |
10557 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1)) | |
10558 (?\C-p (gnus-group-prev-unread-group 1)))) | |
10559 keve key group ended) | |
10560 (save-excursion | |
10561 (set-buffer gnus-group-buffer) | |
10562 (gnus-summary-jump-to-group from-group) | |
10563 (setq group | |
10564 (if (eq gnus-keep-same-level 'best) | |
10565 (gnus-summary-best-group gnus-newsgroup-name) | |
10566 (gnus-summary-search-group backward gnus-keep-same-level)))) | |
10567 (while (not ended) | |
10568 (gnus-message | |
10569 5 "No more%s articles%s" (if unread " unread" "") | |
10570 (if (and group | |
10571 (not (gnus-ephemeral-group-p gnus-newsgroup-name))) | |
10572 (format " (Type %s for %s [%s])" | |
10573 (single-key-description cmd) group | |
10574 (car (gnus-gethash group gnus-newsrc-hashtb))) | |
10575 (format " (Type %s to exit %s)" | |
10576 (single-key-description cmd) | |
10577 gnus-newsgroup-name))) | |
10578 ;; Confirm auto selection. | |
10579 (setq key (car (setq keve (gnus-read-event-char)))) | |
10580 (setq ended t) | |
10581 (cond | |
10582 ((assq key keystrokes) | |
10583 (let ((obuf (current-buffer))) | |
10584 (switch-to-buffer gnus-group-buffer) | |
10585 (and group | |
10586 (gnus-group-jump-to-group group)) | |
10587 (eval (cadr (assq key keystrokes))) | |
10588 (setq group (gnus-group-group-name)) | |
10589 (switch-to-buffer obuf)) | |
10590 (setq ended nil)) | |
10591 ((equal key cmd) | |
10592 (if (or (not group) | |
10593 (gnus-ephemeral-group-p gnus-newsgroup-name)) | |
10594 (gnus-summary-exit) | |
10595 (gnus-summary-next-group nil group backward))) | |
10596 (t | |
10597 (push (cdr keve) unread-command-events)))))) | |
10598 | |
10599 (defun gnus-read-event-char () | |
10600 "Get the next event." | |
10601 (let ((event (read-event))) | |
10602 (cons (and (numberp event) event) event))) | |
10603 | |
10604 (defun gnus-summary-next-unread-article () | |
10605 "Select unread article after current one." | |
10606 (interactive) | |
10607 (gnus-summary-next-article t (and gnus-auto-select-same | |
10608 (gnus-summary-article-subject)))) | |
10609 | |
10610 (defun gnus-summary-prev-article (&optional unread subject) | |
10611 "Select the article after the current one. | |
10612 If UNREAD is non-nil, only unread articles are selected." | |
10613 (interactive "P") | |
10614 (gnus-summary-next-article unread subject t)) | |
10615 | |
10616 (defun gnus-summary-prev-unread-article () | |
10617 "Select unred article before current one." | |
10618 (interactive) | |
10619 (gnus-summary-prev-article t (and gnus-auto-select-same | |
10620 (gnus-summary-article-subject)))) | |
10621 | |
10622 (defun gnus-summary-next-page (&optional lines circular) | |
10623 "Show next page of the selected article. | |
10624 If at the end of the current article, select the next article. | |
10625 LINES says how many lines should be scrolled up. | |
10626 | |
10627 If CIRCULAR is non-nil, go to the start of the article instead of | |
10628 selecting the next article when reaching the end of the current | |
10629 article." | |
10630 (interactive "P") | |
10631 (setq gnus-summary-buffer (current-buffer)) | |
10632 (gnus-set-global-variables) | |
10633 (let ((article (gnus-summary-article-number)) | |
10634 (endp nil)) | |
10635 (gnus-configure-windows 'article) | |
10636 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark) | |
10637 (if (and (eq gnus-summary-goto-unread 'never) | |
10638 (not (gnus-summary-last-article-p article))) | |
10639 (gnus-summary-next-article) | |
10640 (gnus-summary-next-unread-article)) | |
10641 (if (or (null gnus-current-article) | |
10642 (null gnus-article-current) | |
10643 (/= article (cdr gnus-article-current)) | |
10644 (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
10645 ;; Selected subject is different from current article's. | |
10646 (gnus-summary-display-article article) | |
10647 (gnus-eval-in-buffer-window gnus-article-buffer | |
10648 (setq endp (gnus-article-next-page lines))) | |
10649 (if endp | |
10650 (cond (circular | |
10651 (gnus-summary-beginning-of-article)) | |
10652 (lines | |
10653 (gnus-message 3 "End of message")) | |
10654 ((null lines) | |
10655 (if (and (eq gnus-summary-goto-unread 'never) | |
10656 (not (gnus-summary-last-article-p article))) | |
10657 (gnus-summary-next-article) | |
10658 (gnus-summary-next-unread-article))))))) | |
10659 (gnus-summary-recenter) | |
10660 (gnus-summary-position-point))) | |
10661 | |
10662 (defun gnus-summary-prev-page (&optional lines) | |
10663 "Show previous page of selected article. | |
10664 Argument LINES specifies lines to be scrolled down." | |
10665 (interactive "P") | |
10666 (gnus-set-global-variables) | |
10667 (let ((article (gnus-summary-article-number))) | |
10668 (gnus-configure-windows 'article) | |
10669 (if (or (null gnus-current-article) | |
10670 (null gnus-article-current) | |
10671 (/= article (cdr gnus-article-current)) | |
10672 (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
10673 ;; Selected subject is different from current article's. | |
10674 (gnus-summary-display-article article) | |
10675 (gnus-summary-recenter) | |
10676 (gnus-eval-in-buffer-window gnus-article-buffer | |
10677 (gnus-article-prev-page lines)))) | |
10678 (gnus-summary-position-point)) | |
10679 | |
10680 (defun gnus-summary-scroll-up (lines) | |
10681 "Scroll up (or down) one line current article. | |
10682 Argument LINES specifies lines to be scrolled up (or down if negative)." | |
10683 (interactive "p") | |
10684 (gnus-set-global-variables) | |
10685 (gnus-configure-windows 'article) | |
10686 (gnus-summary-show-thread) | |
10687 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old) | |
10688 (gnus-eval-in-buffer-window gnus-article-buffer | |
10689 (cond ((> lines 0) | |
10690 (if (gnus-article-next-page lines) | |
10691 (gnus-message 3 "End of message"))) | |
10692 ((< lines 0) | |
10693 (gnus-article-prev-page (- lines)))))) | |
10694 (gnus-summary-recenter) | |
10695 (gnus-summary-position-point)) | |
10696 | |
10697 (defun gnus-summary-next-same-subject () | |
10698 "Select next article which has the same subject as current one." | |
10699 (interactive) | |
10700 (gnus-set-global-variables) | |
10701 (gnus-summary-next-article nil (gnus-summary-article-subject))) | |
10702 | |
10703 (defun gnus-summary-prev-same-subject () | |
10704 "Select previous article which has the same subject as current one." | |
10705 (interactive) | |
10706 (gnus-set-global-variables) | |
10707 (gnus-summary-prev-article nil (gnus-summary-article-subject))) | |
10708 | |
10709 (defun gnus-summary-next-unread-same-subject () | |
10710 "Select next unread article which has the same subject as current one." | |
10711 (interactive) | |
10712 (gnus-set-global-variables) | |
10713 (gnus-summary-next-article t (gnus-summary-article-subject))) | |
10714 | |
10715 (defun gnus-summary-prev-unread-same-subject () | |
10716 "Select previous unread article which has the same subject as current one." | |
10717 (interactive) | |
10718 (gnus-set-global-variables) | |
10719 (gnus-summary-prev-article t (gnus-summary-article-subject))) | |
10720 | |
10721 (defun gnus-summary-first-unread-article () | |
10722 "Select the first unread article. | |
10723 Return nil if there are no unread articles." | |
10724 (interactive) | |
10725 (gnus-set-global-variables) | |
10726 (prog1 | |
10727 (if (gnus-summary-first-subject t) | |
10728 (progn | |
10729 (gnus-summary-show-thread) | |
10730 (gnus-summary-first-subject t) | |
10731 (gnus-summary-display-article (gnus-summary-article-number)))) | |
10732 (gnus-summary-position-point))) | |
10733 | |
10734 (defun gnus-summary-best-unread-article () | |
10735 "Select the unread article with the highest score." | |
10736 (interactive) | |
10737 (gnus-set-global-variables) | |
10738 (let ((best -1000000) | |
10739 (data gnus-newsgroup-data) | |
10740 article score) | |
10741 (while data | |
10742 (and (gnus-data-unread-p (car data)) | |
10743 (> (setq score | |
10744 (gnus-summary-article-score (gnus-data-number (car data)))) | |
10745 best) | |
10746 (setq best score | |
10747 article (gnus-data-number (car data)))) | |
10748 (setq data (cdr data))) | |
10749 (prog1 | |
10750 (if article | |
10751 (gnus-summary-goto-article article) | |
10752 (error "No unread articles")) | |
10753 (gnus-summary-position-point)))) | |
10754 | |
10755 (defun gnus-summary-last-subject () | |
10756 "Go to the last displayed subject line in the group." | |
10757 (let ((article (gnus-data-number (car (gnus-data-list t))))) | |
10758 (when article | |
10759 (gnus-summary-goto-subject article)))) | |
10760 | |
10761 (defun gnus-summary-goto-article (article &optional all-headers force) | |
10762 "Fetch ARTICLE and display it if it exists. | |
10763 If ALL-HEADERS is non-nil, no header lines are hidden." | |
10764 (interactive | |
10765 (list | |
10766 (string-to-int | |
10767 (completing-read | |
10768 "Article number: " | |
10769 (mapcar (lambda (number) (list (int-to-string number))) | |
10770 gnus-newsgroup-limit))) | |
10771 current-prefix-arg | |
10772 t)) | |
10773 (prog1 | |
10774 (if (gnus-summary-goto-subject article force) | |
10775 (gnus-summary-display-article article all-headers) | |
10776 (gnus-message 4 "Couldn't go to article %s" article) nil) | |
10777 (gnus-summary-position-point))) | |
10778 | |
10779 (defun gnus-summary-goto-last-article () | |
10780 "Go to the previously read article." | |
10781 (interactive) | |
10782 (prog1 | |
10783 (and gnus-last-article | |
10784 (gnus-summary-goto-article gnus-last-article)) | |
10785 (gnus-summary-position-point))) | |
10786 | |
10787 (defun gnus-summary-pop-article (number) | |
10788 "Pop one article off the history and go to the previous. | |
10789 NUMBER articles will be popped off." | |
10790 (interactive "p") | |
10791 (let (to) | |
10792 (setq gnus-newsgroup-history | |
10793 (cdr (setq to (nthcdr number gnus-newsgroup-history)))) | |
10794 (if to | |
10795 (gnus-summary-goto-article (car to)) | |
10796 (error "Article history empty"))) | |
10797 (gnus-summary-position-point)) | |
10798 | |
10799 ;; Summary commands and functions for limiting the summary buffer. | |
10800 | |
10801 (defun gnus-summary-limit-to-articles (n) | |
10802 "Limit the summary buffer to the next N articles. | |
10803 If not given a prefix, use the process marked articles instead." | |
10804 (interactive "P") | |
10805 (gnus-set-global-variables) | |
10806 (prog1 | |
10807 (let ((articles (gnus-summary-work-articles n))) | |
10808 (setq gnus-newsgroup-processable nil) | |
10809 (gnus-summary-limit articles)) | |
10810 (gnus-summary-position-point))) | |
10811 | |
10812 (defun gnus-summary-pop-limit (&optional total) | |
10813 "Restore the previous limit. | |
10814 If given a prefix, remove all limits." | |
10815 (interactive "P") | |
10816 (gnus-set-global-variables) | |
10817 (when total | |
10818 (setq gnus-newsgroup-limits | |
10819 (list (mapcar (lambda (h) (mail-header-number h)) | |
10820 gnus-newsgroup-headers)))) | |
10821 (unless gnus-newsgroup-limits | |
10822 (error "No limit to pop")) | |
10823 (prog1 | |
10824 (gnus-summary-limit nil 'pop) | |
10825 (gnus-summary-position-point))) | |
10826 | |
10827 (defun gnus-summary-limit-to-subject (subject &optional header) | |
10828 "Limit the summary buffer to articles that have subjects that match a regexp." | |
10829 (interactive "sRegexp: ") | |
10830 (unless header | |
10831 (setq header "subject")) | |
10832 (when (not (equal "" subject)) | |
10833 (prog1 | |
10834 (let ((articles (gnus-summary-find-matching | |
10835 (or header "subject") subject 'all))) | |
10836 (or articles (error "Found no matches for \"%s\"" subject)) | |
10837 (gnus-summary-limit articles)) | |
10838 (gnus-summary-position-point)))) | |
10839 | |
10840 (defun gnus-summary-limit-to-author (from) | |
10841 "Limit the summary buffer to articles that have authors that match a regexp." | |
10842 (interactive "sRegexp: ") | |
10843 (gnus-summary-limit-to-subject from "from")) | |
10844 | |
10845 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread) | |
10846 (make-obsolete | |
10847 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread) | |
10848 | |
10849 (defun gnus-summary-limit-to-unread (&optional all) | |
10850 "Limit the summary buffer to articles that are not marked as read. | |
10851 If ALL is non-nil, limit strictly to unread articles." | |
10852 (interactive "P") | |
10853 (if all | |
10854 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark)) | |
10855 (gnus-summary-limit-to-marks | |
10856 ;; Concat all the marks that say that an article is read and have | |
10857 ;; those removed. | |
10858 (list gnus-del-mark gnus-read-mark gnus-ancient-mark | |
10859 gnus-killed-mark gnus-kill-file-mark | |
10860 gnus-low-score-mark gnus-expirable-mark | |
10861 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark) | |
10862 'reverse))) | |
10863 | |
10864 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks) | |
10865 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks) | |
10866 | |
10867 (defun gnus-summary-limit-to-marks (marks &optional reverse) | |
10868 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\"). | |
10869 If REVERSE, limit the summary buffer to articles that are not marked | |
10870 with MARKS. MARKS can either be a string of marks or a list of marks. | |
10871 Returns how many articles were removed." | |
10872 (interactive "sMarks: ") | |
10873 (gnus-set-global-variables) | |
10874 (prog1 | |
10875 (let ((data gnus-newsgroup-data) | |
10876 (marks (if (listp marks) marks | |
10877 (append marks nil))) ; Transform to list. | |
10878 articles) | |
10879 (while data | |
10880 (and (if reverse (not (memq (gnus-data-mark (car data)) marks)) | |
10881 (memq (gnus-data-mark (car data)) marks)) | |
10882 (setq articles (cons (gnus-data-number (car data)) articles))) | |
10883 (setq data (cdr data))) | |
10884 (gnus-summary-limit articles)) | |
10885 (gnus-summary-position-point))) | |
10886 | |
10887 (defun gnus-summary-limit-to-score (&optional score) | |
10888 "Limit to articles with score at or above SCORE." | |
10889 (interactive "P") | |
10890 (gnus-set-global-variables) | |
10891 (setq score (if score | |
10892 (prefix-numeric-value score) | |
10893 (or gnus-summary-default-score 0))) | |
10894 (let ((data gnus-newsgroup-data) | |
10895 articles) | |
10896 (while data | |
10897 (when (>= (gnus-summary-article-score (gnus-data-number (car data))) | |
10898 score) | |
10899 (push (gnus-data-number (car data)) articles)) | |
10900 (setq data (cdr data))) | |
10901 (prog1 | |
10902 (gnus-summary-limit articles) | |
10903 (gnus-summary-position-point)))) | |
10904 | |
10905 (defun gnus-summary-limit-include-dormant () | |
10906 "Display all the hidden articles that are marked as dormant." | |
10907 (interactive) | |
10908 (gnus-set-global-variables) | |
10909 (or gnus-newsgroup-dormant | |
10910 (error "There are no dormant articles in this group")) | |
10911 (prog1 | |
10912 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit)) | |
10913 (gnus-summary-position-point))) | |
10914 | |
10915 (defun gnus-summary-limit-exclude-dormant () | |
10916 "Hide all dormant articles." | |
10917 (interactive) | |
10918 (gnus-set-global-variables) | |
10919 (prog1 | |
10920 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse) | |
10921 (gnus-summary-position-point))) | |
10922 | |
10923 (defun gnus-summary-limit-exclude-childless-dormant () | |
10924 "Hide all dormant articles that have no children." | |
10925 (interactive) | |
10926 (gnus-set-global-variables) | |
10927 (let ((data (gnus-data-list t)) | |
10928 articles d children) | |
10929 ;; Find all articles that are either not dormant or have | |
10930 ;; children. | |
10931 (while (setq d (pop data)) | |
10932 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark)) | |
10933 (and (setq children | |
10934 (gnus-article-children (gnus-data-number d))) | |
10935 (let (found) | |
10936 (while children | |
10937 (when (memq (car children) articles) | |
10938 (setq children nil | |
10939 found t)) | |
10940 (pop children)) | |
10941 found))) | |
10942 (push (gnus-data-number d) articles))) | |
10943 ;; Do the limiting. | |
10944 (prog1 | |
10945 (gnus-summary-limit articles) | |
10946 (gnus-summary-position-point)))) | |
10947 | |
10948 (defun gnus-summary-limit-mark-excluded-as-read (&optional all) | |
10949 "Mark all unread excluded articles as read. | |
10950 If ALL, mark even excluded ticked and dormants as read." | |
10951 (interactive "P") | |
10952 (let ((articles (gnus-sorted-complement | |
10953 (sort | |
10954 (mapcar (lambda (h) (mail-header-number h)) | |
10955 gnus-newsgroup-headers) | |
10956 '<) | |
10957 (sort gnus-newsgroup-limit '<))) | |
10958 article) | |
10959 (setq gnus-newsgroup-unreads nil) | |
10960 (if all | |
10961 (setq gnus-newsgroup-dormant nil | |
10962 gnus-newsgroup-marked nil | |
10963 gnus-newsgroup-reads | |
10964 (nconc | |
10965 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles) | |
10966 gnus-newsgroup-reads)) | |
10967 (while (setq article (pop articles)) | |
10968 (unless (or (memq article gnus-newsgroup-dormant) | |
10969 (memq article gnus-newsgroup-marked)) | |
10970 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads)))))) | |
10971 | |
10972 (defun gnus-summary-limit (articles &optional pop) | |
10973 (if pop | |
10974 ;; We pop the previous limit off the stack and use that. | |
10975 (setq articles (car gnus-newsgroup-limits) | |
10976 gnus-newsgroup-limits (cdr gnus-newsgroup-limits)) | |
10977 ;; We use the new limit, so we push the old limit on the stack. | |
10978 (setq gnus-newsgroup-limits | |
10979 (cons gnus-newsgroup-limit gnus-newsgroup-limits))) | |
10980 ;; Set the limit. | |
10981 (setq gnus-newsgroup-limit articles) | |
10982 (let ((total (length gnus-newsgroup-data)) | |
10983 (data (gnus-data-find-list (gnus-summary-article-number))) | |
10984 (gnus-summary-mark-below nil) ; Inhibit this. | |
10985 found) | |
10986 ;; This will do all the work of generating the new summary buffer | |
10987 ;; according to the new limit. | |
10988 (gnus-summary-prepare) | |
10989 ;; Hide any threads, possibly. | |
10990 (and gnus-show-threads | |
10991 gnus-thread-hide-subtree | |
10992 (gnus-summary-hide-all-threads)) | |
10993 ;; Try to return to the article you were at, or one in the | |
10994 ;; neighborhood. | |
10995 (if data | |
10996 ;; We try to find some article after the current one. | |
10997 (while data | |
10998 (and (gnus-summary-goto-subject | |
10999 (gnus-data-number (car data)) nil t) | |
11000 (setq data nil | |
11001 found t)) | |
11002 (setq data (cdr data)))) | |
11003 (or found | |
11004 ;; If there is no data, that means that we were after the last | |
11005 ;; article. The same goes when we can't find any articles | |
11006 ;; after the current one. | |
11007 (progn | |
11008 (goto-char (point-max)) | |
11009 (gnus-summary-find-prev))) | |
11010 ;; We return how many articles were removed from the summary | |
11011 ;; buffer as a result of the new limit. | |
11012 (- total (length gnus-newsgroup-data)))) | |
11013 | |
11014 (defsubst gnus-invisible-cut-children (threads) | |
11015 (let ((num 0)) | |
11016 (while threads | |
11017 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit) | |
11018 (incf num)) | |
11019 (pop threads)) | |
11020 (< num 2))) | |
11021 | |
11022 (defsubst gnus-cut-thread (thread) | |
11023 "Go forwards in the thread until we find an article that we want to display." | |
11024 (when (or (eq gnus-fetch-old-headers 'some) | |
11025 (eq gnus-build-sparse-threads 'some) | |
11026 (eq gnus-build-sparse-threads 'more)) | |
11027 ;; Deal with old-fetched headers and sparse threads. | |
11028 (while (and | |
11029 thread | |
11030 (or | |
11031 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse) | |
11032 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient)) | |
11033 (or (<= (length (cdr thread)) 1) | |
11034 (gnus-invisible-cut-children (cdr thread)))) | |
11035 (setq thread (cadr thread)))) | |
11036 thread) | |
11037 | |
11038 (defun gnus-cut-threads (threads) | |
11039 "Cut off all uninteresting articles from the beginning of threads." | |
11040 (when (or (eq gnus-fetch-old-headers 'some) | |
11041 (eq gnus-build-sparse-threads 'some) | |
11042 (eq gnus-build-sparse-threads 'more)) | |
11043 (let ((th threads)) | |
11044 (while th | |
11045 (setcar th (gnus-cut-thread (car th))) | |
11046 (setq th (cdr th))))) | |
11047 ;; Remove nixed out threads. | |
11048 (delq nil threads)) | |
11049 | |
11050 (defun gnus-summary-initial-limit (&optional show-if-empty) | |
11051 "Figure out what the initial limit is supposed to be on group entry. | |
11052 This entails weeding out unwanted dormants, low-scored articles, | |
11053 fetch-old-headers verbiage, and so on." | |
11054 ;; Most groups have nothing to remove. | |
11055 (if (or gnus-inhibit-limiting | |
11056 (and (null gnus-newsgroup-dormant) | |
11057 (not (eq gnus-fetch-old-headers 'some)) | |
11058 (null gnus-summary-expunge-below) | |
11059 (not (eq gnus-build-sparse-threads 'some)) | |
11060 (not (eq gnus-build-sparse-threads 'more)) | |
11061 (null gnus-thread-expunge-below) | |
11062 (not gnus-use-nocem))) | |
11063 () ; Do nothing. | |
11064 (push gnus-newsgroup-limit gnus-newsgroup-limits) | |
11065 (setq gnus-newsgroup-limit nil) | |
11066 (mapatoms | |
11067 (lambda (node) | |
11068 (unless (car (symbol-value node)) | |
11069 ;; These threads have no parents -- they are roots. | |
11070 (let ((nodes (cdr (symbol-value node))) | |
11071 thread) | |
11072 (while nodes | |
11073 (if (and gnus-thread-expunge-below | |
11074 (< (gnus-thread-total-score (car nodes)) | |
11075 gnus-thread-expunge-below)) | |
11076 (gnus-expunge-thread (pop nodes)) | |
11077 (setq thread (pop nodes)) | |
11078 (gnus-summary-limit-children thread)))))) | |
11079 gnus-newsgroup-dependencies) | |
11080 ;; If this limitation resulted in an empty group, we might | |
11081 ;; pop the previous limit and use it instead. | |
11082 (when (and (not gnus-newsgroup-limit) | |
11083 show-if-empty) | |
11084 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits))) | |
11085 gnus-newsgroup-limit)) | |
11086 | |
11087 (defun gnus-summary-limit-children (thread) | |
11088 "Return 1 if this subthread is visible and 0 if it is not." | |
11089 ;; First we get the number of visible children to this thread. This | |
11090 ;; is done by recursing down the thread using this function, so this | |
11091 ;; will really go down to a leaf article first, before slowly | |
11092 ;; working its way up towards the root. | |
11093 (when thread | |
11094 (let ((children | |
11095 (if (cdr thread) | |
11096 (apply '+ (mapcar 'gnus-summary-limit-children | |
11097 (cdr thread))) | |
11098 0)) | |
11099 (number (mail-header-number (car thread))) | |
11100 score) | |
11101 (if (or | |
11102 ;; If this article is dormant and has absolutely no visible | |
11103 ;; children, then this article isn't visible. | |
11104 (and (memq number gnus-newsgroup-dormant) | |
11105 (= children 0)) | |
11106 ;; If this is "fetch-old-headered" and there is only one | |
11107 ;; visible child (or less), then we don't want this article. | |
11108 (and (eq gnus-fetch-old-headers 'some) | |
11109 (memq number gnus-newsgroup-ancient) | |
11110 (zerop children)) | |
11111 ;; If this is a sparsely inserted article with no children, | |
11112 ;; we don't want it. | |
11113 (and (eq gnus-build-sparse-threads 'some) | |
11114 (memq number gnus-newsgroup-sparse) | |
11115 (zerop children)) | |
11116 ;; If we use expunging, and this article is really | |
11117 ;; low-scored, then we don't want this article. | |
11118 (when (and gnus-summary-expunge-below | |
11119 (< (setq score | |
11120 (or (cdr (assq number gnus-newsgroup-scored)) | |
11121 gnus-summary-default-score)) | |
11122 gnus-summary-expunge-below)) | |
11123 ;; We increase the expunge-tally here, but that has | |
11124 ;; nothing to do with the limits, really. | |
11125 (incf gnus-newsgroup-expunged-tally) | |
11126 ;; We also mark as read here, if that's wanted. | |
11127 (when (and gnus-summary-mark-below | |
11128 (< score gnus-summary-mark-below)) | |
11129 (setq gnus-newsgroup-unreads | |
11130 (delq number gnus-newsgroup-unreads)) | |
11131 (if gnus-newsgroup-auto-expire | |
11132 (push number gnus-newsgroup-expirable) | |
11133 (push (cons number gnus-low-score-mark) | |
11134 gnus-newsgroup-reads))) | |
11135 t) | |
11136 (and gnus-use-nocem | |
11137 (gnus-nocem-unwanted-article-p (mail-header-id (car thread))))) | |
11138 ;; Nope, invisible article. | |
11139 0 | |
11140 ;; Ok, this article is to be visible, so we add it to the limit | |
11141 ;; and return 1. | |
11142 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit)) | |
11143 1)))) | |
11144 | |
11145 (defun gnus-expunge-thread (thread) | |
11146 "Mark all articles in THREAD as read." | |
11147 (let* ((number (mail-header-number (car thread)))) | |
11148 (incf gnus-newsgroup-expunged-tally) | |
11149 ;; We also mark as read here, if that's wanted. | |
11150 (setq gnus-newsgroup-unreads | |
11151 (delq number gnus-newsgroup-unreads)) | |
11152 (if gnus-newsgroup-auto-expire | |
11153 (push number gnus-newsgroup-expirable) | |
11154 (push (cons number gnus-low-score-mark) | |
11155 gnus-newsgroup-reads))) | |
11156 ;; Go recursively through all subthreads. | |
11157 (mapcar 'gnus-expunge-thread (cdr thread))) | |
11158 | |
11159 ;; Summary article oriented commands | |
11160 | |
11161 (defun gnus-summary-refer-parent-article (n) | |
11162 "Refer parent article N times. | |
11163 The difference between N and the number of articles fetched is returned." | |
11164 (interactive "p") | |
11165 (gnus-set-global-variables) | |
11166 (while | |
11167 (and | |
11168 (> n 0) | |
11169 (let* ((header (gnus-summary-article-header)) | |
11170 (ref | |
11171 ;; If we try to find the parent of the currently | |
11172 ;; displayed article, then we take a look at the actual | |
11173 ;; References header, since this is slightly more | |
11174 ;; reliable than the References field we got from the | |
11175 ;; server. | |
11176 (if (and (eq (mail-header-number header) | |
11177 (cdr gnus-article-current)) | |
11178 (equal gnus-newsgroup-name | |
11179 (car gnus-article-current))) | |
11180 (save-excursion | |
11181 (set-buffer gnus-original-article-buffer) | |
11182 (nnheader-narrow-to-headers) | |
11183 (prog1 | |
11184 (message-fetch-field "references") | |
11185 (widen))) | |
11186 ;; It's not the current article, so we take a bet on | |
11187 ;; the value we got from the server. | |
11188 (mail-header-references header)))) | |
11189 (if (setq ref (or ref (mail-header-references header))) | |
11190 (or (gnus-summary-refer-article (gnus-parent-id ref)) | |
11191 (gnus-message 1 "Couldn't find parent")) | |
11192 (gnus-message 1 "No references in article %d" | |
11193 (gnus-summary-article-number)) | |
11194 nil))) | |
11195 (setq n (1- n))) | |
11196 (gnus-summary-position-point) | |
11197 n) | |
11198 | |
11199 (defun gnus-summary-refer-references () | |
11200 "Fetch all articles mentioned in the References header. | |
11201 Return how many articles were fetched." | |
11202 (interactive) | |
11203 (gnus-set-global-variables) | |
11204 (let ((ref (mail-header-references (gnus-summary-article-header))) | |
11205 (current (gnus-summary-article-number)) | |
11206 (n 0)) | |
11207 ;; For each Message-ID in the References header... | |
11208 (while (string-match "<[^>]*>" ref) | |
11209 (incf n) | |
11210 ;; ... fetch that article. | |
11211 (gnus-summary-refer-article | |
11212 (prog1 (match-string 0 ref) | |
11213 (setq ref (substring ref (match-end 0)))))) | |
11214 (gnus-summary-goto-subject current) | |
11215 (gnus-summary-position-point) | |
11216 n)) | |
11217 | |
11218 (defun gnus-summary-refer-article (message-id) | |
11219 "Fetch an article specified by MESSAGE-ID." | |
11220 (interactive "sMessage-ID: ") | |
11221 (when (and (stringp message-id) | |
11222 (not (zerop (length message-id)))) | |
11223 ;; Construct the correct Message-ID if necessary. | |
11224 ;; Suggested by tale@pawl.rpi.edu. | |
11225 (unless (string-match "^<" message-id) | |
11226 (setq message-id (concat "<" message-id))) | |
11227 (unless (string-match ">$" message-id) | |
11228 (setq message-id (concat message-id ">"))) | |
11229 (let* ((header (gnus-id-to-header message-id)) | |
11230 (sparse (and header | |
11231 (memq (mail-header-number header) | |
11232 gnus-newsgroup-sparse)))) | |
11233 (if header | |
11234 (prog1 | |
11235 ;; The article is present in the buffer, to we just go to it. | |
11236 (gnus-summary-goto-article | |
11237 (mail-header-number header) nil header) | |
11238 (when sparse | |
11239 (gnus-summary-update-article (mail-header-number header)))) | |
11240 ;; We fetch the article | |
11241 (let ((gnus-override-method | |
11242 (and (gnus-news-group-p gnus-newsgroup-name) | |
11243 gnus-refer-article-method)) | |
11244 number) | |
11245 ;; Start the special refer-article method, if necessary. | |
11246 (when (and gnus-refer-article-method | |
11247 (gnus-news-group-p gnus-newsgroup-name)) | |
11248 (gnus-check-server gnus-refer-article-method)) | |
11249 ;; Fetch the header, and display the article. | |
11250 (if (setq number (gnus-summary-insert-subject message-id)) | |
11251 (gnus-summary-select-article nil nil nil number) | |
11252 (gnus-message 3 "Couldn't fetch article %s" message-id))))))) | |
11253 | |
11254 (defun gnus-summary-enter-digest-group (&optional force) | |
11255 "Enter a digest group based on the current article." | |
11256 (interactive "P") | |
11257 (gnus-set-global-variables) | |
11258 (gnus-summary-select-article) | |
11259 (let ((name (format "%s-%d" | |
11260 (gnus-group-prefixed-name | |
11261 gnus-newsgroup-name (list 'nndoc "")) | |
11262 gnus-current-article)) | |
11263 (ogroup gnus-newsgroup-name) | |
11264 (case-fold-search t) | |
11265 (buf (current-buffer)) | |
11266 dig) | |
11267 (save-excursion | |
11268 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*")) | |
11269 (insert-buffer-substring gnus-original-article-buffer) | |
11270 (narrow-to-region | |
11271 (goto-char (point-min)) | |
11272 (or (search-forward "\n\n" nil t) (point))) | |
11273 (goto-char (point-min)) | |
11274 (delete-matching-lines "^\\(Path\\):\\|^From ") | |
11275 (widen)) | |
11276 (unwind-protect | |
11277 (if (gnus-group-read-ephemeral-group | |
11278 name `(nndoc ,name (nndoc-address | |
11279 ,(get-buffer dig)) | |
11280 (nndoc-article-type ,(if force 'digest 'guess))) t) | |
11281 ;; Make all postings to this group go to the parent group. | |
11282 (nconc (gnus-info-params (gnus-get-info name)) | |
11283 (list (cons 'to-group ogroup))) | |
11284 ;; Couldn't select this doc group. | |
11285 (switch-to-buffer buf) | |
11286 (gnus-set-global-variables) | |
11287 (gnus-configure-windows 'summary) | |
11288 (gnus-message 3 "Article couldn't be entered?")) | |
11289 (kill-buffer dig)))) | |
11290 | |
11291 (defun gnus-summary-isearch-article (&optional regexp-p) | |
11292 "Do incremental search forward on the current article. | |
11293 If REGEXP-P (the prefix) is non-nil, do regexp isearch." | |
11294 (interactive "P") | |
11295 (gnus-set-global-variables) | |
11296 (gnus-summary-select-article) | |
11297 (gnus-configure-windows 'article) | |
11298 (gnus-eval-in-buffer-window gnus-article-buffer | |
11299 ;;(goto-char (point-min)) | |
11300 (isearch-forward regexp-p))) | |
11301 | |
11302 (defun gnus-summary-search-article-forward (regexp &optional backward) | |
11303 "Search for an article containing REGEXP forward. | |
11304 If BACKWARD, search backward instead." | |
11305 (interactive | |
11306 (list (read-string | |
11307 (format "Search article %s (regexp%s): " | |
11308 (if current-prefix-arg "backward" "forward") | |
11309 (if gnus-last-search-regexp | |
11310 (concat ", default " gnus-last-search-regexp) | |
11311 ""))) | |
11312 current-prefix-arg)) | |
11313 (gnus-set-global-variables) | |
11314 (if (string-equal regexp "") | |
11315 (setq regexp (or gnus-last-search-regexp "")) | |
11316 (setq gnus-last-search-regexp regexp)) | |
11317 (unless (gnus-summary-search-article regexp backward) | |
11318 (error "Search failed: \"%s\"" regexp))) | |
11319 | |
11320 (defun gnus-summary-search-article-backward (regexp) | |
11321 "Search for an article containing REGEXP backward." | |
11322 (interactive | |
11323 (list (read-string | |
11324 (format "Search article backward (regexp%s): " | |
11325 (if gnus-last-search-regexp | |
11326 (concat ", default " gnus-last-search-regexp) | |
11327 ""))))) | |
11328 (gnus-summary-search-article-forward regexp 'backward)) | |
11329 | |
11330 (defun gnus-summary-search-article (regexp &optional backward) | |
11331 "Search for an article containing REGEXP. | |
11332 Optional argument BACKWARD means do search for backward. | |
11333 `gnus-select-article-hook' is not called during the search." | |
11334 (let ((gnus-select-article-hook nil) ;Disable hook. | |
11335 (gnus-article-display-hook nil) | |
11336 (gnus-mark-article-hook nil) ;Inhibit marking as read. | |
11337 (re-search | |
11338 (if backward | |
11339 're-search-backward 're-search-forward)) | |
11340 (sum (current-buffer)) | |
11341 (found nil)) | |
11342 (gnus-save-hidden-threads | |
11343 (gnus-summary-select-article) | |
11344 (set-buffer gnus-article-buffer) | |
11345 (when backward | |
11346 (forward-line -1)) | |
11347 (while (not found) | |
11348 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current)) | |
11349 (if (if backward | |
11350 (re-search-backward regexp nil t) | |
11351 (re-search-forward regexp nil t)) | |
11352 ;; We found the regexp. | |
11353 (progn | |
11354 (setq found 'found) | |
11355 (beginning-of-line) | |
11356 (set-window-start | |
11357 (get-buffer-window (current-buffer)) | |
11358 (point)) | |
11359 (forward-line 1) | |
11360 (set-buffer sum)) | |
11361 ;; We didn't find it, so we go to the next article. | |
11362 (set-buffer sum) | |
11363 (if (not (if backward (gnus-summary-find-prev) | |
11364 (gnus-summary-find-next))) | |
11365 ;; No more articles. | |
11366 (setq found t) | |
11367 ;; Select the next article and adjust point. | |
11368 (gnus-summary-select-article) | |
11369 (set-buffer gnus-article-buffer) | |
11370 (widen) | |
11371 (goto-char (if backward (point-max) (point-min)))))) | |
11372 (gnus-message 7 "")) | |
11373 ;; Return whether we found the regexp. | |
11374 (when (eq found 'found) | |
11375 (gnus-summary-show-thread) | |
11376 (gnus-summary-goto-subject gnus-current-article) | |
11377 (gnus-summary-position-point) | |
11378 t))) | |
11379 | |
11380 (defun gnus-summary-find-matching (header regexp &optional backward unread | |
11381 not-case-fold) | |
11382 "Return a list of all articles that match REGEXP on HEADER. | |
11383 The search stars on the current article and goes forwards unless | |
11384 BACKWARD is non-nil. If BACKWARD is `all', do all articles. | |
11385 If UNREAD is non-nil, only unread articles will | |
11386 be taken into consideration. If NOT-CASE-FOLD, case won't be folded | |
11387 in the comparisons." | |
11388 (let ((data (if (eq backward 'all) gnus-newsgroup-data | |
11389 (gnus-data-find-list | |
11390 (gnus-summary-article-number) (gnus-data-list backward)))) | |
11391 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h))) | |
11392 (case-fold-search (not not-case-fold)) | |
11393 articles d) | |
11394 (or (fboundp (intern (concat "mail-header-" header))) | |
11395 (error "%s is not a valid header" header)) | |
11396 (while data | |
11397 (setq d (car data)) | |
11398 (and (or (not unread) ; We want all articles... | |
11399 (gnus-data-unread-p d)) ; Or just unreads. | |
11400 (vectorp (gnus-data-header d)) ; It's not a pseudo. | |
11401 (string-match regexp (funcall func (gnus-data-header d))) ; Match. | |
11402 (setq articles (cons (gnus-data-number d) articles))) ; Success! | |
11403 (setq data (cdr data))) | |
11404 (nreverse articles))) | |
11405 | |
11406 (defun gnus-summary-execute-command (header regexp command &optional backward) | |
11407 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND. | |
11408 If HEADER is an empty string (or nil), the match is done on the entire | |
11409 article. If BACKWARD (the prefix) is non-nil, search backward instead." | |
11410 (interactive | |
11411 (list (let ((completion-ignore-case t)) | |
11412 (completing-read | |
11413 "Header name: " | |
11414 (mapcar (lambda (string) (list string)) | |
11415 '("Number" "Subject" "From" "Lines" "Date" | |
11416 "Message-ID" "Xref" "References" "Body")) | |
11417 nil 'require-match)) | |
11418 (read-string "Regexp: ") | |
11419 (read-key-sequence "Command: ") | |
11420 current-prefix-arg)) | |
11421 (when (equal header "Body") | |
11422 (setq header "")) | |
11423 (gnus-set-global-variables) | |
11424 ;; Hidden thread subtrees must be searched as well. | |
11425 (gnus-summary-show-all-threads) | |
11426 ;; We don't want to change current point nor window configuration. | |
11427 (save-excursion | |
11428 (save-window-excursion | |
11429 (gnus-message 6 "Executing %s..." (key-description command)) | |
11430 ;; We'd like to execute COMMAND interactively so as to give arguments. | |
11431 (gnus-execute header regexp | |
11432 `(lambda () (call-interactively ',(key-binding command))) | |
11433 backward) | |
11434 (gnus-message 6 "Executing %s...done" (key-description command))))) | |
11435 | |
11436 (defun gnus-summary-beginning-of-article () | |
11437 "Scroll the article back to the beginning." | |
11438 (interactive) | |
11439 (gnus-set-global-variables) | |
11440 (gnus-summary-select-article) | |
11441 (gnus-configure-windows 'article) | |
11442 (gnus-eval-in-buffer-window gnus-article-buffer | |
11443 (widen) | |
11444 (goto-char (point-min)) | |
11445 (and gnus-break-pages (gnus-narrow-to-page)))) | |
11446 | |
11447 (defun gnus-summary-end-of-article () | |
11448 "Scroll to the end of the article." | |
11449 (interactive) | |
11450 (gnus-set-global-variables) | |
11451 (gnus-summary-select-article) | |
11452 (gnus-configure-windows 'article) | |
11453 (gnus-eval-in-buffer-window gnus-article-buffer | |
11454 (widen) | |
11455 (goto-char (point-max)) | |
11456 (recenter -3) | |
11457 (and gnus-break-pages (gnus-narrow-to-page)))) | |
11458 | |
11459 (defun gnus-summary-show-article (&optional arg) | |
11460 "Force re-fetching of the current article. | |
11461 If ARG (the prefix) is non-nil, show the raw article without any | |
11462 article massaging functions being run." | |
11463 (interactive "P") | |
11464 (gnus-set-global-variables) | |
11465 (if (not arg) | |
11466 ;; Select the article the normal way. | |
11467 (gnus-summary-select-article nil 'force) | |
11468 ;; Bind the article treatment functions to nil. | |
11469 (let ((gnus-have-all-headers t) | |
11470 gnus-article-display-hook | |
11471 gnus-article-prepare-hook | |
11472 gnus-break-pages | |
11473 gnus-visual) | |
11474 (gnus-summary-select-article nil 'force))) | |
11475 (gnus-summary-goto-subject gnus-current-article) | |
11476 ; (gnus-configure-windows 'article) | |
11477 (gnus-summary-position-point)) | |
11478 | |
11479 (defun gnus-summary-verbose-headers (&optional arg) | |
11480 "Toggle permanent full header display. | |
11481 If ARG is a positive number, turn header display on. | |
11482 If ARG is a negative number, turn header display off." | |
11483 (interactive "P") | |
11484 (gnus-set-global-variables) | |
11485 (gnus-summary-toggle-header arg) | |
11486 (setq gnus-show-all-headers | |
11487 (cond ((or (not (numberp arg)) | |
11488 (zerop arg)) | |
11489 (not gnus-show-all-headers)) | |
11490 ((natnump arg) | |
11491 t)))) | |
11492 | |
11493 (defun gnus-summary-toggle-header (&optional arg) | |
11494 "Show the headers if they are hidden, or hide them if they are shown. | |
11495 If ARG is a positive number, show the entire header. | |
11496 If ARG is a negative number, hide the unwanted header lines." | |
11497 (interactive "P") | |
11498 (gnus-set-global-variables) | |
11499 (save-excursion | |
11500 (set-buffer gnus-article-buffer) | |
11501 (let* ((buffer-read-only nil) | |
11502 (inhibit-point-motion-hooks t) | |
11503 (hidden (text-property-any | |
11504 (goto-char (point-min)) (search-forward "\n\n") | |
11505 'invisible t)) | |
11506 e) | |
11507 (goto-char (point-min)) | |
11508 (when (search-forward "\n\n" nil t) | |
11509 (delete-region (point-min) (1- (point)))) | |
11510 (goto-char (point-min)) | |
11511 (save-excursion | |
11512 (set-buffer gnus-original-article-buffer) | |
11513 (goto-char (point-min)) | |
11514 (setq e (1- (or (search-forward "\n\n" nil t) (point-max))))) | |
11515 (insert-buffer-substring gnus-original-article-buffer 1 e) | |
11516 (let ((gnus-inhibit-hiding t)) | |
11517 (run-hooks 'gnus-article-display-hook)) | |
11518 (if (or (not hidden) (and (numberp arg) (< arg 0))) | |
11519 (gnus-article-hide-headers))))) | |
11520 | |
11521 (defun gnus-summary-show-all-headers () | |
11522 "Make all header lines visible." | |
11523 (interactive) | |
11524 (gnus-set-global-variables) | |
11525 (gnus-article-show-all-headers)) | |
11526 | |
11527 (defun gnus-summary-toggle-mime (&optional arg) | |
11528 "Toggle MIME processing. | |
11529 If ARG is a positive number, turn MIME processing on." | |
11530 (interactive "P") | |
11531 (gnus-set-global-variables) | |
11532 (setq gnus-show-mime | |
11533 (if (null arg) (not gnus-show-mime) | |
11534 (> (prefix-numeric-value arg) 0))) | |
11535 (gnus-summary-select-article t 'force)) | |
11536 | |
11537 (defun gnus-summary-caesar-message (&optional arg) | |
11538 "Caesar rotate the current article by 13. | |
11539 The numerical prefix specifies how manu places to rotate each letter | |
11540 forward." | |
11541 (interactive "P") | |
11542 (gnus-set-global-variables) | |
11543 (gnus-summary-select-article) | |
11544 (let ((mail-header-separator "")) | |
11545 (gnus-eval-in-buffer-window gnus-article-buffer | |
11546 (save-restriction | |
11547 (widen) | |
11548 (let ((start (window-start)) | |
11549 buffer-read-only) | |
11550 (message-caesar-buffer-body arg) | |
11551 (set-window-start (get-buffer-window (current-buffer)) start)))))) | |
11552 | |
11553 (defun gnus-summary-stop-page-breaking () | |
11554 "Stop page breaking in the current article." | |
11555 (interactive) | |
11556 (gnus-set-global-variables) | |
11557 (gnus-summary-select-article) | |
11558 (gnus-eval-in-buffer-window gnus-article-buffer | |
11559 (widen))) | |
11560 | |
11561 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action) | |
11562 "Move the current article to a different newsgroup. | |
11563 If N is a positive number, move the N next articles. | |
11564 If N is a negative number, move the N previous articles. | |
11565 If N is nil and any articles have been marked with the process mark, | |
11566 move those articles instead. | |
11567 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to. | |
11568 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but | |
11569 re-spool using this method. | |
11570 | |
11571 For this function to work, both the current newsgroup and the | |
11572 newsgroup that you want to move to have to support the `request-move' | |
11573 and `request-accept' functions." | |
11574 (interactive "P") | |
11575 (unless action (setq action 'move)) | |
11576 (gnus-set-global-variables) | |
11577 ;; Check whether the source group supports the required functions. | |
11578 (cond ((and (eq action 'move) | |
11579 (not (gnus-check-backend-function | |
11580 'request-move-article gnus-newsgroup-name))) | |
11581 (error "The current group does not support article moving")) | |
11582 ((and (eq action 'crosspost) | |
11583 (not (gnus-check-backend-function | |
11584 'request-replace-article gnus-newsgroup-name))) | |
11585 (error "The current group does not support article editing"))) | |
11586 (let ((articles (gnus-summary-work-articles n)) | |
11587 (prefix (gnus-group-real-prefix gnus-newsgroup-name)) | |
11588 (names '((move "Move" "Moving") | |
11589 (copy "Copy" "Copying") | |
11590 (crosspost "Crosspost" "Crossposting"))) | |
11591 (copy-buf (save-excursion | |
11592 (nnheader-set-temp-buffer " *copy article*"))) | |
11593 art-group to-method new-xref article to-groups) | |
11594 (unless (assq action names) | |
11595 (error "Unknown action %s" action)) | |
11596 ;; Read the newsgroup name. | |
11597 (when (and (not to-newsgroup) | |
11598 (not select-method)) | |
11599 (setq to-newsgroup | |
11600 (gnus-read-move-group-name | |
11601 (cadr (assq action names)) | |
11602 (symbol-value (intern (format "gnus-current-%s-group" action))) | |
11603 articles prefix)) | |
11604 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup)) | |
11605 (setq to-method (or select-method | |
11606 (gnus-group-name-to-method to-newsgroup))) | |
11607 ;; Check the method we are to move this article to... | |
11608 (or (gnus-check-backend-function 'request-accept-article (car to-method)) | |
11609 (error "%s does not support article copying" (car to-method))) | |
11610 (or (gnus-check-server to-method) | |
11611 (error "Can't open server %s" (car to-method))) | |
11612 (gnus-message 6 "%s to %s: %s..." | |
11613 (caddr (assq action names)) | |
11614 (or (car select-method) to-newsgroup) articles) | |
11615 (while articles | |
11616 (setq article (pop articles)) | |
11617 (setq | |
11618 art-group | |
11619 (cond | |
11620 ;; Move the article. | |
11621 ((eq action 'move) | |
11622 (gnus-request-move-article | |
11623 article ; Article to move | |
11624 gnus-newsgroup-name ; From newsgrouo | |
11625 (nth 1 (gnus-find-method-for-group | |
11626 gnus-newsgroup-name)) ; Server | |
11627 (list 'gnus-request-accept-article | |
11628 to-newsgroup (list 'quote select-method) | |
11629 (not articles)) ; Accept form | |
11630 (not articles))) ; Only save nov last time | |
11631 ;; Copy the article. | |
11632 ((eq action 'copy) | |
11633 (save-excursion | |
11634 (set-buffer copy-buf) | |
11635 (gnus-request-article-this-buffer article gnus-newsgroup-name) | |
11636 (gnus-request-accept-article | |
11637 to-newsgroup select-method (not articles)))) | |
11638 ;; Crosspost the article. | |
11639 ((eq action 'crosspost) | |
11640 (let ((xref (mail-header-xref (gnus-summary-article-header article)))) | |
11641 (setq new-xref (concat gnus-newsgroup-name ":" article)) | |
11642 (if (and xref (not (string= xref ""))) | |
11643 (progn | |
11644 (when (string-match "^Xref: " xref) | |
11645 (setq xref (substring xref (match-end 0)))) | |
11646 (setq new-xref (concat xref " " new-xref))) | |
11647 (setq new-xref (concat (system-name) " " new-xref))) | |
11648 (save-excursion | |
11649 (set-buffer copy-buf) | |
11650 (gnus-request-article-this-buffer article gnus-newsgroup-name) | |
11651 (nnheader-replace-header "xref" new-xref) | |
11652 (gnus-request-accept-article | |
11653 to-newsgroup select-method (not articles))))))) | |
11654 (if (not art-group) | |
11655 (gnus-message 1 "Couldn't %s article %s" | |
11656 (cadr (assq action names)) article) | |
11657 (let* ((entry | |
11658 (or | |
11659 (gnus-gethash (car art-group) gnus-newsrc-hashtb) | |
11660 (gnus-gethash | |
11661 (gnus-group-prefixed-name | |
11662 (car art-group) | |
11663 (or select-method | |
11664 (gnus-find-method-for-group to-newsgroup))) | |
11665 gnus-newsrc-hashtb))) | |
11666 (info (nth 2 entry)) | |
11667 (to-group (gnus-info-group info))) | |
11668 ;; Update the group that has been moved to. | |
11669 (when (and info | |
11670 (memq action '(move copy))) | |
11671 (unless (member to-group to-groups) | |
11672 (push to-group to-groups)) | |
11673 | |
11674 (unless (memq article gnus-newsgroup-unreads) | |
11675 (gnus-info-set-read | |
11676 info (gnus-add-to-range (gnus-info-read info) | |
11677 (list (cdr art-group))))) | |
11678 | |
11679 ;; Copy any marks over to the new group. | |
11680 (let ((marks gnus-article-mark-lists) | |
11681 (to-article (cdr art-group))) | |
11682 | |
11683 ;; See whether the article is to be put in the cache. | |
11684 (when gnus-use-cache | |
11685 (gnus-cache-possibly-enter-article | |
11686 to-group to-article | |
11687 (let ((header (copy-sequence | |
11688 (gnus-summary-article-header article)))) | |
11689 (mail-header-set-number header to-article) | |
11690 header) | |
11691 (memq article gnus-newsgroup-marked) | |
11692 (memq article gnus-newsgroup-dormant) | |
11693 (memq article gnus-newsgroup-unreads))) | |
11694 | |
11695 (while marks | |
11696 (when (memq article (symbol-value | |
11697 (intern (format "gnus-newsgroup-%s" | |
11698 (caar marks))))) | |
11699 ;; If the other group is the same as this group, | |
11700 ;; then we have to add the mark to the list. | |
11701 (when (equal to-group gnus-newsgroup-name) | |
11702 (set (intern (format "gnus-newsgroup-%s" (caar marks))) | |
11703 (cons to-article | |
11704 (symbol-value | |
11705 (intern (format "gnus-newsgroup-%s" | |
11706 (caar marks))))))) | |
11707 ;; Copy mark to other group. | |
11708 (gnus-add-marked-articles | |
11709 to-group (cdar marks) (list to-article) info)) | |
11710 (setq marks (cdr marks))))) | |
11711 | |
11712 ;; Update the Xref header in this article to point to | |
11713 ;; the new crossposted article we have just created. | |
11714 (when (eq action 'crosspost) | |
11715 (save-excursion | |
11716 (set-buffer copy-buf) | |
11717 (gnus-request-article-this-buffer article gnus-newsgroup-name) | |
11718 (nnheader-replace-header | |
11719 "xref" (concat new-xref " " (gnus-group-prefixed-name | |
11720 (car art-group) to-method) | |
11721 ":" (cdr art-group))) | |
11722 (gnus-request-replace-article | |
11723 article gnus-newsgroup-name (current-buffer))))) | |
11724 | |
11725 (gnus-summary-goto-subject article) | |
11726 (when (eq action 'move) | |
11727 (gnus-summary-mark-article article gnus-canceled-mark))) | |
11728 (gnus-summary-remove-process-mark article)) | |
11729 ;; Re-activate all groups that have been moved to. | |
11730 (while to-groups | |
11731 (gnus-activate-group (pop to-groups))) | |
11732 | |
11733 (gnus-kill-buffer copy-buf) | |
11734 (gnus-summary-position-point) | |
11735 (gnus-set-mode-line 'summary))) | |
11736 | |
11737 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method) | |
11738 "Move the current article to a different newsgroup. | |
11739 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to. | |
11740 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but | |
11741 re-spool using this method." | |
11742 (interactive "P") | |
11743 (gnus-summary-move-article n nil select-method 'copy)) | |
11744 | |
11745 (defun gnus-summary-crosspost-article (&optional n) | |
11746 "Crosspost the current article to some other group." | |
11747 (interactive "P") | |
11748 (gnus-summary-move-article n nil nil 'crosspost)) | |
11749 | |
11750 (defvar gnus-summary-respool-default-method nil | |
11751 "Default method for respooling an article. | |
11752 If nil, use to the current newsgroup method.") | |
11753 | |
11754 (defun gnus-summary-respool-article (&optional n method) | |
11755 "Respool the current article. | |
11756 The article will be squeezed through the mail spooling process again, | |
11757 which means that it will be put in some mail newsgroup or other | |
11758 depending on `nnmail-split-methods'. | |
11759 If N is a positive number, respool the N next articles. | |
11760 If N is a negative number, respool the N previous articles. | |
11761 If N is nil and any articles have been marked with the process mark, | |
11762 respool those articles instead. | |
11763 | |
11764 Respooling can be done both from mail groups and \"real\" newsgroups. | |
11765 In the former case, the articles in question will be moved from the | |
11766 current group into whatever groups they are destined to. In the | |
11767 latter case, they will be copied into the relevant groups." | |
11768 (interactive | |
11769 (list current-prefix-arg | |
11770 (let* ((methods (gnus-methods-using 'respool)) | |
11771 (methname | |
11772 (symbol-name (or gnus-summary-respool-default-method | |
11773 (car (gnus-find-method-for-group | |
11774 gnus-newsgroup-name))))) | |
11775 (method | |
11776 (gnus-completing-read | |
11777 methname "What backend do you want to use when respooling?" | |
11778 methods nil t nil 'gnus-method-history)) | |
11779 ms) | |
11780 (cond | |
11781 ((zerop (length (setq ms (gnus-servers-using-backend method)))) | |
11782 (list (intern method) "")) | |
11783 ((= 1 (length ms)) | |
11784 (car ms)) | |
11785 (t | |
11786 (cdr (completing-read | |
11787 "Server name: " | |
11788 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t))))))) | |
11789 (gnus-set-global-variables) | |
11790 (unless method | |
11791 (error "No method given for respooling")) | |
11792 (if (assoc (symbol-name | |
11793 (car (gnus-find-method-for-group gnus-newsgroup-name))) | |
11794 (gnus-methods-using 'respool)) | |
11795 (gnus-summary-move-article n nil method) | |
11796 (gnus-summary-copy-article n nil method))) | |
11797 | |
11798 (defun gnus-summary-import-article (file) | |
11799 "Import a random file into a mail newsgroup." | |
11800 (interactive "fImport file: ") | |
11801 (gnus-set-global-variables) | |
11802 (let ((group gnus-newsgroup-name) | |
11803 (now (current-time)) | |
11804 atts lines) | |
11805 (or (gnus-check-backend-function 'request-accept-article group) | |
11806 (error "%s does not support article importing" group)) | |
11807 (or (file-readable-p file) | |
11808 (not (file-regular-p file)) | |
11809 (error "Can't read %s" file)) | |
11810 (save-excursion | |
11811 (set-buffer (get-buffer-create " *import file*")) | |
11812 (buffer-disable-undo (current-buffer)) | |
11813 (erase-buffer) | |
11814 (insert-file-contents file) | |
11815 (goto-char (point-min)) | |
11816 (unless (nnheader-article-p) | |
11817 ;; This doesn't look like an article, so we fudge some headers. | |
11818 (setq atts (file-attributes file) | |
11819 lines (count-lines (point-min) (point-max))) | |
11820 (insert "From: " (read-string "From: ") "\n" | |
11821 "Subject: " (read-string "Subject: ") "\n" | |
11822 "Date: " (timezone-make-date-arpa-standard | |
11823 (current-time-string (nth 5 atts)) | |
11824 (current-time-zone now) | |
11825 (current-time-zone now)) "\n" | |
11826 "Message-ID: " (message-make-message-id) "\n" | |
11827 "Lines: " (int-to-string lines) "\n" | |
11828 "Chars: " (int-to-string (nth 7 atts)) "\n\n")) | |
11829 (gnus-request-accept-article group nil t) | |
11830 (kill-buffer (current-buffer))))) | |
11831 | |
11832 (defun gnus-summary-expire-articles (&optional now) | |
11833 "Expire all articles that are marked as expirable in the current group." | |
11834 (interactive) | |
11835 (gnus-set-global-variables) | |
11836 (when (gnus-check-backend-function | |
11837 'request-expire-articles gnus-newsgroup-name) | |
11838 ;; This backend supports expiry. | |
11839 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name)) | |
11840 (expirable (if total | |
11841 (gnus-list-of-read-articles gnus-newsgroup-name) | |
11842 (setq gnus-newsgroup-expirable | |
11843 (sort gnus-newsgroup-expirable '<)))) | |
11844 (expiry-wait (if now 'immediate | |
11845 (gnus-group-get-parameter | |
11846 gnus-newsgroup-name 'expiry-wait))) | |
11847 es) | |
11848 (when expirable | |
11849 ;; There are expirable articles in this group, so we run them | |
11850 ;; through the expiry process. | |
11851 (gnus-message 6 "Expiring articles...") | |
11852 ;; The list of articles that weren't expired is returned. | |
11853 (if expiry-wait | |
11854 (let ((nnmail-expiry-wait-function nil) | |
11855 (nnmail-expiry-wait expiry-wait)) | |
11856 (setq es (gnus-request-expire-articles | |
11857 expirable gnus-newsgroup-name))) | |
11858 (setq es (gnus-request-expire-articles | |
11859 expirable gnus-newsgroup-name))) | |
11860 (or total (setq gnus-newsgroup-expirable es)) | |
11861 ;; We go through the old list of expirable, and mark all | |
11862 ;; really expired articles as nonexistent. | |
11863 (unless (eq es expirable) ;If nothing was expired, we don't mark. | |
11864 (let ((gnus-use-cache nil)) | |
11865 (while expirable | |
11866 (unless (memq (car expirable) es) | |
11867 (when (gnus-data-find (car expirable)) | |
11868 (gnus-summary-mark-article | |
11869 (car expirable) gnus-canceled-mark))) | |
11870 (setq expirable (cdr expirable))))) | |
11871 (gnus-message 6 "Expiring articles...done"))))) | |
11872 | |
11873 (defun gnus-summary-expire-articles-now () | |
11874 "Expunge all expirable articles in the current group. | |
11875 This means that *all* articles that are marked as expirable will be | |
11876 deleted forever, right now." | |
11877 (interactive) | |
11878 (gnus-set-global-variables) | |
11879 (or gnus-expert-user | |
11880 (gnus-y-or-n-p | |
11881 "Are you really, really, really sure you want to delete all these messages? ") | |
11882 (error "Phew!")) | |
11883 (gnus-summary-expire-articles t)) | |
11884 | |
11885 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. | |
11886 (defun gnus-summary-delete-article (&optional n) | |
11887 "Delete the N next (mail) articles. | |
11888 This command actually deletes articles. This is not a marking | |
11889 command. The article will disappear forever from your life, never to | |
11890 return. | |
11891 If N is negative, delete backwards. | |
11892 If N is nil and articles have been marked with the process mark, | |
11893 delete these instead." | |
11894 (interactive "P") | |
11895 (gnus-set-global-variables) | |
11896 (or (gnus-check-backend-function 'request-expire-articles | |
11897 gnus-newsgroup-name) | |
11898 (error "The current newsgroup does not support article deletion.")) | |
11899 ;; Compute the list of articles to delete. | |
11900 (let ((articles (gnus-summary-work-articles n)) | |
11901 not-deleted) | |
11902 (if (and gnus-novice-user | |
11903 (not (gnus-y-or-n-p | |
11904 (format "Do you really want to delete %s forever? " | |
11905 (if (> (length articles) 1) | |
11906 (format "these %s articles" (length articles)) | |
11907 "this article"))))) | |
11908 () | |
11909 ;; Delete the articles. | |
11910 (setq not-deleted (gnus-request-expire-articles | |
11911 articles gnus-newsgroup-name 'force)) | |
11912 (while articles | |
11913 (gnus-summary-remove-process-mark (car articles)) | |
11914 ;; The backend might not have been able to delete the article | |
11915 ;; after all. | |
11916 (or (memq (car articles) not-deleted) | |
11917 (gnus-summary-mark-article (car articles) gnus-canceled-mark)) | |
11918 (setq articles (cdr articles)))) | |
11919 (gnus-summary-position-point) | |
11920 (gnus-set-mode-line 'summary) | |
11921 not-deleted)) | |
11922 | |
11923 (defun gnus-summary-edit-article (&optional force) | |
11924 "Enter into a buffer and edit the current article. | |
11925 This will have permanent effect only in mail groups. | |
11926 If FORCE is non-nil, allow editing of articles even in read-only | |
11927 groups." | |
11928 (interactive "P") | |
11929 (save-excursion | |
11930 (set-buffer gnus-summary-buffer) | |
11931 (gnus-set-global-variables) | |
11932 (when (and (not force) | |
11933 (gnus-group-read-only-p)) | |
11934 (error "The current newsgroup does not support article editing.")) | |
11935 (gnus-summary-select-article t nil t) | |
11936 (gnus-configure-windows 'article) | |
11937 (select-window (get-buffer-window gnus-article-buffer)) | |
11938 (gnus-message 6 "C-c C-c to end edits") | |
11939 (setq buffer-read-only nil) | |
11940 (text-mode) | |
11941 (use-local-map (copy-keymap (current-local-map))) | |
11942 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done) | |
11943 (buffer-enable-undo) | |
11944 (widen) | |
11945 (goto-char (point-min)) | |
11946 (search-forward "\n\n" nil t))) | |
11947 | |
11948 (defun gnus-summary-edit-article-done () | |
11949 "Make edits to the current article permanent." | |
11950 (interactive) | |
11951 (if (gnus-group-read-only-p) | |
11952 (progn | |
11953 (let ((beep (not (eq major-mode 'text-mode)))) | |
11954 (gnus-summary-edit-article-postpone) | |
11955 (when beep | |
11956 (gnus-error | |
11957 3 "The current newsgroup does not support article editing.")))) | |
11958 (let ((buf (format "%s" (buffer-string)))) | |
11959 (erase-buffer) | |
11960 (insert buf) | |
11961 (if (not (gnus-request-replace-article | |
11962 (cdr gnus-article-current) (car gnus-article-current) | |
11963 (current-buffer))) | |
11964 (error "Couldn't replace article.") | |
11965 (gnus-article-mode) | |
11966 (use-local-map gnus-article-mode-map) | |
11967 (setq buffer-read-only t) | |
11968 (buffer-disable-undo (current-buffer)) | |
11969 (gnus-configure-windows 'summary) | |
11970 (gnus-summary-update-article (cdr gnus-article-current)) | |
11971 (when gnus-use-cache | |
11972 (gnus-cache-update-article | |
11973 (car gnus-article-current) (cdr gnus-article-current))) | |
11974 (when gnus-keep-backlog | |
11975 (gnus-backlog-remove-article | |
11976 (car gnus-article-current) (cdr gnus-article-current)))) | |
11977 (save-excursion | |
11978 (when (get-buffer gnus-original-article-buffer) | |
11979 (set-buffer gnus-original-article-buffer) | |
11980 (setq gnus-original-article nil))) | |
11981 (setq gnus-article-current nil | |
11982 gnus-current-article nil) | |
11983 (run-hooks 'gnus-article-display-hook) | |
11984 (and (gnus-visual-p 'summary-highlight 'highlight) | |
11985 (run-hooks 'gnus-visual-mark-article-hook))))) | |
11986 | |
11987 (defun gnus-summary-edit-article-postpone () | |
11988 "Postpone changes to the current article." | |
11989 (interactive) | |
11990 (gnus-article-mode) | |
11991 (use-local-map gnus-article-mode-map) | |
11992 (setq buffer-read-only t) | |
11993 (buffer-disable-undo (current-buffer)) | |
11994 (gnus-configure-windows 'summary) | |
11995 (and (gnus-visual-p 'summary-highlight 'highlight) | |
11996 (run-hooks 'gnus-visual-mark-article-hook))) | |
11997 | |
11998 (defun gnus-summary-respool-query () | |
11999 "Query where the respool algorithm would put this article." | |
12000 (interactive) | |
12001 (gnus-set-global-variables) | |
12002 (gnus-summary-select-article) | |
12003 (save-excursion | |
12004 (set-buffer gnus-article-buffer) | |
12005 (save-restriction | |
12006 (goto-char (point-min)) | |
12007 (search-forward "\n\n") | |
12008 (narrow-to-region (point-min) (point)) | |
12009 (pp-eval-expression | |
12010 (list 'quote (mapcar 'car (nnmail-article-group 'identity))))))) | |
12011 | |
12012 ;; Summary marking commands. | |
12013 | |
12014 (defun gnus-summary-kill-same-subject-and-select (&optional unmark) | |
12015 "Mark articles which has the same subject as read, and then select the next. | |
12016 If UNMARK is positive, remove any kind of mark. | |
12017 If UNMARK is negative, tick articles." | |
12018 (interactive "P") | |
12019 (gnus-set-global-variables) | |
12020 (if unmark | |
12021 (setq unmark (prefix-numeric-value unmark))) | |
12022 (let ((count | |
12023 (gnus-summary-mark-same-subject | |
12024 (gnus-summary-article-subject) unmark))) | |
12025 ;; Select next unread article. If auto-select-same mode, should | |
12026 ;; select the first unread article. | |
12027 (gnus-summary-next-article t (and gnus-auto-select-same | |
12028 (gnus-summary-article-subject))) | |
12029 (gnus-message 7 "%d article%s marked as %s" | |
12030 count (if (= count 1) " is" "s are") | |
12031 (if unmark "unread" "read")))) | |
12032 | |
12033 (defun gnus-summary-kill-same-subject (&optional unmark) | |
12034 "Mark articles which has the same subject as read. | |
12035 If UNMARK is positive, remove any kind of mark. | |
12036 If UNMARK is negative, tick articles." | |
12037 (interactive "P") | |
12038 (gnus-set-global-variables) | |
12039 (if unmark | |
12040 (setq unmark (prefix-numeric-value unmark))) | |
12041 (let ((count | |
12042 (gnus-summary-mark-same-subject | |
12043 (gnus-summary-article-subject) unmark))) | |
12044 ;; If marked as read, go to next unread subject. | |
12045 (if (null unmark) | |
12046 ;; Go to next unread subject. | |
12047 (gnus-summary-next-subject 1 t)) | |
12048 (gnus-message 7 "%d articles are marked as %s" | |
12049 count (if unmark "unread" "read")))) | |
12050 | |
12051 (defun gnus-summary-mark-same-subject (subject &optional unmark) | |
12052 "Mark articles with same SUBJECT as read, and return marked number. | |
12053 If optional argument UNMARK is positive, remove any kinds of marks. | |
12054 If optional argument UNMARK is negative, mark articles as unread instead." | |
12055 (let ((count 1)) | |
12056 (save-excursion | |
12057 (cond | |
12058 ((null unmark) ; Mark as read. | |
12059 (while (and | |
12060 (progn | |
12061 (gnus-summary-mark-article-as-read gnus-killed-mark) | |
12062 (gnus-summary-show-thread) t) | |
12063 (gnus-summary-find-subject subject)) | |
12064 (setq count (1+ count)))) | |
12065 ((> unmark 0) ; Tick. | |
12066 (while (and | |
12067 (progn | |
12068 (gnus-summary-mark-article-as-unread gnus-ticked-mark) | |
12069 (gnus-summary-show-thread) t) | |
12070 (gnus-summary-find-subject subject)) | |
12071 (setq count (1+ count)))) | |
12072 (t ; Mark as unread. | |
12073 (while (and | |
12074 (progn | |
12075 (gnus-summary-mark-article-as-unread gnus-unread-mark) | |
12076 (gnus-summary-show-thread) t) | |
12077 (gnus-summary-find-subject subject)) | |
12078 (setq count (1+ count))))) | |
12079 (gnus-set-mode-line 'summary) | |
12080 ;; Return the number of marked articles. | |
12081 count))) | |
12082 | |
12083 (defun gnus-summary-mark-as-processable (n &optional unmark) | |
12084 "Set the process mark on the next N articles. | |
12085 If N is negative, mark backward instead. If UNMARK is non-nil, remove | |
12086 the process mark instead. The difference between N and the actual | |
12087 number of articles marked is returned." | |
12088 (interactive "p") | |
12089 (gnus-set-global-variables) | |
12090 (let ((backward (< n 0)) | |
12091 (n (abs n))) | |
12092 (while (and | |
12093 (> n 0) | |
12094 (if unmark | |
12095 (gnus-summary-remove-process-mark | |
12096 (gnus-summary-article-number)) | |
12097 (gnus-summary-set-process-mark (gnus-summary-article-number))) | |
12098 (zerop (gnus-summary-next-subject (if backward -1 1) nil t))) | |
12099 (setq n (1- n))) | |
12100 (if (/= 0 n) (gnus-message 7 "No more articles")) | |
12101 (gnus-summary-recenter) | |
12102 (gnus-summary-position-point) | |
12103 n)) | |
12104 | |
12105 (defun gnus-summary-unmark-as-processable (n) | |
12106 "Remove the process mark from the next N articles. | |
12107 If N is negative, mark backward instead. The difference between N and | |
12108 the actual number of articles marked is returned." | |
12109 (interactive "p") | |
12110 (gnus-set-global-variables) | |
12111 (gnus-summary-mark-as-processable n t)) | |
12112 | |
12113 (defun gnus-summary-unmark-all-processable () | |
12114 "Remove the process mark from all articles." | |
12115 (interactive) | |
12116 (gnus-set-global-variables) | |
12117 (save-excursion | |
12118 (while gnus-newsgroup-processable | |
12119 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable)))) | |
12120 (gnus-summary-position-point)) | |
12121 | |
12122 (defun gnus-summary-mark-as-expirable (n) | |
12123 "Mark N articles forward as expirable. | |
12124 If N is negative, mark backward instead. The difference between N and | |
12125 the actual number of articles marked is returned." | |
12126 (interactive "p") | |
12127 (gnus-set-global-variables) | |
12128 (gnus-summary-mark-forward n gnus-expirable-mark)) | |
12129 | |
12130 (defun gnus-summary-mark-article-as-replied (article) | |
12131 "Mark ARTICLE replied and update the summary line." | |
12132 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied)) | |
12133 (let ((buffer-read-only nil)) | |
12134 (when (gnus-summary-goto-subject article) | |
12135 (gnus-summary-update-secondary-mark article)))) | |
12136 | |
12137 (defun gnus-summary-set-bookmark (article) | |
12138 "Set a bookmark in current article." | |
12139 (interactive (list (gnus-summary-article-number))) | |
12140 (gnus-set-global-variables) | |
12141 (if (or (not (get-buffer gnus-article-buffer)) | |
12142 (not gnus-current-article) | |
12143 (not gnus-article-current) | |
12144 (not (equal gnus-newsgroup-name (car gnus-article-current)))) | |
12145 (error "No current article selected")) | |
12146 ;; Remove old bookmark, if one exists. | |
12147 (let ((old (assq article gnus-newsgroup-bookmarks))) | |
12148 (if old (setq gnus-newsgroup-bookmarks | |
12149 (delq old gnus-newsgroup-bookmarks)))) | |
12150 ;; Set the new bookmark, which is on the form | |
12151 ;; (article-number . line-number-in-body). | |
12152 (setq gnus-newsgroup-bookmarks | |
12153 (cons | |
12154 (cons article | |
12155 (save-excursion | |
12156 (set-buffer gnus-article-buffer) | |
12157 (count-lines | |
12158 (min (point) | |
12159 (save-excursion | |
12160 (goto-char (point-min)) | |
12161 (search-forward "\n\n" nil t) | |
12162 (point))) | |
12163 (point)))) | |
12164 gnus-newsgroup-bookmarks)) | |
12165 (gnus-message 6 "A bookmark has been added to the current article.")) | |
12166 | |
12167 (defun gnus-summary-remove-bookmark (article) | |
12168 "Remove the bookmark from the current article." | |
12169 (interactive (list (gnus-summary-article-number))) | |
12170 (gnus-set-global-variables) | |
12171 ;; Remove old bookmark, if one exists. | |
12172 (let ((old (assq article gnus-newsgroup-bookmarks))) | |
12173 (if old | |
12174 (progn | |
12175 (setq gnus-newsgroup-bookmarks | |
12176 (delq old gnus-newsgroup-bookmarks)) | |
12177 (gnus-message 6 "Removed bookmark.")) | |
12178 (gnus-message 6 "No bookmark in current article.")))) | |
12179 | |
12180 ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
12181 (defun gnus-summary-mark-as-dormant (n) | |
12182 "Mark N articles forward as dormant. | |
12183 If N is negative, mark backward instead. The difference between N and | |
12184 the actual number of articles marked is returned." | |
12185 (interactive "p") | |
12186 (gnus-set-global-variables) | |
12187 (gnus-summary-mark-forward n gnus-dormant-mark)) | |
12188 | |
12189 (defun gnus-summary-set-process-mark (article) | |
12190 "Set the process mark on ARTICLE and update the summary line." | |
12191 (setq gnus-newsgroup-processable | |
12192 (cons article | |
12193 (delq article gnus-newsgroup-processable))) | |
12194 (when (gnus-summary-goto-subject article) | |
12195 (gnus-summary-show-thread) | |
12196 (gnus-summary-update-secondary-mark article))) | |
12197 | |
12198 (defun gnus-summary-remove-process-mark (article) | |
12199 "Remove the process mark from ARTICLE and update the summary line." | |
12200 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable)) | |
12201 (when (gnus-summary-goto-subject article) | |
12202 (gnus-summary-show-thread) | |
12203 (gnus-summary-update-secondary-mark article))) | |
12204 | |
12205 (defun gnus-summary-set-saved-mark (article) | |
12206 "Set the process mark on ARTICLE and update the summary line." | |
12207 (push article gnus-newsgroup-saved) | |
12208 (when (gnus-summary-goto-subject article) | |
12209 (gnus-summary-update-secondary-mark article))) | |
12210 | |
12211 (defun gnus-summary-mark-forward (n &optional mark no-expire) | |
12212 "Mark N articles as read forwards. | |
12213 If N is negative, mark backwards instead. Mark with MARK, ?r by default. | |
12214 The difference between N and the actual number of articles marked is | |
12215 returned." | |
12216 (interactive "p") | |
12217 (gnus-set-global-variables) | |
12218 (let ((backward (< n 0)) | |
12219 (gnus-summary-goto-unread | |
12220 (and gnus-summary-goto-unread | |
12221 (not (eq gnus-summary-goto-unread 'never)) | |
12222 (not (memq mark (list gnus-unread-mark | |
12223 gnus-ticked-mark gnus-dormant-mark))))) | |
12224 (n (abs n)) | |
12225 (mark (or mark gnus-del-mark))) | |
12226 (while (and (> n 0) | |
12227 (gnus-summary-mark-article nil mark no-expire) | |
12228 (zerop (gnus-summary-next-subject | |
12229 (if backward -1 1) | |
12230 (and gnus-summary-goto-unread | |
12231 (not (eq gnus-summary-goto-unread 'never))) | |
12232 t))) | |
12233 (setq n (1- n))) | |
12234 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread "))) | |
12235 (gnus-summary-recenter) | |
12236 (gnus-summary-position-point) | |
12237 (gnus-set-mode-line 'summary) | |
12238 n)) | |
12239 | |
12240 (defun gnus-summary-mark-article-as-read (mark) | |
12241 "Mark the current article quickly as read with MARK." | |
12242 (let ((article (gnus-summary-article-number))) | |
12243 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
12244 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
12245 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
12246 (setq gnus-newsgroup-reads | |
12247 (cons (cons article mark) gnus-newsgroup-reads)) | |
12248 ;; Possibly remove from cache, if that is used. | |
12249 (and gnus-use-cache (gnus-cache-enter-remove-article article)) | |
12250 ;; Allow the backend to change the mark. | |
12251 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark)) | |
12252 ;; Check for auto-expiry. | |
12253 (when (and gnus-newsgroup-auto-expire | |
12254 (or (= mark gnus-killed-mark) (= mark gnus-del-mark) | |
12255 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark) | |
12256 (= mark gnus-ancient-mark) | |
12257 (= mark gnus-read-mark) (= mark gnus-souped-mark))) | |
12258 (setq mark gnus-expirable-mark) | |
12259 (push article gnus-newsgroup-expirable)) | |
12260 ;; Set the mark in the buffer. | |
12261 (gnus-summary-update-mark mark 'unread) | |
12262 t)) | |
12263 | |
12264 (defun gnus-summary-mark-article-as-unread (mark) | |
12265 "Mark the current article quickly as unread with MARK." | |
12266 (let ((article (gnus-summary-article-number))) | |
12267 (if (< article 0) | |
12268 (gnus-error 1 "Unmarkable article") | |
12269 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
12270 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
12271 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)) | |
12272 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads)) | |
12273 (cond ((= mark gnus-ticked-mark) | |
12274 (push article gnus-newsgroup-marked)) | |
12275 ((= mark gnus-dormant-mark) | |
12276 (push article gnus-newsgroup-dormant)) | |
12277 (t | |
12278 (push article gnus-newsgroup-unreads))) | |
12279 (setq gnus-newsgroup-reads | |
12280 (delq (assq article gnus-newsgroup-reads) | |
12281 gnus-newsgroup-reads)) | |
12282 | |
12283 ;; See whether the article is to be put in the cache. | |
12284 (and gnus-use-cache | |
12285 (vectorp (gnus-summary-article-header article)) | |
12286 (save-excursion | |
12287 (gnus-cache-possibly-enter-article | |
12288 gnus-newsgroup-name article | |
12289 (gnus-summary-article-header article) | |
12290 (= mark gnus-ticked-mark) | |
12291 (= mark gnus-dormant-mark) (= mark gnus-unread-mark)))) | |
12292 | |
12293 ;; Fix the mark. | |
12294 (gnus-summary-update-mark mark 'unread)) | |
12295 t)) | |
12296 | |
12297 (defun gnus-summary-mark-article (&optional article mark no-expire) | |
12298 "Mark ARTICLE with MARK. MARK can be any character. | |
12299 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), | |
12300 `??' (dormant) and `?E' (expirable). | |
12301 If MARK is nil, then the default character `?D' is used. | |
12302 If ARTICLE is nil, then the article on the current line will be | |
12303 marked." | |
12304 ;; The mark might be a string. | |
12305 (and (stringp mark) | |
12306 (setq mark (aref mark 0))) | |
12307 ;; If no mark is given, then we check auto-expiring. | |
12308 (and (not no-expire) | |
12309 gnus-newsgroup-auto-expire | |
12310 (or (not mark) | |
12311 (and (numberp mark) | |
12312 (or (= mark gnus-killed-mark) (= mark gnus-del-mark) | |
12313 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark) | |
12314 (= mark gnus-read-mark) (= mark gnus-souped-mark)))) | |
12315 (setq mark gnus-expirable-mark)) | |
12316 (let* ((mark (or mark gnus-del-mark)) | |
12317 (article (or article (gnus-summary-article-number)))) | |
12318 (or article (error "No article on current line")) | |
12319 (if (or (= mark gnus-unread-mark) | |
12320 (= mark gnus-ticked-mark) | |
12321 (= mark gnus-dormant-mark)) | |
12322 (gnus-mark-article-as-unread article mark) | |
12323 (gnus-mark-article-as-read article mark)) | |
12324 | |
12325 ;; See whether the article is to be put in the cache. | |
12326 (and gnus-use-cache | |
12327 (not (= mark gnus-canceled-mark)) | |
12328 (vectorp (gnus-summary-article-header article)) | |
12329 (save-excursion | |
12330 (gnus-cache-possibly-enter-article | |
12331 gnus-newsgroup-name article | |
12332 (gnus-summary-article-header article) | |
12333 (= mark gnus-ticked-mark) | |
12334 (= mark gnus-dormant-mark) (= mark gnus-unread-mark)))) | |
12335 | |
12336 (if (gnus-summary-goto-subject article nil t) | |
12337 (let ((buffer-read-only nil)) | |
12338 (gnus-summary-show-thread) | |
12339 ;; Fix the mark. | |
12340 (gnus-summary-update-mark mark 'unread) | |
12341 t)))) | |
12342 | |
12343 (defun gnus-summary-update-secondary-mark (article) | |
12344 "Update the secondary (read, process, cache) mark." | |
12345 (gnus-summary-update-mark | |
12346 (cond ((memq article gnus-newsgroup-processable) | |
12347 gnus-process-mark) | |
12348 ((memq article gnus-newsgroup-cached) | |
12349 gnus-cached-mark) | |
12350 ((memq article gnus-newsgroup-replied) | |
12351 gnus-replied-mark) | |
12352 ((memq article gnus-newsgroup-saved) | |
12353 gnus-saved-mark) | |
12354 (t gnus-unread-mark)) | |
12355 'replied) | |
12356 (when (gnus-visual-p 'summary-highlight 'highlight) | |
12357 (run-hooks 'gnus-summary-update-hook)) | |
12358 t) | |
12359 | |
12360 (defun gnus-summary-update-mark (mark type) | |
12361 (beginning-of-line) | |
12362 (let ((forward (cdr (assq type gnus-summary-mark-positions))) | |
12363 (buffer-read-only nil)) | |
12364 (when (and forward | |
12365 (<= (+ forward (point)) (point-max))) | |
12366 ;; Go to the right position on the line. | |
12367 (goto-char (+ forward (point))) | |
12368 ;; Replace the old mark with the new mark. | |
12369 (subst-char-in-region (point) (1+ (point)) (following-char) mark) | |
12370 ;; Optionally update the marks by some user rule. | |
12371 (when (eq type 'unread) | |
12372 (gnus-data-set-mark | |
12373 (gnus-data-find (gnus-summary-article-number)) mark) | |
12374 (gnus-summary-update-line (eq mark gnus-unread-mark)))))) | |
12375 | |
12376 (defun gnus-mark-article-as-read (article &optional mark) | |
12377 "Enter ARTICLE in the pertinent lists and remove it from others." | |
12378 ;; Make the article expirable. | |
12379 (let ((mark (or mark gnus-del-mark))) | |
12380 (if (= mark gnus-expirable-mark) | |
12381 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable)) | |
12382 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))) | |
12383 ;; Remove from unread and marked lists. | |
12384 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
12385 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
12386 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
12387 (push (cons article mark) gnus-newsgroup-reads) | |
12388 ;; Possibly remove from cache, if that is used. | |
12389 (when gnus-use-cache | |
12390 (gnus-cache-enter-remove-article article)))) | |
12391 | |
12392 (defun gnus-mark-article-as-unread (article &optional mark) | |
12393 "Enter ARTICLE in the pertinent lists and remove it from others." | |
12394 (let ((mark (or mark gnus-ticked-mark))) | |
12395 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
12396 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) | |
12397 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)) | |
12398 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
12399 (cond ((= mark gnus-ticked-mark) | |
12400 (push article gnus-newsgroup-marked)) | |
12401 ((= mark gnus-dormant-mark) | |
12402 (push article gnus-newsgroup-dormant)) | |
12403 (t | |
12404 (push article gnus-newsgroup-unreads))) | |
12405 (setq gnus-newsgroup-reads | |
12406 (delq (assq article gnus-newsgroup-reads) | |
12407 gnus-newsgroup-reads)))) | |
12408 | |
12409 (defalias 'gnus-summary-mark-as-unread-forward | |
12410 'gnus-summary-tick-article-forward) | |
12411 (make-obsolete 'gnus-summary-mark-as-unread-forward | |
12412 'gnus-summary-tick-article-forward) | |
12413 (defun gnus-summary-tick-article-forward (n) | |
12414 "Tick N articles forwards. | |
12415 If N is negative, tick backwards instead. | |
12416 The difference between N and the number of articles ticked is returned." | |
12417 (interactive "p") | |
12418 (gnus-summary-mark-forward n gnus-ticked-mark)) | |
12419 | |
12420 (defalias 'gnus-summary-mark-as-unread-backward | |
12421 'gnus-summary-tick-article-backward) | |
12422 (make-obsolete 'gnus-summary-mark-as-unread-backward | |
12423 'gnus-summary-tick-article-backward) | |
12424 (defun gnus-summary-tick-article-backward (n) | |
12425 "Tick N articles backwards. | |
12426 The difference between N and the number of articles ticked is returned." | |
12427 (interactive "p") | |
12428 (gnus-summary-mark-forward (- n) gnus-ticked-mark)) | |
12429 | |
12430 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article) | |
12431 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article) | |
12432 (defun gnus-summary-tick-article (&optional article clear-mark) | |
12433 "Mark current article as unread. | |
12434 Optional 1st argument ARTICLE specifies article number to be marked as unread. | |
12435 Optional 2nd argument CLEAR-MARK remove any kinds of mark." | |
12436 (interactive) | |
12437 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark | |
12438 gnus-ticked-mark))) | |
12439 | |
12440 (defun gnus-summary-mark-as-read-forward (n) | |
12441 "Mark N articles as read forwards. | |
12442 If N is negative, mark backwards instead. | |
12443 The difference between N and the actual number of articles marked is | |
12444 returned." | |
12445 (interactive "p") | |
12446 (gnus-summary-mark-forward n gnus-del-mark t)) | |
12447 | |
12448 (defun gnus-summary-mark-as-read-backward (n) | |
12449 "Mark the N articles as read backwards. | |
12450 The difference between N and the actual number of articles marked is | |
12451 returned." | |
12452 (interactive "p") | |
12453 (gnus-summary-mark-forward (- n) gnus-del-mark t)) | |
12454 | |
12455 (defun gnus-summary-mark-as-read (&optional article mark) | |
12456 "Mark current article as read. | |
12457 ARTICLE specifies the article to be marked as read. | |
12458 MARK specifies a string to be inserted at the beginning of the line." | |
12459 (gnus-summary-mark-article article mark)) | |
12460 | |
12461 (defun gnus-summary-clear-mark-forward (n) | |
12462 "Clear marks from N articles forward. | |
12463 If N is negative, clear backward instead. | |
12464 The difference between N and the number of marks cleared is returned." | |
12465 (interactive "p") | |
12466 (gnus-summary-mark-forward n gnus-unread-mark)) | |
12467 | |
12468 (defun gnus-summary-clear-mark-backward (n) | |
12469 "Clear marks from N articles backward. | |
12470 The difference between N and the number of marks cleared is returned." | |
12471 (interactive "p") | |
12472 (gnus-summary-mark-forward (- n) gnus-unread-mark)) | |
12473 | |
12474 (defun gnus-summary-mark-unread-as-read () | |
12475 "Intended to be used by `gnus-summary-mark-article-hook'." | |
12476 (when (memq gnus-current-article gnus-newsgroup-unreads) | |
12477 (gnus-summary-mark-article gnus-current-article gnus-read-mark))) | |
12478 | |
12479 (defun gnus-summary-mark-read-and-unread-as-read () | |
12480 "Intended to be used by `gnus-summary-mark-article-hook'." | |
12481 (let ((mark (gnus-summary-article-mark))) | |
12482 (when (or (gnus-unread-mark-p mark) | |
12483 (gnus-read-mark-p mark)) | |
12484 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))) | |
12485 | |
12486 (defun gnus-summary-mark-region-as-read (point mark all) | |
12487 "Mark all unread articles between point and mark as read. | |
12488 If given a prefix, mark all articles between point and mark as read, | |
12489 even ticked and dormant ones." | |
12490 (interactive "r\nP") | |
12491 (save-excursion | |
12492 (let (article) | |
12493 (goto-char point) | |
12494 (beginning-of-line) | |
12495 (while (and | |
12496 (< (point) mark) | |
12497 (progn | |
12498 (when (or all | |
12499 (memq (setq article (gnus-summary-article-number)) | |
12500 gnus-newsgroup-unreads)) | |
12501 (gnus-summary-mark-article article gnus-del-mark)) | |
12502 t) | |
12503 (gnus-summary-find-next)))))) | |
12504 | |
12505 (defun gnus-summary-mark-below (score mark) | |
12506 "Mark articles with score less than SCORE with MARK." | |
12507 (interactive "P\ncMark: ") | |
12508 (gnus-set-global-variables) | |
12509 (setq score (if score | |
12510 (prefix-numeric-value score) | |
12511 (or gnus-summary-default-score 0))) | |
12512 (save-excursion | |
12513 (set-buffer gnus-summary-buffer) | |
12514 (goto-char (point-min)) | |
12515 (while | |
12516 (progn | |
12517 (and (< (gnus-summary-article-score) score) | |
12518 (gnus-summary-mark-article nil mark)) | |
12519 (gnus-summary-find-next))))) | |
12520 | |
12521 (defun gnus-summary-kill-below (&optional score) | |
12522 "Mark articles with score below SCORE as read." | |
12523 (interactive "P") | |
12524 (gnus-set-global-variables) | |
12525 (gnus-summary-mark-below score gnus-killed-mark)) | |
12526 | |
12527 (defun gnus-summary-clear-above (&optional score) | |
12528 "Clear all marks from articles with score above SCORE." | |
12529 (interactive "P") | |
12530 (gnus-set-global-variables) | |
12531 (gnus-summary-mark-above score gnus-unread-mark)) | |
12532 | |
12533 (defun gnus-summary-tick-above (&optional score) | |
12534 "Tick all articles with score above SCORE." | |
12535 (interactive "P") | |
12536 (gnus-set-global-variables) | |
12537 (gnus-summary-mark-above score gnus-ticked-mark)) | |
12538 | |
12539 (defun gnus-summary-mark-above (score mark) | |
12540 "Mark articles with score over SCORE with MARK." | |
12541 (interactive "P\ncMark: ") | |
12542 (gnus-set-global-variables) | |
12543 (setq score (if score | |
12544 (prefix-numeric-value score) | |
12545 (or gnus-summary-default-score 0))) | |
12546 (save-excursion | |
12547 (set-buffer gnus-summary-buffer) | |
12548 (goto-char (point-min)) | |
12549 (while (and (progn | |
12550 (if (> (gnus-summary-article-score) score) | |
12551 (gnus-summary-mark-article nil mark)) | |
12552 t) | |
12553 (gnus-summary-find-next))))) | |
12554 | |
12555 ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
12556 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged) | |
12557 (defun gnus-summary-limit-include-expunged (&optional no-error) | |
12558 "Display all the hidden articles that were expunged for low scores." | |
12559 (interactive) | |
12560 (gnus-set-global-variables) | |
12561 (let ((buffer-read-only nil)) | |
12562 (let ((scored gnus-newsgroup-scored) | |
12563 headers h) | |
12564 (while scored | |
12565 (or (gnus-summary-goto-subject (caar scored)) | |
12566 (and (setq h (gnus-summary-article-header (caar scored))) | |
12567 (< (cdar scored) gnus-summary-expunge-below) | |
12568 (setq headers (cons h headers)))) | |
12569 (setq scored (cdr scored))) | |
12570 (if (not headers) | |
12571 (when (not no-error) | |
12572 (error "No expunged articles hidden.")) | |
12573 (goto-char (point-min)) | |
12574 (gnus-summary-prepare-unthreaded (nreverse headers)) | |
12575 (goto-char (point-min)) | |
12576 (gnus-summary-position-point) | |
12577 t)))) | |
12578 | |
12579 (defun gnus-summary-catchup (&optional all quietly to-here not-mark) | |
12580 "Mark all articles not marked as unread in this newsgroup as read. | |
12581 If prefix argument ALL is non-nil, all articles are marked as read. | |
12582 If QUIETLY is non-nil, no questions will be asked. | |
12583 If TO-HERE is non-nil, it should be a point in the buffer. All | |
12584 articles before this point will be marked as read. | |
12585 The number of articles marked as read is returned." | |
12586 (interactive "P") | |
12587 (gnus-set-global-variables) | |
12588 (prog1 | |
12589 (if (or quietly | |
12590 (not gnus-interactive-catchup) ;Without confirmation? | |
12591 gnus-expert-user | |
12592 (gnus-y-or-n-p | |
12593 (if all | |
12594 "Mark absolutely all articles as read? " | |
12595 "Mark all unread articles as read? "))) | |
12596 (if (and not-mark | |
12597 (not gnus-newsgroup-adaptive) | |
12598 (not gnus-newsgroup-auto-expire)) | |
12599 (progn | |
12600 (when all | |
12601 (setq gnus-newsgroup-marked nil | |
12602 gnus-newsgroup-dormant nil)) | |
12603 (setq gnus-newsgroup-unreads nil)) | |
12604 ;; We actually mark all articles as canceled, which we | |
12605 ;; have to do when using auto-expiry or adaptive scoring. | |
12606 (gnus-summary-show-all-threads) | |
12607 (if (gnus-summary-first-subject (not all)) | |
12608 (while (and | |
12609 (if to-here (< (point) to-here) t) | |
12610 (gnus-summary-mark-article-as-read gnus-catchup-mark) | |
12611 (gnus-summary-find-next (not all))))) | |
12612 (unless to-here | |
12613 (setq gnus-newsgroup-unreads nil)) | |
12614 (gnus-set-mode-line 'summary))) | |
12615 (let ((method (gnus-find-method-for-group gnus-newsgroup-name))) | |
12616 (if (and (not to-here) (eq 'nnvirtual (car method))) | |
12617 (nnvirtual-catchup-group | |
12618 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all))) | |
12619 (gnus-summary-position-point))) | |
12620 | |
12621 (defun gnus-summary-catchup-to-here (&optional all) | |
12622 "Mark all unticked articles before the current one as read. | |
12623 If ALL is non-nil, also mark ticked and dormant articles as read." | |
12624 (interactive "P") | |
12625 (gnus-set-global-variables) | |
12626 (save-excursion | |
12627 (gnus-save-hidden-threads | |
12628 (let ((beg (point))) | |
12629 ;; We check that there are unread articles. | |
12630 (when (or all (gnus-summary-find-prev)) | |
12631 (gnus-summary-catchup all t beg))))) | |
12632 (gnus-summary-position-point)) | |
12633 | |
12634 (defun gnus-summary-catchup-all (&optional quietly) | |
12635 "Mark all articles in this newsgroup as read." | |
12636 (interactive "P") | |
12637 (gnus-set-global-variables) | |
12638 (gnus-summary-catchup t quietly)) | |
12639 | |
12640 (defun gnus-summary-catchup-and-exit (&optional all quietly) | |
12641 "Mark all articles not marked as unread in this newsgroup as read, then exit. | |
12642 If prefix argument ALL is non-nil, all articles are marked as read." | |
12643 (interactive "P") | |
12644 (gnus-set-global-variables) | |
12645 (gnus-summary-catchup all quietly nil 'fast) | |
12646 ;; Select next newsgroup or exit. | |
12647 (if (eq gnus-auto-select-next 'quietly) | |
12648 (gnus-summary-next-group nil) | |
12649 (gnus-summary-exit))) | |
12650 | |
12651 (defun gnus-summary-catchup-all-and-exit (&optional quietly) | |
12652 "Mark all articles in this newsgroup as read, and then exit." | |
12653 (interactive "P") | |
12654 (gnus-set-global-variables) | |
12655 (gnus-summary-catchup-and-exit t quietly)) | |
12656 | |
12657 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>. | |
12658 (defun gnus-summary-catchup-and-goto-next-group (&optional all) | |
12659 "Mark all articles in this group as read and select the next group. | |
12660 If given a prefix, mark all articles, unread as well as ticked, as | |
12661 read." | |
12662 (interactive "P") | |
12663 (gnus-set-global-variables) | |
12664 (save-excursion | |
12665 (gnus-summary-catchup all)) | |
12666 (gnus-summary-next-article t nil nil t)) | |
12667 | |
12668 ;; Thread-based commands. | |
12669 | |
12670 (defun gnus-summary-articles-in-thread (&optional article) | |
12671 "Return a list of all articles in the current thread. | |
12672 If ARTICLE is non-nil, return all articles in the thread that starts | |
12673 with that article." | |
12674 (let* ((article (or article (gnus-summary-article-number))) | |
12675 (data (gnus-data-find-list article)) | |
12676 (top-level (gnus-data-level (car data))) | |
12677 (top-subject | |
12678 (cond ((null gnus-thread-operation-ignore-subject) | |
12679 (gnus-simplify-subject-re | |
12680 (mail-header-subject (gnus-data-header (car data))))) | |
12681 ((eq gnus-thread-operation-ignore-subject 'fuzzy) | |
12682 (gnus-simplify-subject-fuzzy | |
12683 (mail-header-subject (gnus-data-header (car data))))) | |
12684 (t nil))) | |
12685 (end-point (save-excursion | |
12686 (if (gnus-summary-go-to-next-thread) | |
12687 (point) (point-max)))) | |
12688 articles) | |
12689 (while (and data | |
12690 (< (gnus-data-pos (car data)) end-point)) | |
12691 (when (or (not top-subject) | |
12692 (string= top-subject | |
12693 (if (eq gnus-thread-operation-ignore-subject 'fuzzy) | |
12694 (gnus-simplify-subject-fuzzy | |
12695 (mail-header-subject | |
12696 (gnus-data-header (car data)))) | |
12697 (gnus-simplify-subject-re | |
12698 (mail-header-subject | |
12699 (gnus-data-header (car data))))))) | |
12700 (push (gnus-data-number (car data)) articles)) | |
12701 (unless (and (setq data (cdr data)) | |
12702 (> (gnus-data-level (car data)) top-level)) | |
12703 (setq data nil))) | |
12704 ;; Return the list of articles. | |
12705 (nreverse articles))) | |
12706 | |
12707 (defun gnus-summary-rethread-current () | |
12708 "Rethread the thread the current article is part of." | |
12709 (interactive) | |
12710 (gnus-set-global-variables) | |
12711 (let* ((gnus-show-threads t) | |
12712 (article (gnus-summary-article-number)) | |
12713 (id (mail-header-id (gnus-summary-article-header))) | |
12714 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id))))) | |
12715 (unless id | |
12716 (error "No article on the current line")) | |
12717 (gnus-rebuild-thread id) | |
12718 (gnus-summary-goto-subject article))) | |
12719 | |
12720 (defun gnus-summary-reparent-thread () | |
12721 "Make current article child of the marked (or previous) article. | |
12722 | |
12723 Note that the re-threading will only work if `gnus-thread-ignore-subject' | |
12724 is non-nil or the Subject: of both articles are the same." | |
12725 (interactive) | |
12726 (or (not (gnus-group-read-only-p)) | |
12727 (error "The current newsgroup does not support article editing.")) | |
12728 (or (<= (length gnus-newsgroup-processable) 1) | |
12729 (error "No more than one article may be marked.")) | |
12730 (save-window-excursion | |
12731 (let ((gnus-article-buffer " *reparent*") | |
12732 (current-article (gnus-summary-article-number)) | |
12733 ; first grab the marked article, otherwise one line up. | |
12734 (parent-article (if (not (null gnus-newsgroup-processable)) | |
12735 (car gnus-newsgroup-processable) | |
12736 (save-excursion | |
12737 (if (eq (forward-line -1) 0) | |
12738 (gnus-summary-article-number) | |
12739 (error "Beginning of summary buffer.")))))) | |
12740 (or (not (eq current-article parent-article)) | |
12741 (error "An article may not be self-referential.")) | |
12742 (let ((message-id (mail-header-id | |
12743 (gnus-summary-article-header parent-article)))) | |
12744 (or (and message-id (not (equal message-id ""))) | |
12745 (error "No message-id in desired parent.")) | |
12746 (gnus-summary-select-article t t nil current-article) | |
12747 (set-buffer gnus-article-buffer) | |
12748 (setq buffer-read-only nil) | |
12749 (let ((buf (format "%s" (buffer-string)))) | |
12750 (erase-buffer) | |
12751 (insert buf)) | |
12752 (goto-char (point-min)) | |
12753 (if (search-forward-regexp "^References: " nil t) | |
12754 (insert message-id " " ) | |
12755 (insert "References: " message-id "\n")) | |
12756 (or (gnus-request-replace-article current-article | |
12757 (car gnus-article-current) | |
12758 gnus-article-buffer) | |
12759 (error "Couldn't replace article.")) | |
12760 (set-buffer gnus-summary-buffer) | |
12761 (gnus-summary-unmark-all-processable) | |
12762 (gnus-summary-rethread-current) | |
12763 (gnus-message 3 "Article %d is now the child of article %d." | |
12764 current-article parent-article))))) | |
12765 | |
12766 (defun gnus-summary-toggle-threads (&optional arg) | |
12767 "Toggle showing conversation threads. | |
12768 If ARG is positive number, turn showing conversation threads on." | |
12769 (interactive "P") | |
12770 (gnus-set-global-variables) | |
12771 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end))) | |
12772 (setq gnus-show-threads | |
12773 (if (null arg) (not gnus-show-threads) | |
12774 (> (prefix-numeric-value arg) 0))) | |
12775 (gnus-summary-prepare) | |
12776 (gnus-summary-goto-subject current) | |
12777 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off")) | |
12778 (gnus-summary-position-point))) | |
12779 | |
12780 (defun gnus-summary-show-all-threads () | |
12781 "Show all threads." | |
12782 (interactive) | |
12783 (gnus-set-global-variables) | |
12784 (save-excursion | |
12785 (let ((buffer-read-only nil)) | |
12786 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t))) | |
12787 (gnus-summary-position-point)) | |
12788 | |
12789 (defun gnus-summary-show-thread () | |
12790 "Show thread subtrees. | |
12791 Returns nil if no thread was there to be shown." | |
12792 (interactive) | |
12793 (gnus-set-global-variables) | |
12794 (let ((buffer-read-only nil) | |
12795 (orig (point)) | |
12796 ;; first goto end then to beg, to have point at beg after let | |
12797 (end (progn (end-of-line) (point))) | |
12798 (beg (progn (beginning-of-line) (point)))) | |
12799 (prog1 | |
12800 ;; Any hidden lines here? | |
12801 (search-forward "\r" end t) | |
12802 (subst-char-in-region beg end ?\^M ?\n t) | |
12803 (goto-char orig) | |
12804 (gnus-summary-position-point)))) | |
12805 | |
12806 (defun gnus-summary-hide-all-threads () | |
12807 "Hide all thread subtrees." | |
12808 (interactive) | |
12809 (gnus-set-global-variables) | |
12810 (save-excursion | |
12811 (goto-char (point-min)) | |
12812 (gnus-summary-hide-thread) | |
12813 (while (zerop (gnus-summary-next-thread 1 t)) | |
12814 (gnus-summary-hide-thread))) | |
12815 (gnus-summary-position-point)) | |
12816 | |
12817 (defun gnus-summary-hide-thread () | |
12818 "Hide thread subtrees. | |
12819 Returns nil if no threads were there to be hidden." | |
12820 (interactive) | |
12821 (gnus-set-global-variables) | |
12822 (let ((buffer-read-only nil) | |
12823 (start (point)) | |
12824 (article (gnus-summary-article-number))) | |
12825 (goto-char start) | |
12826 ;; Go forward until either the buffer ends or the subthread | |
12827 ;; ends. | |
12828 (when (and (not (eobp)) | |
12829 (or (zerop (gnus-summary-next-thread 1 t)) | |
12830 (goto-char (point-max)))) | |
12831 (prog1 | |
12832 (if (and (> (point) start) | |
12833 (search-backward "\n" start t)) | |
12834 (progn | |
12835 (subst-char-in-region start (point) ?\n ?\^M) | |
12836 (gnus-summary-goto-subject article)) | |
12837 (goto-char start) | |
12838 nil) | |
12839 ;;(gnus-summary-position-point) | |
12840 )))) | |
12841 | |
12842 (defun gnus-summary-go-to-next-thread (&optional previous) | |
12843 "Go to the same level (or less) next thread. | |
12844 If PREVIOUS is non-nil, go to previous thread instead. | |
12845 Return the article number moved to, or nil if moving was impossible." | |
12846 (let ((level (gnus-summary-thread-level)) | |
12847 (way (if previous -1 1)) | |
12848 (beg (point))) | |
12849 (forward-line way) | |
12850 (while (and (not (eobp)) | |
12851 (< level (gnus-summary-thread-level))) | |
12852 (forward-line way)) | |
12853 (if (eobp) | |
12854 (progn | |
12855 (goto-char beg) | |
12856 nil) | |
12857 (setq beg (point)) | |
12858 (prog1 | |
12859 (gnus-summary-article-number) | |
12860 (goto-char beg))))) | |
12861 | |
12862 (defun gnus-summary-go-to-next-thread-old (&optional previous) | |
12863 "Go to the same level (or less) next thread. | |
12864 If PREVIOUS is non-nil, go to previous thread instead. | |
12865 Return the article number moved to, or nil if moving was impossible." | |
12866 (if (and (eq gnus-summary-make-false-root 'dummy) | |
12867 (gnus-summary-article-intangible-p)) | |
12868 (let ((beg (point))) | |
12869 (while (and (zerop (forward-line 1)) | |
12870 (not (gnus-summary-article-intangible-p)) | |
12871 (not (zerop (save-excursion | |
12872 (gnus-summary-thread-level)))))) | |
12873 (if (eobp) | |
12874 (progn | |
12875 (goto-char beg) | |
12876 nil) | |
12877 (point))) | |
12878 (let* ((level (gnus-summary-thread-level)) | |
12879 (article (gnus-summary-article-number)) | |
12880 (data (cdr (gnus-data-find-list article (gnus-data-list previous)))) | |
12881 oart) | |
12882 (while data | |
12883 (if (<= (gnus-data-level (car data)) level) | |
12884 (setq oart (gnus-data-number (car data)) | |
12885 data nil) | |
12886 (setq data (cdr data)))) | |
12887 (and oart | |
12888 (gnus-summary-goto-subject oart))))) | |
12889 | |
12890 (defun gnus-summary-next-thread (n &optional silent) | |
12891 "Go to the same level next N'th thread. | |
12892 If N is negative, search backward instead. | |
12893 Returns the difference between N and the number of skips actually | |
12894 done. | |
12895 | |
12896 If SILENT, don't output messages." | |
12897 (interactive "p") | |
12898 (gnus-set-global-variables) | |
12899 (let ((backward (< n 0)) | |
12900 (n (abs n)) | |
12901 old dum int) | |
12902 (while (and (> n 0) | |
12903 (gnus-summary-go-to-next-thread backward)) | |
12904 (decf n)) | |
12905 (unless silent | |
12906 (gnus-summary-position-point)) | |
12907 (when (and (not silent) (/= 0 n)) | |
12908 (gnus-message 7 "No more threads")) | |
12909 n)) | |
12910 | |
12911 (defun gnus-summary-prev-thread (n) | |
12912 "Go to the same level previous N'th thread. | |
12913 Returns the difference between N and the number of skips actually | |
12914 done." | |
12915 (interactive "p") | |
12916 (gnus-set-global-variables) | |
12917 (gnus-summary-next-thread (- n))) | |
12918 | |
12919 (defun gnus-summary-go-down-thread () | |
12920 "Go down one level in the current thread." | |
12921 (let ((children (gnus-summary-article-children))) | |
12922 (and children | |
12923 (gnus-summary-goto-subject (car children))))) | |
12924 | |
12925 (defun gnus-summary-go-up-thread () | |
12926 "Go up one level in the current thread." | |
12927 (let ((parent (gnus-summary-article-parent))) | |
12928 (and parent | |
12929 (gnus-summary-goto-subject parent)))) | |
12930 | |
12931 (defun gnus-summary-down-thread (n) | |
12932 "Go down thread N steps. | |
12933 If N is negative, go up instead. | |
12934 Returns the difference between N and how many steps down that were | |
12935 taken." | |
12936 (interactive "p") | |
12937 (gnus-set-global-variables) | |
12938 (let ((up (< n 0)) | |
12939 (n (abs n))) | |
12940 (while (and (> n 0) | |
12941 (if up (gnus-summary-go-up-thread) | |
12942 (gnus-summary-go-down-thread))) | |
12943 (setq n (1- n))) | |
12944 (gnus-summary-position-point) | |
12945 (if (/= 0 n) (gnus-message 7 "Can't go further")) | |
12946 n)) | |
12947 | |
12948 (defun gnus-summary-up-thread (n) | |
12949 "Go up thread N steps. | |
12950 If N is negative, go up instead. | |
12951 Returns the difference between N and how many steps down that were | |
12952 taken." | |
12953 (interactive "p") | |
12954 (gnus-set-global-variables) | |
12955 (gnus-summary-down-thread (- n))) | |
12956 | |
12957 (defun gnus-summary-top-thread () | |
12958 "Go to the top of the thread." | |
12959 (interactive) | |
12960 (gnus-set-global-variables) | |
12961 (while (gnus-summary-go-up-thread)) | |
12962 (gnus-summary-article-number)) | |
12963 | |
12964 (defun gnus-summary-kill-thread (&optional unmark) | |
12965 "Mark articles under current thread as read. | |
12966 If the prefix argument is positive, remove any kinds of marks. | |
12967 If the prefix argument is negative, tick articles instead." | |
12968 (interactive "P") | |
12969 (gnus-set-global-variables) | |
12970 (when unmark | |
12971 (setq unmark (prefix-numeric-value unmark))) | |
12972 (let ((articles (gnus-summary-articles-in-thread))) | |
12973 (save-excursion | |
12974 ;; Expand the thread. | |
12975 (gnus-summary-show-thread) | |
12976 ;; Mark all the articles. | |
12977 (while articles | |
12978 (gnus-summary-goto-subject (car articles)) | |
12979 (cond ((null unmark) | |
12980 (gnus-summary-mark-article-as-read gnus-killed-mark)) | |
12981 ((> unmark 0) | |
12982 (gnus-summary-mark-article-as-unread gnus-unread-mark)) | |
12983 (t | |
12984 (gnus-summary-mark-article-as-unread gnus-ticked-mark))) | |
12985 (setq articles (cdr articles)))) | |
12986 ;; Hide killed subtrees. | |
12987 (and (null unmark) | |
12988 gnus-thread-hide-killed | |
12989 (gnus-summary-hide-thread)) | |
12990 ;; If marked as read, go to next unread subject. | |
12991 (if (null unmark) | |
12992 ;; Go to next unread subject. | |
12993 (gnus-summary-next-subject 1 t))) | |
12994 (gnus-set-mode-line 'summary)) | |
12995 | |
12996 ;; Summary sorting commands | |
12997 | |
12998 (defun gnus-summary-sort-by-number (&optional reverse) | |
12999 "Sort summary buffer by article number. | |
13000 Argument REVERSE means reverse order." | |
13001 (interactive "P") | |
13002 (gnus-summary-sort 'number reverse)) | |
13003 | |
13004 (defun gnus-summary-sort-by-author (&optional reverse) | |
13005 "Sort summary buffer by author name alphabetically. | |
13006 If case-fold-search is non-nil, case of letters is ignored. | |
13007 Argument REVERSE means reverse order." | |
13008 (interactive "P") | |
13009 (gnus-summary-sort 'author reverse)) | |
13010 | |
13011 (defun gnus-summary-sort-by-subject (&optional reverse) | |
13012 "Sort summary buffer by subject alphabetically. `Re:'s are ignored. | |
13013 If case-fold-search is non-nil, case of letters is ignored. | |
13014 Argument REVERSE means reverse order." | |
13015 (interactive "P") | |
13016 (gnus-summary-sort 'subject reverse)) | |
13017 | |
13018 (defun gnus-summary-sort-by-date (&optional reverse) | |
13019 "Sort summary buffer by date. | |
13020 Argument REVERSE means reverse order." | |
13021 (interactive "P") | |
13022 (gnus-summary-sort 'date reverse)) | |
13023 | |
13024 (defun gnus-summary-sort-by-score (&optional reverse) | |
13025 "Sort summary buffer by score. | |
13026 Argument REVERSE means reverse order." | |
13027 (interactive "P") | |
13028 (gnus-summary-sort 'score reverse)) | |
13029 | |
13030 (defun gnus-summary-sort (predicate reverse) | |
13031 "Sort summary buffer by PREDICATE. REVERSE means reverse order." | |
13032 (gnus-set-global-variables) | |
13033 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate))) | |
13034 (article (intern (format "gnus-article-sort-by-%s" predicate))) | |
13035 (gnus-thread-sort-functions | |
13036 (list | |
13037 (if (not reverse) | |
13038 thread | |
13039 `(lambda (t1 t2) | |
13040 (,thread t2 t1))))) | |
13041 (gnus-article-sort-functions | |
13042 (list | |
13043 (if (not reverse) | |
13044 article | |
13045 `(lambda (t1 t2) | |
13046 (,article t2 t1))))) | |
13047 (buffer-read-only) | |
13048 (gnus-summary-prepare-hook nil)) | |
13049 ;; We do the sorting by regenerating the threads. | |
13050 (gnus-summary-prepare) | |
13051 ;; Hide subthreads if needed. | |
13052 (when (and gnus-show-threads gnus-thread-hide-subtree) | |
13053 (gnus-summary-hide-all-threads))) | |
13054 ;; If in async mode, we send some info to the backend. | |
13055 (when gnus-newsgroup-async | |
13056 (gnus-request-asynchronous | |
13057 gnus-newsgroup-name gnus-newsgroup-data))) | |
13058 | |
13059 (defun gnus-sortable-date (date) | |
13060 "Make sortable string by string-lessp from DATE. | |
13061 Timezone package is used." | |
13062 (condition-case () | |
13063 (progn | |
13064 (setq date (inline (timezone-fix-time | |
13065 date nil | |
13066 (aref (inline (timezone-parse-date date)) 4)))) | |
13067 (inline | |
13068 (timezone-make-sortable-date | |
13069 (aref date 0) (aref date 1) (aref date 2) | |
13070 (inline | |
13071 (timezone-make-time-string | |
13072 (aref date 3) (aref date 4) (aref date 5)))))) | |
13073 (error ""))) | |
13074 | |
13075 ;; Summary saving commands. | |
13076 | |
13077 (defun gnus-summary-save-article (&optional n not-saved) | |
13078 "Save the current article using the default saver function. | |
13079 If N is a positive number, save the N next articles. | |
13080 If N is a negative number, save the N previous articles. | |
13081 If N is nil and any articles have been marked with the process mark, | |
13082 save those articles instead. | |
13083 The variable `gnus-default-article-saver' specifies the saver function." | |
13084 (interactive "P") | |
13085 (gnus-set-global-variables) | |
13086 (let ((articles (gnus-summary-work-articles n)) | |
13087 (save-buffer (save-excursion | |
13088 (nnheader-set-temp-buffer " *Gnus Save*"))) | |
13089 file header article) | |
13090 (while articles | |
13091 (setq header (gnus-summary-article-header | |
13092 (setq article (pop articles)))) | |
13093 (if (not (vectorp header)) | |
13094 ;; This is a pseudo-article. | |
13095 (if (assq 'name header) | |
13096 (gnus-copy-file (cdr (assq 'name header))) | |
13097 (gnus-message 1 "Article %d is unsaveable" article)) | |
13098 ;; This is a real article. | |
13099 (save-window-excursion | |
13100 (gnus-summary-select-article t nil nil article)) | |
13101 (save-excursion | |
13102 (set-buffer save-buffer) | |
13103 (erase-buffer) | |
13104 (insert-buffer-substring gnus-original-article-buffer)) | |
13105 (unless gnus-save-all-headers | |
13106 ;; Remove headers accoring to `gnus-saved-headers'. | |
13107 (let ((gnus-visible-headers | |
13108 (or gnus-saved-headers gnus-visible-headers)) | |
13109 (gnus-article-buffer save-buffer)) | |
13110 (gnus-article-hide-headers 1 t))) | |
13111 (save-window-excursion | |
13112 (if (not gnus-default-article-saver) | |
13113 (error "No default saver is defined.") | |
13114 ;; !!! Magic! The saving functions all save | |
13115 ;; `gnus-original-article-buffer' (or so they think), | |
13116 ;; but we bind that variable to our save-buffer. | |
13117 (set-buffer gnus-article-buffer) | |
13118 (let ((gnus-original-article-buffer save-buffer)) | |
13119 (set-buffer gnus-summary-buffer) | |
13120 (setq file (funcall | |
13121 gnus-default-article-saver | |
13122 (cond | |
13123 ((not gnus-prompt-before-saving) | |
13124 'default) | |
13125 ((eq gnus-prompt-before-saving 'always) | |
13126 nil) | |
13127 (t file))))))) | |
13128 (gnus-summary-remove-process-mark article) | |
13129 (unless not-saved | |
13130 (gnus-summary-set-saved-mark article)))) | |
13131 (gnus-kill-buffer save-buffer) | |
13132 (gnus-summary-position-point) | |
13133 n)) | |
13134 | |
13135 (defun gnus-summary-pipe-output (&optional arg) | |
13136 "Pipe the current article to a subprocess. | |
13137 If N is a positive number, pipe the N next articles. | |
13138 If N is a negative number, pipe the N previous articles. | |
13139 If N is nil and any articles have been marked with the process mark, | |
13140 pipe those articles instead." | |
13141 (interactive "P") | |
13142 (gnus-set-global-variables) | |
13143 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)) | |
13144 (gnus-summary-save-article arg t)) | |
13145 (gnus-configure-windows 'pipe)) | |
13146 | |
13147 (defun gnus-summary-save-article-mail (&optional arg) | |
13148 "Append the current article to an mail file. | |
13149 If N is a positive number, save the N next articles. | |
13150 If N is a negative number, save the N previous articles. | |
13151 If N is nil and any articles have been marked with the process mark, | |
13152 save those articles instead." | |
13153 (interactive "P") | |
13154 (gnus-set-global-variables) | |
13155 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail)) | |
13156 (gnus-summary-save-article arg))) | |
13157 | |
13158 (defun gnus-summary-save-article-rmail (&optional arg) | |
13159 "Append the current article to an rmail file. | |
13160 If N is a positive number, save the N next articles. | |
13161 If N is a negative number, save the N previous articles. | |
13162 If N is nil and any articles have been marked with the process mark, | |
13163 save those articles instead." | |
13164 (interactive "P") | |
13165 (gnus-set-global-variables) | |
13166 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail)) | |
13167 (gnus-summary-save-article arg))) | |
13168 | |
13169 (defun gnus-summary-save-article-file (&optional arg) | |
13170 "Append the current article to a file. | |
13171 If N is a positive number, save the N next articles. | |
13172 If N is a negative number, save the N previous articles. | |
13173 If N is nil and any articles have been marked with the process mark, | |
13174 save those articles instead." | |
13175 (interactive "P") | |
13176 (gnus-set-global-variables) | |
13177 (let ((gnus-default-article-saver 'gnus-summary-save-in-file)) | |
13178 (gnus-summary-save-article arg))) | |
13179 | |
13180 (defun gnus-summary-save-article-body-file (&optional arg) | |
13181 "Append the current article body to a file. | |
13182 If N is a positive number, save the N next articles. | |
13183 If N is a negative number, save the N previous articles. | |
13184 If N is nil and any articles have been marked with the process mark, | |
13185 save those articles instead." | |
13186 (interactive "P") | |
13187 (gnus-set-global-variables) | |
13188 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file)) | |
13189 (gnus-summary-save-article arg))) | |
13190 | |
13191 (defun gnus-get-split-value (methods) | |
13192 "Return a value based on the split METHODS." | |
13193 (let (split-name method result match) | |
13194 (when methods | |
13195 (save-excursion | |
13196 (set-buffer gnus-original-article-buffer) | |
13197 (save-restriction | |
13198 (nnheader-narrow-to-headers) | |
13199 (while methods | |
13200 (goto-char (point-min)) | |
13201 (setq method (pop methods)) | |
13202 (setq match (car method)) | |
13203 (when (cond | |
13204 ((stringp match) | |
13205 ;; Regular expression. | |
13206 (condition-case () | |
13207 (re-search-forward match nil t) | |
13208 (error nil))) | |
13209 ((gnus-functionp match) | |
13210 ;; Function. | |
13211 (save-restriction | |
13212 (widen) | |
13213 (setq result (funcall match gnus-newsgroup-name)))) | |
13214 ((consp match) | |
13215 ;; Form. | |
13216 (save-restriction | |
13217 (widen) | |
13218 (setq result (eval match))))) | |
13219 (setq split-name (append (cdr method) split-name)) | |
13220 (cond ((stringp result) | |
13221 (push result split-name)) | |
13222 ((consp result) | |
13223 (setq split-name (append result split-name))))))))) | |
13224 split-name)) | |
13225 | |
13226 (defun gnus-read-move-group-name (prompt default articles prefix) | |
13227 "Read a group name." | |
13228 (let* ((split-name (gnus-get-split-value gnus-move-split-methods)) | |
13229 (minibuffer-confirm-incomplete nil) ; XEmacs | |
13230 group-map | |
13231 (dum (mapatoms | |
13232 (lambda (g) | |
13233 (and (boundp g) | |
13234 (symbol-name g) | |
13235 (memq 'respool | |
13236 (assoc (symbol-name | |
13237 (car (gnus-find-method-for-group | |
13238 (symbol-name g)))) | |
13239 gnus-valid-select-methods)) | |
13240 (push (list (symbol-name g)) group-map))) | |
13241 gnus-active-hashtb)) | |
13242 (prom | |
13243 (format "%s %s to:" | |
13244 prompt | |
13245 (if (> (length articles) 1) | |
13246 (format "these %d articles" (length articles)) | |
13247 "this article"))) | |
13248 (to-newsgroup | |
13249 (cond | |
13250 ((null split-name) | |
13251 (gnus-completing-read default prom | |
13252 group-map nil nil prefix | |
13253 'gnus-group-history)) | |
13254 ((= 1 (length split-name)) | |
13255 (gnus-completing-read (car split-name) prom group-map | |
13256 nil nil nil | |
13257 'gnus-group-history)) | |
13258 (t | |
13259 (gnus-completing-read nil prom | |
13260 (mapcar (lambda (el) (list el)) | |
13261 (nreverse split-name)) | |
13262 nil nil nil | |
13263 'gnus-group-history))))) | |
13264 (when to-newsgroup | |
13265 (if (or (string= to-newsgroup "") | |
13266 (string= to-newsgroup prefix)) | |
13267 (setq to-newsgroup (or default ""))) | |
13268 (or (gnus-active to-newsgroup) | |
13269 (gnus-activate-group to-newsgroup) | |
13270 (if (gnus-y-or-n-p (format "No such group: %s. Create it? " | |
13271 to-newsgroup)) | |
13272 (or (and (gnus-request-create-group | |
13273 to-newsgroup (gnus-group-name-to-method to-newsgroup)) | |
13274 (gnus-activate-group to-newsgroup nil nil | |
13275 (gnus-group-name-to-method | |
13276 to-newsgroup))) | |
13277 (error "Couldn't create group %s" to-newsgroup))) | |
13278 (error "No such group: %s" to-newsgroup))) | |
13279 to-newsgroup)) | |
13280 | |
13281 (defun gnus-read-save-file-name (prompt default-name) | |
13282 (let* ((split-name (gnus-get-split-value gnus-split-methods)) | |
13283 (file | |
13284 ;; Let the split methods have their say. | |
13285 (cond | |
13286 ;; No split name was found. | |
13287 ((null split-name) | |
13288 (read-file-name | |
13289 (concat prompt " (default " | |
13290 (file-name-nondirectory default-name) ") ") | |
13291 (file-name-directory default-name) | |
13292 default-name)) | |
13293 ;; A single split name was found | |
13294 ((= 1 (length split-name)) | |
13295 (let* ((name (car split-name)) | |
13296 (dir (cond ((file-directory-p name) | |
13297 (file-name-as-directory name)) | |
13298 ((file-exists-p name) name) | |
13299 (t gnus-article-save-directory)))) | |
13300 (read-file-name | |
13301 (concat prompt " (default " name ") ") | |
13302 dir name))) | |
13303 ;; A list of splits was found. | |
13304 (t | |
13305 (setq split-name (nreverse split-name)) | |
13306 (let (result) | |
13307 (let ((file-name-history (nconc split-name file-name-history))) | |
13308 (setq result | |
13309 (read-file-name | |
13310 (concat prompt " (`M-p' for defaults) ") | |
13311 gnus-article-save-directory | |
13312 (car split-name)))) | |
13313 (car (push result file-name-history))))))) | |
13314 ;; Create the directory. | |
13315 (unless (equal (directory-file-name file) file) | |
13316 (make-directory (file-name-directory file) t)) | |
13317 ;; If we have read a directory, we append the default file name. | |
13318 (when (file-directory-p file) | |
13319 (setq file (concat (file-name-as-directory file) | |
13320 (file-name-nondirectory default-name)))) | |
13321 ;; Possibly translate some characters. | |
13322 (nnheader-translate-file-chars file))) | |
13323 | |
13324 (defun gnus-article-archive-name (group) | |
13325 "Return the first instance of an \"Archive-name\" in the current buffer." | |
13326 (let ((case-fold-search t)) | |
13327 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t) | |
13328 (nnheader-concat gnus-article-save-directory | |
13329 (match-string 1))))) | |
13330 | |
13331 (defun gnus-summary-save-in-rmail (&optional filename) | |
13332 "Append this article to Rmail file. | |
13333 Optional argument FILENAME specifies file name. | |
13334 Directory to save to is default to `gnus-article-save-directory'." | |
13335 (interactive) | |
13336 (gnus-set-global-variables) | |
13337 (let ((default-name | |
13338 (funcall gnus-rmail-save-name gnus-newsgroup-name | |
13339 gnus-current-headers gnus-newsgroup-last-rmail))) | |
13340 (setq filename | |
13341 (cond ((eq filename 'default) | |
13342 default-name) | |
13343 (filename filename) | |
13344 (t (gnus-read-save-file-name | |
13345 "Save in rmail file:" default-name)))) | |
13346 (gnus-make-directory (file-name-directory filename)) | |
13347 (gnus-eval-in-buffer-window gnus-original-article-buffer | |
13348 (save-excursion | |
13349 (save-restriction | |
13350 (widen) | |
13351 (gnus-output-to-rmail filename)))) | |
13352 ;; Remember the directory name to save articles | |
13353 (setq gnus-newsgroup-last-rmail filename))) | |
13354 | |
13355 (defun gnus-summary-save-in-mail (&optional filename) | |
13356 "Append this article to Unix mail file. | |
13357 Optional argument FILENAME specifies file name. | |
13358 Directory to save to is default to `gnus-article-save-directory'." | |
13359 (interactive) | |
13360 (gnus-set-global-variables) | |
13361 (let ((default-name | |
13362 (funcall gnus-mail-save-name gnus-newsgroup-name | |
13363 gnus-current-headers gnus-newsgroup-last-mail))) | |
13364 (setq filename | |
13365 (cond ((eq filename 'default) | |
13366 default-name) | |
13367 (filename filename) | |
13368 (t (gnus-read-save-file-name | |
13369 "Save in Unix mail file:" default-name)))) | |
13370 (setq filename | |
13371 (expand-file-name filename | |
13372 (and default-name | |
13373 (file-name-directory default-name)))) | |
13374 (gnus-make-directory (file-name-directory filename)) | |
13375 (gnus-eval-in-buffer-window gnus-original-article-buffer | |
13376 (save-excursion | |
13377 (save-restriction | |
13378 (widen) | |
13379 (if (and (file-readable-p filename) (mail-file-babyl-p filename)) | |
13380 (gnus-output-to-rmail filename) | |
13381 (let ((mail-use-rfc822 t)) | |
13382 (rmail-output filename 1 t t)))))) | |
13383 ;; Remember the directory name to save articles. | |
13384 (setq gnus-newsgroup-last-mail filename))) | |
13385 | |
13386 (defun gnus-summary-save-in-file (&optional filename) | |
13387 "Append this article to file. | |
13388 Optional argument FILENAME specifies file name. | |
13389 Directory to save to is default to `gnus-article-save-directory'." | |
13390 (interactive) | |
13391 (gnus-set-global-variables) | |
13392 (let ((default-name | |
13393 (funcall gnus-file-save-name gnus-newsgroup-name | |
13394 gnus-current-headers gnus-newsgroup-last-file))) | |
13395 (setq filename | |
13396 (cond ((eq filename 'default) | |
13397 default-name) | |
13398 (filename filename) | |
13399 (t (gnus-read-save-file-name | |
13400 "Save in file:" default-name)))) | |
13401 (gnus-make-directory (file-name-directory filename)) | |
13402 (gnus-eval-in-buffer-window gnus-original-article-buffer | |
13403 (save-excursion | |
13404 (save-restriction | |
13405 (widen) | |
13406 (gnus-output-to-file filename)))) | |
13407 ;; Remember the directory name to save articles. | |
13408 (setq gnus-newsgroup-last-file filename))) | |
13409 | |
13410 (defun gnus-summary-save-body-in-file (&optional filename) | |
13411 "Append this article body to a file. | |
13412 Optional argument FILENAME specifies file name. | |
13413 The directory to save in defaults to `gnus-article-save-directory'." | |
13414 (interactive) | |
13415 (gnus-set-global-variables) | |
13416 (let ((default-name | |
13417 (funcall gnus-file-save-name gnus-newsgroup-name | |
13418 gnus-current-headers gnus-newsgroup-last-file))) | |
13419 (setq filename | |
13420 (cond ((eq filename 'default) | |
13421 default-name) | |
13422 (filename filename) | |
13423 (t (gnus-read-save-file-name | |
13424 "Save body in file:" default-name)))) | |
13425 (gnus-make-directory (file-name-directory filename)) | |
13426 (gnus-eval-in-buffer-window gnus-original-article-buffer | |
13427 (save-excursion | |
13428 (save-restriction | |
13429 (widen) | |
13430 (goto-char (point-min)) | |
13431 (and (search-forward "\n\n" nil t) | |
13432 (narrow-to-region (point) (point-max))) | |
13433 (gnus-output-to-file filename)))) | |
13434 ;; Remember the directory name to save articles. | |
13435 (setq gnus-newsgroup-last-file filename))) | |
13436 | |
13437 (defun gnus-summary-save-in-pipe (&optional command) | |
13438 "Pipe this article to subprocess." | |
13439 (interactive) | |
13440 (gnus-set-global-variables) | |
13441 (setq command | |
13442 (cond ((eq command 'default) | |
13443 gnus-last-shell-command) | |
13444 (command command) | |
13445 (t (read-string "Shell command on article: " | |
13446 gnus-last-shell-command)))) | |
13447 (if (string-equal command "") | |
13448 (setq command gnus-last-shell-command)) | |
13449 (gnus-eval-in-buffer-window gnus-article-buffer | |
13450 (save-restriction | |
13451 (widen) | |
13452 (shell-command-on-region (point-min) (point-max) command nil))) | |
13453 (setq gnus-last-shell-command command)) | |
13454 | |
13455 ;; Summary extract commands | |
13456 | |
13457 (defun gnus-summary-insert-pseudos (pslist &optional not-view) | |
13458 (let ((buffer-read-only nil) | |
13459 (article (gnus-summary-article-number)) | |
13460 after-article b e) | |
13461 (or (gnus-summary-goto-subject article) | |
13462 (error "No such article: %d" article)) | |
13463 (gnus-summary-position-point) | |
13464 ;; If all commands are to be bunched up on one line, we collect | |
13465 ;; them here. | |
13466 (if gnus-view-pseudos-separately | |
13467 () | |
13468 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<))) | |
13469 files action) | |
13470 (while ps | |
13471 (setq action (cdr (assq 'action (car ps)))) | |
13472 (setq files (list (cdr (assq 'name (car ps))))) | |
13473 (while (and ps (cdr ps) | |
13474 (string= (or action "1") | |
13475 (or (cdr (assq 'action (cadr ps))) "2"))) | |
13476 (setq files (cons (cdr (assq 'name (cadr ps))) files)) | |
13477 (setcdr ps (cddr ps))) | |
13478 (if (not files) | |
13479 () | |
13480 (if (not (string-match "%s" action)) | |
13481 (setq files (cons " " files))) | |
13482 (setq files (cons " " files)) | |
13483 (and (assq 'execute (car ps)) | |
13484 (setcdr (assq 'execute (car ps)) | |
13485 (funcall (if (string-match "%s" action) | |
13486 'format 'concat) | |
13487 action | |
13488 (mapconcat (lambda (f) f) files " "))))) | |
13489 (setq ps (cdr ps))))) | |
13490 (if (and gnus-view-pseudos (not not-view)) | |
13491 (while pslist | |
13492 (and (assq 'execute (car pslist)) | |
13493 (gnus-execute-command (cdr (assq 'execute (car pslist))) | |
13494 (eq gnus-view-pseudos 'not-confirm))) | |
13495 (setq pslist (cdr pslist))) | |
13496 (save-excursion | |
13497 (while pslist | |
13498 (setq after-article (or (cdr (assq 'article (car pslist))) | |
13499 (gnus-summary-article-number))) | |
13500 (gnus-summary-goto-subject after-article) | |
13501 (forward-line 1) | |
13502 (setq b (point)) | |
13503 (insert " " (file-name-nondirectory | |
13504 (cdr (assq 'name (car pslist)))) | |
13505 ": " (or (cdr (assq 'execute (car pslist))) "") "\n") | |
13506 (setq e (point)) | |
13507 (forward-line -1) ; back to `b' | |
13508 (gnus-add-text-properties | |
13509 b (1- e) (list 'gnus-number gnus-reffed-article-number | |
13510 gnus-mouse-face-prop gnus-mouse-face)) | |
13511 (gnus-data-enter | |
13512 after-article gnus-reffed-article-number | |
13513 gnus-unread-mark b (car pslist) 0 (- e b)) | |
13514 (push gnus-reffed-article-number gnus-newsgroup-unreads) | |
13515 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)) | |
13516 (setq pslist (cdr pslist))))))) | |
13517 | |
13518 (defun gnus-pseudos< (p1 p2) | |
13519 (let ((c1 (cdr (assq 'action p1))) | |
13520 (c2 (cdr (assq 'action p2)))) | |
13521 (and c1 c2 (string< c1 c2)))) | |
13522 | |
13523 (defun gnus-request-pseudo-article (props) | |
13524 (cond ((assq 'execute props) | |
13525 (gnus-execute-command (cdr (assq 'execute props))))) | |
13526 (let ((gnus-current-article (gnus-summary-article-number))) | |
13527 (run-hooks 'gnus-mark-article-hook))) | |
13528 | |
13529 (defun gnus-execute-command (command &optional automatic) | |
13530 (save-excursion | |
13531 (gnus-article-setup-buffer) | |
13532 (set-buffer gnus-article-buffer) | |
13533 (setq buffer-read-only nil) | |
13534 (let ((command (if automatic command (read-string "Command: " command))) | |
13535 ;; Just binding this here doesn't help, because there might | |
13536 ;; be output from the process after exiting the scope of | |
13537 ;; this `let'. | |
13538 ;; (buffer-read-only nil) | |
13539 ) | |
13540 (erase-buffer) | |
13541 (insert "$ " command "\n\n") | |
13542 (if gnus-view-pseudo-asynchronously | |
13543 (start-process "gnus-execute" nil shell-file-name | |
13544 shell-command-switch command) | |
13545 (call-process shell-file-name nil t nil | |
13546 shell-command-switch command))))) | |
13547 | |
13548 (defun gnus-copy-file (file &optional to) | |
13549 "Copy FILE to TO." | |
13550 (interactive | |
13551 (list (read-file-name "Copy file: " default-directory) | |
13552 (read-file-name "Copy file to: " default-directory))) | |
13553 (gnus-set-global-variables) | |
13554 (or to (setq to (read-file-name "Copy file to: " default-directory))) | |
13555 (and (file-directory-p to) | |
13556 (setq to (concat (file-name-as-directory to) | |
13557 (file-name-nondirectory file)))) | |
13558 (copy-file file to)) | |
13559 | |
13560 ;; Summary kill commands. | |
13561 | |
13562 (defun gnus-summary-edit-global-kill (article) | |
13563 "Edit the \"global\" kill file." | |
13564 (interactive (list (gnus-summary-article-number))) | |
13565 (gnus-set-global-variables) | |
13566 (gnus-group-edit-global-kill article)) | |
13567 | |
13568 (defun gnus-summary-edit-local-kill () | |
13569 "Edit a local kill file applied to the current newsgroup." | |
13570 (interactive) | |
13571 (gnus-set-global-variables) | |
13572 (setq gnus-current-headers (gnus-summary-article-header)) | |
13573 (gnus-set-global-variables) | |
13574 (gnus-group-edit-local-kill | |
13575 (gnus-summary-article-number) gnus-newsgroup-name)) | |
13576 | |
13577 | |
13578 ;;; | |
13579 ;;; Gnus article mode | |
13580 ;;; | |
13581 | |
13582 (put 'gnus-article-mode 'mode-class 'special) | |
13583 | |
13584 (if gnus-article-mode-map | |
13585 nil | |
13586 (setq gnus-article-mode-map (make-keymap)) | |
13587 (suppress-keymap gnus-article-mode-map) | |
13588 | |
13589 (gnus-define-keys gnus-article-mode-map | |
13590 " " gnus-article-goto-next-page | |
13591 "\177" gnus-article-goto-prev-page | |
13592 [delete] gnus-article-goto-prev-page | |
13593 "\C-c^" gnus-article-refer-article | |
13594 "h" gnus-article-show-summary | |
13595 "s" gnus-article-show-summary | |
13596 "\C-c\C-m" gnus-article-mail | |
13597 "?" gnus-article-describe-briefly | |
13598 gnus-mouse-2 gnus-article-push-button | |
13599 "\r" gnus-article-press-button | |
13600 "\t" gnus-article-next-button | |
13601 "\M-\t" gnus-article-prev-button | |
13602 "<" beginning-of-buffer | |
13603 ">" end-of-buffer | |
13604 "\C-c\C-i" gnus-info-find-node | |
13605 "\C-c\C-b" gnus-bug) | |
13606 | |
13607 (substitute-key-definition | |
13608 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)) | |
13609 | |
13610 (defun gnus-article-mode () | |
13611 "Major mode for displaying an article. | |
13612 | |
13613 All normal editing commands are switched off. | |
13614 | |
13615 The following commands are available: | |
13616 | |
13617 \\<gnus-article-mode-map> | |
13618 \\[gnus-article-next-page]\t Scroll the article one page forwards | |
13619 \\[gnus-article-prev-page]\t Scroll the article one page backwards | |
13620 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point | |
13621 \\[gnus-article-show-summary]\t Display the summary buffer | |
13622 \\[gnus-article-mail]\t Send a reply to the address near point | |
13623 \\[gnus-article-describe-briefly]\t Describe the current mode briefly | |
13624 \\[gnus-info-find-node]\t Go to the Gnus info node" | |
13625 (interactive) | |
13626 (when (and menu-bar-mode | |
13627 (gnus-visual-p 'article-menu 'menu)) | |
13628 (gnus-article-make-menu-bar)) | |
13629 (kill-all-local-variables) | |
13630 (gnus-simplify-mode-line) | |
13631 (setq mode-name "Article") | |
13632 (setq major-mode 'gnus-article-mode) | |
13633 (make-local-variable 'minor-mode-alist) | |
13634 (or (assq 'gnus-show-mime minor-mode-alist) | |
13635 (setq minor-mode-alist | |
13636 (cons (list 'gnus-show-mime " MIME") minor-mode-alist))) | |
13637 (use-local-map gnus-article-mode-map) | |
13638 (make-local-variable 'page-delimiter) | |
13639 (setq page-delimiter gnus-page-delimiter) | |
13640 (buffer-disable-undo (current-buffer)) | |
13641 (setq buffer-read-only t) ;Disable modification | |
13642 (run-hooks 'gnus-article-mode-hook)) | |
13643 | |
13644 (defun gnus-article-setup-buffer () | |
13645 "Initialize the article buffer." | |
13646 (let* ((name (if gnus-single-article-buffer "*Article*" | |
13647 (concat "*Article " gnus-newsgroup-name "*"))) | |
13648 (original | |
13649 (progn (string-match "\\*Article" name) | |
13650 (concat " *Original Article" | |
13651 (substring name (match-end 0)))))) | |
13652 (setq gnus-article-buffer name) | |
13653 (setq gnus-original-article-buffer original) | |
13654 ;; This might be a variable local to the summary buffer. | |
13655 (unless gnus-single-article-buffer | |
13656 (save-excursion | |
13657 (set-buffer gnus-summary-buffer) | |
13658 (setq gnus-article-buffer name) | |
13659 (setq gnus-original-article-buffer original) | |
13660 (gnus-set-global-variables)) | |
13661 (make-local-variable 'gnus-summary-buffer)) | |
13662 ;; Init original article buffer. | |
13663 (save-excursion | |
13664 (set-buffer (get-buffer-create gnus-original-article-buffer)) | |
13665 (buffer-disable-undo (current-buffer)) | |
13666 (setq major-mode 'gnus-original-article-mode) | |
13667 (gnus-add-current-to-buffer-list) | |
13668 (make-local-variable 'gnus-original-article)) | |
13669 (if (get-buffer name) | |
13670 (save-excursion | |
13671 (set-buffer name) | |
13672 (buffer-disable-undo (current-buffer)) | |
13673 (setq buffer-read-only t) | |
13674 (gnus-add-current-to-buffer-list) | |
13675 (or (eq major-mode 'gnus-article-mode) | |
13676 (gnus-article-mode)) | |
13677 (current-buffer)) | |
13678 (save-excursion | |
13679 (set-buffer (get-buffer-create name)) | |
13680 (gnus-add-current-to-buffer-list) | |
13681 (gnus-article-mode) | |
13682 (current-buffer))))) | |
13683 | |
13684 ;; Set article window start at LINE, where LINE is the number of lines | |
13685 ;; from the head of the article. | |
13686 (defun gnus-article-set-window-start (&optional line) | |
13687 (set-window-start | |
13688 (get-buffer-window gnus-article-buffer t) | |
13689 (save-excursion | |
13690 (set-buffer gnus-article-buffer) | |
13691 (goto-char (point-min)) | |
13692 (if (not line) | |
13693 (point-min) | |
13694 (gnus-message 6 "Moved to bookmark") | |
13695 (search-forward "\n\n" nil t) | |
13696 (forward-line line) | |
13697 (point))))) | |
13698 | |
13699 (defun gnus-kill-all-overlays () | |
13700 "Delete all overlays in the current buffer." | |
13701 (when (fboundp 'overlay-lists) | |
13702 (let* ((overlayss (overlay-lists)) | |
13703 (buffer-read-only nil) | |
13704 (overlays (nconc (car overlayss) (cdr overlayss)))) | |
13705 (while overlays | |
13706 (delete-overlay (pop overlays)))))) | |
13707 | |
13708 (defun gnus-request-article-this-buffer (article group) | |
13709 "Get an article and insert it into this buffer." | |
13710 (let (do-update-line) | |
13711 (prog1 | |
13712 (save-excursion | |
13713 (erase-buffer) | |
13714 (gnus-kill-all-overlays) | |
13715 (setq group (or group gnus-newsgroup-name)) | |
13716 | |
13717 ;; Open server if it has closed. | |
13718 (gnus-check-server (gnus-find-method-for-group group)) | |
13719 | |
13720 ;; Using `gnus-request-article' directly will insert the article into | |
13721 ;; `nntp-server-buffer' - so we'll save some time by not having to | |
13722 ;; copy it from the server buffer into the article buffer. | |
13723 | |
13724 ;; We only request an article by message-id when we do not have the | |
13725 ;; headers for it, so we'll have to get those. | |
13726 (when (stringp article) | |
13727 (let ((gnus-override-method gnus-refer-article-method)) | |
13728 (gnus-read-header article))) | |
13729 | |
13730 ;; If the article number is negative, that means that this article | |
13731 ;; doesn't belong in this newsgroup (possibly), so we find its | |
13732 ;; message-id and request it by id instead of number. | |
13733 (when (and (numberp article) | |
13734 gnus-summary-buffer | |
13735 (get-buffer gnus-summary-buffer) | |
13736 (buffer-name (get-buffer gnus-summary-buffer))) | |
13737 (save-excursion | |
13738 (set-buffer gnus-summary-buffer) | |
13739 (let ((header (gnus-summary-article-header article))) | |
13740 (if (< article 0) | |
13741 (cond | |
13742 ((memq article gnus-newsgroup-sparse) | |
13743 ;; This is a sparse gap article. | |
13744 (setq do-update-line article) | |
13745 (setq article (mail-header-id header)) | |
13746 (let ((gnus-override-method gnus-refer-article-method)) | |
13747 (gnus-read-header article)) | |
13748 (setq gnus-newsgroup-sparse | |
13749 (delq article gnus-newsgroup-sparse))) | |
13750 ((vectorp header) | |
13751 ;; It's a real article. | |
13752 (setq article (mail-header-id header))) | |
13753 (t | |
13754 ;; It is an extracted pseudo-article. | |
13755 (setq article 'pseudo) | |
13756 (gnus-request-pseudo-article header)))) | |
13757 | |
13758 (let ((method (gnus-find-method-for-group | |
13759 gnus-newsgroup-name))) | |
13760 (if (not (eq (car method) 'nneething)) | |
13761 () | |
13762 (let ((dir (concat (file-name-as-directory (nth 1 method)) | |
13763 (mail-header-subject header)))) | |
13764 (if (file-directory-p dir) | |
13765 (progn | |
13766 (setq article 'nneething) | |
13767 (gnus-group-enter-directory dir))))))))) | |
13768 | |
13769 (cond | |
13770 ;; Refuse to select canceled articles. | |
13771 ((and (numberp article) | |
13772 gnus-summary-buffer | |
13773 (get-buffer gnus-summary-buffer) | |
13774 (buffer-name (get-buffer gnus-summary-buffer)) | |
13775 (eq (cdr (save-excursion | |
13776 (set-buffer gnus-summary-buffer) | |
13777 (assq article gnus-newsgroup-reads))) | |
13778 gnus-canceled-mark)) | |
13779 nil) | |
13780 ;; We first check `gnus-original-article-buffer'. | |
13781 ((and (get-buffer gnus-original-article-buffer) | |
13782 (numberp article) | |
13783 (save-excursion | |
13784 (set-buffer gnus-original-article-buffer) | |
13785 (and (equal (car gnus-original-article) group) | |
13786 (eq (cdr gnus-original-article) article)))) | |
13787 (insert-buffer-substring gnus-original-article-buffer) | |
13788 'article) | |
13789 ;; Check the backlog. | |
13790 ((and gnus-keep-backlog | |
13791 (gnus-backlog-request-article group article (current-buffer))) | |
13792 'article) | |
13793 ;; Check the cache. | |
13794 ((and gnus-use-cache | |
13795 (numberp article) | |
13796 (gnus-cache-request-article article group)) | |
13797 'article) | |
13798 ;; Get the article and put into the article buffer. | |
13799 ((or (stringp article) (numberp article)) | |
13800 (let ((gnus-override-method | |
13801 (and (stringp article) gnus-refer-article-method)) | |
13802 (buffer-read-only nil)) | |
13803 (erase-buffer) | |
13804 (gnus-kill-all-overlays) | |
13805 (if (gnus-request-article article group (current-buffer)) | |
13806 (progn | |
13807 (and gnus-keep-backlog | |
13808 (numberp article) | |
13809 (gnus-backlog-enter-article | |
13810 group article (current-buffer))) | |
13811 'article)))) | |
13812 ;; It was a pseudo. | |
13813 (t article))) | |
13814 | |
13815 ;; Take the article from the original article buffer | |
13816 ;; and place it in the buffer it's supposed to be in. | |
13817 (when (and (get-buffer gnus-article-buffer) | |
13818 ;;(numberp article) | |
13819 (equal (buffer-name (current-buffer)) | |
13820 (buffer-name (get-buffer gnus-article-buffer)))) | |
13821 (save-excursion | |
13822 (if (get-buffer gnus-original-article-buffer) | |
13823 (set-buffer (get-buffer gnus-original-article-buffer)) | |
13824 (set-buffer (get-buffer-create gnus-original-article-buffer)) | |
13825 (buffer-disable-undo (current-buffer)) | |
13826 (setq major-mode 'gnus-original-article-mode) | |
13827 (setq buffer-read-only t) | |
13828 (gnus-add-current-to-buffer-list)) | |
13829 (let (buffer-read-only) | |
13830 (erase-buffer) | |
13831 (insert-buffer-substring gnus-article-buffer)) | |
13832 (setq gnus-original-article (cons group article)))) | |
13833 | |
13834 ;; Update sparse articles. | |
13835 (when (and do-update-line | |
13836 (or (numberp article) | |
13837 (stringp article))) | |
13838 (let ((buf (current-buffer))) | |
13839 (set-buffer gnus-summary-buffer) | |
13840 (gnus-summary-update-article do-update-line) | |
13841 (gnus-summary-goto-subject do-update-line nil t) | |
13842 (set-window-point (get-buffer-window (current-buffer) t) | |
13843 (point)) | |
13844 (set-buffer buf)))))) | |
13845 | |
13846 (defun gnus-read-header (id &optional header) | |
13847 "Read the headers of article ID and enter them into the Gnus system." | |
13848 (let ((group gnus-newsgroup-name) | |
13849 (gnus-override-method | |
13850 (and (gnus-news-group-p gnus-newsgroup-name) | |
13851 gnus-refer-article-method)) | |
13852 where) | |
13853 ;; First we check to see whether the header in question is already | |
13854 ;; fetched. | |
13855 (if (stringp id) | |
13856 ;; This is a Message-ID. | |
13857 (setq header (or header (gnus-id-to-header id))) | |
13858 ;; This is an article number. | |
13859 (setq header (or header (gnus-summary-article-header id)))) | |
13860 (if (and header | |
13861 (not (memq (mail-header-number header) gnus-newsgroup-sparse))) | |
13862 ;; We have found the header. | |
13863 header | |
13864 ;; We have to really fetch the header to this article. | |
13865 (when (setq where (gnus-request-head id group)) | |
13866 (save-excursion | |
13867 (set-buffer nntp-server-buffer) | |
13868 (goto-char (point-max)) | |
13869 (insert ".\n") | |
13870 (goto-char (point-min)) | |
13871 (insert "211 ") | |
13872 (princ (cond | |
13873 ((numberp id) id) | |
13874 ((cdr where) (cdr where)) | |
13875 (header (mail-header-number header)) | |
13876 (t gnus-reffed-article-number)) | |
13877 (current-buffer)) | |
13878 (insert " Article retrieved.\n")) | |
13879 ;(when (and header | |
13880 ; (memq (mail-header-number header) gnus-newsgroup-sparse)) | |
13881 ; (setcar (gnus-id-to-thread id) nil)) | |
13882 (if (not (setq header (car (gnus-get-newsgroup-headers)))) | |
13883 () ; Malformed head. | |
13884 (unless (memq (mail-header-number header) gnus-newsgroup-sparse) | |
13885 (if (and (stringp id) | |
13886 (not (string= (gnus-group-real-name group) | |
13887 (car where)))) | |
13888 ;; If we fetched by Message-ID and the article came | |
13889 ;; from a different group, we fudge some bogus article | |
13890 ;; numbers for this article. | |
13891 (mail-header-set-number header gnus-reffed-article-number)) | |
13892 (decf gnus-reffed-article-number) | |
13893 (gnus-remove-header (mail-header-number header)) | |
13894 (push header gnus-newsgroup-headers) | |
13895 (setq gnus-current-headers header) | |
13896 (push (mail-header-number header) gnus-newsgroup-limit)) | |
13897 header))))) | |
13898 | |
13899 (defun gnus-remove-header (number) | |
13900 "Remove header NUMBER from `gnus-newsgroup-headers'." | |
13901 (if (and gnus-newsgroup-headers | |
13902 (= number (mail-header-number (car gnus-newsgroup-headers)))) | |
13903 (pop gnus-newsgroup-headers) | |
13904 (let ((headers gnus-newsgroup-headers)) | |
13905 (while (and (cdr headers) | |
13906 (not (= number (mail-header-number (cadr headers))))) | |
13907 (pop headers)) | |
13908 (when (cdr headers) | |
13909 (setcdr headers (cddr headers)))))) | |
13910 | |
13911 (defun gnus-article-prepare (article &optional all-headers header) | |
13912 "Prepare ARTICLE in article mode buffer. | |
13913 ARTICLE should either be an article number or a Message-ID. | |
13914 If ARTICLE is an id, HEADER should be the article headers. | |
13915 If ALL-HEADERS is non-nil, no headers are hidden." | |
13916 (save-excursion | |
13917 ;; Make sure we start in a summary buffer. | |
13918 (unless (eq major-mode 'gnus-summary-mode) | |
13919 (set-buffer gnus-summary-buffer)) | |
13920 (setq gnus-summary-buffer (current-buffer)) | |
13921 ;; Make sure the connection to the server is alive. | |
13922 (unless (gnus-server-opened | |
13923 (gnus-find-method-for-group gnus-newsgroup-name)) | |
13924 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name)) | |
13925 (gnus-request-group gnus-newsgroup-name t)) | |
13926 (let* ((article (if header (mail-header-number header) article)) | |
13927 (summary-buffer (current-buffer)) | |
13928 (internal-hook gnus-article-internal-prepare-hook) | |
13929 (group gnus-newsgroup-name) | |
13930 result) | |
13931 (save-excursion | |
13932 (gnus-article-setup-buffer) | |
13933 (set-buffer gnus-article-buffer) | |
13934 ;; Deactivate active regions. | |
13935 (when (and (boundp 'transient-mark-mode) | |
13936 transient-mark-mode) | |
13937 (setq mark-active nil)) | |
13938 (if (not (setq result (let ((buffer-read-only nil)) | |
13939 (gnus-request-article-this-buffer | |
13940 article group)))) | |
13941 ;; There is no such article. | |
13942 (save-excursion | |
13943 (when (and (numberp article) | |
13944 (not (memq article gnus-newsgroup-sparse))) | |
13945 (setq gnus-article-current | |
13946 (cons gnus-newsgroup-name article)) | |
13947 (set-buffer gnus-summary-buffer) | |
13948 (setq gnus-current-article article) | |
13949 (gnus-summary-mark-article article gnus-canceled-mark)) | |
13950 (unless (memq article gnus-newsgroup-sparse) | |
13951 (gnus-error | |
13952 1 "No such article (may have expired or been canceled)"))) | |
13953 (if (or (eq result 'pseudo) (eq result 'nneething)) | |
13954 (progn | |
13955 (save-excursion | |
13956 (set-buffer summary-buffer) | |
13957 (setq gnus-last-article gnus-current-article | |
13958 gnus-newsgroup-history (cons gnus-current-article | |
13959 gnus-newsgroup-history) | |
13960 gnus-current-article 0 | |
13961 gnus-current-headers nil | |
13962 gnus-article-current nil) | |
13963 (if (eq result 'nneething) | |
13964 (gnus-configure-windows 'summary) | |
13965 (gnus-configure-windows 'article)) | |
13966 (gnus-set-global-variables)) | |
13967 (gnus-set-mode-line 'article)) | |
13968 ;; The result from the `request' was an actual article - | |
13969 ;; or at least some text that is now displayed in the | |
13970 ;; article buffer. | |
13971 (if (and (numberp article) | |
13972 (not (eq article gnus-current-article))) | |
13973 ;; Seems like a new article has been selected. | |
13974 ;; `gnus-current-article' must be an article number. | |
13975 (save-excursion | |
13976 (set-buffer summary-buffer) | |
13977 (setq gnus-last-article gnus-current-article | |
13978 gnus-newsgroup-history (cons gnus-current-article | |
13979 gnus-newsgroup-history) | |
13980 gnus-current-article article | |
13981 gnus-current-headers | |
13982 (gnus-summary-article-header gnus-current-article) | |
13983 gnus-article-current | |
13984 (cons gnus-newsgroup-name gnus-current-article)) | |
13985 (unless (vectorp gnus-current-headers) | |
13986 (setq gnus-current-headers nil)) | |
13987 (gnus-summary-show-thread) | |
13988 (run-hooks 'gnus-mark-article-hook) | |
13989 (gnus-set-mode-line 'summary) | |
13990 (and (gnus-visual-p 'article-highlight 'highlight) | |
13991 (run-hooks 'gnus-visual-mark-article-hook)) | |
13992 ;; Set the global newsgroup variables here. | |
13993 ;; Suggested by Jim Sisolak | |
13994 ;; <sisolak@trans4.neep.wisc.edu>. | |
13995 (gnus-set-global-variables) | |
13996 (setq gnus-have-all-headers | |
13997 (or all-headers gnus-show-all-headers)) | |
13998 (and gnus-use-cache | |
13999 (vectorp (gnus-summary-article-header article)) | |
14000 (gnus-cache-possibly-enter-article | |
14001 group article | |
14002 (gnus-summary-article-header article) | |
14003 (memq article gnus-newsgroup-marked) | |
14004 (memq article gnus-newsgroup-dormant) | |
14005 (memq article gnus-newsgroup-unreads))))) | |
14006 (when (or (numberp article) | |
14007 (stringp article)) | |
14008 ;; Hooks for getting information from the article. | |
14009 ;; This hook must be called before being narrowed. | |
14010 (let (buffer-read-only) | |
14011 (run-hooks 'internal-hook) | |
14012 (run-hooks 'gnus-article-prepare-hook) | |
14013 ;; Decode MIME message. | |
14014 (if gnus-show-mime | |
14015 (if (or (not gnus-strict-mime) | |
14016 (gnus-fetch-field "Mime-Version")) | |
14017 (funcall gnus-show-mime-method) | |
14018 (funcall gnus-decode-encoded-word-method))) | |
14019 ;; Perform the article display hooks. | |
14020 (run-hooks 'gnus-article-display-hook)) | |
14021 ;; Do page break. | |
14022 (goto-char (point-min)) | |
14023 (and gnus-break-pages (gnus-narrow-to-page))) | |
14024 (gnus-set-mode-line 'article) | |
14025 (gnus-configure-windows 'article) | |
14026 (goto-char (point-min)) | |
14027 t)))))) | |
14028 | |
14029 (defun gnus-article-show-all-headers () | |
14030 "Show all article headers in article mode buffer." | |
14031 (save-excursion | |
14032 (gnus-article-setup-buffer) | |
14033 (set-buffer gnus-article-buffer) | |
14034 (let ((buffer-read-only nil)) | |
14035 (gnus-unhide-text (point-min) (point-max))))) | |
14036 | |
14037 (defun gnus-article-hide-headers-if-wanted () | |
14038 "Hide unwanted headers if `gnus-have-all-headers' is nil. | |
14039 Provided for backwards compatibility." | |
14040 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers) | |
14041 gnus-inhibit-hiding | |
14042 (gnus-article-hide-headers))) | |
14043 | |
14044 (defsubst gnus-article-header-rank () | |
14045 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'." | |
14046 (let ((list gnus-sorted-header-list) | |
14047 (i 0)) | |
14048 (while list | |
14049 (when (looking-at (car list)) | |
14050 (setq list nil)) | |
14051 (setq list (cdr list)) | |
14052 (incf i)) | |
14053 i)) | |
14054 | |
14055 (defun gnus-article-hide-headers (&optional arg delete) | |
14056 "Toggle whether to hide unwanted headers and possibly sort them as well. | |
14057 If given a negative prefix, always show; if given a positive prefix, | |
14058 always hide." | |
14059 (interactive (gnus-hidden-arg)) | |
14060 (if (gnus-article-check-hidden-text 'headers arg) | |
14061 ;; Show boring headers as well. | |
14062 (gnus-article-show-hidden-text 'boring-headers) | |
14063 ;; This function might be inhibited. | |
14064 (unless gnus-inhibit-hiding | |
14065 (save-excursion | |
14066 (set-buffer gnus-article-buffer) | |
14067 (save-restriction | |
14068 (let ((buffer-read-only nil) | |
14069 (props (nconc (list 'gnus-type 'headers) | |
14070 gnus-hidden-properties)) | |
14071 (max (1+ (length gnus-sorted-header-list))) | |
14072 (ignored (when (not (stringp gnus-visible-headers)) | |
14073 (cond ((stringp gnus-ignored-headers) | |
14074 gnus-ignored-headers) | |
14075 ((listp gnus-ignored-headers) | |
14076 (mapconcat 'identity gnus-ignored-headers | |
14077 "\\|"))))) | |
14078 (visible | |
14079 (cond ((stringp gnus-visible-headers) | |
14080 gnus-visible-headers) | |
14081 ((and gnus-visible-headers | |
14082 (listp gnus-visible-headers)) | |
14083 (mapconcat 'identity gnus-visible-headers "\\|")))) | |
14084 (inhibit-point-motion-hooks t) | |
14085 want-list beg) | |
14086 ;; First we narrow to just the headers. | |
14087 (widen) | |
14088 (goto-char (point-min)) | |
14089 ;; Hide any "From " lines at the beginning of (mail) articles. | |
14090 (while (looking-at "From ") | |
14091 (forward-line 1)) | |
14092 (unless (bobp) | |
14093 (if delete | |
14094 (delete-region (point-min) (point)) | |
14095 (gnus-hide-text (point-min) (point) props))) | |
14096 ;; Then treat the rest of the header lines. | |
14097 (narrow-to-region | |
14098 (point) | |
14099 (progn (search-forward "\n\n" nil t) (forward-line -1) (point))) | |
14100 ;; Then we use the two regular expressions | |
14101 ;; `gnus-ignored-headers' and `gnus-visible-headers' to | |
14102 ;; select which header lines is to remain visible in the | |
14103 ;; article buffer. | |
14104 (goto-char (point-min)) | |
14105 (while (re-search-forward "^[^ \t]*:" nil t) | |
14106 (beginning-of-line) | |
14107 ;; We add the headers we want to keep to a list and delete | |
14108 ;; them from the buffer. | |
14109 (gnus-put-text-property | |
14110 (point) (1+ (point)) 'message-rank | |
14111 (if (or (and visible (looking-at visible)) | |
14112 (and ignored | |
14113 (not (looking-at ignored)))) | |
14114 (gnus-article-header-rank) | |
14115 (+ 2 max))) | |
14116 (forward-line 1)) | |
14117 (message-sort-headers-1) | |
14118 (when (setq beg (text-property-any | |
14119 (point-min) (point-max) 'message-rank (+ 2 max))) | |
14120 ;; We make the unwanted headers invisible. | |
14121 (if delete | |
14122 (delete-region beg (point-max)) | |
14123 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>. | |
14124 (gnus-hide-text-type beg (point-max) 'headers)) | |
14125 ;; Work around XEmacs lossage. | |
14126 (gnus-put-text-property (point-min) beg 'invisible nil)))))))) | |
14127 | |
14128 (defun gnus-article-hide-boring-headers (&optional arg) | |
14129 "Toggle hiding of headers that aren't very interesting. | |
14130 If given a negative prefix, always show; if given a positive prefix, | |
14131 always hide." | |
14132 (interactive (gnus-hidden-arg)) | |
14133 (unless (gnus-article-check-hidden-text 'boring-headers arg) | |
14134 (save-excursion | |
14135 (set-buffer gnus-article-buffer) | |
14136 (save-restriction | |
14137 (let ((buffer-read-only nil) | |
14138 (list gnus-boring-article-headers) | |
14139 (inhibit-point-motion-hooks t) | |
14140 elem) | |
14141 (nnheader-narrow-to-headers) | |
14142 (while list | |
14143 (setq elem (pop list)) | |
14144 (goto-char (point-min)) | |
14145 (cond | |
14146 ;; Hide empty headers. | |
14147 ((eq elem 'empty) | |
14148 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t) | |
14149 (forward-line -1) | |
14150 (gnus-hide-text-type | |
14151 (progn (beginning-of-line) (point)) | |
14152 (progn | |
14153 (end-of-line) | |
14154 (if (re-search-forward "^[^ \t]" nil t) | |
14155 (match-beginning 0) | |
14156 (point-max))) | |
14157 'boring-headers))) | |
14158 ;; Hide boring Newsgroups header. | |
14159 ((eq elem 'newsgroups) | |
14160 (when (equal (message-fetch-field "newsgroups") | |
14161 (gnus-group-real-name gnus-newsgroup-name)) | |
14162 (gnus-article-hide-header "newsgroups"))) | |
14163 ((eq elem 'followup-to) | |
14164 (when (equal (message-fetch-field "followup-to") | |
14165 (message-fetch-field "newsgroups")) | |
14166 (gnus-article-hide-header "followup-to"))) | |
14167 ((eq elem 'reply-to) | |
14168 (let ((from (message-fetch-field "from")) | |
14169 (reply-to (message-fetch-field "reply-to"))) | |
14170 (when (and | |
14171 from reply-to | |
14172 (equal | |
14173 (nth 1 (funcall gnus-extract-address-components from)) | |
14174 (nth 1 (funcall gnus-extract-address-components | |
14175 reply-to)))) | |
14176 (gnus-article-hide-header "reply-to")))) | |
14177 ((eq elem 'date) | |
14178 (let ((date (message-fetch-field "date"))) | |
14179 (when (and date | |
14180 (< (gnus-days-between date (current-time-string)) | |
14181 4)) | |
14182 (gnus-article-hide-header "date"))))))))))) | |
14183 | |
14184 (defun gnus-article-hide-header (header) | |
14185 (save-excursion | |
14186 (goto-char (point-min)) | |
14187 (when (re-search-forward (concat "^" header ":") nil t) | |
14188 (gnus-hide-text-type | |
14189 (progn (beginning-of-line) (point)) | |
14190 (progn | |
14191 (end-of-line) | |
14192 (if (re-search-forward "^[^ \t]" nil t) | |
14193 (match-beginning 0) | |
14194 (point-max))) | |
14195 'boring-headers)))) | |
14196 | |
14197 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>. | |
14198 (defun gnus-article-treat-overstrike () | |
14199 "Translate overstrikes into bold text." | |
14200 (interactive) | |
14201 (save-excursion | |
14202 (set-buffer gnus-article-buffer) | |
14203 (let ((buffer-read-only nil)) | |
14204 (while (search-forward "\b" nil t) | |
14205 (let ((next (following-char)) | |
14206 (previous (char-after (- (point) 2)))) | |
14207 (cond | |
14208 ((eq next previous) | |
14209 (gnus-put-text-property (- (point) 2) (point) 'invisible t) | |
14210 (gnus-put-text-property (point) (1+ (point)) 'face 'bold)) | |
14211 ((eq next ?_) | |
14212 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t) | |
14213 (gnus-put-text-property | |
14214 (- (point) 2) (1- (point)) 'face 'underline)) | |
14215 ((eq previous ?_) | |
14216 (gnus-put-text-property (- (point) 2) (point) 'invisible t) | |
14217 (gnus-put-text-property | |
14218 (point) (1+ (point)) 'face 'underline)))))))) | |
14219 | |
14220 (defun gnus-article-word-wrap () | |
14221 "Format too long lines." | |
14222 (interactive) | |
14223 (save-excursion | |
14224 (set-buffer gnus-article-buffer) | |
14225 (let ((buffer-read-only nil)) | |
14226 (widen) | |
14227 (goto-char (point-min)) | |
14228 (search-forward "\n\n" nil t) | |
14229 (end-of-line 1) | |
14230 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$") | |
14231 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?") | |
14232 (adaptive-fill-mode t)) | |
14233 (while (not (eobp)) | |
14234 (and (>= (current-column) (min fill-column (window-width))) | |
14235 (/= (preceding-char) ?:) | |
14236 (fill-paragraph nil)) | |
14237 (end-of-line 2)))))) | |
14238 | |
14239 (defun gnus-article-remove-cr () | |
14240 "Remove carriage returns from an article." | |
14241 (interactive) | |
14242 (save-excursion | |
14243 (set-buffer gnus-article-buffer) | |
14244 (let ((buffer-read-only nil)) | |
14245 (goto-char (point-min)) | |
14246 (while (search-forward "\r" nil t) | |
14247 (replace-match "" t t))))) | |
14248 | |
14249 (defun gnus-article-remove-trailing-blank-lines () | |
14250 "Remove all trailing blank lines from the article." | |
14251 (interactive) | |
14252 (save-excursion | |
14253 (set-buffer gnus-article-buffer) | |
14254 (let ((buffer-read-only nil)) | |
14255 (goto-char (point-max)) | |
14256 (delete-region | |
14257 (point) | |
14258 (progn | |
14259 (while (looking-at "^[ \t]*$") | |
14260 (forward-line -1)) | |
14261 (forward-line 1) | |
14262 (point)))))) | |
14263 | |
14264 (defun gnus-article-display-x-face (&optional force) | |
14265 "Look for an X-Face header and display it if present." | |
14266 (interactive (list 'force)) | |
14267 (save-excursion | |
14268 (set-buffer gnus-article-buffer) | |
14269 ;; Delete the old process, if any. | |
14270 (when (process-status "gnus-x-face") | |
14271 (delete-process "gnus-x-face")) | |
14272 (let ((inhibit-point-motion-hooks t) | |
14273 (case-fold-search nil) | |
14274 from) | |
14275 (save-restriction | |
14276 (nnheader-narrow-to-headers) | |
14277 (setq from (message-fetch-field "from")) | |
14278 (goto-char (point-min)) | |
14279 (when (and gnus-article-x-face-command | |
14280 (or force | |
14281 ;; Check whether this face is censored. | |
14282 (not gnus-article-x-face-too-ugly) | |
14283 (and gnus-article-x-face-too-ugly from | |
14284 (not (string-match gnus-article-x-face-too-ugly | |
14285 from)))) | |
14286 ;; Has to be present. | |
14287 (re-search-forward "^X-Face: " nil t)) | |
14288 ;; We now have the area of the buffer where the X-Face is stored. | |
14289 (let ((beg (point)) | |
14290 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t)))) | |
14291 ;; We display the face. | |
14292 (if (symbolp gnus-article-x-face-command) | |
14293 ;; The command is a lisp function, so we call it. | |
14294 (if (gnus-functionp gnus-article-x-face-command) | |
14295 (funcall gnus-article-x-face-command beg end) | |
14296 (error "%s is not a function" gnus-article-x-face-command)) | |
14297 ;; The command is a string, so we interpret the command | |
14298 ;; as a, well, command, and fork it off. | |
14299 (let ((process-connection-type nil)) | |
14300 (process-kill-without-query | |
14301 (start-process | |
14302 "gnus-x-face" nil shell-file-name shell-command-switch | |
14303 gnus-article-x-face-command)) | |
14304 (process-send-region "gnus-x-face" beg end) | |
14305 (process-send-eof "gnus-x-face"))))))))) | |
14306 | |
14307 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522) | |
14308 (defun gnus-decode-rfc1522 () | |
14309 "Hack to remove QP encoding from headers." | |
14310 (let ((case-fold-search t) | |
14311 (inhibit-point-motion-hooks t) | |
14312 (buffer-read-only nil) | |
14313 string) | |
14314 (save-restriction | |
14315 (narrow-to-region | |
14316 (goto-char (point-min)) | |
14317 (or (search-forward "\n\n" nil t) (point-max))) | |
14318 | |
14319 (goto-char (point-min)) | |
14320 (while (re-search-forward | |
14321 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t) | |
14322 (setq string (match-string 1)) | |
14323 (narrow-to-region (match-beginning 0) (match-end 0)) | |
14324 (delete-region (point-min) (point-max)) | |
14325 (insert string) | |
14326 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max)) | |
14327 (subst-char-in-region (point-min) (point-max) ?_ ? ) | |
14328 (widen) | |
14329 (goto-char (point-min)))))) | |
14330 | |
14331 (defun gnus-article-de-quoted-unreadable (&optional force) | |
14332 "Do a naive translation of a quoted-printable-encoded article. | |
14333 This is in no way, shape or form meant as a replacement for real MIME | |
14334 processing, but is simply a stop-gap measure until MIME support is | |
14335 written. | |
14336 If FORCE, decode the article whether it is marked as quoted-printable | |
14337 or not." | |
14338 (interactive (list 'force)) | |
14339 (save-excursion | |
14340 (set-buffer gnus-article-buffer) | |
14341 (let ((case-fold-search t) | |
14342 (buffer-read-only nil) | |
14343 (type (gnus-fetch-field "content-transfer-encoding"))) | |
14344 (gnus-decode-rfc1522) | |
14345 (when (or force | |
14346 (and type (string-match "quoted-printable" (downcase type)))) | |
14347 (goto-char (point-min)) | |
14348 (search-forward "\n\n" nil 'move) | |
14349 (gnus-mime-decode-quoted-printable (point) (point-max)))))) | |
14350 | |
14351 (defun gnus-mime-decode-quoted-printable (from to) | |
14352 "Decode Quoted-Printable in the region between FROM and TO." | |
14353 (interactive "r") | |
14354 (goto-char from) | |
14355 (while (search-forward "=" to t) | |
14356 (cond ((eq (following-char) ?\n) | |
14357 (delete-char -1) | |
14358 (delete-char 1)) | |
14359 ((looking-at "[0-9A-F][0-9A-F]") | |
14360 (subst-char-in-region | |
14361 (1- (point)) (point) ?= | |
14362 (hexl-hex-string-to-integer | |
14363 (buffer-substring (point) (+ 2 (point))))) | |
14364 (delete-char 2)) | |
14365 ((looking-at "=") | |
14366 (delete-char 1)) | |
14367 ((gnus-message 3 "Malformed MIME quoted-printable message"))))) | |
14368 | |
14369 (defun gnus-article-hide-pgp (&optional arg) | |
14370 "Toggle hiding of any PGP headers and signatures in the current article. | |
14371 If given a negative prefix, always show; if given a positive prefix, | |
14372 always hide." | |
14373 (interactive (gnus-hidden-arg)) | |
14374 (unless (gnus-article-check-hidden-text 'pgp arg) | |
14375 (save-excursion | |
14376 (set-buffer gnus-article-buffer) | |
14377 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties)) | |
14378 buffer-read-only beg end) | |
14379 (widen) | |
14380 (goto-char (point-min)) | |
14381 ;; Hide the "header". | |
14382 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t) | |
14383 (gnus-hide-text (match-beginning 0) (match-end 0) props)) | |
14384 (setq beg (point)) | |
14385 ;; Hide the actual signature. | |
14386 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t) | |
14387 (setq end (1+ (match-beginning 0))) | |
14388 (gnus-hide-text | |
14389 end | |
14390 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t) | |
14391 (match-end 0) | |
14392 ;; Perhaps we shouldn't hide to the end of the buffer | |
14393 ;; if there is no end to the signature? | |
14394 (point-max)) | |
14395 props)) | |
14396 ;; Hide "- " PGP quotation markers. | |
14397 (when (and beg end) | |
14398 (narrow-to-region beg end) | |
14399 (goto-char (point-min)) | |
14400 (while (re-search-forward "^- " nil t) | |
14401 (gnus-hide-text (match-beginning 0) (match-end 0) props)) | |
14402 (widen)))))) | |
14403 | |
14404 (defun gnus-article-hide-pem (&optional arg) | |
14405 "Toggle hiding of any PEM headers and signatures in the current article. | |
14406 If given a negative prefix, always show; if given a positive prefix, | |
14407 always hide." | |
14408 (interactive (gnus-hidden-arg)) | |
14409 (unless (gnus-article-check-hidden-text 'pem arg) | |
14410 (save-excursion | |
14411 (set-buffer gnus-article-buffer) | |
14412 (let ((props (nconc (list 'gnus-type 'pem) gnus-hidden-properties)) | |
14413 buffer-read-only end) | |
14414 (widen) | |
14415 (goto-char (point-min)) | |
14416 ;; hide the horrendously ugly "header". | |
14417 (and (search-forward "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n" | |
14418 nil | |
14419 t) | |
14420 (setq end (1+ (match-beginning 0))) | |
14421 (gnus-hide-text | |
14422 end | |
14423 (if (search-forward "\n\n" nil t) | |
14424 (match-end 0) | |
14425 (point-max)) | |
14426 props)) | |
14427 ;; hide the trailer as well | |
14428 (and (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n" | |
14429 nil | |
14430 t) | |
14431 (gnus-hide-text (match-beginning 0) (match-end 0) props)))))) | |
14432 | |
14433 (defun gnus-article-hide-signature (&optional arg) | |
14434 "Hide the signature in the current article. | |
14435 If given a negative prefix, always show; if given a positive prefix, | |
14436 always hide." | |
14437 (interactive (gnus-hidden-arg)) | |
14438 (unless (gnus-article-check-hidden-text 'signature arg) | |
14439 (save-excursion | |
14440 (set-buffer gnus-article-buffer) | |
14441 (save-restriction | |
14442 (let ((buffer-read-only nil)) | |
14443 (when (gnus-narrow-to-signature) | |
14444 (gnus-hide-text-type (point-min) (point-max) 'signature))))))) | |
14445 | |
14446 (defun gnus-article-strip-leading-blank-lines () | |
14447 "Remove all blank lines from the beginning of the article." | |
14448 (interactive) | |
14449 (save-excursion | |
14450 (set-buffer gnus-article-buffer) | |
14451 (let (buffer-read-only) | |
14452 (goto-char (point-min)) | |
14453 (when (search-forward "\n\n" nil t) | |
14454 (while (looking-at "[ \t]$") | |
14455 (gnus-delete-line)))))) | |
14456 | |
14457 (defvar mime::preview/content-list) | |
14458 (defvar mime::preview-content-info/point-min) | |
14459 (defun gnus-narrow-to-signature () | |
14460 "Narrow to the signature." | |
14461 (widen) | |
14462 (if (and (boundp 'mime::preview/content-list) | |
14463 mime::preview/content-list) | |
14464 (let ((pcinfo (car (last mime::preview/content-list)))) | |
14465 (condition-case () | |
14466 (narrow-to-region | |
14467 (funcall (intern "mime::preview-content-info/point-min") pcinfo) | |
14468 (point-max)) | |
14469 (error nil)))) | |
14470 (goto-char (point-max)) | |
14471 (when (re-search-backward gnus-signature-separator nil t) | |
14472 (forward-line 1) | |
14473 (when (or (null gnus-signature-limit) | |
14474 (and (numberp gnus-signature-limit) | |
14475 (< (- (point-max) (point)) gnus-signature-limit)) | |
14476 (and (gnus-functionp gnus-signature-limit) | |
14477 (funcall gnus-signature-limit)) | |
14478 (and (stringp gnus-signature-limit) | |
14479 (not (re-search-forward gnus-signature-limit nil t)))) | |
14480 (narrow-to-region (point) (point-max)) | |
14481 t))) | |
14482 | |
14483 (defun gnus-hidden-arg () | |
14484 "Return the current prefix arg as a number, or 0 if no prefix." | |
14485 (list (if current-prefix-arg | |
14486 (prefix-numeric-value current-prefix-arg) | |
14487 0))) | |
14488 | |
14489 (defun gnus-article-check-hidden-text (type arg) | |
14490 "Return nil if hiding is necessary. | |
14491 Arg can be nil or a number. Nil and positive means hide, negative | |
14492 means show, 0 means toggle." | |
14493 (save-excursion | |
14494 (set-buffer gnus-article-buffer) | |
14495 (let ((hide (gnus-article-hidden-text-p type))) | |
14496 (cond | |
14497 ((or (null arg) | |
14498 (> arg 0)) | |
14499 nil) | |
14500 ((< arg 0) | |
14501 (gnus-article-show-hidden-text type)) | |
14502 (t | |
14503 (if (eq hide 'hidden) | |
14504 (gnus-article-show-hidden-text type) | |
14505 nil)))))) | |
14506 | |
14507 (defun gnus-article-hidden-text-p (type) | |
14508 "Say whether the current buffer contains hidden text of type TYPE." | |
14509 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type))) | |
14510 (when pos | |
14511 (if (get-text-property pos 'invisible) | |
14512 'hidden | |
14513 'shown)))) | |
14514 | |
14515 (defun gnus-article-hide (&optional arg force) | |
14516 "Hide all the gruft in the current article. | |
14517 This means that PGP stuff, signatures, cited text and (some) | |
14518 headers will be hidden. | |
14519 If given a prefix, show the hidden text instead." | |
14520 (interactive (list current-prefix-arg 'force)) | |
14521 (gnus-article-hide-headers arg) | |
14522 (gnus-article-hide-pgp arg) | |
14523 (gnus-article-hide-citation-maybe arg force) | |
14524 (gnus-article-hide-signature arg)) | |
14525 | |
14526 (defun gnus-article-show-hidden-text (type &optional hide) | |
14527 "Show all hidden text of type TYPE. | |
14528 If HIDE, hide the text instead." | |
14529 (save-excursion | |
14530 (set-buffer gnus-article-buffer) | |
14531 (let ((buffer-read-only nil) | |
14532 (inhibit-point-motion-hooks t) | |
14533 (beg (point-min))) | |
14534 (while (gnus-goto-char (text-property-any | |
14535 beg (point-max) 'gnus-type type)) | |
14536 (setq beg (point)) | |
14537 (forward-char) | |
14538 (if hide | |
14539 (gnus-hide-text beg (point) gnus-hidden-properties) | |
14540 (gnus-unhide-text beg (point))) | |
14541 (setq beg (point))) | |
14542 t))) | |
14543 | |
14544 (defvar gnus-article-time-units | |
14545 `((year . ,(* 365.25 24 60 60)) | |
14546 (week . ,(* 7 24 60 60)) | |
14547 (day . ,(* 24 60 60)) | |
14548 (hour . ,(* 60 60)) | |
14549 (minute . 60) | |
14550 (second . 1)) | |
14551 "Mapping from time units to seconds.") | |
14552 | |
14553 (defun gnus-article-date-ut (&optional type highlight) | |
14554 "Convert DATE date to universal time in the current article. | |
14555 If TYPE is `local', convert to local time; if it is `lapsed', output | |
14556 how much time has lapsed since DATE." | |
14557 (interactive (list 'ut t)) | |
14558 (let* ((header (or gnus-current-headers | |
14559 (gnus-summary-article-header) "")) | |
14560 (date (and (vectorp header) (mail-header-date header))) | |
14561 (date-regexp "^Date: \\|^X-Sent: ") | |
14562 (now (current-time)) | |
14563 (inhibit-point-motion-hooks t) | |
14564 bface eface) | |
14565 (when (and date (not (string= date ""))) | |
14566 (save-excursion | |
14567 (set-buffer gnus-article-buffer) | |
14568 (save-restriction | |
14569 (nnheader-narrow-to-headers) | |
14570 (let ((buffer-read-only nil)) | |
14571 ;; Delete any old Date headers. | |
14572 (if (re-search-forward date-regexp nil t) | |
14573 (progn | |
14574 (setq bface (get-text-property (gnus-point-at-bol) 'face) | |
14575 eface (get-text-property (1- (gnus-point-at-eol)) | |
14576 'face)) | |
14577 (message-remove-header date-regexp t) | |
14578 (beginning-of-line)) | |
14579 (goto-char (point-max))) | |
14580 (insert (gnus-make-date-line date type)) | |
14581 ;; Do highlighting. | |
14582 (forward-line -1) | |
14583 (when (and (gnus-visual-p 'article-highlight 'highlight) | |
14584 (looking-at "\\([^:]+\\): *\\(.*\\)$")) | |
14585 (gnus-put-text-property (match-beginning 1) (match-end 1) | |
14586 'face bface) | |
14587 (gnus-put-text-property (match-beginning 2) (match-end 2) | |
14588 'face eface)))))))) | |
14589 | |
14590 (defun gnus-make-date-line (date type) | |
14591 "Return a DATE line of TYPE." | |
14592 (cond | |
14593 ;; Convert to the local timezone. We have to slap a | |
14594 ;; `condition-case' round the calls to the timezone | |
14595 ;; functions since they aren't particularly resistant to | |
14596 ;; buggy dates. | |
14597 ((eq type 'local) | |
14598 (concat "Date: " (condition-case () | |
14599 (timezone-make-date-arpa-standard date) | |
14600 (error date)) | |
14601 "\n")) | |
14602 ;; Convert to Universal Time. | |
14603 ((eq type 'ut) | |
14604 (concat "Date: " | |
14605 (condition-case () | |
14606 (timezone-make-date-arpa-standard date nil "UT") | |
14607 (error date)) | |
14608 "\n")) | |
14609 ;; Get the original date from the article. | |
14610 ((eq type 'original) | |
14611 (concat "Date: " date "\n")) | |
14612 ;; Do an X-Sent lapsed format. | |
14613 ((eq type 'lapsed) | |
14614 ;; If the date is seriously mangled, the timezone | |
14615 ;; functions are liable to bug out, so we condition-case | |
14616 ;; the entire thing. | |
14617 (let* ((now (current-time)) | |
14618 (real-time | |
14619 (condition-case () | |
14620 (gnus-time-minus | |
14621 (gnus-encode-date | |
14622 (timezone-make-date-arpa-standard | |
14623 (current-time-string now) | |
14624 (current-time-zone now) "UT")) | |
14625 (gnus-encode-date | |
14626 (timezone-make-date-arpa-standard | |
14627 date nil "UT"))) | |
14628 (error '(0 0)))) | |
14629 (real-sec (+ (* (float (car real-time)) 65536) | |
14630 (cadr real-time))) | |
14631 (sec (abs real-sec)) | |
14632 num prev) | |
14633 (cond | |
14634 ((equal real-time '(0 0)) | |
14635 "X-Sent: Unknown\n") | |
14636 ((zerop sec) | |
14637 "X-Sent: Now\n") | |
14638 (t | |
14639 (concat | |
14640 "X-Sent: " | |
14641 ;; This is a bit convoluted, but basically we go | |
14642 ;; through the time units for years, weeks, etc, | |
14643 ;; and divide things to see whether that results | |
14644 ;; in positive answers. | |
14645 (mapconcat | |
14646 (lambda (unit) | |
14647 (if (zerop (setq num (ffloor (/ sec (cdr unit))))) | |
14648 ;; The (remaining) seconds are too few to | |
14649 ;; be divided into this time unit. | |
14650 "" | |
14651 ;; It's big enough, so we output it. | |
14652 (setq sec (- sec (* num (cdr unit)))) | |
14653 (prog1 | |
14654 (concat (if prev ", " "") (int-to-string | |
14655 (floor num)) | |
14656 " " (symbol-name (car unit)) | |
14657 (if (> num 1) "s" "")) | |
14658 (setq prev t)))) | |
14659 gnus-article-time-units "") | |
14660 ;; If dates are odd, then it might appear like the | |
14661 ;; article was sent in the future. | |
14662 (if (> real-sec 0) | |
14663 " ago\n" | |
14664 " in the future\n")))))) | |
14665 (t | |
14666 (error "Unknown conversion type: %s" type)))) | |
14667 | |
14668 (defun gnus-article-date-local (&optional highlight) | |
14669 "Convert the current article date to the local timezone." | |
14670 (interactive (list t)) | |
14671 (gnus-article-date-ut 'local highlight)) | |
14672 | |
14673 (defun gnus-article-date-original (&optional highlight) | |
14674 "Convert the current article date to what it was originally. | |
14675 This is only useful if you have used some other date conversion | |
14676 function and want to see what the date was before converting." | |
14677 (interactive (list t)) | |
14678 (gnus-article-date-ut 'original highlight)) | |
14679 | |
14680 (defun gnus-article-date-lapsed (&optional highlight) | |
14681 "Convert the current article date to time lapsed since it was sent." | |
14682 (interactive (list t)) | |
14683 (gnus-article-date-ut 'lapsed highlight)) | |
14684 | |
14685 (defun gnus-article-maybe-highlight () | |
14686 "Do some article highlighting if `gnus-visual' is non-nil." | |
14687 (if (gnus-visual-p 'article-highlight 'highlight) | |
14688 (gnus-article-highlight-some))) | |
14689 | |
14690 ;;; Article savers. | |
14691 | |
14692 (defun gnus-output-to-rmail (file-name) | |
14693 "Append the current article to an Rmail file named FILE-NAME." | |
14694 (require 'rmail) | |
14695 ;; Most of these codes are borrowed from rmailout.el. | |
14696 (setq file-name (expand-file-name file-name)) | |
14697 (setq rmail-default-rmail-file file-name) | |
14698 (let ((artbuf (current-buffer)) | |
14699 (tmpbuf (get-buffer-create " *Gnus-output*"))) | |
14700 (save-excursion | |
14701 (or (get-file-buffer file-name) | |
14702 (file-exists-p file-name) | |
14703 (if (gnus-yes-or-no-p | |
14704 (concat "\"" file-name "\" does not exist, create it? ")) | |
14705 (let ((file-buffer (create-file-buffer file-name))) | |
14706 (save-excursion | |
14707 (set-buffer file-buffer) | |
14708 (rmail-insert-rmail-file-header) | |
14709 (let ((require-final-newline nil)) | |
14710 (write-region (point-min) (point-max) file-name t 1))) | |
14711 (kill-buffer file-buffer)) | |
14712 (error "Output file does not exist"))) | |
14713 (set-buffer tmpbuf) | |
14714 (buffer-disable-undo (current-buffer)) | |
14715 (erase-buffer) | |
14716 (insert-buffer-substring artbuf) | |
14717 (gnus-convert-article-to-rmail) | |
14718 ;; Decide whether to append to a file or to an Emacs buffer. | |
14719 (let ((outbuf (get-file-buffer file-name))) | |
14720 (if (not outbuf) | |
14721 (append-to-file (point-min) (point-max) file-name) | |
14722 ;; File has been visited, in buffer OUTBUF. | |
14723 (set-buffer outbuf) | |
14724 (let ((buffer-read-only nil) | |
14725 (msg (and (boundp 'rmail-current-message) | |
14726 (symbol-value 'rmail-current-message)))) | |
14727 ;; If MSG is non-nil, buffer is in RMAIL mode. | |
14728 (if msg | |
14729 (progn (widen) | |
14730 (narrow-to-region (point-max) (point-max)))) | |
14731 (insert-buffer-substring tmpbuf) | |
14732 (if msg | |
14733 (progn | |
14734 (goto-char (point-min)) | |
14735 (widen) | |
14736 (search-backward "\^_") | |
14737 (narrow-to-region (point) (point-max)) | |
14738 (goto-char (1+ (point-min))) | |
14739 (rmail-count-new-messages t) | |
14740 (rmail-show-message msg))))))) | |
14741 (kill-buffer tmpbuf))) | |
14742 | |
14743 (defun gnus-output-to-file (file-name) | |
14744 "Append the current article to a file named FILE-NAME." | |
14745 (let ((artbuf (current-buffer))) | |
14746 (nnheader-temp-write nil | |
14747 (insert-buffer-substring artbuf) | |
14748 ;; Append newline at end of the buffer as separator, and then | |
14749 ;; save it to file. | |
14750 (goto-char (point-max)) | |
14751 (insert "\n") | |
14752 (append-to-file (point-min) (point-max) file-name)))) | |
14753 | |
14754 (defun gnus-convert-article-to-rmail () | |
14755 "Convert article in current buffer to Rmail message format." | |
14756 (let ((buffer-read-only nil)) | |
14757 ;; Convert article directly into Babyl format. | |
14758 ;; Suggested by Rob Austein <sra@lcs.mit.edu> | |
14759 (goto-char (point-min)) | |
14760 (insert "\^L\n0, unseen,,\n*** EOOH ***\n") | |
14761 (while (search-forward "\n\^_" nil t) ;single char | |
14762 (replace-match "\n^_" t t)) ;2 chars: "^" and "_" | |
14763 (goto-char (point-max)) | |
14764 (insert "\^_"))) | |
14765 | |
14766 (defun gnus-narrow-to-page (&optional arg) | |
14767 "Narrow the article buffer to a page. | |
14768 If given a numerical ARG, move forward ARG pages." | |
14769 (interactive "P") | |
14770 (setq arg (if arg (prefix-numeric-value arg) 0)) | |
14771 (save-excursion | |
14772 (set-buffer gnus-article-buffer) | |
14773 (goto-char (point-min)) | |
14774 (widen) | |
14775 (when (gnus-visual-p 'page-marker) | |
14776 (let ((buffer-read-only nil)) | |
14777 (gnus-remove-text-with-property 'gnus-prev) | |
14778 (gnus-remove-text-with-property 'gnus-next))) | |
14779 (when | |
14780 (cond ((< arg 0) | |
14781 (re-search-backward page-delimiter nil 'move (1+ (abs arg)))) | |
14782 ((> arg 0) | |
14783 (re-search-forward page-delimiter nil 'move arg))) | |
14784 (goto-char (match-end 0))) | |
14785 (narrow-to-region | |
14786 (point) | |
14787 (if (re-search-forward page-delimiter nil 'move) | |
14788 (match-beginning 0) | |
14789 (point))) | |
14790 (when (and (gnus-visual-p 'page-marker) | |
14791 (not (= (point-min) 1))) | |
14792 (save-excursion | |
14793 (goto-char (point-min)) | |
14794 (gnus-insert-prev-page-button))) | |
14795 (when (and (gnus-visual-p 'page-marker) | |
14796 (not (= (1- (point-max)) (buffer-size)))) | |
14797 (save-excursion | |
14798 (goto-char (point-max)) | |
14799 (gnus-insert-next-page-button))))) | |
14800 | |
14801 ;; Article mode commands | |
14802 | |
14803 (defun gnus-article-goto-next-page () | |
14804 "Show the next page of the article." | |
14805 (interactive) | |
14806 (when (gnus-article-next-page) | |
14807 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n)))) | |
14808 | |
14809 (defun gnus-article-goto-prev-page () | |
14810 "Show the next page of the article." | |
14811 (interactive) | |
14812 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n)) | |
14813 (gnus-article-prev-page nil))) | |
14814 | |
14815 (defun gnus-article-next-page (&optional lines) | |
14816 "Show the next page of the current article. | |
14817 If end of article, return non-nil. Otherwise return nil. | |
14818 Argument LINES specifies lines to be scrolled up." | |
14819 (interactive "p") | |
14820 (move-to-window-line -1) | |
14821 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo) | |
14822 (if (save-excursion | |
14823 (end-of-line) | |
14824 (and (pos-visible-in-window-p) ;Not continuation line. | |
14825 (eobp))) | |
14826 ;; Nothing in this page. | |
14827 (if (or (not gnus-break-pages) | |
14828 (save-excursion | |
14829 (save-restriction | |
14830 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer? | |
14831 t ;Nothing more. | |
14832 (gnus-narrow-to-page 1) ;Go to next page. | |
14833 nil) | |
14834 ;; More in this page. | |
14835 (condition-case () | |
14836 (scroll-up lines) | |
14837 (end-of-buffer | |
14838 ;; Long lines may cause an end-of-buffer error. | |
14839 (goto-char (point-max)))) | |
14840 (move-to-window-line 0) | |
14841 nil)) | |
14842 | |
14843 (defun gnus-article-prev-page (&optional lines) | |
14844 "Show previous page of current article. | |
14845 Argument LINES specifies lines to be scrolled down." | |
14846 (interactive "p") | |
14847 (move-to-window-line 0) | |
14848 (if (and gnus-break-pages | |
14849 (bobp) | |
14850 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer? | |
14851 (progn | |
14852 (gnus-narrow-to-page -1) ;Go to previous page. | |
14853 (goto-char (point-max)) | |
14854 (recenter -1)) | |
14855 (prog1 | |
14856 (condition-case () | |
14857 (scroll-down lines) | |
14858 (error nil)) | |
14859 (move-to-window-line 0)))) | |
14860 | |
14861 (defun gnus-article-refer-article () | |
14862 "Read article specified by message-id around point." | |
14863 (interactive) | |
14864 (let ((point (point))) | |
14865 (search-forward ">" nil t) ;Move point to end of "<....>". | |
14866 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t) | |
14867 (let ((message-id (match-string 1))) | |
14868 (goto-char point) | |
14869 (set-buffer gnus-summary-buffer) | |
14870 (gnus-summary-refer-article message-id)) | |
14871 (goto-char (point)) | |
14872 (error "No references around point")))) | |
14873 | |
14874 (defun gnus-article-show-summary () | |
14875 "Reconfigure windows to show summary buffer." | |
14876 (interactive) | |
14877 (gnus-configure-windows 'article) | |
14878 (gnus-summary-goto-subject gnus-current-article)) | |
14879 | |
14880 (defun gnus-article-describe-briefly () | |
14881 "Describe article mode commands briefly." | |
14882 (interactive) | |
14883 (gnus-message 6 | |
14884 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help"))) | |
14885 | |
14886 (defun gnus-article-summary-command () | |
14887 "Execute the last keystroke in the summary buffer." | |
14888 (interactive) | |
14889 (let ((obuf (current-buffer)) | |
14890 (owin (current-window-configuration)) | |
14891 func) | |
14892 (switch-to-buffer gnus-summary-buffer 'norecord) | |
14893 (setq func (lookup-key (current-local-map) (this-command-keys))) | |
14894 (call-interactively func) | |
14895 (set-buffer obuf) | |
14896 (set-window-configuration owin) | |
14897 (set-window-point (get-buffer-window (current-buffer)) (point)))) | |
14898 | |
14899 (defun gnus-article-summary-command-nosave () | |
14900 "Execute the last keystroke in the summary buffer." | |
14901 (interactive) | |
14902 (let (func) | |
14903 (pop-to-buffer gnus-summary-buffer 'norecord) | |
14904 (setq func (lookup-key (current-local-map) (this-command-keys))) | |
14905 (call-interactively func))) | |
14906 | |
14907 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window) | |
14908 "Read a summary buffer key sequence and execute it from the article buffer." | |
14909 (interactive "P") | |
14910 (let ((nosaves | |
14911 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F" | |
14912 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP" | |
14913 "=" "^" "\M-^" "|")) | |
14914 (nosave-but-article | |
14915 '("A\r")) | |
14916 keys) | |
14917 (save-excursion | |
14918 (set-buffer gnus-summary-buffer) | |
14919 (push (or key last-command-event) unread-command-events) | |
14920 (setq keys (read-key-sequence nil))) | |
14921 (message "") | |
14922 | |
14923 (if (or (member keys nosaves) | |
14924 (member keys nosave-but-article)) | |
14925 (let (func) | |
14926 (save-window-excursion | |
14927 (pop-to-buffer gnus-summary-buffer 'norecord) | |
14928 (setq func (lookup-key (current-local-map) keys))) | |
14929 (if (not func) | |
14930 (ding) | |
14931 (set-buffer gnus-summary-buffer) | |
14932 (call-interactively func)) | |
14933 (when (member keys nosave-but-article) | |
14934 (pop-to-buffer gnus-article-buffer 'norecord))) | |
14935 (let ((obuf (current-buffer)) | |
14936 (owin (current-window-configuration)) | |
14937 (opoint (point)) | |
14938 func in-buffer) | |
14939 (if not-restore-window | |
14940 (pop-to-buffer gnus-summary-buffer 'norecord) | |
14941 (switch-to-buffer gnus-summary-buffer 'norecord)) | |
14942 (setq in-buffer (current-buffer)) | |
14943 (if (setq func (lookup-key (current-local-map) keys)) | |
14944 (call-interactively func) | |
14945 (ding)) | |
14946 (when (eq in-buffer (current-buffer)) | |
14947 (set-buffer obuf) | |
14948 (unless not-restore-window | |
14949 (set-window-configuration owin)) | |
14950 (set-window-point (get-buffer-window (current-buffer)) opoint)))))) | |
14951 | |
14952 | |
14953 ;;; | |
14954 ;;; Kill file handling. | |
14955 ;;; | |
14956 | |
14957 ;;;###autoload | |
14958 (defalias 'gnus-batch-kill 'gnus-batch-score) | |
14959 ;;;###autoload | |
14960 (defun gnus-batch-score () | |
14961 "Run batched scoring. | |
14962 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ... | |
14963 Newsgroups is a list of strings in Bnews format. If you want to score | |
14964 the comp hierarchy, you'd say \"comp.all\". If you would not like to | |
14965 score the alt hierarchy, you'd say \"!alt.all\"." | |
14966 (interactive) | |
14967 (let* ((yes-and-no | |
14968 (gnus-newsrc-parse-options | |
14969 (apply (function concat) | |
14970 (mapcar (lambda (g) (concat g " ")) | |
14971 command-line-args-left)))) | |
14972 (gnus-expert-user t) | |
14973 (nnmail-spool-file nil) | |
14974 (gnus-use-dribble-file nil) | |
14975 (yes (car yes-and-no)) | |
14976 (no (cdr yes-and-no)) | |
14977 group newsrc entry | |
14978 ;; Disable verbose message. | |
14979 gnus-novice-user gnus-large-newsgroup) | |
14980 ;; Eat all arguments. | |
14981 (setq command-line-args-left nil) | |
14982 ;; Start Gnus. | |
14983 (gnus) | |
14984 ;; Apply kills to specified newsgroups in command line arguments. | |
14985 (setq newsrc (cdr gnus-newsrc-alist)) | |
14986 (while newsrc | |
14987 (setq group (caar newsrc)) | |
14988 (setq entry (gnus-gethash group gnus-newsrc-hashtb)) | |
14989 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed) | |
14990 (and (car entry) | |
14991 (or (eq (car entry) t) | |
14992 (not (zerop (car entry))))) | |
14993 (if yes (string-match yes group) t) | |
14994 (or (null no) (not (string-match no group)))) | |
14995 (progn | |
14996 (gnus-summary-read-group group nil t nil t) | |
14997 (and (eq (current-buffer) (get-buffer gnus-summary-buffer)) | |
14998 (gnus-summary-exit)))) | |
14999 (setq newsrc (cdr newsrc))) | |
15000 ;; Exit Emacs. | |
15001 (switch-to-buffer gnus-group-buffer) | |
15002 (gnus-group-save-newsrc))) | |
15003 | |
15004 (defun gnus-apply-kill-file () | |
15005 "Apply a kill file to the current newsgroup. | |
15006 Returns the number of articles marked as read." | |
15007 (if (or (file-exists-p (gnus-newsgroup-kill-file nil)) | |
15008 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name))) | |
15009 (gnus-apply-kill-file-internal) | |
15010 0)) | |
15011 | |
15012 (defun gnus-kill-save-kill-buffer () | |
15013 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name))) | |
15014 (when (get-file-buffer file) | |
15015 (save-excursion | |
15016 (set-buffer (get-file-buffer file)) | |
15017 (and (buffer-modified-p) (save-buffer)) | |
15018 (kill-buffer (current-buffer)))))) | |
15019 | |
15020 (defvar gnus-kill-file-name "KILL" | |
15021 "Suffix of the kill files.") | |
15022 | |
15023 (defun gnus-newsgroup-kill-file (newsgroup) | |
15024 "Return the name of a kill file name for NEWSGROUP. | |
15025 If NEWSGROUP is nil, return the global kill file name instead." | |
15026 (cond | |
15027 ;; The global KILL file is placed at top of the directory. | |
15028 ((or (null newsgroup) | |
15029 (string-equal newsgroup "")) | |
15030 (expand-file-name gnus-kill-file-name | |
15031 gnus-kill-files-directory)) | |
15032 ;; Append ".KILL" to newsgroup name. | |
15033 ((gnus-use-long-file-name 'not-kill) | |
15034 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup) | |
15035 "." gnus-kill-file-name) | |
15036 gnus-kill-files-directory)) | |
15037 ;; Place "KILL" under the hierarchical directory. | |
15038 (t | |
15039 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup) | |
15040 "/" gnus-kill-file-name) | |
15041 gnus-kill-files-directory)))) | |
15042 | |
15043 | |
15044 ;;; | |
15045 ;;; Dribble file | |
15046 ;;; | |
15047 | |
15048 (defvar gnus-dribble-ignore nil) | |
15049 (defvar gnus-dribble-eval-file nil) | |
15050 | |
15051 (defun gnus-dribble-file-name () | |
15052 "Return the dribble file for the current .newsrc." | |
15053 (concat | |
15054 (if gnus-dribble-directory | |
15055 (concat (file-name-as-directory gnus-dribble-directory) | |
15056 (file-name-nondirectory gnus-current-startup-file)) | |
15057 gnus-current-startup-file) | |
15058 "-dribble")) | |
15059 | |
15060 (defun gnus-dribble-enter (string) | |
15061 "Enter STRING into the dribble buffer." | |
15062 (if (and (not gnus-dribble-ignore) | |
15063 gnus-dribble-buffer | |
15064 (buffer-name gnus-dribble-buffer)) | |
15065 (let ((obuf (current-buffer))) | |
15066 (set-buffer gnus-dribble-buffer) | |
15067 (insert string "\n") | |
15068 (set-window-point (get-buffer-window (current-buffer)) (point-max)) | |
15069 (bury-buffer gnus-dribble-buffer) | |
15070 (set-buffer obuf)))) | |
15071 | |
15072 (defun gnus-dribble-read-file () | |
15073 "Read the dribble file from disk." | |
15074 (let ((dribble-file (gnus-dribble-file-name))) | |
15075 (save-excursion | |
15076 (set-buffer (setq gnus-dribble-buffer | |
15077 (get-buffer-create | |
15078 (file-name-nondirectory dribble-file)))) | |
15079 (gnus-add-current-to-buffer-list) | |
15080 (erase-buffer) | |
15081 (setq buffer-file-name dribble-file) | |
15082 (auto-save-mode t) | |
15083 (buffer-disable-undo (current-buffer)) | |
15084 (bury-buffer (current-buffer)) | |
15085 (set-buffer-modified-p nil) | |
15086 (let ((auto (make-auto-save-file-name)) | |
15087 (gnus-dribble-ignore t) | |
15088 modes) | |
15089 (when (or (file-exists-p auto) (file-exists-p dribble-file)) | |
15090 ;; Load whichever file is newest -- the auto save file | |
15091 ;; or the "real" file. | |
15092 (if (file-newer-than-file-p auto dribble-file) | |
15093 (insert-file-contents auto) | |
15094 (insert-file-contents dribble-file)) | |
15095 (unless (zerop (buffer-size)) | |
15096 (set-buffer-modified-p t)) | |
15097 ;; Set the file modes to reflect the .newsrc file modes. | |
15098 (save-buffer) | |
15099 (when (and (file-exists-p gnus-current-startup-file) | |
15100 (setq modes (file-modes gnus-current-startup-file))) | |
15101 (set-file-modes dribble-file modes)) | |
15102 ;; Possibly eval the file later. | |
15103 (when (gnus-y-or-n-p | |
15104 "Auto-save file exists. Do you want to read it? ") | |
15105 (setq gnus-dribble-eval-file t))))))) | |
15106 | |
15107 (defun gnus-dribble-eval-file () | |
15108 (when gnus-dribble-eval-file | |
15109 (setq gnus-dribble-eval-file nil) | |
15110 (save-excursion | |
15111 (let ((gnus-dribble-ignore t)) | |
15112 (set-buffer gnus-dribble-buffer) | |
15113 (eval-buffer (current-buffer)))))) | |
15114 | |
15115 (defun gnus-dribble-delete-file () | |
15116 (when (file-exists-p (gnus-dribble-file-name)) | |
15117 (delete-file (gnus-dribble-file-name))) | |
15118 (when gnus-dribble-buffer | |
15119 (save-excursion | |
15120 (set-buffer gnus-dribble-buffer) | |
15121 (let ((auto (make-auto-save-file-name))) | |
15122 (if (file-exists-p auto) | |
15123 (delete-file auto)) | |
15124 (erase-buffer) | |
15125 (set-buffer-modified-p nil))))) | |
15126 | |
15127 (defun gnus-dribble-save () | |
15128 (when (and gnus-dribble-buffer | |
15129 (buffer-name gnus-dribble-buffer)) | |
15130 (save-excursion | |
15131 (set-buffer gnus-dribble-buffer) | |
15132 (save-buffer)))) | |
15133 | |
15134 (defun gnus-dribble-clear () | |
15135 (when (gnus-buffer-exists-p gnus-dribble-buffer) | |
15136 (save-excursion | |
15137 (set-buffer gnus-dribble-buffer) | |
15138 (erase-buffer) | |
15139 (set-buffer-modified-p nil) | |
15140 (setq buffer-saved-size (buffer-size))))) | |
15141 | |
15142 | |
15143 ;;; | |
15144 ;;; Server Communication | |
15145 ;;; | |
15146 | |
15147 (defun gnus-start-news-server (&optional confirm) | |
15148 "Open a method for getting news. | |
15149 If CONFIRM is non-nil, the user will be asked for an NNTP server." | |
15150 (let (how) | |
15151 (if gnus-current-select-method | |
15152 ;; Stream is already opened. | |
15153 nil | |
15154 ;; Open NNTP server. | |
15155 (if (null gnus-nntp-service) (setq gnus-nntp-server nil)) | |
15156 (if confirm | |
15157 (progn | |
15158 ;; Read server name with completion. | |
15159 (setq gnus-nntp-server | |
15160 (completing-read "NNTP server: " | |
15161 (mapcar (lambda (server) (list server)) | |
15162 (cons (list gnus-nntp-server) | |
15163 gnus-secondary-servers)) | |
15164 nil nil gnus-nntp-server)))) | |
15165 | |
15166 (if (and gnus-nntp-server | |
15167 (stringp gnus-nntp-server) | |
15168 (not (string= gnus-nntp-server ""))) | |
15169 (setq gnus-select-method | |
15170 (cond ((or (string= gnus-nntp-server "") | |
15171 (string= gnus-nntp-server "::")) | |
15172 (list 'nnspool (system-name))) | |
15173 ((string-match "^:" gnus-nntp-server) | |
15174 (list 'nnmh gnus-nntp-server | |
15175 (list 'nnmh-directory | |
15176 (file-name-as-directory | |
15177 (expand-file-name | |
15178 (concat "~/" (substring | |
15179 gnus-nntp-server 1))))) | |
15180 (list 'nnmh-get-new-mail nil))) | |
15181 (t | |
15182 (list 'nntp gnus-nntp-server))))) | |
15183 | |
15184 (setq how (car gnus-select-method)) | |
15185 (cond ((eq how 'nnspool) | |
15186 (require 'nnspool) | |
15187 (gnus-message 5 "Looking up local news spool...")) | |
15188 ((eq how 'nnmh) | |
15189 (require 'nnmh) | |
15190 (gnus-message 5 "Looking up mh spool...")) | |
15191 (t | |
15192 (require 'nntp))) | |
15193 (setq gnus-current-select-method gnus-select-method) | |
15194 (run-hooks 'gnus-open-server-hook) | |
15195 (or | |
15196 ;; gnus-open-server-hook might have opened it | |
15197 (gnus-server-opened gnus-select-method) | |
15198 (gnus-open-server gnus-select-method) | |
15199 (gnus-y-or-n-p | |
15200 (format | |
15201 "%s (%s) open error: '%s'. Continue? " | |
15202 (car gnus-select-method) (cadr gnus-select-method) | |
15203 (gnus-status-message gnus-select-method))) | |
15204 (gnus-error 1 "Couldn't open server on %s" | |
15205 (nth 1 gnus-select-method)))))) | |
15206 | |
15207 (defun gnus-check-group (group) | |
15208 "Try to make sure that the server where GROUP exists is alive." | |
15209 (let ((method (gnus-find-method-for-group group))) | |
15210 (or (gnus-server-opened method) | |
15211 (gnus-open-server method)))) | |
15212 | |
15213 (defun gnus-check-server (&optional method silent) | |
15214 "Check whether the connection to METHOD is down. | |
15215 If METHOD is nil, use `gnus-select-method'. | |
15216 If it is down, start it up (again)." | |
15217 (let ((method (or method gnus-select-method))) | |
15218 ;; Transform virtual server names into select methods. | |
15219 (when (stringp method) | |
15220 (setq method (gnus-server-to-method method))) | |
15221 (if (gnus-server-opened method) | |
15222 ;; The stream is already opened. | |
15223 t | |
15224 ;; Open the server. | |
15225 (unless silent | |
15226 (gnus-message 5 "Opening %s server%s..." (car method) | |
15227 (if (equal (nth 1 method) "") "" | |
15228 (format " on %s" (nth 1 method))))) | |
15229 (run-hooks 'gnus-open-server-hook) | |
15230 (prog1 | |
15231 (gnus-open-server method) | |
15232 (unless silent | |
15233 (message "")))))) | |
15234 | |
15235 (defun gnus-get-function (method function &optional noerror) | |
15236 "Return a function symbol based on METHOD and FUNCTION." | |
15237 ;; Translate server names into methods. | |
15238 (unless method | |
15239 (error "Attempted use of a nil select method")) | |
15240 (when (stringp method) | |
15241 (setq method (gnus-server-to-method method))) | |
15242 (let ((func (intern (format "%s-%s" (car method) function)))) | |
15243 ;; If the functions isn't bound, we require the backend in | |
15244 ;; question. | |
15245 (unless (fboundp func) | |
15246 (require (car method)) | |
15247 (when (and (not (fboundp func)) | |
15248 (not noerror)) | |
15249 ;; This backend doesn't implement this function. | |
15250 (error "No such function: %s" func))) | |
15251 func)) | |
15252 | |
15253 | |
15254 ;;; | |
15255 ;;; Interface functions to the backends. | |
15256 ;;; | |
15257 | |
15258 (defun gnus-open-server (method) | |
15259 "Open a connection to METHOD." | |
15260 (when (stringp method) | |
15261 (setq method (gnus-server-to-method method))) | |
15262 (let ((elem (assoc method gnus-opened-servers))) | |
15263 ;; If this method was previously denied, we just return nil. | |
15264 (if (eq (nth 1 elem) 'denied) | |
15265 (progn | |
15266 (gnus-message 1 "Denied server") | |
15267 nil) | |
15268 ;; Open the server. | |
15269 (let ((result | |
15270 (funcall (gnus-get-function method 'open-server) | |
15271 (nth 1 method) (nthcdr 2 method)))) | |
15272 ;; If this hasn't been opened before, we add it to the list. | |
15273 (unless elem | |
15274 (setq elem (list method nil) | |
15275 gnus-opened-servers (cons elem gnus-opened-servers))) | |
15276 ;; Set the status of this server. | |
15277 (setcar (cdr elem) (if result 'ok 'denied)) | |
15278 ;; Return the result from the "open" call. | |
15279 result)))) | |
15280 | |
15281 (defun gnus-close-server (method) | |
15282 "Close the connection to METHOD." | |
15283 (when (stringp method) | |
15284 (setq method (gnus-server-to-method method))) | |
15285 (funcall (gnus-get-function method 'close-server) (nth 1 method))) | |
15286 | |
15287 (defun gnus-request-list (method) | |
15288 "Request the active file from METHOD." | |
15289 (when (stringp method) | |
15290 (setq method (gnus-server-to-method method))) | |
15291 (funcall (gnus-get-function method 'request-list) (nth 1 method))) | |
15292 | |
15293 (defun gnus-request-list-newsgroups (method) | |
15294 "Request the newsgroups file from METHOD." | |
15295 (when (stringp method) | |
15296 (setq method (gnus-server-to-method method))) | |
15297 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method))) | |
15298 | |
15299 (defun gnus-request-newgroups (date method) | |
15300 "Request all new groups since DATE from METHOD." | |
15301 (when (stringp method) | |
15302 (setq method (gnus-server-to-method method))) | |
15303 (funcall (gnus-get-function method 'request-newgroups) | |
15304 date (nth 1 method))) | |
15305 | |
15306 (defun gnus-server-opened (method) | |
15307 "Check whether a connection to METHOD has been opened." | |
15308 (when (stringp method) | |
15309 (setq method (gnus-server-to-method method))) | |
15310 (funcall (gnus-get-function method 'server-opened) (nth 1 method))) | |
15311 | |
15312 (defun gnus-status-message (method) | |
15313 "Return the status message from METHOD. | |
15314 If METHOD is a string, it is interpreted as a group name. The method | |
15315 this group uses will be queried." | |
15316 (let ((method (if (stringp method) (gnus-find-method-for-group method) | |
15317 method))) | |
15318 (funcall (gnus-get-function method 'status-message) (nth 1 method)))) | |
15319 | |
15320 (defun gnus-request-group (group &optional dont-check method) | |
15321 "Request GROUP. If DONT-CHECK, no information is required." | |
15322 (let ((method (or method (gnus-find-method-for-group group)))) | |
15323 (when (stringp method) | |
15324 (setq method (gnus-server-to-method method))) | |
15325 (funcall (gnus-get-function method 'request-group) | |
15326 (gnus-group-real-name group) (nth 1 method) dont-check))) | |
15327 | |
15328 (defun gnus-request-asynchronous (group &optional articles) | |
15329 "Request that GROUP behave asynchronously. | |
15330 ARTICLES is the `data' of the group." | |
15331 (let ((method (gnus-find-method-for-group group))) | |
15332 (funcall (gnus-get-function method 'request-asynchronous) | |
15333 (gnus-group-real-name group) (nth 1 method) articles))) | |
15334 | |
15335 (defun gnus-list-active-group (group) | |
15336 "Request active information on GROUP." | |
15337 (let ((method (gnus-find-method-for-group group)) | |
15338 (func 'list-active-group)) | |
15339 (when (gnus-check-backend-function func group) | |
15340 (funcall (gnus-get-function method func) | |
15341 (gnus-group-real-name group) (nth 1 method))))) | |
15342 | |
15343 (defun gnus-request-group-description (group) | |
15344 "Request a description of GROUP." | |
15345 (let ((method (gnus-find-method-for-group group)) | |
15346 (func 'request-group-description)) | |
15347 (when (gnus-check-backend-function func group) | |
15348 (funcall (gnus-get-function method func) | |
15349 (gnus-group-real-name group) (nth 1 method))))) | |
15350 | |
15351 (defun gnus-close-group (group) | |
15352 "Request the GROUP be closed." | |
15353 (let ((method (gnus-find-method-for-group group))) | |
15354 (funcall (gnus-get-function method 'close-group) | |
15355 (gnus-group-real-name group) (nth 1 method)))) | |
15356 | |
15357 (defun gnus-retrieve-headers (articles group &optional fetch-old) | |
15358 "Request headers for ARTICLES in GROUP. | |
15359 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group." | |
15360 (let ((method (gnus-find-method-for-group group))) | |
15361 (if (and gnus-use-cache (numberp (car articles))) | |
15362 (gnus-cache-retrieve-headers articles group fetch-old) | |
15363 (funcall (gnus-get-function method 'retrieve-headers) | |
15364 articles (gnus-group-real-name group) (nth 1 method) | |
15365 fetch-old)))) | |
15366 | |
15367 (defun gnus-retrieve-groups (groups method) | |
15368 "Request active information on GROUPS from METHOD." | |
15369 (when (stringp method) | |
15370 (setq method (gnus-server-to-method method))) | |
15371 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method))) | |
15372 | |
15373 (defun gnus-request-type (group &optional article) | |
15374 "Return the type (`post' or `mail') of GROUP (and ARTICLE)." | |
15375 (let ((method (gnus-find-method-for-group group))) | |
15376 (if (not (gnus-check-backend-function 'request-type (car method))) | |
15377 'unknown | |
15378 (funcall (gnus-get-function method 'request-type) | |
15379 (gnus-group-real-name group) article)))) | |
15380 | |
15381 (defun gnus-request-update-mark (group article mark) | |
15382 "Return the type (`post' or `mail') of GROUP (and ARTICLE)." | |
15383 (let ((method (gnus-find-method-for-group group))) | |
15384 (if (not (gnus-check-backend-function 'request-update-mark (car method))) | |
15385 mark | |
15386 (funcall (gnus-get-function method 'request-update-mark) | |
15387 (gnus-group-real-name group) article mark)))) | |
15388 | |
15389 (defun gnus-request-article (article group &optional buffer) | |
15390 "Request the ARTICLE in GROUP. | |
15391 ARTICLE can either be an article number or an article Message-ID. | |
15392 If BUFFER, insert the article in that group." | |
15393 (let ((method (gnus-find-method-for-group group))) | |
15394 (funcall (gnus-get-function method 'request-article) | |
15395 article (gnus-group-real-name group) (nth 1 method) buffer))) | |
15396 | |
15397 (defun gnus-request-head (article group) | |
15398 "Request the head of ARTICLE in GROUP." | |
15399 (let* ((method (gnus-find-method-for-group group)) | |
15400 (head (gnus-get-function method 'request-head t))) | |
15401 (if (fboundp head) | |
15402 (funcall head article (gnus-group-real-name group) (nth 1 method)) | |
15403 (let ((res (gnus-request-article article group))) | |
15404 (when res | |
15405 (save-excursion | |
15406 (set-buffer nntp-server-buffer) | |
15407 (goto-char (point-min)) | |
15408 (when (search-forward "\n\n" nil t) | |
15409 (delete-region (1- (point)) (point-max))) | |
15410 (nnheader-fold-continuation-lines))) | |
15411 res)))) | |
15412 | |
15413 (defun gnus-request-body (article group) | |
15414 "Request the body of ARTICLE in GROUP." | |
15415 (let ((method (gnus-find-method-for-group group))) | |
15416 (funcall (gnus-get-function method 'request-body) | |
15417 article (gnus-group-real-name group) (nth 1 method)))) | |
15418 | |
15419 (defun gnus-request-post (method) | |
15420 "Post the current buffer using METHOD." | |
15421 (when (stringp method) | |
15422 (setq method (gnus-server-to-method method))) | |
15423 (funcall (gnus-get-function method 'request-post) (nth 1 method))) | |
15424 | |
15425 (defun gnus-request-scan (group method) | |
15426 "Request a SCAN being performed in GROUP from METHOD. | |
15427 If GROUP is nil, all groups on METHOD are scanned." | |
15428 (let ((method (if group (gnus-find-method-for-group group) method))) | |
15429 (funcall (gnus-get-function method 'request-scan) | |
15430 (and group (gnus-group-real-name group)) (nth 1 method)))) | |
15431 | |
15432 (defsubst gnus-request-update-info (info method) | |
15433 "Request that METHOD update INFO." | |
15434 (when (stringp method) | |
15435 (setq method (gnus-server-to-method method))) | |
15436 (when (gnus-check-backend-function 'request-update-info (car method)) | |
15437 (funcall (gnus-get-function method 'request-update-info) | |
15438 (gnus-group-real-name (gnus-info-group info)) | |
15439 info (nth 1 method)))) | |
15440 | |
15441 (defun gnus-request-expire-articles (articles group &optional force) | |
15442 (let ((method (gnus-find-method-for-group group))) | |
15443 (funcall (gnus-get-function method 'request-expire-articles) | |
15444 articles (gnus-group-real-name group) (nth 1 method) | |
15445 force))) | |
15446 | |
15447 (defun gnus-request-move-article | |
15448 (article group server accept-function &optional last) | |
15449 (let ((method (gnus-find-method-for-group group))) | |
15450 (funcall (gnus-get-function method 'request-move-article) | |
15451 article (gnus-group-real-name group) | |
15452 (nth 1 method) accept-function last))) | |
15453 | |
15454 (defun gnus-request-accept-article (group method &optional last) | |
15455 ;; Make sure there's a newline at the end of the article. | |
15456 (when (stringp method) | |
15457 (setq method (gnus-server-to-method method))) | |
15458 (when (and (not method) | |
15459 (stringp group)) | |
15460 (setq method (gnus-group-name-to-method group))) | |
15461 (goto-char (point-max)) | |
15462 (unless (bolp) | |
15463 (insert "\n")) | |
15464 (let ((func (car (or method (gnus-find-method-for-group group))))) | |
15465 (funcall (intern (format "%s-request-accept-article" func)) | |
15466 (if (stringp group) (gnus-group-real-name group) group) | |
15467 (cadr method) | |
15468 last))) | |
15469 | |
15470 (defun gnus-request-replace-article (article group buffer) | |
15471 (let ((func (car (gnus-find-method-for-group group)))) | |
15472 (funcall (intern (format "%s-request-replace-article" func)) | |
15473 article (gnus-group-real-name group) buffer))) | |
15474 | |
15475 (defun gnus-request-associate-buffer (group) | |
15476 (let ((method (gnus-find-method-for-group group))) | |
15477 (funcall (gnus-get-function method 'request-associate-buffer) | |
15478 (gnus-group-real-name group)))) | |
15479 | |
15480 (defun gnus-request-restore-buffer (article group) | |
15481 "Request a new buffer restored to the state of ARTICLE." | |
15482 (let ((method (gnus-find-method-for-group group))) | |
15483 (funcall (gnus-get-function method 'request-restore-buffer) | |
15484 article (gnus-group-real-name group) (nth 1 method)))) | |
15485 | |
15486 (defun gnus-request-create-group (group &optional method) | |
15487 (when (stringp method) | |
15488 (setq method (gnus-server-to-method method))) | |
15489 (let ((method (or method (gnus-find-method-for-group group)))) | |
15490 (funcall (gnus-get-function method 'request-create-group) | |
15491 (gnus-group-real-name group) (nth 1 method)))) | |
15492 | |
15493 (defun gnus-request-delete-group (group &optional force) | |
15494 (let ((method (gnus-find-method-for-group group))) | |
15495 (funcall (gnus-get-function method 'request-delete-group) | |
15496 (gnus-group-real-name group) force (nth 1 method)))) | |
15497 | |
15498 (defun gnus-request-rename-group (group new-name) | |
15499 (let ((method (gnus-find-method-for-group group))) | |
15500 (funcall (gnus-get-function method 'request-rename-group) | |
15501 (gnus-group-real-name group) | |
15502 (gnus-group-real-name new-name) (nth 1 method)))) | |
15503 | |
15504 (defun gnus-member-of-valid (symbol group) | |
15505 "Find out if GROUP has SYMBOL as part of its \"valid\" spec." | |
15506 (memq symbol (assoc | |
15507 (symbol-name (car (gnus-find-method-for-group group))) | |
15508 gnus-valid-select-methods))) | |
15509 | |
15510 (defun gnus-method-option-p (method option) | |
15511 "Return non-nil if select METHOD has OPTION as a parameter." | |
15512 (when (stringp method) | |
15513 (setq method (gnus-server-to-method method))) | |
15514 (memq option (assoc (format "%s" (car method)) | |
15515 gnus-valid-select-methods))) | |
15516 | |
15517 (defun gnus-server-extend-method (group method) | |
15518 ;; This function "extends" a virtual server. If the server is | |
15519 ;; "hello", and the select method is ("hello" (my-var "something")) | |
15520 ;; in the group "alt.alt", this will result in a new virtual server | |
15521 ;; called "hello+alt.alt". | |
15522 (let ((entry | |
15523 (gnus-copy-sequence | |
15524 (if (equal (car method) "native") gnus-select-method | |
15525 (cdr (assoc (car method) gnus-server-alist)))))) | |
15526 (setcar (cdr entry) (concat (nth 1 entry) "+" group)) | |
15527 (nconc entry (cdr method)))) | |
15528 | |
15529 (defun gnus-server-status (method) | |
15530 "Return the status of METHOD." | |
15531 (nth 1 (assoc method gnus-opened-servers))) | |
15532 | |
15533 (defun gnus-group-name-to-method (group) | |
15534 "Return a select method suitable for GROUP." | |
15535 (if (string-match ":" group) | |
15536 (let ((server (substring group 0 (match-beginning 0)))) | |
15537 (if (string-match "\\+" server) | |
15538 (list (intern (substring server 0 (match-beginning 0))) | |
15539 (substring server (match-end 0))) | |
15540 (list (intern server) ""))) | |
15541 gnus-select-method)) | |
15542 | |
15543 (defun gnus-find-method-for-group (group &optional info) | |
15544 "Find the select method that GROUP uses." | |
15545 (or gnus-override-method | |
15546 (and (not group) | |
15547 gnus-select-method) | |
15548 (let ((info (or info (gnus-get-info group))) | |
15549 method) | |
15550 (if (or (not info) | |
15551 (not (setq method (gnus-info-method info))) | |
15552 (equal method "native")) | |
15553 gnus-select-method | |
15554 (setq method | |
15555 (cond ((stringp method) | |
15556 (gnus-server-to-method method)) | |
15557 ((stringp (car method)) | |
15558 (gnus-server-extend-method group method)) | |
15559 (t | |
15560 method))) | |
15561 (cond ((equal (cadr method) "") | |
15562 method) | |
15563 ((null (cadr method)) | |
15564 (list (car method) "")) | |
15565 (t | |
15566 (gnus-server-add-address method))))))) | |
15567 | |
15568 (defun gnus-check-backend-function (func group) | |
15569 "Check whether GROUP supports function FUNC." | |
15570 (let ((method (if (stringp group) (car (gnus-find-method-for-group group)) | |
15571 group))) | |
15572 (fboundp (intern (format "%s-%s" method func))))) | |
15573 | |
15574 (defun gnus-methods-using (feature) | |
15575 "Find all methods that have FEATURE." | |
15576 (let ((valids gnus-valid-select-methods) | |
15577 outs) | |
15578 (while valids | |
15579 (if (memq feature (car valids)) | |
15580 (setq outs (cons (car valids) outs))) | |
15581 (setq valids (cdr valids))) | |
15582 outs)) | |
15583 | |
15584 | |
15585 ;;; | |
15586 ;;; Active & Newsrc File Handling | |
15587 ;;; | |
15588 | |
15589 (defun gnus-setup-news (&optional rawfile level dont-connect) | |
15590 "Setup news information. | |
15591 If RAWFILE is non-nil, the .newsrc file will also be read. | |
15592 If LEVEL is non-nil, the news will be set up at level LEVEL." | |
15593 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile))))) | |
15594 | |
15595 (when init | |
15596 ;; Clear some variables to re-initialize news information. | |
15597 (setq gnus-newsrc-alist nil | |
15598 gnus-active-hashtb nil) | |
15599 ;; Read the newsrc file and create `gnus-newsrc-hashtb'. | |
15600 (gnus-read-newsrc-file rawfile)) | |
15601 | |
15602 (when (and (not (assoc "archive" gnus-server-alist)) | |
15603 (gnus-archive-server-wanted-p)) | |
15604 (push (cons "archive" gnus-message-archive-method) | |
15605 gnus-server-alist)) | |
15606 | |
15607 ;; If we don't read the complete active file, we fill in the | |
15608 ;; hashtb here. | |
15609 (if (or (null gnus-read-active-file) | |
15610 (eq gnus-read-active-file 'some)) | |
15611 (gnus-update-active-hashtb-from-killed)) | |
15612 | |
15613 ;; Read the active file and create `gnus-active-hashtb'. | |
15614 ;; If `gnus-read-active-file' is nil, then we just create an empty | |
15615 ;; hash table. The partial filling out of the hash table will be | |
15616 ;; done in `gnus-get-unread-articles'. | |
15617 (and gnus-read-active-file | |
15618 (not level) | |
15619 (gnus-read-active-file)) | |
15620 | |
15621 (or gnus-active-hashtb | |
15622 (setq gnus-active-hashtb (make-vector 4095 0))) | |
15623 | |
15624 ;; Initialize the cache. | |
15625 (when gnus-use-cache | |
15626 (gnus-cache-open)) | |
15627 | |
15628 ;; Possibly eval the dribble file. | |
15629 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file)) | |
15630 | |
15631 ;; Slave Gnusii should then clear the dribble buffer. | |
15632 (when (and init gnus-slave) | |
15633 (gnus-dribble-clear)) | |
15634 | |
15635 (gnus-update-format-specifications) | |
15636 | |
15637 ;; See whether we need to read the description file. | |
15638 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format) | |
15639 (not gnus-description-hashtb) | |
15640 (not dont-connect) | |
15641 gnus-read-active-file) | |
15642 (gnus-read-all-descriptions-files)) | |
15643 | |
15644 ;; Find new newsgroups and treat them. | |
15645 (if (and init gnus-check-new-newsgroups (not level) | |
15646 (gnus-check-server gnus-select-method)) | |
15647 (gnus-find-new-newsgroups)) | |
15648 | |
15649 ;; We might read in new NoCeM messages here. | |
15650 (when (and gnus-use-nocem | |
15651 (not level) | |
15652 (not dont-connect)) | |
15653 (gnus-nocem-scan-groups)) | |
15654 | |
15655 ;; Find the number of unread articles in each non-dead group. | |
15656 (let ((gnus-read-active-file (and (not level) gnus-read-active-file))) | |
15657 (gnus-get-unread-articles level)) | |
15658 | |
15659 (if (and init gnus-check-bogus-newsgroups | |
15660 gnus-read-active-file (not level) | |
15661 (gnus-server-opened gnus-select-method)) | |
15662 (gnus-check-bogus-newsgroups)))) | |
15663 | |
15664 (defun gnus-find-new-newsgroups (&optional arg) | |
15665 "Search for new newsgroups and add them. | |
15666 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.' | |
15667 The `-n' option line from .newsrc is respected. | |
15668 If ARG (the prefix), use the `ask-server' method to query | |
15669 the server for new groups." | |
15670 (interactive "P") | |
15671 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups))) | |
15672 (null gnus-read-active-file) | |
15673 (eq gnus-read-active-file 'some)) | |
15674 'ask-server gnus-check-new-newsgroups))) | |
15675 (unless (gnus-check-first-time-used) | |
15676 (if (or (consp check) | |
15677 (eq check 'ask-server)) | |
15678 ;; Ask the server for new groups. | |
15679 (gnus-ask-server-for-new-groups) | |
15680 ;; Go through the active hashtb and look for new groups. | |
15681 (let ((groups 0) | |
15682 group new-newsgroups) | |
15683 (gnus-message 5 "Looking for new newsgroups...") | |
15684 (unless gnus-have-read-active-file | |
15685 (gnus-read-active-file)) | |
15686 (setq gnus-newsrc-last-checked-date (current-time-string)) | |
15687 (unless gnus-killed-hashtb | |
15688 (gnus-make-hashtable-from-killed)) | |
15689 ;; Go though every newsgroup in `gnus-active-hashtb' and compare | |
15690 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'. | |
15691 (mapatoms | |
15692 (lambda (sym) | |
15693 (if (or (null (setq group (symbol-name sym))) | |
15694 (not (boundp sym)) | |
15695 (null (symbol-value sym)) | |
15696 (gnus-gethash group gnus-killed-hashtb) | |
15697 (gnus-gethash group gnus-newsrc-hashtb)) | |
15698 () | |
15699 (let ((do-sub (gnus-matches-options-n group))) | |
15700 (cond | |
15701 ((eq do-sub 'subscribe) | |
15702 (setq groups (1+ groups)) | |
15703 (gnus-sethash group group gnus-killed-hashtb) | |
15704 (funcall gnus-subscribe-options-newsgroup-method group)) | |
15705 ((eq do-sub 'ignore) | |
15706 nil) | |
15707 (t | |
15708 (setq groups (1+ groups)) | |
15709 (gnus-sethash group group gnus-killed-hashtb) | |
15710 (if gnus-subscribe-hierarchical-interactive | |
15711 (setq new-newsgroups (cons group new-newsgroups)) | |
15712 (funcall gnus-subscribe-newsgroup-method group))))))) | |
15713 gnus-active-hashtb) | |
15714 (when new-newsgroups | |
15715 (gnus-subscribe-hierarchical-interactive new-newsgroups)) | |
15716 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
15717 (if (> groups 0) | |
15718 (gnus-message 6 "%d new newsgroup%s arrived." | |
15719 groups (if (> groups 1) "s have" " has")) | |
15720 (gnus-message 6 "No new newsgroups."))))))) | |
15721 | |
15722 (defun gnus-matches-options-n (group) | |
15723 ;; Returns `subscribe' if the group is to be unconditionally | |
15724 ;; subscribed, `ignore' if it is to be ignored, and nil if there is | |
15725 ;; no match for the group. | |
15726 | |
15727 ;; First we check the two user variables. | |
15728 (cond | |
15729 ((and gnus-options-subscribe | |
15730 (string-match gnus-options-subscribe group)) | |
15731 'subscribe) | |
15732 ((and gnus-auto-subscribed-groups | |
15733 (string-match gnus-auto-subscribed-groups group)) | |
15734 'subscribe) | |
15735 ((and gnus-options-not-subscribe | |
15736 (string-match gnus-options-not-subscribe group)) | |
15737 'ignore) | |
15738 ;; Then we go through the list that was retrieved from the .newsrc | |
15739 ;; file. This list has elements on the form | |
15740 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list | |
15741 ;; is in the reverse order of the options line) is returned. | |
15742 (t | |
15743 (let ((regs gnus-newsrc-options-n)) | |
15744 (while (and regs | |
15745 (not (string-match (caar regs) group))) | |
15746 (setq regs (cdr regs))) | |
15747 (and regs (cdar regs)))))) | |
15748 | |
15749 (defun gnus-ask-server-for-new-groups () | |
15750 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string))) | |
15751 (methods (cons gnus-select-method | |
15752 (nconc | |
15753 (when (gnus-archive-server-wanted-p) | |
15754 (list "archive")) | |
15755 (append | |
15756 (and (consp gnus-check-new-newsgroups) | |
15757 gnus-check-new-newsgroups) | |
15758 gnus-secondary-select-methods)))) | |
15759 (groups 0) | |
15760 (new-date (current-time-string)) | |
15761 group new-newsgroups got-new method hashtb | |
15762 gnus-override-subscribe-method) | |
15763 ;; Go through both primary and secondary select methods and | |
15764 ;; request new newsgroups. | |
15765 (while (setq method (gnus-server-get-method nil (pop methods))) | |
15766 (setq new-newsgroups nil) | |
15767 (setq gnus-override-subscribe-method method) | |
15768 (when (and (gnus-check-server method) | |
15769 (gnus-request-newgroups date method)) | |
15770 (save-excursion | |
15771 (setq got-new t) | |
15772 (setq hashtb (gnus-make-hashtable 100)) | |
15773 (set-buffer nntp-server-buffer) | |
15774 ;; Enter all the new groups into a hashtable. | |
15775 (gnus-active-to-gnus-format method hashtb 'ignore)) | |
15776 ;; Now all new groups from `method' are in `hashtb'. | |
15777 (mapatoms | |
15778 (lambda (group-sym) | |
15779 (if (or (null (setq group (symbol-name group-sym))) | |
15780 (not (boundp group-sym)) | |
15781 (null (symbol-value group-sym)) | |
15782 (gnus-gethash group gnus-newsrc-hashtb) | |
15783 (member group gnus-zombie-list) | |
15784 (member group gnus-killed-list)) | |
15785 ;; The group is already known. | |
15786 () | |
15787 ;; Make this group active. | |
15788 (when (symbol-value group-sym) | |
15789 (gnus-set-active group (symbol-value group-sym))) | |
15790 ;; Check whether we want it or not. | |
15791 (let ((do-sub (gnus-matches-options-n group))) | |
15792 (cond | |
15793 ((eq do-sub 'subscribe) | |
15794 (incf groups) | |
15795 (gnus-sethash group group gnus-killed-hashtb) | |
15796 (funcall gnus-subscribe-options-newsgroup-method group)) | |
15797 ((eq do-sub 'ignore) | |
15798 nil) | |
15799 (t | |
15800 (incf groups) | |
15801 (gnus-sethash group group gnus-killed-hashtb) | |
15802 (if gnus-subscribe-hierarchical-interactive | |
15803 (push group new-newsgroups) | |
15804 (funcall gnus-subscribe-newsgroup-method group))))))) | |
15805 hashtb)) | |
15806 (when new-newsgroups | |
15807 (gnus-subscribe-hierarchical-interactive new-newsgroups))) | |
15808 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
15809 (when (> groups 0) | |
15810 (gnus-message 6 "%d new newsgroup%s arrived." | |
15811 groups (if (> groups 1) "s have" " has"))) | |
15812 (and got-new (setq gnus-newsrc-last-checked-date new-date)) | |
15813 got-new)) | |
15814 | |
15815 (defun gnus-check-first-time-used () | |
15816 (if (or (> (length gnus-newsrc-alist) 1) | |
15817 (file-exists-p gnus-startup-file) | |
15818 (file-exists-p (concat gnus-startup-file ".el")) | |
15819 (file-exists-p (concat gnus-startup-file ".eld"))) | |
15820 nil | |
15821 (gnus-message 6 "First time user; subscribing you to default groups") | |
15822 (unless (gnus-read-active-file-p) | |
15823 (gnus-read-active-file)) | |
15824 (setq gnus-newsrc-last-checked-date (current-time-string)) | |
15825 (let ((groups gnus-default-subscribed-newsgroups) | |
15826 group) | |
15827 (if (eq groups t) | |
15828 nil | |
15829 (setq groups (or groups gnus-backup-default-subscribed-newsgroups)) | |
15830 (mapatoms | |
15831 (lambda (sym) | |
15832 (if (null (setq group (symbol-name sym))) | |
15833 () | |
15834 (let ((do-sub (gnus-matches-options-n group))) | |
15835 (cond | |
15836 ((eq do-sub 'subscribe) | |
15837 (gnus-sethash group group gnus-killed-hashtb) | |
15838 (funcall gnus-subscribe-options-newsgroup-method group)) | |
15839 ((eq do-sub 'ignore) | |
15840 nil) | |
15841 (t | |
15842 (setq gnus-killed-list (cons group gnus-killed-list))))))) | |
15843 gnus-active-hashtb) | |
15844 (while groups | |
15845 (if (gnus-active (car groups)) | |
15846 (gnus-group-change-level | |
15847 (car groups) gnus-level-default-subscribed gnus-level-killed)) | |
15848 (setq groups (cdr groups))) | |
15849 (gnus-group-make-help-group) | |
15850 (and gnus-novice-user | |
15851 (gnus-message 7 "`A k' to list killed groups")))))) | |
15852 | |
15853 (defun gnus-subscribe-group (group previous &optional method) | |
15854 (gnus-group-change-level | |
15855 (if method | |
15856 (list t group gnus-level-default-subscribed nil nil method) | |
15857 group) | |
15858 gnus-level-default-subscribed gnus-level-killed previous t)) | |
15859 | |
15860 ;; `gnus-group-change-level' is the fundamental function for changing | |
15861 ;; subscription levels of newsgroups. This might mean just changing | |
15862 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back | |
15863 ;; again, which subscribes/unsubscribes a group, which is equally | |
15864 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and | |
15865 ;; from 8-9 to 1-7 means that you remove the group from the list of | |
15866 ;; killed (or zombie) groups and add them to the (kinda) subscribed | |
15867 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8, | |
15868 ;; which is trivial. | |
15869 ;; ENTRY can either be a string (newsgroup name) or a list (if | |
15870 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST), | |
15871 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb' | |
15872 ;; entries. | |
15873 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and | |
15874 ;; PREVIOUS is the group (in hashtb entry format) to insert this group | |
15875 ;; after. | |
15876 (defun gnus-group-change-level (entry level &optional oldlevel | |
15877 previous fromkilled) | |
15878 (let (group info active num) | |
15879 ;; Glean what info we can from the arguments | |
15880 (if (consp entry) | |
15881 (if fromkilled (setq group (nth 1 entry)) | |
15882 (setq group (car (nth 2 entry)))) | |
15883 (setq group entry)) | |
15884 (if (and (stringp entry) | |
15885 oldlevel | |
15886 (< oldlevel gnus-level-zombie)) | |
15887 (setq entry (gnus-gethash entry gnus-newsrc-hashtb))) | |
15888 (if (and (not oldlevel) | |
15889 (consp entry)) | |
15890 (setq oldlevel (gnus-info-level (nth 2 entry))) | |
15891 (setq oldlevel (or oldlevel 9))) | |
15892 (if (stringp previous) | |
15893 (setq previous (gnus-gethash previous gnus-newsrc-hashtb))) | |
15894 | |
15895 (if (and (>= oldlevel gnus-level-zombie) | |
15896 (gnus-gethash group gnus-newsrc-hashtb)) | |
15897 ;; We are trying to subscribe a group that is already | |
15898 ;; subscribed. | |
15899 () ; Do nothing. | |
15900 | |
15901 (or (gnus-ephemeral-group-p group) | |
15902 (gnus-dribble-enter | |
15903 (format "(gnus-group-change-level %S %S %S %S %S)" | |
15904 group level oldlevel (car (nth 2 previous)) fromkilled))) | |
15905 | |
15906 ;; Then we remove the newgroup from any old structures, if needed. | |
15907 ;; If the group was killed, we remove it from the killed or zombie | |
15908 ;; list. If not, and it is in fact going to be killed, we remove | |
15909 ;; it from the newsrc hash table and assoc. | |
15910 (cond | |
15911 ((>= oldlevel gnus-level-zombie) | |
15912 (if (= oldlevel gnus-level-zombie) | |
15913 (setq gnus-zombie-list (delete group gnus-zombie-list)) | |
15914 (setq gnus-killed-list (delete group gnus-killed-list)))) | |
15915 (t | |
15916 (if (and (>= level gnus-level-zombie) | |
15917 entry) | |
15918 (progn | |
15919 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb) | |
15920 (if (nth 3 entry) | |
15921 (setcdr (gnus-gethash (car (nth 3 entry)) | |
15922 gnus-newsrc-hashtb) | |
15923 (cdr entry))) | |
15924 (setcdr (cdr entry) (cdddr entry)))))) | |
15925 | |
15926 ;; Finally we enter (if needed) the list where it is supposed to | |
15927 ;; go, and change the subscription level. If it is to be killed, | |
15928 ;; we enter it into the killed or zombie list. | |
15929 (cond | |
15930 ((>= level gnus-level-zombie) | |
15931 ;; Remove from the hash table. | |
15932 (gnus-sethash group nil gnus-newsrc-hashtb) | |
15933 ;; We do not enter foreign groups into the list of dead | |
15934 ;; groups. | |
15935 (unless (gnus-group-foreign-p group) | |
15936 (if (= level gnus-level-zombie) | |
15937 (setq gnus-zombie-list (cons group gnus-zombie-list)) | |
15938 (setq gnus-killed-list (cons group gnus-killed-list))))) | |
15939 (t | |
15940 ;; If the list is to be entered into the newsrc assoc, and | |
15941 ;; it was killed, we have to create an entry in the newsrc | |
15942 ;; hashtb format and fix the pointers in the newsrc assoc. | |
15943 (if (< oldlevel gnus-level-zombie) | |
15944 ;; It was alive, and it is going to stay alive, so we | |
15945 ;; just change the level and don't change any pointers or | |
15946 ;; hash table entries. | |
15947 (setcar (cdaddr entry) level) | |
15948 (if (listp entry) | |
15949 (setq info (cdr entry) | |
15950 num (car entry)) | |
15951 (setq active (gnus-active group)) | |
15952 (setq num | |
15953 (if active (- (1+ (cdr active)) (car active)) t)) | |
15954 ;; Check whether the group is foreign. If so, the | |
15955 ;; foreign select method has to be entered into the | |
15956 ;; info. | |
15957 (let ((method (or gnus-override-subscribe-method | |
15958 (gnus-group-method group)))) | |
15959 (if (eq method gnus-select-method) | |
15960 (setq info (list group level nil)) | |
15961 (setq info (list group level nil nil method))))) | |
15962 (unless previous | |
15963 (setq previous | |
15964 (let ((p gnus-newsrc-alist)) | |
15965 (while (cddr p) | |
15966 (setq p (cdr p))) | |
15967 p))) | |
15968 (setq entry (cons info (cddr previous))) | |
15969 (if (cdr previous) | |
15970 (progn | |
15971 (setcdr (cdr previous) entry) | |
15972 (gnus-sethash group (cons num (cdr previous)) | |
15973 gnus-newsrc-hashtb)) | |
15974 (setcdr previous entry) | |
15975 (gnus-sethash group (cons num previous) | |
15976 gnus-newsrc-hashtb)) | |
15977 (when (cdr entry) | |
15978 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry))))) | |
15979 (when gnus-group-change-level-function | |
15980 (funcall gnus-group-change-level-function group level oldlevel))))) | |
15981 | |
15982 (defun gnus-kill-newsgroup (newsgroup) | |
15983 "Obsolete function. Kills a newsgroup." | |
15984 (gnus-group-change-level | |
15985 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed)) | |
15986 | |
15987 (defun gnus-check-bogus-newsgroups (&optional confirm) | |
15988 "Remove bogus newsgroups. | |
15989 If CONFIRM is non-nil, the user has to confirm the deletion of every | |
15990 newsgroup." | |
15991 (let ((newsrc (cdr gnus-newsrc-alist)) | |
15992 bogus group entry info) | |
15993 (gnus-message 5 "Checking bogus newsgroups...") | |
15994 (unless (gnus-read-active-file-p) | |
15995 (gnus-read-active-file)) | |
15996 (when (gnus-read-active-file-p) | |
15997 ;; Find all bogus newsgroup that are subscribed. | |
15998 (while newsrc | |
15999 (setq info (pop newsrc) | |
16000 group (gnus-info-group info)) | |
16001 (unless (or (gnus-active group) ; Active | |
16002 (gnus-info-method info) ; Foreign | |
16003 (and confirm | |
16004 (not (gnus-y-or-n-p | |
16005 (format "Remove bogus newsgroup: %s " group))))) | |
16006 ;; Found a bogus newsgroup. | |
16007 (push group bogus))) | |
16008 ;; Remove all bogus subscribed groups by first killing them, and | |
16009 ;; then removing them from the list of killed groups. | |
16010 (while bogus | |
16011 (when (setq entry (gnus-gethash (setq group (pop bogus)) | |
16012 gnus-newsrc-hashtb)) | |
16013 (gnus-group-change-level entry gnus-level-killed) | |
16014 (setq gnus-killed-list (delete group gnus-killed-list)))) | |
16015 ;; Then we remove all bogus groups from the list of killed and | |
16016 ;; zombie groups. They are removed without confirmation. | |
16017 (let ((dead-lists '(gnus-killed-list gnus-zombie-list)) | |
16018 killed) | |
16019 (while dead-lists | |
16020 (setq killed (symbol-value (car dead-lists))) | |
16021 (while killed | |
16022 (unless (gnus-active (setq group (pop killed))) | |
16023 ;; The group is bogus. | |
16024 ;; !!!Slow as hell. | |
16025 (set (car dead-lists) | |
16026 (delete group (symbol-value (car dead-lists)))))) | |
16027 (setq dead-lists (cdr dead-lists)))) | |
16028 (run-hooks 'gnus-check-bogus-groups-hook) | |
16029 (gnus-message 5 "Checking bogus newsgroups...done")))) | |
16030 | |
16031 (defun gnus-check-duplicate-killed-groups () | |
16032 "Remove duplicates from the list of killed groups." | |
16033 (interactive) | |
16034 (let ((killed gnus-killed-list)) | |
16035 (while killed | |
16036 (gnus-message 9 "%d" (length killed)) | |
16037 (setcdr killed (delete (car killed) (cdr killed))) | |
16038 (setq killed (cdr killed))))) | |
16039 | |
16040 ;; We want to inline a function from gnus-cache, so we cheat here: | |
16041 (eval-when-compile | |
16042 (provide 'gnus) | |
16043 (setq gnus-directory (or (getenv "SAVEDIR") "~/News/")) | |
16044 (require 'gnus-cache)) | |
16045 | |
16046 (defun gnus-get-unread-articles-in-group (info active &optional update) | |
16047 (when active | |
16048 ;; Allow the backend to update the info in the group. | |
16049 (when (and update | |
16050 (gnus-request-update-info | |
16051 info (gnus-find-method-for-group (gnus-info-group info)))) | |
16052 (gnus-activate-group (gnus-info-group info) nil t)) | |
16053 (let* ((range (gnus-info-read info)) | |
16054 (num 0)) | |
16055 ;; If a cache is present, we may have to alter the active info. | |
16056 (when (and gnus-use-cache info) | |
16057 (inline (gnus-cache-possibly-alter-active | |
16058 (gnus-info-group info) active))) | |
16059 ;; Modify the list of read articles according to what articles | |
16060 ;; are available; then tally the unread articles and add the | |
16061 ;; number to the group hash table entry. | |
16062 (cond | |
16063 ((zerop (cdr active)) | |
16064 (setq num 0)) | |
16065 ((not range) | |
16066 (setq num (- (1+ (cdr active)) (car active)))) | |
16067 ((not (listp (cdr range))) | |
16068 ;; Fix a single (num . num) range according to the | |
16069 ;; active hash table. | |
16070 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>. | |
16071 (and (< (cdr range) (car active)) (setcdr range (1- (car active)))) | |
16072 (and (> (cdr range) (cdr active)) (setcdr range (cdr active))) | |
16073 ;; Compute number of unread articles. | |
16074 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range)))))) | |
16075 (t | |
16076 ;; The read list is a list of ranges. Fix them according to | |
16077 ;; the active hash table. | |
16078 ;; First peel off any elements that are below the lower | |
16079 ;; active limit. | |
16080 (while (and (cdr range) | |
16081 (>= (car active) | |
16082 (or (and (atom (cadr range)) (cadr range)) | |
16083 (caadr range)))) | |
16084 (if (numberp (car range)) | |
16085 (setcar range | |
16086 (cons (car range) | |
16087 (or (and (numberp (cadr range)) | |
16088 (cadr range)) | |
16089 (cdadr range)))) | |
16090 (setcdr (car range) | |
16091 (or (and (numberp (nth 1 range)) (nth 1 range)) | |
16092 (cdadr range)))) | |
16093 (setcdr range (cddr range))) | |
16094 ;; Adjust the first element to be the same as the lower limit. | |
16095 (if (and (not (atom (car range))) | |
16096 (< (cdar range) (car active))) | |
16097 (setcdr (car range) (1- (car active)))) | |
16098 ;; Then we want to peel off any elements that are higher | |
16099 ;; than the upper active limit. | |
16100 (let ((srange range)) | |
16101 ;; Go past all legal elements. | |
16102 (while (and (cdr srange) | |
16103 (<= (or (and (atom (cadr srange)) | |
16104 (cadr srange)) | |
16105 (caadr srange)) (cdr active))) | |
16106 (setq srange (cdr srange))) | |
16107 (if (cdr srange) | |
16108 ;; Nuke all remaining illegal elements. | |
16109 (setcdr srange nil)) | |
16110 | |
16111 ;; Adjust the final element. | |
16112 (if (and (not (atom (car srange))) | |
16113 (> (cdar srange) (cdr active))) | |
16114 (setcdr (car srange) (cdr active)))) | |
16115 ;; Compute the number of unread articles. | |
16116 (while range | |
16117 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range)) | |
16118 (cdar range))) | |
16119 (or (and (atom (car range)) (car range)) | |
16120 (caar range))))) | |
16121 (setq range (cdr range))) | |
16122 (setq num (max 0 (- (cdr active) num))))) | |
16123 ;; Set the number of unread articles. | |
16124 (when info | |
16125 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num)) | |
16126 num))) | |
16127 | |
16128 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb' | |
16129 ;; and compute how many unread articles there are in each group. | |
16130 (defun gnus-get-unread-articles (&optional level) | |
16131 (let* ((newsrc (cdr gnus-newsrc-alist)) | |
16132 (level (or level gnus-activate-level (1+ gnus-level-subscribed))) | |
16133 (foreign-level | |
16134 (min | |
16135 (cond ((and gnus-activate-foreign-newsgroups | |
16136 (not (numberp gnus-activate-foreign-newsgroups))) | |
16137 (1+ gnus-level-subscribed)) | |
16138 ((numberp gnus-activate-foreign-newsgroups) | |
16139 gnus-activate-foreign-newsgroups) | |
16140 (t 0)) | |
16141 level)) | |
16142 info group active method) | |
16143 (gnus-message 5 "Checking new news...") | |
16144 | |
16145 (while newsrc | |
16146 (setq active (gnus-active (setq group (gnus-info-group | |
16147 (setq info (pop newsrc)))))) | |
16148 | |
16149 ;; Check newsgroups. If the user doesn't want to check them, or | |
16150 ;; they can't be checked (for instance, if the news server can't | |
16151 ;; be reached) we just set the number of unread articles in this | |
16152 ;; newsgroup to t. This means that Gnus thinks that there are | |
16153 ;; unread articles, but it has no idea how many. | |
16154 (if (and (setq method (gnus-info-method info)) | |
16155 (not (gnus-server-equal | |
16156 gnus-select-method | |
16157 (setq method (gnus-server-get-method nil method)))) | |
16158 (not (gnus-secondary-method-p method))) | |
16159 ;; These groups are foreign. Check the level. | |
16160 (when (<= (gnus-info-level info) foreign-level) | |
16161 (setq active (gnus-activate-group group 'scan)) | |
16162 (unless (inline (gnus-virtual-group-p group)) | |
16163 (inline (gnus-close-group group))) | |
16164 (when (fboundp (intern (concat (symbol-name (car method)) | |
16165 "-request-update-info"))) | |
16166 (inline (gnus-request-update-info info method)))) | |
16167 ;; These groups are native or secondary. | |
16168 (when (and (<= (gnus-info-level info) level) | |
16169 (not gnus-read-active-file)) | |
16170 (setq active (gnus-activate-group group 'scan)) | |
16171 (inline (gnus-close-group group)))) | |
16172 | |
16173 ;; Get the number of unread articles in the group. | |
16174 (if active | |
16175 (inline (gnus-get-unread-articles-in-group info active)) | |
16176 ;; The group couldn't be reached, so we nix out the number of | |
16177 ;; unread articles and stuff. | |
16178 (gnus-set-active group nil) | |
16179 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))) | |
16180 | |
16181 (gnus-message 5 "Checking new news...done"))) | |
16182 | |
16183 ;; Create a hash table out of the newsrc alist. The `car's of the | |
16184 ;; alist elements are used as keys. | |
16185 (defun gnus-make-hashtable-from-newsrc-alist () | |
16186 (let ((alist gnus-newsrc-alist) | |
16187 (ohashtb gnus-newsrc-hashtb) | |
16188 prev) | |
16189 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist))) | |
16190 (setq alist | |
16191 (setq prev (setq gnus-newsrc-alist | |
16192 (if (equal (caar gnus-newsrc-alist) | |
16193 "dummy.group") | |
16194 gnus-newsrc-alist | |
16195 (cons (list "dummy.group" 0 nil) alist))))) | |
16196 (while alist | |
16197 (gnus-sethash | |
16198 (caar alist) | |
16199 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb))) | |
16200 prev) | |
16201 gnus-newsrc-hashtb) | |
16202 (setq prev alist | |
16203 alist (cdr alist))))) | |
16204 | |
16205 (defun gnus-make-hashtable-from-killed () | |
16206 "Create a hash table from the killed and zombie lists." | |
16207 (let ((lists '(gnus-killed-list gnus-zombie-list)) | |
16208 list) | |
16209 (setq gnus-killed-hashtb | |
16210 (gnus-make-hashtable | |
16211 (+ (length gnus-killed-list) (length gnus-zombie-list)))) | |
16212 (while (setq list (pop lists)) | |
16213 (setq list (symbol-value list)) | |
16214 (while list | |
16215 (gnus-sethash (car list) (pop list) gnus-killed-hashtb))))) | |
16216 | |
16217 (defun gnus-activate-group (group &optional scan dont-check method) | |
16218 ;; Check whether a group has been activated or not. | |
16219 ;; If SCAN, request a scan of that group as well. | |
16220 (let ((method (or method (gnus-find-method-for-group group))) | |
16221 active) | |
16222 (and (gnus-check-server method) | |
16223 ;; We escape all bugs and quit here to make it possible to | |
16224 ;; continue if a group is so out-there that it reports bugs | |
16225 ;; and stuff. | |
16226 (progn | |
16227 (and scan | |
16228 (gnus-check-backend-function 'request-scan (car method)) | |
16229 (gnus-request-scan group method)) | |
16230 t) | |
16231 (condition-case () | |
16232 (gnus-request-group group dont-check method) | |
16233 ; (error nil) | |
16234 (quit nil)) | |
16235 (save-excursion | |
16236 (set-buffer nntp-server-buffer) | |
16237 (goto-char (point-min)) | |
16238 ;; Parse the result we got from `gnus-request-group'. | |
16239 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+") | |
16240 (progn | |
16241 (goto-char (match-beginning 1)) | |
16242 (gnus-set-active | |
16243 group (setq active (cons (read (current-buffer)) | |
16244 (read (current-buffer))))) | |
16245 ;; Return the new active info. | |
16246 active)))))) | |
16247 | |
16248 (defun gnus-update-read-articles (group unread) | |
16249 "Update the list of read and ticked articles in GROUP using the | |
16250 UNREAD and TICKED lists. | |
16251 Note: UNSELECTED has to be sorted over `<'. | |
16252 Returns whether the updating was successful." | |
16253 (let* ((active (or gnus-newsgroup-active (gnus-active group))) | |
16254 (entry (gnus-gethash group gnus-newsrc-hashtb)) | |
16255 (info (nth 2 entry)) | |
16256 (prev 1) | |
16257 (unread (sort (copy-sequence unread) '<)) | |
16258 read) | |
16259 (if (or (not info) (not active)) | |
16260 ;; There is no info on this group if it was, in fact, | |
16261 ;; killed. Gnus stores no information on killed groups, so | |
16262 ;; there's nothing to be done. | |
16263 ;; One could store the information somewhere temporarily, | |
16264 ;; perhaps... Hmmm... | |
16265 () | |
16266 ;; Remove any negative articles numbers. | |
16267 (while (and unread (< (car unread) 0)) | |
16268 (setq unread (cdr unread))) | |
16269 ;; Remove any expired article numbers | |
16270 (while (and unread (< (car unread) (car active))) | |
16271 (setq unread (cdr unread))) | |
16272 ;; Compute the ranges of read articles by looking at the list of | |
16273 ;; unread articles. | |
16274 (while unread | |
16275 (if (/= (car unread) prev) | |
16276 (setq read (cons (if (= prev (1- (car unread))) prev | |
16277 (cons prev (1- (car unread)))) read))) | |
16278 (setq prev (1+ (car unread))) | |
16279 (setq unread (cdr unread))) | |
16280 (when (<= prev (cdr active)) | |
16281 (setq read (cons (cons prev (cdr active)) read))) | |
16282 ;; Enter this list into the group info. | |
16283 (gnus-info-set-read | |
16284 info (if (> (length read) 1) (nreverse read) read)) | |
16285 ;; Set the number of unread articles in gnus-newsrc-hashtb. | |
16286 (gnus-get-unread-articles-in-group info (gnus-active group)) | |
16287 t))) | |
16288 | |
16289 (defun gnus-make-articles-unread (group articles) | |
16290 "Mark ARTICLES in GROUP as unread." | |
16291 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb) | |
16292 (gnus-gethash (gnus-group-real-name group) | |
16293 gnus-newsrc-hashtb)))) | |
16294 (ranges (gnus-info-read info)) | |
16295 news article) | |
16296 (while articles | |
16297 (when (gnus-member-of-range | |
16298 (setq article (pop articles)) ranges) | |
16299 (setq news (cons article news)))) | |
16300 (when news | |
16301 (gnus-info-set-read | |
16302 info (gnus-remove-from-range (gnus-info-read info) (nreverse news))) | |
16303 (gnus-group-update-group group t)))) | |
16304 | |
16305 ;; Enter all dead groups into the hashtb. | |
16306 (defun gnus-update-active-hashtb-from-killed () | |
16307 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0))) | |
16308 (lists (list gnus-killed-list gnus-zombie-list)) | |
16309 killed) | |
16310 (while lists | |
16311 (setq killed (car lists)) | |
16312 (while killed | |
16313 (gnus-sethash (car killed) nil hashtb) | |
16314 (setq killed (cdr killed))) | |
16315 (setq lists (cdr lists))))) | |
16316 | |
16317 (defun gnus-get-killed-groups () | |
16318 "Go through the active hashtb and mark all unknown groups as killed." | |
16319 ;; First make sure active file has been read. | |
16320 (unless (gnus-read-active-file-p) | |
16321 (let ((gnus-read-active-file t)) | |
16322 (gnus-read-active-file))) | |
16323 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed)) | |
16324 ;; Go through all newsgroups that are known to Gnus - enlarge kill list. | |
16325 (mapatoms | |
16326 (lambda (sym) | |
16327 (let ((groups 0) | |
16328 (group (symbol-name sym))) | |
16329 (if (or (null group) | |
16330 (gnus-gethash group gnus-killed-hashtb) | |
16331 (gnus-gethash group gnus-newsrc-hashtb)) | |
16332 () | |
16333 (let ((do-sub (gnus-matches-options-n group))) | |
16334 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore)) | |
16335 () | |
16336 (setq groups (1+ groups)) | |
16337 (setq gnus-killed-list | |
16338 (cons group gnus-killed-list)) | |
16339 (gnus-sethash group group gnus-killed-hashtb)))))) | |
16340 gnus-active-hashtb)) | |
16341 | |
16342 ;; Get the active file(s) from the backend(s). | |
16343 (defun gnus-read-active-file () | |
16344 (gnus-group-set-mode-line) | |
16345 (let ((methods | |
16346 (append | |
16347 (if (gnus-check-server gnus-select-method) | |
16348 ;; The native server is available. | |
16349 (cons gnus-select-method gnus-secondary-select-methods) | |
16350 ;; The native server is down, so we just do the | |
16351 ;; secondary ones. | |
16352 gnus-secondary-select-methods) | |
16353 ;; Also read from the archive server. | |
16354 (when (gnus-archive-server-wanted-p) | |
16355 (list "archive")))) | |
16356 list-type) | |
16357 (setq gnus-have-read-active-file nil) | |
16358 (save-excursion | |
16359 (set-buffer nntp-server-buffer) | |
16360 (while methods | |
16361 (let* ((method (if (stringp (car methods)) | |
16362 (gnus-server-get-method nil (car methods)) | |
16363 (car methods))) | |
16364 (where (nth 1 method)) | |
16365 (mesg (format "Reading active file%s via %s..." | |
16366 (if (and where (not (zerop (length where)))) | |
16367 (concat " from " where) "") | |
16368 (car method)))) | |
16369 (gnus-message 5 mesg) | |
16370 (when (gnus-check-server method) | |
16371 ;; Request that the backend scan its incoming messages. | |
16372 (and (gnus-check-backend-function 'request-scan (car method)) | |
16373 (gnus-request-scan nil method)) | |
16374 (cond | |
16375 ((and (eq gnus-read-active-file 'some) | |
16376 (gnus-check-backend-function 'retrieve-groups (car method))) | |
16377 (let ((newsrc (cdr gnus-newsrc-alist)) | |
16378 (gmethod (gnus-server-get-method nil method)) | |
16379 groups info) | |
16380 (while (setq info (pop newsrc)) | |
16381 (when (gnus-server-equal | |
16382 (gnus-find-method-for-group | |
16383 (gnus-info-group info) info) | |
16384 gmethod) | |
16385 (push (gnus-group-real-name (gnus-info-group info)) | |
16386 groups))) | |
16387 (when groups | |
16388 (gnus-check-server method) | |
16389 (setq list-type (gnus-retrieve-groups groups method)) | |
16390 (cond | |
16391 ((not list-type) | |
16392 (gnus-error | |
16393 1.2 "Cannot read partial active file from %s server." | |
16394 (car method))) | |
16395 ((eq list-type 'active) | |
16396 (gnus-active-to-gnus-format method gnus-active-hashtb)) | |
16397 (t | |
16398 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))) | |
16399 (t | |
16400 (if (not (gnus-request-list method)) | |
16401 (unless (equal method gnus-message-archive-method) | |
16402 (gnus-error 1 "Cannot read active file from %s server." | |
16403 (car method))) | |
16404 (gnus-message 5 mesg) | |
16405 (gnus-active-to-gnus-format method gnus-active-hashtb) | |
16406 ;; We mark this active file as read. | |
16407 (push method gnus-have-read-active-file) | |
16408 (gnus-message 5 "%sdone" mesg)))))) | |
16409 (setq methods (cdr methods)))))) | |
16410 | |
16411 ;; Read an active file and place the results in `gnus-active-hashtb'. | |
16412 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors) | |
16413 (unless method | |
16414 (setq method gnus-select-method)) | |
16415 (let ((cur (current-buffer)) | |
16416 (hashtb (or hashtb | |
16417 (if (and gnus-active-hashtb | |
16418 (not (equal method gnus-select-method))) | |
16419 gnus-active-hashtb | |
16420 (setq gnus-active-hashtb | |
16421 (if (equal method gnus-select-method) | |
16422 (gnus-make-hashtable | |
16423 (count-lines (point-min) (point-max))) | |
16424 (gnus-make-hashtable 4096))))))) | |
16425 ;; Delete unnecessary lines. | |
16426 (goto-char (point-min)) | |
16427 (while (search-forward "\nto." nil t) | |
16428 (delete-region (1+ (match-beginning 0)) | |
16429 (progn (forward-line 1) (point)))) | |
16430 (or (string= gnus-ignored-newsgroups "") | |
16431 (progn | |
16432 (goto-char (point-min)) | |
16433 (delete-matching-lines gnus-ignored-newsgroups))) | |
16434 ;; Make the group names readable as a lisp expression even if they | |
16435 ;; contain special characters. | |
16436 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>. | |
16437 (goto-char (point-max)) | |
16438 (while (re-search-backward "[][';?()#]" nil t) | |
16439 (insert ?\\)) | |
16440 ;; If these are groups from a foreign select method, we insert the | |
16441 ;; group prefix in front of the group names. | |
16442 (and method (not (gnus-server-equal | |
16443 (gnus-server-get-method nil method) | |
16444 (gnus-server-get-method nil gnus-select-method))) | |
16445 (let ((prefix (gnus-group-prefixed-name "" method))) | |
16446 (goto-char (point-min)) | |
16447 (while (and (not (eobp)) | |
16448 (progn (insert prefix) | |
16449 (zerop (forward-line 1))))))) | |
16450 ;; Store the active file in a hash table. | |
16451 (goto-char (point-min)) | |
16452 (if (string-match "%[oO]" gnus-group-line-format) | |
16453 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>. | |
16454 ;; If we want information on moderated groups, we use this | |
16455 ;; loop... | |
16456 (let* ((mod-hashtb (make-vector 7 0)) | |
16457 (m (intern "m" mod-hashtb)) | |
16458 group max min) | |
16459 (while (not (eobp)) | |
16460 (condition-case nil | |
16461 (progn | |
16462 (narrow-to-region (point) (gnus-point-at-eol)) | |
16463 (setq group (let ((obarray hashtb)) (read cur))) | |
16464 (if (and (numberp (setq max (read cur))) | |
16465 (numberp (setq min (read cur))) | |
16466 (progn | |
16467 (skip-chars-forward " \t") | |
16468 (not | |
16469 (or (= (following-char) ?=) | |
16470 (= (following-char) ?x) | |
16471 (= (following-char) ?j))))) | |
16472 (set group (cons min max)) | |
16473 (set group nil)) | |
16474 ;; Enter moderated groups into a list. | |
16475 (if (eq (let ((obarray mod-hashtb)) (read cur)) m) | |
16476 (setq gnus-moderated-list | |
16477 (cons (symbol-name group) gnus-moderated-list)))) | |
16478 (error | |
16479 (and group | |
16480 (symbolp group) | |
16481 (set group nil)))) | |
16482 (widen) | |
16483 (forward-line 1))) | |
16484 ;; And if we do not care about moderation, we use this loop, | |
16485 ;; which is faster. | |
16486 (let (group max min) | |
16487 (while (not (eobp)) | |
16488 (condition-case () | |
16489 (progn | |
16490 (narrow-to-region (point) (gnus-point-at-eol)) | |
16491 ;; group gets set to a symbol interned in the hash table | |
16492 ;; (what a hack!!) - jwz | |
16493 (setq group (let ((obarray hashtb)) (read cur))) | |
16494 (if (and (numberp (setq max (read cur))) | |
16495 (numberp (setq min (read cur))) | |
16496 (progn | |
16497 (skip-chars-forward " \t") | |
16498 (not | |
16499 (or (= (following-char) ?=) | |
16500 (= (following-char) ?x) | |
16501 (= (following-char) ?j))))) | |
16502 (set group (cons min max)) | |
16503 (set group nil))) | |
16504 (error | |
16505 (progn | |
16506 (and group | |
16507 (symbolp group) | |
16508 (set group nil)) | |
16509 (or ignore-errors | |
16510 (gnus-message 3 "Warning - illegal active: %s" | |
16511 (buffer-substring | |
16512 (gnus-point-at-bol) (gnus-point-at-eol))))))) | |
16513 (widen) | |
16514 (forward-line 1)))))) | |
16515 | |
16516 (defun gnus-groups-to-gnus-format (method &optional hashtb) | |
16517 ;; Parse a "groups" active file. | |
16518 (let ((cur (current-buffer)) | |
16519 (hashtb (or hashtb | |
16520 (if (and method gnus-active-hashtb) | |
16521 gnus-active-hashtb | |
16522 (setq gnus-active-hashtb | |
16523 (gnus-make-hashtable | |
16524 (count-lines (point-min) (point-max))))))) | |
16525 (prefix (and method | |
16526 (not (gnus-server-equal | |
16527 (gnus-server-get-method nil method) | |
16528 (gnus-server-get-method nil gnus-select-method))) | |
16529 (gnus-group-prefixed-name "" method)))) | |
16530 | |
16531 (goto-char (point-min)) | |
16532 ;; We split this into to separate loops, one with the prefix | |
16533 ;; and one without to speed the reading up somewhat. | |
16534 (if prefix | |
16535 (let (min max opoint group) | |
16536 (while (not (eobp)) | |
16537 (condition-case () | |
16538 (progn | |
16539 (read cur) (read cur) | |
16540 (setq min (read cur) | |
16541 max (read cur) | |
16542 opoint (point)) | |
16543 (skip-chars-forward " \t") | |
16544 (insert prefix) | |
16545 (goto-char opoint) | |
16546 (set (let ((obarray hashtb)) (read cur)) | |
16547 (cons min max))) | |
16548 (error (and group (symbolp group) (set group nil)))) | |
16549 (forward-line 1))) | |
16550 (let (min max group) | |
16551 (while (not (eobp)) | |
16552 (condition-case () | |
16553 (if (= (following-char) ?2) | |
16554 (progn | |
16555 (read cur) (read cur) | |
16556 (setq min (read cur) | |
16557 max (read cur)) | |
16558 (set (setq group (let ((obarray hashtb)) (read cur))) | |
16559 (cons min max)))) | |
16560 (error (and group (symbolp group) (set group nil)))) | |
16561 (forward-line 1)))))) | |
16562 | |
16563 (defun gnus-read-newsrc-file (&optional force) | |
16564 "Read startup file. | |
16565 If FORCE is non-nil, the .newsrc file is read." | |
16566 ;; Reset variables that might be defined in the .newsrc.eld file. | |
16567 (let ((variables gnus-variable-list)) | |
16568 (while variables | |
16569 (set (car variables) nil) | |
16570 (setq variables (cdr variables)))) | |
16571 (let* ((newsrc-file gnus-current-startup-file) | |
16572 (quick-file (concat newsrc-file ".el"))) | |
16573 (save-excursion | |
16574 ;; We always load the .newsrc.eld file. If always contains | |
16575 ;; much information that can not be gotten from the .newsrc | |
16576 ;; file (ticked articles, killed groups, foreign methods, etc.) | |
16577 (gnus-read-newsrc-el-file quick-file) | |
16578 | |
16579 (if (and (file-exists-p gnus-current-startup-file) | |
16580 (or force | |
16581 (and (file-newer-than-file-p newsrc-file quick-file) | |
16582 (file-newer-than-file-p newsrc-file | |
16583 (concat quick-file "d"))) | |
16584 (not gnus-newsrc-alist))) | |
16585 ;; We read the .newsrc file. Note that if there if a | |
16586 ;; .newsrc.eld file exists, it has already been read, and | |
16587 ;; the `gnus-newsrc-hashtb' has been created. While reading | |
16588 ;; the .newsrc file, Gnus will only use the information it | |
16589 ;; can find there for changing the data already read - | |
16590 ;; ie. reading the .newsrc file will not trash the data | |
16591 ;; already read (except for read articles). | |
16592 (save-excursion | |
16593 (gnus-message 5 "Reading %s..." newsrc-file) | |
16594 (set-buffer (find-file-noselect newsrc-file)) | |
16595 (buffer-disable-undo (current-buffer)) | |
16596 (gnus-newsrc-to-gnus-format) | |
16597 (kill-buffer (current-buffer)) | |
16598 (gnus-message 5 "Reading %s...done" newsrc-file))) | |
16599 | |
16600 ;; Read any slave files. | |
16601 (unless gnus-slave | |
16602 (gnus-master-read-slave-newsrc)) | |
16603 | |
16604 ;; Convert old to new. | |
16605 (gnus-convert-old-newsrc)))) | |
16606 | 1905 |
16607 (defun gnus-continuum-version (version) | 1906 (defun gnus-continuum-version (version) |
16608 "Return VERSION as a floating point number." | 1907 "Return VERSION as a floating point number." |
16609 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version) | 1908 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version) |
16610 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version)) | 1909 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version)) |
16625 ((member alpha '("September" "s")) "5.01") | 1924 ((member alpha '("September" "s")) "5.01") |
16626 ((member alpha '("Red" "r")) "5.03")) | 1925 ((member alpha '("Red" "r")) "5.03")) |
16627 minor least) | 1926 minor least) |
16628 (format "%d.%02d%02d" major minor least)))))) | 1927 (format "%d.%02d%02d" major minor least)))))) |
16629 | 1928 |
16630 (defun gnus-convert-old-newsrc () | 1929 (defun gnus-info-find-node () |
16631 "Convert old newsrc into the new format, if needed." | 1930 "Find Info documentation of Gnus." |
16632 (let ((fcv (and gnus-newsrc-file-version | 1931 (interactive) |
16633 (gnus-continuum-version gnus-newsrc-file-version)))) | 1932 ;; Enlarge info window if needed. |
1933 (let (gnus-info-buffer) | |
1934 (Info-goto-node (cadr (assq major-mode gnus-info-nodes))) | |
1935 (setq gnus-info-buffer (current-buffer)) | |
1936 (gnus-configure-windows 'info))) | |
1937 | |
1938 ;;; More various functions. | |
1939 | |
1940 (defun gnus-group-read-only-p (&optional group) | |
1941 "Check whether GROUP supports editing or not. | |
1942 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note | |
1943 that that variable is buffer-local to the summary buffers." | |
1944 (let ((group (or group gnus-newsgroup-name))) | |
1945 (not (gnus-check-backend-function 'request-replace-article group)))) | |
1946 | |
1947 (defun gnus-group-total-expirable-p (group) | |
1948 "Check whether GROUP is total-expirable or not." | |
1949 (let ((params (gnus-group-find-parameter group)) | |
1950 val) | |
16634 (cond | 1951 (cond |
16635 ;; No .newsrc.eld file was loaded. | 1952 ((memq 'total-expire params) |
16636 ((null fcv) nil) | 1953 t) |
16637 ;; Gnus 5 .newsrc.eld was loaded. | 1954 ((setq val (assq 'total-expire params)) ; (auto-expire . t) |
16638 ((< fcv (gnus-continuum-version "September Gnus v0.1")) | 1955 (cdr val)) |
16639 (gnus-convert-old-ticks))))) | 1956 (gnus-total-expirable-newsgroups ; Check var. |
16640 | 1957 (string-match gnus-total-expirable-newsgroups group))))) |
16641 (defun gnus-convert-old-ticks () | 1958 |
16642 (let ((newsrc (cdr gnus-newsrc-alist)) | 1959 (defun gnus-group-auto-expirable-p (group) |
16643 marks info dormant ticked) | 1960 "Check whether GROUP is total-expirable or not." |
16644 (while (setq info (pop newsrc)) | 1961 (let ((params (gnus-group-find-parameter group)) |
16645 (when (setq marks (gnus-info-marks info)) | 1962 val) |
16646 (setq dormant (cdr (assq 'dormant marks)) | 1963 (cond |
16647 ticked (cdr (assq 'tick marks))) | 1964 ((memq 'auto-expire params) |
16648 (when (or dormant ticked) | 1965 t) |
16649 (gnus-info-set-read | 1966 ((setq val (assq 'auto-expire params)) ; (auto-expire . t) |
16650 info | 1967 (cdr val)) |
16651 (gnus-add-to-range | 1968 (gnus-auto-expirable-newsgroups ; Check var. |
16652 (gnus-info-read info) | 1969 (string-match gnus-auto-expirable-newsgroups group))))) |
16653 (nconc (gnus-uncompress-range dormant) | 1970 |
16654 (gnus-uncompress-range ticked))))))))) | 1971 (defun gnus-virtual-group-p (group) |
16655 | 1972 "Say whether GROUP is virtual or not." |
16656 (defun gnus-read-newsrc-el-file (file) | 1973 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group))) |
16657 (let ((ding-file (concat file "d"))) | 1974 gnus-valid-select-methods))) |
16658 ;; We always, always read the .eld file. | 1975 |
16659 (gnus-message 5 "Reading %s..." ding-file) | 1976 (defun gnus-news-group-p (group &optional article) |
16660 (let (gnus-newsrc-assoc) | 1977 "Return non-nil if GROUP (and ARTICLE) come from a news server." |
16661 (condition-case nil | 1978 (or (gnus-member-of-valid 'post group) ; Ordinary news group. |
16662 (load ding-file t t t) | 1979 (and (gnus-member-of-valid 'post-mail group) ; Combined group. |
16663 (error | 1980 (eq (gnus-request-type group article) 'news)))) |
16664 (gnus-error 1 "Error in %s" ding-file))) | 1981 |
16665 (when gnus-newsrc-assoc | 1982 ;; Returns a list of writable groups. |
16666 (setq gnus-newsrc-alist gnus-newsrc-assoc))) | 1983 (defun gnus-writable-groups () |
16667 (gnus-make-hashtable-from-newsrc-alist) | 1984 (let ((alist gnus-newsrc-alist) |
16668 (when (file-newer-than-file-p file ding-file) | 1985 groups group) |
16669 ;; Old format quick file | 1986 (while (setq group (car (pop alist))) |
16670 (gnus-message 5 "Reading %s..." file) | 1987 (unless (gnus-group-read-only-p group) |
16671 ;; The .el file is newer than the .eld file, so we read that one | 1988 (push group groups))) |
16672 ;; as well. | 1989 (nreverse groups))) |
16673 (gnus-read-old-newsrc-el-file file)))) | 1990 |
16674 | 1991 ;; Check whether to use long file names. |
16675 ;; Parse the old-style quick startup file | 1992 (defun gnus-use-long-file-name (symbol) |
16676 (defun gnus-read-old-newsrc-el-file (file) | 1993 ;; The variable has to be set... |
16677 (let (newsrc killed marked group m info) | 1994 (and gnus-use-long-file-name |
16678 (prog1 | 1995 ;; If it isn't a list, then we return t. |
16679 (let ((gnus-killed-assoc nil) | 1996 (or (not (listp gnus-use-long-file-name)) |
16680 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc) | 1997 ;; If it is a list, and the list contains `symbol', we |
16681 (prog1 | 1998 ;; return nil. |
16682 (condition-case nil | 1999 (not (memq symbol gnus-use-long-file-name))))) |
16683 (load file t t t) | 2000 |
16684 (error nil)) | 2001 ;; Generate a unique new group name. |
16685 (setq newsrc gnus-newsrc-assoc | 2002 (defun gnus-generate-new-group-name (leaf) |
16686 killed gnus-killed-assoc | 2003 (let ((name leaf) |
16687 marked gnus-marked-assoc))) | 2004 (num 0)) |
16688 (setq gnus-newsrc-alist nil) | 2005 (while (gnus-gethash name gnus-newsrc-hashtb) |
16689 (while (setq group (pop newsrc)) | 2006 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">"))) |
16690 (if (setq info (gnus-get-info (car group))) | 2007 name)) |
16691 (progn | 2008 |
16692 (gnus-info-set-read info (cddr group)) | 2009 (defun gnus-ephemeral-group-p (group) |
16693 (gnus-info-set-level | 2010 "Say whether GROUP is ephemeral or not." |
16694 info (if (nth 1 group) gnus-level-default-subscribed | 2011 (gnus-group-get-parameter group 'quit-config)) |
16695 gnus-level-default-unsubscribed)) | 2012 |
16696 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist))) | 2013 (defun gnus-group-quit-config (group) |
16697 (push (setq info | 2014 "Return the quit-config of GROUP." |
16698 (list (car group) | 2015 (gnus-group-get-parameter group 'quit-config)) |
16699 (if (nth 1 group) gnus-level-default-subscribed | 2016 |
16700 gnus-level-default-unsubscribed) | 2017 (defun gnus-kill-ephemeral-group (group) |
16701 (cddr group))) | 2018 "Remove ephemeral GROUP from relevant structures." |
16702 gnus-newsrc-alist)) | 2019 (gnus-sethash group nil gnus-newsrc-hashtb)) |
16703 ;; Copy marks into info. | 2020 |
16704 (when (setq m (assoc (car group) marked)) | 2021 (defun gnus-simplify-mode-line () |
16705 (unless (nthcdr 3 info) | 2022 "Make mode lines a bit simpler." |
16706 (nconc info (list nil))) | 2023 (setq mode-line-modified "-- ") |
16707 (gnus-info-set-marks | 2024 (when (listp mode-line-format) |
16708 info (list (cons 'tick (gnus-compress-sequence | 2025 (make-local-variable 'mode-line-format) |
16709 (sort (cdr m) '<) t)))))) | 2026 (setq mode-line-format (copy-sequence mode-line-format)) |
16710 (setq newsrc killed) | 2027 (when (equal (nth 3 mode-line-format) " ") |
16711 (while newsrc | 2028 (setcar (nthcdr 3 mode-line-format) " ")))) |
16712 (setcar newsrc (caar newsrc)) | 2029 |
16713 (setq newsrc (cdr newsrc))) | 2030 ;;; Servers and groups. |
16714 (setq gnus-killed-list killed)) | 2031 |
16715 ;; The .el file version of this variable does not begin with | 2032 (defsubst gnus-server-add-address (method) |
16716 ;; "options", while the .eld version does, so we just add it if it | 2033 (let ((method-name (symbol-name (car method)))) |
16717 ;; isn't there. | 2034 (if (and (memq 'address (assoc method-name gnus-valid-select-methods)) |
16718 (and | 2035 (not (assq (intern (concat method-name "-address")) method)) |
16719 gnus-newsrc-options | 2036 (memq 'physical-address (assq (car method) |
16720 (progn | 2037 gnus-valid-select-methods))) |
16721 (and (not (string-match "^ *options" gnus-newsrc-options)) | 2038 (append method (list (list (intern (concat method-name "-address")) |
16722 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options))) | 2039 (nth 1 method)))) |
16723 (and (not (string-match "\n$" gnus-newsrc-options)) | 2040 method))) |
16724 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n"))) | 2041 |
16725 ;; Finally, if we read some options lines, we parse them. | 2042 (defsubst gnus-server-get-method (group method) |
16726 (or (string= gnus-newsrc-options "") | 2043 ;; Input either a server name, and extended server name, or a |
16727 (gnus-newsrc-parse-options gnus-newsrc-options)))) | 2044 ;; select method, and return a select method. |
16728 | 2045 (cond ((stringp method) |
16729 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)) | 2046 (gnus-server-to-method method)) |
16730 (gnus-make-hashtable-from-newsrc-alist))) | 2047 ((equal method gnus-select-method) |
16731 | 2048 gnus-select-method) |
16732 (defun gnus-make-newsrc-file (file) | 2049 ((and (stringp (car method)) group) |
16733 "Make server dependent file name by catenating FILE and server host name." | 2050 (gnus-server-extend-method group method)) |
16734 (let* ((file (expand-file-name file nil)) | 2051 ((and method (not group) |
16735 (real-file (concat file "-" (nth 1 gnus-select-method)))) | 2052 (equal (cadr method) "")) |
16736 (if (or (file-exists-p real-file) | 2053 method) |
16737 (file-exists-p (concat real-file ".el")) | 2054 (t |
16738 (file-exists-p (concat real-file ".eld"))) | 2055 (gnus-server-add-address method)))) |
16739 real-file file))) | 2056 |
16740 | 2057 (defun gnus-server-to-method (server) |
16741 (defun gnus-newsrc-to-gnus-format () | 2058 "Map virtual server names to select methods." |
16742 (setq gnus-newsrc-options "") | 2059 (or |
16743 (setq gnus-newsrc-options-n nil) | 2060 ;; Is this a method, perhaps? |
16744 | 2061 (and server (listp server) server) |
16745 (or gnus-active-hashtb | 2062 ;; Perhaps this is the native server? |
16746 (setq gnus-active-hashtb (make-vector 4095 0))) | 2063 (and (equal server "native") gnus-select-method) |
16747 (let ((buf (current-buffer)) | 2064 ;; It should be in the server alist. |
16748 (already-read (> (length gnus-newsrc-alist) 1)) | 2065 (cdr (assoc server gnus-server-alist)) |
16749 group subscribed options-symbol newsrc Options-symbol | 2066 ;; It could be in the predefined server alist. |
16750 symbol reads num1) | 2067 (cdr (assoc server gnus-predefined-server-alist)) |
16751 (goto-char (point-min)) | 2068 ;; If not, we look through all the opened server |
16752 ;; We intern the symbol `options' in the active hashtb so that we | 2069 ;; to see whether we can find it there. |
16753 ;; can `eq' against it later. | 2070 (let ((opened gnus-opened-servers)) |
16754 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil) | 2071 (while (and opened |
16755 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil) | 2072 (not (equal server (format "%s:%s" (caaar opened) |
16756 | 2073 (cadaar opened))))) |
16757 (while (not (eobp)) | 2074 (pop opened)) |
16758 ;; We first read the first word on the line by narrowing and | 2075 (caar opened)))) |
16759 ;; then reading into `gnus-active-hashtb'. Most groups will | 2076 |
16760 ;; already exist in that hashtb, so this will save some string | 2077 (defmacro gnus-method-equal (ss1 ss2) |
16761 ;; space. | 2078 "Say whether two servers are equal." |
16762 (narrow-to-region | 2079 `(let ((s1 ,ss1) |
16763 (point) | 2080 (s2 ,ss2)) |
16764 (progn (skip-chars-forward "^ \t!:\n") (point))) | 2081 (or (equal s1 s2) |
16765 (goto-char (point-min)) | 2082 (and (= (length s1) (length s2)) |
16766 (setq symbol | 2083 (progn |
16767 (and (/= (point-min) (point-max)) | 2084 (while (and s1 (member (car s1) s2)) |
16768 (let ((obarray gnus-active-hashtb)) (read buf)))) | 2085 (setq s1 (cdr s1))) |
16769 (widen) | 2086 (null s1)))))) |
16770 ;; Now, the symbol we have read is either `options' or a group | 2087 |
16771 ;; name. If it is an options line, we just add it to a string. | 2088 (defun gnus-server-equal (m1 m2) |
16772 (cond | 2089 "Say whether two methods are equal." |
16773 ((or (eq symbol options-symbol) | 2090 (let ((m1 (cond ((null m1) gnus-select-method) |
16774 (eq symbol Options-symbol)) | 2091 ((stringp m1) (gnus-server-to-method m1)) |
16775 (setq gnus-newsrc-options | 2092 (t m1))) |
16776 ;; This concating is quite inefficient, but since our | 2093 (m2 (cond ((null m2) gnus-select-method) |
16777 ;; thorough studies show that approx 99.37% of all | 2094 ((stringp m2) (gnus-server-to-method m2)) |
16778 ;; .newsrc files only contain a single options line, we | 2095 (t m2)))) |
16779 ;; don't give a damn, frankly, my dear. | 2096 (gnus-method-equal m1 m2))) |
16780 (concat gnus-newsrc-options | 2097 |
16781 (buffer-substring | 2098 (defun gnus-servers-using-backend (backend) |
16782 (gnus-point-at-bol) | 2099 "Return a list of known servers using BACKEND." |
16783 ;; Options may continue on the next line. | 2100 (let ((opened gnus-opened-servers) |
16784 (or (and (re-search-forward "^[^ \t]" nil 'move) | 2101 out) |
16785 (progn (beginning-of-line) (point))) | 2102 (while opened |
16786 (point))))) | 2103 (when (eq backend (caaar opened)) |
16787 (forward-line -1)) | 2104 (push (caar opened) out)) |
16788 (symbol | 2105 (pop opened)) |
16789 ;; Group names can be just numbers. | 2106 out)) |
16790 (when (numberp symbol) | 2107 |
16791 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb))) | 2108 (defun gnus-archive-server-wanted-p () |
16792 (or (boundp symbol) (set symbol nil)) | 2109 "Say whether the user wants to use the archive server." |
16793 ;; It was a group name. | 2110 (cond |
16794 (setq subscribed (= (following-char) ?:) | 2111 ((or (not gnus-message-archive-method) |
16795 group (symbol-name symbol) | 2112 (not gnus-message-archive-group)) |
16796 reads nil) | 2113 nil) |
16797 (if (eolp) | 2114 ((and gnus-message-archive-method gnus-message-archive-group) |
16798 ;; If the line ends here, this is clearly a buggy line, so | 2115 t) |
16799 ;; we put point a the beginning of line and let the cond | 2116 (t |
16800 ;; below do the error handling. | 2117 (let ((active (cadr (assq 'nnfolder-active-file |
16801 (beginning-of-line) | 2118 gnus-message-archive-method)))) |
16802 ;; We skip to the beginning of the ranges. | 2119 (and active |
16803 (skip-chars-forward "!: \t")) | 2120 (file-exists-p active)))))) |
16804 ;; We are now at the beginning of the list of read articles. | 2121 |
16805 ;; We read them range by range. | 2122 (defun gnus-group-prefixed-name (group method) |
16806 (while | 2123 "Return the whole name from GROUP and METHOD." |
16807 (cond | 2124 (and (stringp method) (setq method (gnus-server-to-method method))) |
16808 ((looking-at "[0-9]+") | 2125 (if (not method) |
16809 ;; We narrow and read a number instead of buffer-substring/ | 2126 group |
16810 ;; string-to-int because it's faster. narrow/widen is | 2127 (concat (format "%s" (car method)) |
16811 ;; faster than save-restriction/narrow, and save-restriction | 2128 (when (and |
16812 ;; produces a garbage object. | 2129 (or (assoc (format "%s" (car method)) |
16813 (setq num1 (progn | 2130 (gnus-methods-using 'address)) |
16814 (narrow-to-region (match-beginning 0) (match-end 0)) | 2131 (gnus-server-equal method gnus-message-archive-method)) |
16815 (read buf))) | 2132 (nth 1 method) |
16816 (widen) | 2133 (not (string= (nth 1 method) ""))) |
16817 ;; If the next character is a dash, then this is a range. | 2134 (concat "+" (nth 1 method))) |
16818 (if (= (following-char) ?-) | 2135 ":" group))) |
16819 (progn | 2136 |
16820 ;; We read the upper bound of the range. | 2137 (defun gnus-group-real-prefix (group) |
16821 (forward-char 1) | 2138 "Return the prefix of the current group name." |
16822 (if (not (looking-at "[0-9]+")) | 2139 (if (string-match "^[^:]+:" group) |
16823 ;; This is a buggy line, by we pretend that | 2140 (substring group 0 (match-end 0)) |
16824 ;; it's kinda OK. Perhaps the user should be | 2141 "")) |
16825 ;; dinged? | 2142 |
16826 (setq reads (cons num1 reads)) | 2143 (defun gnus-group-method (group) |
16827 (setq reads | 2144 "Return the server or method used for selecting GROUP. |
16828 (cons | 2145 You should probably use `gnus-find-method-for-group' instead." |
16829 (cons num1 | 2146 (let ((prefix (gnus-group-real-prefix group))) |
16830 (progn | 2147 (if (equal prefix "") |
16831 (narrow-to-region (match-beginning 0) | 2148 gnus-select-method |
16832 (match-end 0)) | 2149 (let ((servers gnus-opened-servers) |
16833 (read buf))) | 2150 (server "") |
16834 reads)) | 2151 backend possible found) |
16835 (widen))) | 2152 (if (string-match "^[^\\+]+\\+" prefix) |
16836 ;; It was just a simple number, so we add it to the | 2153 (setq backend (intern (substring prefix 0 (1- (match-end 0)))) |
16837 ;; list of ranges. | 2154 server (substring prefix (match-end 0) (1- (length prefix)))) |
16838 (setq reads (cons num1 reads))) | 2155 (setq backend (intern (substring prefix 0 (1- (length prefix)))))) |
16839 ;; If the next char in ?\n, then we have reached the end | 2156 (while servers |
16840 ;; of the line and return nil. | 2157 (when (eq (caaar servers) backend) |
16841 (/= (following-char) ?\n)) | 2158 (setq possible (caar servers)) |
16842 ((= (following-char) ?\n) | 2159 (when (equal (cadaar servers) server) |
16843 ;; End of line, so we end. | 2160 (setq found (caar servers)))) |
16844 nil) | 2161 (pop servers)) |
16845 (t | 2162 (or (car (rassoc found gnus-server-alist)) |
16846 ;; Not numbers and not eol, so this might be a buggy | 2163 found |
16847 ;; line... | 2164 (car (rassoc possible gnus-server-alist)) |
16848 (or (eobp) | 2165 possible |
16849 ;; If it was eob instead of ?\n, we allow it. | 2166 (list backend server)))))) |
16850 (progn | 2167 |
16851 ;; The line was buggy. | 2168 (defsubst gnus-secondary-method-p (method) |
16852 (setq group nil) | 2169 "Return whether METHOD is a secondary select method." |
16853 (gnus-error 3.1 "Mangled line: %s" | 2170 (let ((methods gnus-secondary-select-methods) |
16854 (buffer-substring (gnus-point-at-bol) | 2171 (gmethod (gnus-server-get-method nil method))) |
16855 (gnus-point-at-eol))))) | 2172 (while (and methods |
16856 nil)) | 2173 (not (equal (gnus-server-get-method nil (car methods)) |
16857 ;; Skip past ", ". Spaces are illegal in these ranges, but | 2174 gmethod))) |
16858 ;; we allow them, because it's a common mistake to put a | 2175 (setq methods (cdr methods))) |
16859 ;; space after the comma. | 2176 methods)) |
16860 (skip-chars-forward ", ")) | 2177 |
16861 | 2178 (defun gnus-group-foreign-p (group) |
16862 ;; We have already read .newsrc.eld, so we gently update the | 2179 "Say whether a group is foreign or not." |
16863 ;; data in the hash table with the information we have just | 2180 (and (not (gnus-group-native-p group)) |
16864 ;; read. | 2181 (not (gnus-group-secondary-p group)))) |
16865 (when group | 2182 |
16866 (let ((info (gnus-get-info group)) | 2183 (defun gnus-group-native-p (group) |
16867 level) | 2184 "Say whether the group is native or not." |
16868 (if info | 2185 (not (string-match ":" group))) |
16869 ;; There is an entry for this file in the alist. | 2186 |
16870 (progn | 2187 (defun gnus-group-secondary-p (group) |
16871 (gnus-info-set-read info (nreverse reads)) | 2188 "Say whether the group is secondary or not." |
16872 ;; We update the level very gently. In fact, we | 2189 (gnus-secondary-method-p (gnus-find-method-for-group group))) |
16873 ;; only change it if there's been a status change | 2190 |
16874 ;; from subscribed to unsubscribed, or vice versa. | 2191 (defun gnus-group-find-parameter (group &optional symbol) |
16875 (setq level (gnus-info-level info)) | 2192 "Return the group parameters for GROUP. |
16876 (cond ((and (<= level gnus-level-subscribed) | 2193 If SYMBOL, return the value of that symbol in the group parameters." |
16877 (not subscribed)) | |
16878 (setq level (if reads | |
16879 gnus-level-default-unsubscribed | |
16880 (1+ gnus-level-default-unsubscribed)))) | |
16881 ((and (> level gnus-level-subscribed) subscribed) | |
16882 (setq level gnus-level-default-subscribed))) | |
16883 (gnus-info-set-level info level)) | |
16884 ;; This is a new group. | |
16885 (setq info (list group | |
16886 (if subscribed | |
16887 gnus-level-default-subscribed | |
16888 (if reads | |
16889 (1+ gnus-level-subscribed) | |
16890 gnus-level-default-unsubscribed)) | |
16891 (nreverse reads)))) | |
16892 (setq newsrc (cons info newsrc)))))) | |
16893 (forward-line 1)) | |
16894 | |
16895 (setq newsrc (nreverse newsrc)) | |
16896 | |
16897 (if (not already-read) | |
16898 () | |
16899 ;; We now have two newsrc lists - `newsrc', which is what we | |
16900 ;; have read from .newsrc, and `gnus-newsrc-alist', which is | |
16901 ;; what we've read from .newsrc.eld. We have to merge these | |
16902 ;; lists. We do this by "attaching" any (foreign) groups in the | |
16903 ;; gnus-newsrc-alist to the (native) group that precedes them. | |
16904 (let ((rc (cdr gnus-newsrc-alist)) | |
16905 (prev gnus-newsrc-alist) | |
16906 entry mentry) | |
16907 (while rc | |
16908 (or (null (nth 4 (car rc))) ; It's a native group. | |
16909 (assoc (caar rc) newsrc) ; It's already in the alist. | |
16910 (if (setq entry (assoc (caar prev) newsrc)) | |
16911 (setcdr (setq mentry (memq entry newsrc)) | |
16912 (cons (car rc) (cdr mentry))) | |
16913 (setq newsrc (cons (car rc) newsrc)))) | |
16914 (setq prev rc | |
16915 rc (cdr rc))))) | |
16916 | |
16917 (setq gnus-newsrc-alist newsrc) | |
16918 ;; We make the newsrc hashtb. | |
16919 (gnus-make-hashtable-from-newsrc-alist) | |
16920 | |
16921 ;; Finally, if we read some options lines, we parse them. | |
16922 (or (string= gnus-newsrc-options "") | |
16923 (gnus-newsrc-parse-options gnus-newsrc-options)))) | |
16924 | |
16925 ;; Parse options lines to find "options -n !all rec.all" and stuff. | |
16926 ;; The return value will be a list on the form | |
16927 ;; ((regexp1 . ignore) | |
16928 ;; (regexp2 . subscribe)...) | |
16929 ;; When handling new newsgroups, groups that match a `ignore' regexp | |
16930 ;; will be ignored, and groups that match a `subscribe' regexp will be | |
16931 ;; subscribed. A line like | |
16932 ;; options -n !all rec.all | |
16933 ;; will lead to a list that looks like | |
16934 ;; (("^rec\\..+" . subscribe) | |
16935 ;; ("^.+" . ignore)) | |
16936 ;; So all "rec.*" groups will be subscribed, while all the other | |
16937 ;; groups will be ignored. Note that "options -n !all rec.all" is very | |
16938 ;; different from "options -n rec.all !all". | |
16939 (defun gnus-newsrc-parse-options (options) | |
16940 (let (out eol) | |
16941 (save-excursion | |
16942 (gnus-set-work-buffer) | |
16943 (insert (regexp-quote options)) | |
16944 ;; First we treat all continuation lines. | |
16945 (goto-char (point-min)) | |
16946 (while (re-search-forward "\n[ \t]+" nil t) | |
16947 (replace-match " " t t)) | |
16948 ;; Then we transform all "all"s into ".+"s. | |
16949 (goto-char (point-min)) | |
16950 (while (re-search-forward "\\ball\\b" nil t) | |
16951 (replace-match ".+" t t)) | |
16952 (goto-char (point-min)) | |
16953 ;; We remove all other options than the "-n" ones. | |
16954 (while (re-search-forward "[ \t]-[^n][^-]*" nil t) | |
16955 (replace-match " ") | |
16956 (forward-char -1)) | |
16957 (goto-char (point-min)) | |
16958 | |
16959 ;; We are only interested in "options -n" lines - we | |
16960 ;; ignore the other option lines. | |
16961 (while (re-search-forward "[ \t]-n" nil t) | |
16962 (setq eol | |
16963 (or (save-excursion | |
16964 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t) | |
16965 (- (point) 2))) | |
16966 (gnus-point-at-eol))) | |
16967 ;; Search for all "words"... | |
16968 (while (re-search-forward "[^ \t,\n]+" eol t) | |
16969 (if (= (char-after (match-beginning 0)) ?!) | |
16970 ;; If the word begins with a bang (!), this is a "not" | |
16971 ;; spec. We put this spec (minus the bang) and the | |
16972 ;; symbol `ignore' into the list. | |
16973 (setq out (cons (cons (concat | |
16974 "^" (buffer-substring | |
16975 (1+ (match-beginning 0)) | |
16976 (match-end 0))) | |
16977 'ignore) out)) | |
16978 ;; There was no bang, so this is a "yes" spec. | |
16979 (setq out (cons (cons (concat "^" (match-string 0)) | |
16980 'subscribe) out))))) | |
16981 | |
16982 (setq gnus-newsrc-options-n out)))) | |
16983 | |
16984 (defun gnus-save-newsrc-file (&optional force) | |
16985 "Save .newsrc file." | |
16986 ;; Note: We cannot save .newsrc file if all newsgroups are removed | |
16987 ;; from the variable gnus-newsrc-alist. | |
16988 (when (and (or gnus-newsrc-alist gnus-killed-list) | |
16989 gnus-current-startup-file) | |
16990 (save-excursion | |
16991 (if (and (or gnus-use-dribble-file gnus-slave) | |
16992 (not force) | |
16993 (or (not gnus-dribble-buffer) | |
16994 (not (buffer-name gnus-dribble-buffer)) | |
16995 (zerop (save-excursion | |
16996 (set-buffer gnus-dribble-buffer) | |
16997 (buffer-size))))) | |
16998 (gnus-message 4 "(No changes need to be saved)") | |
16999 (run-hooks 'gnus-save-newsrc-hook) | |
17000 (if gnus-slave | |
17001 (gnus-slave-save-newsrc) | |
17002 ;; Save .newsrc. | |
17003 (when gnus-save-newsrc-file | |
17004 (gnus-message 5 "Saving %s..." gnus-current-startup-file) | |
17005 (gnus-gnus-to-newsrc-format) | |
17006 (gnus-message 5 "Saving %s...done" gnus-current-startup-file)) | |
17007 ;; Save .newsrc.eld. | |
17008 (set-buffer (get-buffer-create " *Gnus-newsrc*")) | |
17009 (make-local-variable 'version-control) | |
17010 (setq version-control 'never) | |
17011 (setq buffer-file-name | |
17012 (concat gnus-current-startup-file ".eld")) | |
17013 (setq default-directory (file-name-directory buffer-file-name)) | |
17014 (gnus-add-current-to-buffer-list) | |
17015 (buffer-disable-undo (current-buffer)) | |
17016 (erase-buffer) | |
17017 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file) | |
17018 (gnus-gnus-to-quick-newsrc-format) | |
17019 (run-hooks 'gnus-save-quick-newsrc-hook) | |
17020 (save-buffer) | |
17021 (kill-buffer (current-buffer)) | |
17022 (gnus-message | |
17023 5 "Saving %s.eld...done" gnus-current-startup-file)) | |
17024 (gnus-dribble-delete-file) | |
17025 (gnus-group-set-mode-line))))) | |
17026 | |
17027 (defun gnus-gnus-to-quick-newsrc-format () | |
17028 "Insert Gnus variables such as gnus-newsrc-alist in lisp format." | |
17029 (insert ";; Gnus startup file.\n") | |
17030 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n") | |
17031 (insert ";; to read .newsrc.\n") | |
17032 (insert "(setq gnus-newsrc-file-version " | |
17033 (prin1-to-string gnus-version) ")\n") | |
17034 (let ((variables | |
17035 (if gnus-save-killed-list gnus-variable-list | |
17036 ;; Remove the `gnus-killed-list' from the list of variables | |
17037 ;; to be saved, if required. | |
17038 (delq 'gnus-killed-list (copy-sequence gnus-variable-list)))) | |
17039 ;; Peel off the "dummy" group. | |
17040 (gnus-newsrc-alist (cdr gnus-newsrc-alist)) | |
17041 variable) | |
17042 ;; Insert the variables into the file. | |
17043 (while variables | |
17044 (when (and (boundp (setq variable (pop variables))) | |
17045 (symbol-value variable)) | |
17046 (insert "(setq " (symbol-name variable) " '") | |
17047 (prin1 (symbol-value variable) (current-buffer)) | |
17048 (insert ")\n"))))) | |
17049 | |
17050 (defun gnus-gnus-to-newsrc-format () | |
17051 ;; Generate and save the .newsrc file. | |
17052 (save-excursion | 2194 (save-excursion |
17053 (set-buffer (create-file-buffer gnus-current-startup-file)) | 2195 (set-buffer gnus-group-buffer) |
17054 (let ((newsrc (cdr gnus-newsrc-alist)) | 2196 (let ((parameters (funcall gnus-group-get-parameter-function group))) |
17055 (standard-output (current-buffer)) | 2197 (if symbol |
17056 info ranges range method) | 2198 (gnus-group-parameter-value parameters symbol) |
17057 (setq buffer-file-name gnus-current-startup-file) | 2199 parameters)))) |
17058 (setq default-directory (file-name-directory buffer-file-name)) | 2200 |
17059 (buffer-disable-undo (current-buffer)) | 2201 (defun gnus-group-get-parameter (group &optional symbol) |
17060 (erase-buffer) | 2202 "Return the group parameters for GROUP. |
17061 ;; Write options. | 2203 If SYMBOL, return the value of that symbol in the group parameters." |
17062 (if gnus-newsrc-options (insert gnus-newsrc-options)) | 2204 (let ((params (gnus-info-params (gnus-get-info group)))) |
17063 ;; Write subscribed and unsubscribed. | 2205 (if symbol |
17064 (while (setq info (pop newsrc)) | 2206 (gnus-group-parameter-value params symbol) |
17065 ;; Don't write foreign groups to .newsrc. | 2207 params))) |
17066 (when (or (null (setq method (gnus-info-method info))) | 2208 |
17067 (equal method "native") | 2209 (defun gnus-group-parameter-value (params symbol) |
17068 (gnus-server-equal method gnus-select-method)) | 2210 "Return the value of SYMBOL in group PARAMS." |
17069 (insert (gnus-info-group info) | 2211 (or (car (memq symbol params)) ; It's either a simple symbol |
17070 (if (> (gnus-info-level info) gnus-level-subscribed) | 2212 (cdr (assq symbol params)))) ; or a cons. |
17071 "!" ":")) | 2213 |
17072 (when (setq ranges (gnus-info-read info)) | 2214 (defun gnus-group-add-parameter (group param) |
17073 (insert " ") | 2215 "Add parameter PARAM to GROUP." |
17074 (if (not (listp (cdr ranges))) | 2216 (let ((info (gnus-get-info group))) |
17075 (if (= (car ranges) (cdr ranges)) | 2217 (if (not info) |
17076 (princ (car ranges)) | 2218 () ; This is a dead group. We just ignore it. |
17077 (princ (car ranges)) | 2219 ;; Cons the new param to the old one and update. |
17078 (insert "-") | 2220 (gnus-group-set-info (cons param (gnus-info-params info)) |
17079 (princ (cdr ranges))) | 2221 group 'params)))) |
17080 (while (setq range (pop ranges)) | 2222 |
17081 (if (or (atom range) (= (car range) (cdr range))) | 2223 (defun gnus-group-set-parameter (group name value) |
17082 (princ (or (and (atom range) range) (car range))) | 2224 "Set parameter NAME to VALUE in GROUP." |
17083 (princ (car range)) | 2225 (let ((info (gnus-get-info group))) |
17084 (insert "-") | 2226 (if (not info) |
17085 (princ (cdr range))) | 2227 () ; This is a dead group. We just ignore it. |
17086 (if ranges (insert ","))))) | 2228 (let ((old-params (gnus-info-params info)) |
17087 (insert "\n"))) | 2229 (new-params (list (cons name value)))) |
17088 (make-local-variable 'version-control) | 2230 (while old-params |
17089 (setq version-control 'never) | 2231 (when (or (not (listp (car old-params))) |
17090 ;; It has been reported that sometime the modtime on the .newsrc | 2232 (not (eq (caar old-params) name))) |
17091 ;; file seems to be off. We really do want to overwrite it, so | 2233 (setq new-params (append new-params (list (car old-params))))) |
17092 ;; we clear the modtime here before saving. It's a bit odd, | 2234 (setq old-params (cdr old-params))) |
17093 ;; though... | 2235 (gnus-group-set-info new-params group 'params))))) |
17094 ;; sometimes the modtime clear isn't sufficient. most brute force: | 2236 |
17095 ;; delete the silly thing entirely first. but this fails to provide | 2237 (defun gnus-group-add-score (group &optional score) |
17096 ;; such niceties as .newsrc~ creation. | 2238 "Add SCORE to the GROUP score. |
17097 (if gnus-modtime-botch | 2239 If SCORE is nil, add 1 to the score of GROUP." |
17098 (delete-file gnus-startup-file) | 2240 (let ((info (gnus-get-info group))) |
17099 (clear-visited-file-modtime)) | 2241 (when info |
17100 (run-hooks 'gnus-save-standard-newsrc-hook) | 2242 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1)))))) |
17101 (save-buffer) | 2243 |
17102 (kill-buffer (current-buffer))))) | 2244 ;; Function written by Stainless Steel Rat <ratinox@peorth.gweep.net> |
2245 (defun gnus-short-group-name (group &optional levels) | |
2246 "Collapse GROUP name LEVELS. | |
2247 Select methods are stripped and any remote host name is stripped down to | |
2248 just the host name." | |
2249 (let* ((name "") (foreign "") (depth -1) (skip 1) | |
2250 (levels (or levels | |
2251 (progn | |
2252 (while (string-match "\\." group skip) | |
2253 (setq skip (match-end 0) | |
2254 depth (+ depth 1))) | |
2255 depth)))) | |
2256 ;; separate foreign select method from group name and collapse. | |
2257 ;; if method contains a server, collapse to non-domain server name, | |
2258 ;; otherwise collapse to select method | |
2259 (when (string-match ":" group) | |
2260 (cond ((string-match "+" group) | |
2261 (let* ((plus (string-match "+" group)) | |
2262 (colon (string-match ":" group (or plus 0))) | |
2263 (dot (string-match "\\." group))) | |
2264 (setq foreign (concat | |
2265 (substring group (+ 1 plus) | |
2266 (cond ((null dot) colon) | |
2267 ((< colon dot) colon) | |
2268 ((< dot colon) dot))) | |
2269 ":") | |
2270 group (substring group (+ 1 colon))))) | |
2271 (t | |
2272 (let* ((colon (string-match ":" group))) | |
2273 (setq foreign (concat (substring group 0 (+ 1 colon))) | |
2274 group (substring group (+ 1 colon))))))) | |
2275 ;; collapse group name leaving LEVELS uncollapsed elements | |
2276 (while group | |
2277 (if (and (string-match "\\." group) (> levels 0)) | |
2278 (setq name (concat name (substring group 0 1)) | |
2279 group (substring group (match-end 0)) | |
2280 levels (- levels 1) | |
2281 name (concat name ".")) | |
2282 (setq name (concat foreign name group) | |
2283 group nil))) | |
2284 name)) | |
17103 | 2285 |
17104 | 2286 |
17105 ;;; | 2287 ;;; |
17106 ;;; Slave functions. | 2288 ;;; Kill file handling. |
17107 ;;; | 2289 ;;; |
17108 | 2290 |
17109 (defun gnus-slave-save-newsrc () | 2291 (defun gnus-apply-kill-file () |
17110 (save-excursion | 2292 "Apply a kill file to the current newsgroup. |
17111 (set-buffer gnus-dribble-buffer) | 2293 Returns the number of articles marked as read." |
17112 (let ((slave-name | 2294 (if (or (file-exists-p (gnus-newsgroup-kill-file nil)) |
17113 (make-temp-name (concat gnus-current-startup-file "-slave-")))) | 2295 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name))) |
17114 (write-region (point-min) (point-max) slave-name nil 'nomesg)))) | 2296 (gnus-apply-kill-file-internal) |
17115 | 2297 0)) |
17116 (defun gnus-master-read-slave-newsrc () | 2298 |
17117 (let ((slave-files | 2299 (defun gnus-kill-save-kill-buffer () |
17118 (directory-files | 2300 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name))) |
17119 (file-name-directory gnus-current-startup-file) | 2301 (when (get-file-buffer file) |
17120 t (concat | |
17121 "^" (regexp-quote | |
17122 (concat | |
17123 (file-name-nondirectory gnus-current-startup-file) | |
17124 "-slave-"))) | |
17125 t)) | |
17126 file) | |
17127 (if (not slave-files) | |
17128 () ; There are no slave files to read. | |
17129 (gnus-message 7 "Reading slave newsrcs...") | |
17130 (save-excursion | 2302 (save-excursion |
17131 (set-buffer (get-buffer-create " *gnus slave*")) | 2303 (set-buffer (get-file-buffer file)) |
17132 (buffer-disable-undo (current-buffer)) | 2304 (when (buffer-modified-p) |
17133 (setq slave-files | 2305 (save-buffer)) |
17134 (sort (mapcar (lambda (file) | 2306 (kill-buffer (current-buffer)))))) |
17135 (list (nth 5 (file-attributes file)) file)) | 2307 |
17136 slave-files) | 2308 (defcustom gnus-kill-file-name "KILL" |
17137 (lambda (f1 f2) | 2309 "Suffix of the kill files." |
17138 (or (< (caar f1) (caar f2)) | 2310 :group 'gnus-score-kill |
17139 (< (nth 1 (car f1)) (nth 1 (car f2))))))) | 2311 :group 'gnus-score-files |
17140 (while slave-files | 2312 :type 'string) |
17141 (erase-buffer) | 2313 |
17142 (setq file (nth 1 (car slave-files))) | 2314 (defun gnus-newsgroup-kill-file (newsgroup) |
17143 (insert-file-contents file) | 2315 "Return the name of a kill file name for NEWSGROUP. |
17144 (if (condition-case () | 2316 If NEWSGROUP is nil, return the global kill file name instead." |
17145 (progn | 2317 (cond |
17146 (eval-buffer (current-buffer)) | 2318 ;; The global KILL file is placed at top of the directory. |
17147 t) | 2319 ((or (null newsgroup) |
17148 (error | 2320 (string-equal newsgroup "")) |
17149 (gnus-error 3.2 "Possible error in %s" file) | 2321 (expand-file-name gnus-kill-file-name |
17150 nil)) | 2322 gnus-kill-files-directory)) |
17151 (or gnus-slave ; Slaves shouldn't delete these files. | 2323 ;; Append ".KILL" to newsgroup name. |
17152 (condition-case () | 2324 ((gnus-use-long-file-name 'not-kill) |
17153 (delete-file file) | 2325 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup) |
17154 (error nil)))) | 2326 "." gnus-kill-file-name) |
17155 (setq slave-files (cdr slave-files)))) | 2327 gnus-kill-files-directory)) |
17156 (gnus-message 7 "Reading slave newsrcs...done")))) | 2328 ;; Place "KILL" under the hierarchical directory. |
17157 | 2329 (t |
17158 | 2330 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup) |
17159 ;;; | 2331 "/" gnus-kill-file-name) |
17160 ;;; Group description. | 2332 gnus-kill-files-directory)))) |
17161 ;;; | 2333 |
17162 | 2334 ;;; Server things. |
17163 (defun gnus-read-all-descriptions-files () | 2335 |
17164 (let ((methods (cons gnus-select-method | 2336 (defun gnus-member-of-valid (symbol group) |
17165 (nconc | 2337 "Find out if GROUP has SYMBOL as part of its \"valid\" spec." |
17166 (when (gnus-archive-server-wanted-p) | 2338 (memq symbol (assoc |
17167 (list "archive")) | 2339 (symbol-name (car (gnus-find-method-for-group group))) |
17168 gnus-secondary-select-methods)))) | 2340 gnus-valid-select-methods))) |
17169 (while methods | 2341 |
17170 (gnus-read-descriptions-file (car methods)) | 2342 (defun gnus-method-option-p (method option) |
17171 (setq methods (cdr methods))) | 2343 "Return non-nil if select METHOD has OPTION as a parameter." |
17172 t)) | 2344 (when (stringp method) |
17173 | 2345 (setq method (gnus-server-to-method method))) |
17174 (defun gnus-read-descriptions-file (&optional method) | 2346 (memq option (assoc (format "%s" (car method)) |
17175 (let ((method (or method gnus-select-method)) | 2347 gnus-valid-select-methods))) |
2348 | |
2349 (defun gnus-server-extend-method (group method) | |
2350 ;; This function "extends" a virtual server. If the server is | |
2351 ;; "hello", and the select method is ("hello" (my-var "something")) | |
2352 ;; in the group "alt.alt", this will result in a new virtual server | |
2353 ;; called "hello+alt.alt". | |
2354 (if (or (not (gnus-similar-server-opened method)) | |
2355 (not (cddr method))) | |
2356 method | |
2357 `(,(car method) ,(concat (cadr method) "+" group) | |
2358 (,(intern (format "%s-address" (car method))) ,(cadr method)) | |
2359 ,@(cddr method)))) | |
2360 | |
2361 (defun gnus-similar-server-opened (method) | |
2362 (let ((opened gnus-opened-servers)) | |
2363 (while (and method opened) | |
2364 (when (and (equal (cadr method) (cadaar opened)) | |
2365 (not (equal method (caar opened)))) | |
2366 (setq method nil)) | |
2367 (pop opened)) | |
2368 (not method))) | |
2369 | |
2370 (defun gnus-server-status (method) | |
2371 "Return the status of METHOD." | |
2372 (nth 1 (assoc method gnus-opened-servers))) | |
2373 | |
2374 (defun gnus-group-name-to-method (group) | |
2375 "Guess a select method based on GROUP." | |
2376 (if (string-match ":" group) | |
2377 (let ((server (substring group 0 (match-beginning 0)))) | |
2378 (if (string-match "\\+" server) | |
2379 (list (intern (substring server 0 (match-beginning 0))) | |
2380 (substring server (match-end 0))) | |
2381 (list (intern server) ""))) | |
2382 gnus-select-method)) | |
2383 | |
2384 (defun gnus-find-method-for-group (group &optional info) | |
2385 "Find the select method that GROUP uses." | |
2386 (or gnus-override-method | |
2387 (and (not group) | |
2388 gnus-select-method) | |
2389 (let ((info (or info (gnus-get-info group))) | |
2390 method) | |
2391 (if (or (not info) | |
2392 (not (setq method (gnus-info-method info))) | |
2393 (equal method "native")) | |
2394 gnus-select-method | |
2395 (setq method | |
2396 (cond ((stringp method) | |
2397 (gnus-server-to-method method)) | |
2398 ((stringp (cadr method)) | |
2399 (gnus-server-extend-method group method)) | |
2400 (t | |
2401 method))) | |
2402 (cond ((equal (cadr method) "") | |
2403 method) | |
2404 ((null (cadr method)) | |
2405 (list (car method) "")) | |
2406 (t | |
2407 (gnus-server-add-address method))))))) | |
2408 | |
2409 (defun gnus-check-backend-function (func group) | |
2410 "Check whether GROUP supports function FUNC. | |
2411 GROUP can either be a string (a group name) or a select method." | |
2412 (ignore-errors | |
2413 (let ((method (if (stringp group) | |
2414 (car (gnus-find-method-for-group group)) | |
2415 group))) | |
2416 (unless (featurep method) | |
2417 (require method)) | |
2418 (fboundp (intern (format "%s-%s" method func)))))) | |
2419 | |
2420 (defun gnus-methods-using (feature) | |
2421 "Find all methods that have FEATURE." | |
2422 (let ((valids gnus-valid-select-methods) | |
2423 outs) | |
2424 (while valids | |
2425 (when (memq feature (car valids)) | |
2426 (push (car valids) outs)) | |
2427 (setq valids (cdr valids))) | |
2428 outs)) | |
2429 | |
2430 (defun gnus-read-group (prompt &optional default) | |
2431 "Prompt the user for a group name. | |
2432 Disallow illegal group names." | |
2433 (let ((prefix "") | |
17176 group) | 2434 group) |
17177 (when (stringp method) | 2435 (while (not group) |
17178 (setq method (gnus-server-to-method method))) | 2436 (when (string-match |
17179 ;; We create the hashtable whether we manage to read the desc file | 2437 "[: `'\"/]\\|^$" |
17180 ;; to avoid trying to re-read after a failed read. | 2438 (setq group (read-string (concat prefix prompt) |
17181 (or gnus-description-hashtb | 2439 (cons (or default "") 0) |
17182 (setq gnus-description-hashtb | 2440 'gnus-group-history))) |
17183 (gnus-make-hashtable (length gnus-active-hashtb)))) | 2441 (setq prefix (format "Illegal group name: \"%s\". " group) |
17184 ;; Mark this method's desc file as read. | 2442 group nil))) |
17185 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read" | 2443 group)) |
17186 gnus-description-hashtb) | 2444 |
17187 | 2445 (defun gnus-read-method (prompt) |
17188 (gnus-message 5 "Reading descriptions file via %s..." (car method)) | 2446 "Prompt the user for a method. |
17189 (cond | 2447 Allow completion over sensible values." |
17190 ((not (gnus-check-server method)) | 2448 (let ((method |
17191 (gnus-message 1 "Couldn't open server") | 2449 (completing-read |
17192 nil) | 2450 prompt (append gnus-valid-select-methods gnus-predefined-server-alist |
17193 ((not (gnus-request-list-newsgroups method)) | 2451 gnus-server-alist) |
17194 (gnus-message 1 "Couldn't read newsgroups descriptions") | 2452 nil t nil 'gnus-method-history))) |
17195 nil) | 2453 (cond |
2454 ((equal method "") | |
2455 (setq method gnus-select-method)) | |
2456 ((assoc method gnus-valid-select-methods) | |
2457 (list (intern method) | |
2458 (if (memq 'prompt-address | |
2459 (assoc method gnus-valid-select-methods)) | |
2460 (read-string "Address: ") | |
2461 ""))) | |
2462 ((assoc method gnus-server-alist) | |
2463 method) | |
17196 (t | 2464 (t |
17197 (save-excursion | 2465 (list (intern method) ""))))) |
17198 (save-restriction | 2466 |
17199 (set-buffer nntp-server-buffer) | 2467 ;;; User-level commands. |
17200 (goto-char (point-min)) | 2468 |
17201 (when (or (search-forward "\n.\n" nil t) | 2469 ;;;###autoload |
17202 (goto-char (point-max))) | 2470 (defun gnus-slave-no-server (&optional arg) |
17203 (beginning-of-line) | 2471 "Read network news as a slave, without connecting to local server" |
17204 (narrow-to-region (point-min) (point))) | 2472 (interactive "P") |
17205 ;; If these are groups from a foreign select method, we insert the | 2473 (gnus-no-server arg t)) |
17206 ;; group prefix in front of the group names. | 2474 |
17207 (and method (not (gnus-server-equal | 2475 ;;;###autoload |
17208 (gnus-server-get-method nil method) | 2476 (defun gnus-no-server (&optional arg slave) |
17209 (gnus-server-get-method nil gnus-select-method))) | 2477 "Read network news. |
17210 (let ((prefix (gnus-group-prefixed-name "" method))) | 2478 If ARG is a positive number, Gnus will use that as the |
17211 (goto-char (point-min)) | 2479 startup level. If ARG is nil, Gnus will be started at level 2. |
17212 (while (and (not (eobp)) | 2480 If ARG is non-nil and not a positive number, Gnus will |
17213 (progn (insert prefix) | 2481 prompt the user for the name of an NNTP server to use. |
17214 (zerop (forward-line 1))))))) | 2482 As opposed to `gnus', this command will not connect to the local server." |
17215 (goto-char (point-min)) | 2483 (interactive "P") |
17216 (while (not (eobp)) | 2484 (gnus-no-server-1 arg slave)) |
17217 ;; If we get an error, we set group to 0, which is not a | 2485 |
17218 ;; symbol... | 2486 ;;;###autoload |
17219 (setq group | 2487 (defun gnus-slave (&optional arg) |
17220 (condition-case () | 2488 "Read news as a slave." |
17221 (let ((obarray gnus-description-hashtb)) | 2489 (interactive "P") |
17222 ;; Group is set to a symbol interned in this | 2490 (gnus arg nil 'slave)) |
17223 ;; hash table. | 2491 |
17224 (read nntp-server-buffer)) | 2492 ;;;###autoload |
17225 (error 0))) | 2493 (defun gnus-other-frame (&optional arg) |
17226 (skip-chars-forward " \t") | 2494 "Pop up a frame to read news." |
17227 ;; ... which leads to this line being effectively ignored. | 2495 (interactive "P") |
17228 (and (symbolp group) | 2496 (let ((window (get-buffer-window gnus-group-buffer))) |
17229 (set group (buffer-substring | 2497 (cond (window |
17230 (point) (progn (end-of-line) (point))))) | 2498 (select-frame (window-frame window))) |
17231 (forward-line 1)))) | 2499 ((= (length (frame-list)) 1) |
17232 (gnus-message 5 "Reading descriptions file...done") | 2500 (select-frame (make-frame))) |
17233 t)))) | 2501 (t |
17234 | 2502 (other-frame 1)))) |
17235 (defun gnus-group-get-description (group) | 2503 (gnus arg)) |
17236 "Get the description of a group by sending XGTITLE to the server." | 2504 |
17237 (when (gnus-request-group-description group) | 2505 ;;;###autoload |
17238 (save-excursion | 2506 (defun gnus (&optional arg dont-connect slave) |
17239 (set-buffer nntp-server-buffer) | 2507 "Read network news. |
17240 (goto-char (point-min)) | 2508 If ARG is non-nil and a positive number, Gnus will use that as the |
17241 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)") | 2509 startup level. If ARG is non-nil and not a positive number, Gnus will |
17242 (match-string 1))))) | 2510 prompt the user for the name of an NNTP server to use." |
17243 | 2511 (interactive "P") |
17244 | 2512 (gnus-1 arg dont-connect slave)) |
17245 ;;; | |
17246 ;;; Buffering of read articles. | |
17247 ;;; | |
17248 | |
17249 (defvar gnus-backlog-buffer " *Gnus Backlog*") | |
17250 (defvar gnus-backlog-articles nil) | |
17251 (defvar gnus-backlog-hashtb nil) | |
17252 | |
17253 (defun gnus-backlog-buffer () | |
17254 "Return the backlog buffer." | |
17255 (or (get-buffer gnus-backlog-buffer) | |
17256 (save-excursion | |
17257 (set-buffer (get-buffer-create gnus-backlog-buffer)) | |
17258 (buffer-disable-undo (current-buffer)) | |
17259 (setq buffer-read-only t) | |
17260 (gnus-add-current-to-buffer-list) | |
17261 (get-buffer gnus-backlog-buffer)))) | |
17262 | |
17263 (defun gnus-backlog-setup () | |
17264 "Initialize backlog variables." | |
17265 (unless gnus-backlog-hashtb | |
17266 (setq gnus-backlog-hashtb (make-vector 1023 0)))) | |
17267 | |
17268 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus) | |
17269 | |
17270 (defun gnus-backlog-shutdown () | |
17271 "Clear all backlog variables and buffers." | |
17272 (when (get-buffer gnus-backlog-buffer) | |
17273 (kill-buffer gnus-backlog-buffer)) | |
17274 (setq gnus-backlog-hashtb nil | |
17275 gnus-backlog-articles nil)) | |
17276 | |
17277 (defun gnus-backlog-enter-article (group number buffer) | |
17278 (gnus-backlog-setup) | |
17279 (let ((ident (intern (concat group ":" (int-to-string number)) | |
17280 gnus-backlog-hashtb)) | |
17281 b) | |
17282 (if (memq ident gnus-backlog-articles) | |
17283 () ; It's already kept. | |
17284 ;; Remove the oldest article, if necessary. | |
17285 (and (numberp gnus-keep-backlog) | |
17286 (>= (length gnus-backlog-articles) gnus-keep-backlog) | |
17287 (gnus-backlog-remove-oldest-article)) | |
17288 (setq gnus-backlog-articles (cons ident gnus-backlog-articles)) | |
17289 ;; Insert the new article. | |
17290 (save-excursion | |
17291 (set-buffer (gnus-backlog-buffer)) | |
17292 (let (buffer-read-only) | |
17293 (goto-char (point-max)) | |
17294 (or (bolp) (insert "\n")) | |
17295 (setq b (point)) | |
17296 (insert-buffer-substring buffer) | |
17297 ;; Tag the beginning of the article with the ident. | |
17298 (gnus-put-text-property b (1+ b) 'gnus-backlog ident)))))) | |
17299 | |
17300 (defun gnus-backlog-remove-oldest-article () | |
17301 (save-excursion | |
17302 (set-buffer (gnus-backlog-buffer)) | |
17303 (goto-char (point-min)) | |
17304 (if (zerop (buffer-size)) | |
17305 () ; The buffer is empty. | |
17306 (let ((ident (get-text-property (point) 'gnus-backlog)) | |
17307 buffer-read-only) | |
17308 ;; Remove the ident from the list of articles. | |
17309 (when ident | |
17310 (setq gnus-backlog-articles (delq ident gnus-backlog-articles))) | |
17311 ;; Delete the article itself. | |
17312 (delete-region | |
17313 (point) (next-single-property-change | |
17314 (1+ (point)) 'gnus-backlog nil (point-max))))))) | |
17315 | |
17316 (defun gnus-backlog-remove-article (group number) | |
17317 "Remove article NUMBER in GROUP from the backlog." | |
17318 (when (numberp number) | |
17319 (gnus-backlog-setup) | |
17320 (let ((ident (intern (concat group ":" (int-to-string number)) | |
17321 gnus-backlog-hashtb)) | |
17322 beg end) | |
17323 (when (memq ident gnus-backlog-articles) | |
17324 ;; It was in the backlog. | |
17325 (save-excursion | |
17326 (set-buffer (gnus-backlog-buffer)) | |
17327 (let (buffer-read-only) | |
17328 (when (setq beg (text-property-any | |
17329 (point-min) (point-max) 'gnus-backlog | |
17330 ident)) | |
17331 ;; Find the end (i. e., the beginning of the next article). | |
17332 (setq end | |
17333 (next-single-property-change | |
17334 (1+ beg) 'gnus-backlog (current-buffer) (point-max))) | |
17335 (delete-region beg end) | |
17336 ;; Return success. | |
17337 t))))))) | |
17338 | |
17339 (defun gnus-backlog-request-article (group number buffer) | |
17340 (when (numberp number) | |
17341 (gnus-backlog-setup) | |
17342 (let ((ident (intern (concat group ":" (int-to-string number)) | |
17343 gnus-backlog-hashtb)) | |
17344 beg end) | |
17345 (when (memq ident gnus-backlog-articles) | |
17346 ;; It was in the backlog. | |
17347 (save-excursion | |
17348 (set-buffer (gnus-backlog-buffer)) | |
17349 (if (not (setq beg (text-property-any | |
17350 (point-min) (point-max) 'gnus-backlog | |
17351 ident))) | |
17352 ;; It wasn't in the backlog after all. | |
17353 (ignore | |
17354 (setq gnus-backlog-articles (delq ident gnus-backlog-articles))) | |
17355 ;; Find the end (i. e., the beginning of the next article). | |
17356 (setq end | |
17357 (next-single-property-change | |
17358 (1+ beg) 'gnus-backlog (current-buffer) (point-max))))) | |
17359 (let ((buffer-read-only nil)) | |
17360 (erase-buffer) | |
17361 (insert-buffer-substring gnus-backlog-buffer beg end) | |
17362 t))))) | |
17363 | 2513 |
17364 ;; Allow redefinition of Gnus functions. | 2514 ;; Allow redefinition of Gnus functions. |
17365 | 2515 |
17366 (gnus-ems-redefine) | 2516 (gnus-ems-redefine) |
17367 | 2517 |