]> code.delx.au - gnu-emacs/blob - lisp/gnus/gnus-sum.el
5447da73fde9b7087604a2bf45e702667c72ccc6
[gnu-emacs] / lisp / gnus / gnus-sum.el
1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 ;; Free Software Foundation, Inc.
4
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;;; Code:
28
29 (eval-when-compile
30 (require 'cl)
31 (defvar tool-bar-map))
32
33 (require 'gnus)
34 (require 'gnus-group)
35 (require 'gnus-spec)
36 (require 'gnus-range)
37 (require 'gnus-int)
38 (require 'gnus-undo)
39 (require 'gnus-util)
40 (require 'mm-decode)
41 (require 'nnoo)
42
43 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
44 (autoload 'gnus-cache-write-active "gnus-cache")
45 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
46 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
47 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
48 (autoload 'mm-uu-dissect "mm-uu")
49 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
50 "Deuglify broken Outlook (Express) articles and redisplay."
51 t)
52 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
53 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
54 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
55
56 (defcustom gnus-kill-summary-on-exit t
57 "*If non-nil, kill the summary buffer when you exit from it.
58 If nil, the summary will become a \"*Dead Summary*\" buffer, and
59 it will be killed sometime later."
60 :group 'gnus-summary-exit
61 :type 'boolean)
62
63 (defcustom gnus-fetch-old-headers nil
64 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
65 If an unread article in the group refers to an older, already read (or
66 just marked as read) article, the old article will not normally be
67 displayed in the Summary buffer. If this variable is t, Gnus
68 will attempt to grab the headers to the old articles, and thereby
69 build complete threads. If it has the value `some', only enough
70 headers to connect otherwise loose threads will be displayed. This
71 variable can also be a number. In that case, no more than that number
72 of old headers will be fetched. If it has the value `invisible', all
73 old headers will be fetched, but none will be displayed.
74
75 The server has to support NOV for any of this to work."
76 :group 'gnus-thread
77 :type '(choice (const :tag "off" nil)
78 (const :tag "on" t)
79 (const some)
80 (const invisible)
81 number
82 (sexp :menu-tag "other" t)))
83
84 (defcustom gnus-refer-thread-limit 200
85 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
86 If t, fetch all the available old headers."
87 :group 'gnus-thread
88 :type '(choice number
89 (sexp :menu-tag "other" t)))
90
91 (defcustom gnus-summary-make-false-root 'adopt
92 "*nil means that Gnus won't gather loose threads.
93 If the root of a thread has expired or been read in a previous
94 session, the information necessary to build a complete thread has been
95 lost. Instead of having many small sub-threads from this original thread
96 scattered all over the summary buffer, Gnus can gather them.
97
98 If non-nil, Gnus will try to gather all loose sub-threads from an
99 original thread into one large thread.
100
101 If this variable is non-nil, it should be one of `none', `adopt',
102 `dummy' or `empty'.
103
104 If this variable is `none', Gnus will not make a false root, but just
105 present the sub-threads after another.
106 If this variable is `dummy', Gnus will create a dummy root that will
107 have all the sub-threads as children.
108 If this variable is `adopt', Gnus will make one of the \"children\"
109 the parent and mark all the step-children as such.
110 If this variable is `empty', the \"children\" are printed with empty
111 subject fields. (Or rather, they will be printed with a string
112 given by the `gnus-summary-same-subject' variable.)"
113 :group 'gnus-thread
114 :type '(choice (const :tag "off" nil)
115 (const none)
116 (const dummy)
117 (const adopt)
118 (const empty)))
119
120 (defcustom gnus-summary-make-false-root-always nil
121 "Always make a false dummy root."
122 :version "22.1"
123 :group 'gnus-thread
124 :type 'boolean)
125
126 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
127 "*A regexp to match subjects to be excluded from loose thread gathering.
128 As loose thread gathering is done on subjects only, that means that
129 there can be many false gatherings performed. By rooting out certain
130 common subjects, gathering might become saner."
131 :group 'gnus-thread
132 :type 'regexp)
133
134 (defcustom gnus-summary-gather-subject-limit nil
135 "*Maximum length of subject comparisons when gathering loose threads.
136 Use nil to compare full subjects. Setting this variable to a low
137 number will help gather threads that have been corrupted by
138 newsreaders chopping off subject lines, but it might also mean that
139 unrelated articles that have subject that happen to begin with the
140 same few characters will be incorrectly gathered.
141
142 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
143 comparing subjects."
144 :group 'gnus-thread
145 :type '(choice (const :tag "off" nil)
146 (const fuzzy)
147 (sexp :menu-tag "on" t)))
148
149 (defcustom gnus-simplify-subject-functions nil
150 "List of functions taking a string argument that simplify subjects.
151 The functions are applied recursively.
152
153 Useful functions to put in this list include:
154 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
155 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
156 :group 'gnus-thread
157 :type '(repeat function))
158
159 (defcustom gnus-simplify-ignored-prefixes nil
160 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
161 :group 'gnus-thread
162 :type '(choice (const :tag "off" nil)
163 regexp))
164
165 (defcustom gnus-build-sparse-threads nil
166 "*If non-nil, fill in the gaps in threads.
167 If `some', only fill in the gaps that are needed to tie loose threads
168 together. If `more', fill in all leaf nodes that Gnus can find. If
169 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
170 :group 'gnus-thread
171 :type '(choice (const :tag "off" nil)
172 (const some)
173 (const more)
174 (sexp :menu-tag "all" t)))
175
176 (defcustom gnus-summary-thread-gathering-function
177 'gnus-gather-threads-by-subject
178 "*Function used for gathering loose threads.
179 There are two pre-defined functions: `gnus-gather-threads-by-subject',
180 which only takes Subjects into consideration; and
181 `gnus-gather-threads-by-references', which compared the References
182 headers of the articles to find matches."
183 :group 'gnus-thread
184 :type '(radio (function-item gnus-gather-threads-by-subject)
185 (function-item gnus-gather-threads-by-references)
186 (function :tag "other")))
187
188 (defcustom gnus-summary-same-subject ""
189 "*String indicating that the current article has the same subject as the previous.
190 This variable will only be used if the value of
191 `gnus-summary-make-false-root' is `empty'."
192 :group 'gnus-summary-format
193 :type 'string)
194
195 (defcustom gnus-summary-goto-unread t
196 "*If t, many commands will go to the next unread article.
197 This applies to marking commands as well as other commands that
198 \"naturally\" select the next article, like, for instance, `SPC' at
199 the end of an article.
200
201 If nil, the marking commands do NOT go to the next unread article
202 \(they go to the next article instead). If `never', commands that
203 usually go to the next unread article, will go to the next article,
204 whether it is read or not."
205 :group 'gnus-summary-marks
206 :link '(custom-manual "(gnus)Setting Marks")
207 :type '(choice (const :tag "off" nil)
208 (const never)
209 (sexp :menu-tag "on" t)))
210
211 (defcustom gnus-summary-default-score 0
212 "*Default article score level.
213 All scores generated by the score files will be added to this score.
214 If this variable is nil, scoring will be disabled."
215 :group 'gnus-score-default
216 :type '(choice (const :tag "disable")
217 integer))
218
219 (defcustom gnus-summary-default-high-score 0
220 "*Default threshold for a high scored article.
221 An article will be highlighted as high scored if its score is greater
222 than this score."
223 :version "22.1"
224 :group 'gnus-score-default
225 :type 'integer)
226
227 (defcustom gnus-summary-default-low-score 0
228 "*Default threshold for a low scored article.
229 An article will be highlighted as low scored if its score is smaller
230 than this score."
231 :version "22.1"
232 :group 'gnus-score-default
233 :type 'integer)
234
235 (defcustom gnus-summary-zcore-fuzz 0
236 "*Fuzziness factor for the zcore in the summary buffer.
237 Articles with scores closer than this to `gnus-summary-default-score'
238 will not be marked."
239 :group 'gnus-summary-format
240 :type 'integer)
241
242 (defcustom gnus-simplify-subject-fuzzy-regexp nil
243 "*Strings to be removed when doing fuzzy matches.
244 This can either be a regular expression or list of regular expressions
245 that will be removed from subject strings if fuzzy subject
246 simplification is selected."
247 :group 'gnus-thread
248 :type '(repeat regexp))
249
250 (defcustom gnus-show-threads t
251 "*If non-nil, display threads in summary mode."
252 :group 'gnus-thread
253 :type 'boolean)
254
255 (defcustom gnus-thread-hide-subtree nil
256 "*If non-nil, hide all threads initially.
257 This can be a predicate specifier which says which threads to hide.
258 If threads are hidden, you have to run the command
259 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
260 to expose hidden threads."
261 :group 'gnus-thread
262 :type '(radio (sexp :format "Non-nil\n"
263 :match (lambda (widget value)
264 (not (or (consp value) (functionp value))))
265 :value t)
266 (const nil)
267 (sexp :tag "Predicate specifier")))
268
269 (defcustom gnus-thread-hide-killed t
270 "*If non-nil, hide killed threads automatically."
271 :group 'gnus-thread
272 :type 'boolean)
273
274 (defcustom gnus-thread-ignore-subject t
275 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
276 If nil, articles that have different subjects from their parents will
277 start separate threads."
278 :group 'gnus-thread
279 :type 'boolean)
280
281 (defcustom gnus-thread-operation-ignore-subject t
282 "*If non-nil, subjects will be ignored when doing thread commands.
283 This affects commands like `gnus-summary-kill-thread' and
284 `gnus-summary-lower-thread'.
285
286 If this variable is nil, articles in the same thread with different
287 subjects will not be included in the operation in question. If this
288 variable is `fuzzy', only articles that have subjects that are fuzzily
289 equal will be included."
290 :group 'gnus-thread
291 :type '(choice (const :tag "off" nil)
292 (const fuzzy)
293 (sexp :tag "on" t)))
294
295 (defcustom gnus-thread-indent-level 4
296 "*Number that says how much each sub-thread should be indented."
297 :group 'gnus-thread
298 :type 'integer)
299
300 (defcustom gnus-auto-extend-newsgroup t
301 "*If non-nil, extend newsgroup forward and backward when requested."
302 :group 'gnus-summary-choose
303 :type 'boolean)
304
305 (defcustom gnus-auto-select-first t
306 "*If non-nil, select the article under point.
307 Which article this is is controlled by the `gnus-auto-select-subject'
308 variable.
309
310 If you want to prevent automatic selection of articles in some
311 newsgroups, set the variable to nil in `gnus-select-group-hook'."
312 :group 'gnus-group-select
313 :type '(choice (const :tag "none" nil)
314 (sexp :menu-tag "first" t)))
315
316 (defcustom gnus-auto-select-subject 'unread
317 "*Says what subject to place under point when entering a group.
318
319 This variable can either be the symbols `first' (place point on the
320 first subject), `unread' (place point on the subject line of the first
321 unread article), `best' (place point on the subject line of the
322 higest-scored article), `unseen' (place point on the subject line of
323 the first unseen article), `unseen-or-unread' (place point on the subject
324 line of the first unseen article or, if all article have been seen, on the
325 subject line of the first unread article), or a function to be called to
326 place point on some subject line."
327 :version "22.1"
328 :group 'gnus-group-select
329 :type '(choice (const best)
330 (const unread)
331 (const first)
332 (const unseen)
333 (const unseen-or-unread)))
334
335 (defcustom gnus-auto-select-next t
336 "*If non-nil, offer to go to the next group from the end of the previous.
337 If the value is t and the next newsgroup is empty, Gnus will exit
338 summary mode and go back to group mode. If the value is neither nil
339 nor t, Gnus will select the following unread newsgroup. In
340 particular, if the value is the symbol `quietly', the next unread
341 newsgroup will be selected without any confirmation, and if it is
342 `almost-quietly', the next group will be selected without any
343 confirmation if you are located on the last article in the group.
344 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
345 will go to the next group without confirmation."
346 :group 'gnus-summary-maneuvering
347 :type '(choice (const :tag "off" nil)
348 (const quietly)
349 (const almost-quietly)
350 (const slightly-quietly)
351 (sexp :menu-tag "on" t)))
352
353 (defcustom gnus-auto-select-same nil
354 "*If non-nil, select the next article with the same subject.
355 If there are no more articles with the same subject, go to
356 the first unread article."
357 :group 'gnus-summary-maneuvering
358 :type 'boolean)
359
360 (defcustom gnus-auto-goto-ignores 'unfetched
361 "*Says how to handle unfetched articles when maneuvering.
362
363 This variable can either be the symbols nil (maneuver to any
364 article), `undownloaded' (maneuvering while unplugged ignores articles
365 that have not been fetched), `always-undownloaded' (maneuvering always
366 ignores articles that have not been fetched), `unfetched' (maneuvering
367 ignores articles whose headers have not been fetched).
368
369 NOTE: The list of unfetched articles will always be nil when plugged
370 and, when unplugged, a subset of the undownloaded article list."
371 :version "22.1"
372 :group 'gnus-summary-maneuvering
373 :type '(choice (const :tag "None" nil)
374 (const :tag "Undownloaded when unplugged" undownloaded)
375 (const :tag "Undownloaded" always-undownloaded)
376 (const :tag "Unfetched" unfetched)))
377
378 (defcustom gnus-summary-check-current nil
379 "*If non-nil, consider the current article when moving.
380 The \"unread\" movement commands will stay on the same line if the
381 current article is unread."
382 :group 'gnus-summary-maneuvering
383 :type 'boolean)
384
385 (defcustom gnus-auto-center-summary t
386 "*If non-nil, always center the current summary buffer.
387 In particular, if `vertical' do only vertical recentering. If non-nil
388 and non-`vertical', do both horizontal and vertical recentering."
389 :group 'gnus-summary-maneuvering
390 :type '(choice (const :tag "none" nil)
391 (const vertical)
392 (integer :tag "height")
393 (sexp :menu-tag "both" t)))
394
395 (defvar gnus-auto-center-group t
396 "*If non-nil, always center the group buffer.")
397
398 (defcustom gnus-show-all-headers nil
399 "*If non-nil, don't hide any headers."
400 :group 'gnus-article-hiding
401 :group 'gnus-article-headers
402 :type 'boolean)
403
404 (defcustom gnus-summary-ignore-duplicates nil
405 "*If non-nil, ignore articles with identical Message-ID headers."
406 :group 'gnus-summary
407 :type 'boolean)
408
409 (defcustom gnus-single-article-buffer t
410 "*If non-nil, display all articles in the same buffer.
411 If nil, each group will get its own article buffer."
412 :group 'gnus-article-various
413 :type 'boolean)
414
415 (defcustom gnus-break-pages t
416 "*If non-nil, do page breaking on articles.
417 The page delimiter is specified by the `gnus-page-delimiter'
418 variable."
419 :group 'gnus-article-various
420 :type 'boolean)
421
422 (defcustom gnus-move-split-methods nil
423 "*Variable used to suggest where articles are to be moved to.
424 It uses the same syntax as the `gnus-split-methods' variable.
425 However, whereas `gnus-split-methods' specifies file names as targets,
426 this variable specifies group names."
427 :group 'gnus-summary-mail
428 :type '(repeat (choice (list :value (fun) function)
429 (cons :value ("" "") regexp (repeat string))
430 (sexp :value nil))))
431
432 ;; FIXME: Although the custom type is `character' for the following variables,
433 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
434
435 (defcustom gnus-unread-mark ? ;Whitespace
436 "*Mark used for unread articles."
437 :group 'gnus-summary-marks
438 :type 'character)
439
440 (defcustom gnus-ticked-mark ?!
441 "*Mark used for ticked articles."
442 :group 'gnus-summary-marks
443 :type 'character)
444
445 (defcustom gnus-dormant-mark ??
446 "*Mark used for dormant articles."
447 :group 'gnus-summary-marks
448 :type 'character)
449
450 (defcustom gnus-del-mark ?r
451 "*Mark used for del'd articles."
452 :group 'gnus-summary-marks
453 :type 'character)
454
455 (defcustom gnus-read-mark ?R
456 "*Mark used for read articles."
457 :group 'gnus-summary-marks
458 :type 'character)
459
460 (defcustom gnus-expirable-mark ?E
461 "*Mark used for expirable articles."
462 :group 'gnus-summary-marks
463 :type 'character)
464
465 (defcustom gnus-killed-mark ?K
466 "*Mark used for killed articles."
467 :group 'gnus-summary-marks
468 :type 'character)
469
470 (defcustom gnus-spam-mark ?$
471 "*Mark used for spam articles."
472 :version "22.1"
473 :group 'gnus-summary-marks
474 :type 'character)
475
476 (defcustom gnus-souped-mark ?F
477 "*Mark used for souped articles."
478 :group 'gnus-summary-marks
479 :type 'character)
480
481 (defcustom gnus-kill-file-mark ?X
482 "*Mark used for articles killed by kill files."
483 :group 'gnus-summary-marks
484 :type 'character)
485
486 (defcustom gnus-low-score-mark ?Y
487 "*Mark used for articles with a low score."
488 :group 'gnus-summary-marks
489 :type 'character)
490
491 (defcustom gnus-catchup-mark ?C
492 "*Mark used for articles that are caught up."
493 :group 'gnus-summary-marks
494 :type 'character)
495
496 (defcustom gnus-replied-mark ?A
497 "*Mark used for articles that have been replied to."
498 :group 'gnus-summary-marks
499 :type 'character)
500
501 (defcustom gnus-forwarded-mark ?F
502 "*Mark used for articles that have been forwarded."
503 :version "22.1"
504 :group 'gnus-summary-marks
505 :type 'character)
506
507 (defcustom gnus-recent-mark ?N
508 "*Mark used for articles that are recent."
509 :version "22.1"
510 :group 'gnus-summary-marks
511 :type 'character)
512
513 (defcustom gnus-cached-mark ?*
514 "*Mark used for articles that are in the cache."
515 :group 'gnus-summary-marks
516 :type 'character)
517
518 (defcustom gnus-saved-mark ?S
519 "*Mark used for articles that have been saved."
520 :group 'gnus-summary-marks
521 :type 'character)
522
523 (defcustom gnus-unseen-mark ?.
524 "*Mark used for articles that haven't been seen."
525 :version "22.1"
526 :group 'gnus-summary-marks
527 :type 'character)
528
529 (defcustom gnus-no-mark ? ;Whitespace
530 "*Mark used for articles that have no other secondary mark."
531 :version "22.1"
532 :group 'gnus-summary-marks
533 :type 'character)
534
535 (defcustom gnus-ancient-mark ?O
536 "*Mark used for ancient articles."
537 :group 'gnus-summary-marks
538 :type 'character)
539
540 (defcustom gnus-sparse-mark ?Q
541 "*Mark used for sparsely reffed articles."
542 :group 'gnus-summary-marks
543 :type 'character)
544
545 (defcustom gnus-canceled-mark ?G
546 "*Mark used for canceled articles."
547 :group 'gnus-summary-marks
548 :type 'character)
549
550 (defcustom gnus-duplicate-mark ?M
551 "*Mark used for duplicate articles."
552 :group 'gnus-summary-marks
553 :type 'character)
554
555 (defcustom gnus-undownloaded-mark ?-
556 "*Mark used for articles that weren't downloaded."
557 :version "22.1"
558 :group 'gnus-summary-marks
559 :type 'character)
560
561 (defcustom gnus-downloaded-mark ?+
562 "*Mark used for articles that were downloaded."
563 :group 'gnus-summary-marks
564 :type 'character)
565
566 (defcustom gnus-downloadable-mark ?%
567 "*Mark used for articles that are to be downloaded."
568 :group 'gnus-summary-marks
569 :type 'character)
570
571 (defcustom gnus-unsendable-mark ?=
572 "*Mark used for articles that won't be sent."
573 :group 'gnus-summary-marks
574 :type 'character)
575
576 (defcustom gnus-score-over-mark ?+
577 "*Score mark used for articles with high scores."
578 :group 'gnus-summary-marks
579 :type 'character)
580
581 (defcustom gnus-score-below-mark ?-
582 "*Score mark used for articles with low scores."
583 :group 'gnus-summary-marks
584 :type 'character)
585
586 (defcustom gnus-empty-thread-mark ? ;Whitespace
587 "*There is no thread under the article."
588 :group 'gnus-summary-marks
589 :type 'character)
590
591 (defcustom gnus-not-empty-thread-mark ?=
592 "*There is a thread under the article."
593 :group 'gnus-summary-marks
594 :type 'character)
595
596 (defcustom gnus-view-pseudo-asynchronously nil
597 "*If non-nil, Gnus will view pseudo-articles asynchronously."
598 :group 'gnus-extract-view
599 :type 'boolean)
600
601 (defcustom gnus-auto-expirable-marks
602 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
603 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
604 gnus-souped-mark gnus-duplicate-mark)
605 "*The list of marks converted into expiration if a group is auto-expirable."
606 :version "21.1"
607 :group 'gnus-summary
608 :type '(repeat character))
609
610 (defcustom gnus-inhibit-user-auto-expire t
611 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
612 :version "21.1"
613 :group 'gnus-summary
614 :type 'boolean)
615
616 (defcustom gnus-view-pseudos nil
617 "*If `automatic', pseudo-articles will be viewed automatically.
618 If `not-confirm', pseudos will be viewed automatically, and the user
619 will not be asked to confirm the command."
620 :group 'gnus-extract-view
621 :type '(choice (const :tag "off" nil)
622 (const automatic)
623 (const not-confirm)))
624
625 (defcustom gnus-view-pseudos-separately t
626 "*If non-nil, one pseudo-article will be created for each file to be viewed.
627 If nil, all files that use the same viewing command will be given as a
628 list of parameters to that command."
629 :group 'gnus-extract-view
630 :type 'boolean)
631
632 (defcustom gnus-insert-pseudo-articles t
633 "*If non-nil, insert pseudo-articles when decoding articles."
634 :group 'gnus-extract-view
635 :type 'boolean)
636
637 (defcustom gnus-summary-dummy-line-format
638 " %(: :%) %S\n"
639 "*The format specification for the dummy roots in the summary buffer.
640 It works along the same lines as a normal formatting string,
641 with some simple extensions.
642
643 %S The subject
644
645 General format specifiers can also be used.
646 See `(gnus)Formatting Variables'."
647 :link '(custom-manual "(gnus)Formatting Variables")
648 :group 'gnus-threading
649 :type 'string)
650
651 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
652 "*The format specification for the summary mode line.
653 It works along the same lines as a normal formatting string,
654 with some simple extensions:
655
656 %G Group name
657 %p Unprefixed group name
658 %A Current article number
659 %z Current article score
660 %V Gnus version
661 %U Number of unread articles in the group
662 %e Number of unselected articles in the group
663 %Z A string with unread/unselected article counts
664 %g Shortish group name
665 %S Subject of the current article
666 %u User-defined spec
667 %s Current score file name
668 %d Number of dormant articles
669 %r Number of articles that have been marked as read in this session
670 %E Number of articles expunged by the score files"
671 :group 'gnus-summary-format
672 :type 'string)
673
674 (defcustom gnus-list-identifiers nil
675 "Regexp that matches list identifiers to be removed from subject.
676 This can also be a list of regexps."
677 :version "21.1"
678 :group 'gnus-summary-format
679 :group 'gnus-article-hiding
680 :type '(choice (const :tag "none" nil)
681 (regexp :value ".*")
682 (repeat :value (".*") regexp)))
683
684 (defcustom gnus-summary-mark-below 0
685 "*Mark all articles with a score below this variable as read.
686 This variable is local to each summary buffer and usually set by the
687 score file."
688 :group 'gnus-score-default
689 :type 'integer)
690
691 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
692 "*List of functions used for sorting articles in the summary buffer.
693
694 Each function takes two articles and returns non-nil if the first
695 article should be sorted before the other. If you use more than one
696 function, the primary sort function should be the last. You should
697 probably always include `gnus-article-sort-by-number' in the list of
698 sorting functions -- preferably first. Also note that sorting by date
699 is often much slower than sorting by number, and the sorting order is
700 very similar. (Sorting by date means sorting by the time the message
701 was sent, sorting by number means sorting by arrival time.)
702
703 Ready-made functions include `gnus-article-sort-by-number',
704 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
705 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
706 and `gnus-article-sort-by-score'.
707
708 When threading is turned on, the variable `gnus-thread-sort-functions'
709 controls how articles are sorted."
710 :group 'gnus-summary-sort
711 :type '(repeat (choice (function-item gnus-article-sort-by-number)
712 (function-item gnus-article-sort-by-author)
713 (function-item gnus-article-sort-by-subject)
714 (function-item gnus-article-sort-by-date)
715 (function-item gnus-article-sort-by-score)
716 (function-item gnus-article-sort-by-random)
717 (function :tag "other"))))
718
719 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
720 "*List of functions used for sorting threads in the summary buffer.
721 By default, threads are sorted by article number.
722
723 Each function takes two threads and returns non-nil if the first
724 thread should be sorted before the other. If you use more than one
725 function, the primary sort function should be the last. You should
726 probably always include `gnus-thread-sort-by-number' in the list of
727 sorting functions -- preferably first. Also note that sorting by date
728 is often much slower than sorting by number, and the sorting order is
729 very similar. (Sorting by date means sorting by the time the message
730 was sent, sorting by number means sorting by arrival time.)
731
732 Ready-made functions include `gnus-thread-sort-by-number',
733 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
734 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
735 `gnus-thread-sort-by-most-recent-number',
736 `gnus-thread-sort-by-most-recent-date',
737 `gnus-thread-sort-by-random', and
738 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
739
740 When threading is turned off, the variable
741 `gnus-article-sort-functions' controls how articles are sorted."
742 :group 'gnus-summary-sort
743 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
744 (function-item gnus-thread-sort-by-author)
745 (function-item gnus-thread-sort-by-subject)
746 (function-item gnus-thread-sort-by-date)
747 (function-item gnus-thread-sort-by-score)
748 (function-item gnus-thread-sort-by-total-score)
749 (function-item gnus-thread-sort-by-random)
750 (function :tag "other"))))
751
752 (defcustom gnus-thread-score-function '+
753 "*Function used for calculating the total score of a thread.
754
755 The function is called with the scores of the article and each
756 subthread and should then return the score of the thread.
757
758 Some functions you can use are `+', `max', or `min'."
759 :group 'gnus-summary-sort
760 :type 'function)
761
762 (defcustom gnus-summary-expunge-below nil
763 "All articles that have a score less than this variable will be expunged.
764 This variable is local to the summary buffers."
765 :group 'gnus-score-default
766 :type '(choice (const :tag "off" nil)
767 integer))
768
769 (defcustom gnus-thread-expunge-below nil
770 "All threads that have a total score less than this variable will be expunged.
771 See `gnus-thread-score-function' for en explanation of what a
772 \"thread score\" is.
773
774 This variable is local to the summary buffers."
775 :group 'gnus-threading
776 :group 'gnus-score-default
777 :type '(choice (const :tag "off" nil)
778 integer))
779
780 (defcustom gnus-summary-mode-hook nil
781 "*A hook for Gnus summary mode.
782 This hook is run before any variables are set in the summary buffer."
783 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
784 :group 'gnus-summary-various
785 :type 'hook)
786
787 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
788 (when (featurep 'xemacs)
789 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
790 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
791 (add-hook 'gnus-summary-mode-hook
792 'gnus-xmas-switch-horizontal-scrollbar-off))
793
794 (defcustom gnus-summary-menu-hook nil
795 "*Hook run after the creation of the summary mode menu."
796 :group 'gnus-summary-visual
797 :type 'hook)
798
799 (defcustom gnus-summary-exit-hook nil
800 "*A hook called on exit from the summary buffer.
801 It will be called with point in the group buffer."
802 :group 'gnus-summary-exit
803 :type 'hook)
804
805 (defcustom gnus-summary-prepare-hook nil
806 "*A hook called after the summary buffer has been generated.
807 If you want to modify the summary buffer, you can use this hook."
808 :group 'gnus-summary-various
809 :type 'hook)
810
811 (defcustom gnus-summary-prepared-hook nil
812 "*A hook called as the last thing after the summary buffer has been generated."
813 :group 'gnus-summary-various
814 :type 'hook)
815
816 (defcustom gnus-summary-generate-hook nil
817 "*A hook run just before generating the summary buffer.
818 This hook is commonly used to customize threading variables and the
819 like."
820 :group 'gnus-summary-various
821 :type 'hook)
822
823 (defcustom gnus-select-group-hook nil
824 "*A hook called when a newsgroup is selected.
825
826 If you'd like to simplify subjects like the
827 `gnus-summary-next-same-subject' command does, you can use the
828 following hook:
829
830 (add-hook gnus-select-group-hook
831 (lambda ()
832 (mapcar (lambda (header)
833 (mail-header-set-subject
834 header
835 (gnus-simplify-subject
836 (mail-header-subject header) 're-only)))
837 gnus-newsgroup-headers)))"
838 :group 'gnus-group-select
839 :type 'hook)
840
841 (defcustom gnus-select-article-hook nil
842 "*A hook called when an article is selected."
843 :group 'gnus-summary-choose
844 :options '(gnus-agent-fetch-selected-article)
845 :type 'hook)
846
847 (defcustom gnus-visual-mark-article-hook
848 (list 'gnus-highlight-selected-summary)
849 "*Hook run after selecting an article in the summary buffer.
850 It is meant to be used for highlighting the article in some way. It
851 is not run if `gnus-visual' is nil."
852 :group 'gnus-summary-visual
853 :type 'hook)
854
855 (defcustom gnus-parse-headers-hook nil
856 "*A hook called before parsing the headers."
857 :group 'gnus-various
858 :type 'hook)
859
860 (defcustom gnus-exit-group-hook nil
861 "*A hook called when exiting summary mode.
862 This hook is not called from the non-updating exit commands like `Q'."
863 :group 'gnus-various
864 :type 'hook)
865
866 (defcustom gnus-summary-update-hook
867 (list 'gnus-summary-highlight-line)
868 "*A hook called when a summary line is changed.
869 The hook will not be called if `gnus-visual' is nil.
870
871 The default function `gnus-summary-highlight-line' will
872 highlight the line according to the `gnus-summary-highlight'
873 variable."
874 :group 'gnus-summary-visual
875 :type 'hook)
876
877 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
878 "*A hook called when an article is selected for the first time.
879 The hook is intended to mark an article as read (or unread)
880 automatically when it is selected."
881 :group 'gnus-summary-choose
882 :type 'hook)
883
884 (defcustom gnus-group-no-more-groups-hook nil
885 "*A hook run when returning to group mode having no more (unread) groups."
886 :group 'gnus-group-select
887 :type 'hook)
888
889 (defcustom gnus-ps-print-hook nil
890 "*A hook run before ps-printing something from Gnus."
891 :group 'gnus-summary
892 :type 'hook)
893
894 (defcustom gnus-summary-article-move-hook nil
895 "*A hook called after an article is moved, copied, respooled, or crossposted."
896 :version "22.1"
897 :group 'gnus-summary
898 :type 'hook)
899
900 (defcustom gnus-summary-article-delete-hook nil
901 "*A hook called after an article is deleted."
902 :version "22.1"
903 :group 'gnus-summary
904 :type 'hook)
905
906 (defcustom gnus-summary-article-expire-hook nil
907 "*A hook called after an article is expired."
908 :version "22.1"
909 :group 'gnus-summary
910 :type 'hook)
911
912 (defcustom gnus-summary-display-arrow
913 (and (fboundp 'display-graphic-p)
914 (display-graphic-p))
915 "*If non-nil, display an arrow highlighting the current article."
916 :version "22.1"
917 :group 'gnus-summary
918 :type 'boolean)
919
920 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
921 "Face used for highlighting the current article in the summary buffer."
922 :group 'gnus-summary-visual
923 :type 'face)
924
925 (defvar gnus-tmp-downloaded nil)
926
927 (defcustom gnus-summary-highlight
928 '(((eq mark gnus-canceled-mark)
929 . gnus-summary-cancelled-face)
930 ((and uncached (> score default-high))
931 . gnus-summary-high-undownloaded-face)
932 ((and uncached (< score default-low))
933 . gnus-summary-low-undownloaded-face)
934 (uncached
935 . gnus-summary-normal-undownloaded-face)
936 ((and (> score default-high)
937 (or (eq mark gnus-dormant-mark)
938 (eq mark gnus-ticked-mark)))
939 . gnus-summary-high-ticked-face)
940 ((and (< score default-low)
941 (or (eq mark gnus-dormant-mark)
942 (eq mark gnus-ticked-mark)))
943 . gnus-summary-low-ticked-face)
944 ((or (eq mark gnus-dormant-mark)
945 (eq mark gnus-ticked-mark))
946 . gnus-summary-normal-ticked-face)
947 ((and (> score default-high) (eq mark gnus-ancient-mark))
948 . gnus-summary-high-ancient-face)
949 ((and (< score default-low) (eq mark gnus-ancient-mark))
950 . gnus-summary-low-ancient-face)
951 ((eq mark gnus-ancient-mark)
952 . gnus-summary-normal-ancient-face)
953 ((and (> score default-high) (eq mark gnus-unread-mark))
954 . gnus-summary-high-unread-face)
955 ((and (< score default-low) (eq mark gnus-unread-mark))
956 . gnus-summary-low-unread-face)
957 ((eq mark gnus-unread-mark)
958 . gnus-summary-normal-unread-face)
959 ((> score default-high)
960 . gnus-summary-high-read-face)
961 ((< score default-low)
962 . gnus-summary-low-read-face)
963 (t
964 . gnus-summary-normal-read-face))
965 "*Controls the highlighting of summary buffer lines.
966
967 A list of (FORM . FACE) pairs. When deciding how a a particular
968 summary line should be displayed, each form is evaluated. The content
969 of the face field after the first true form is used. You can change
970 how those summary lines are displayed, by editing the face field.
971
972 You can use the following variables in the FORM field.
973
974 score: The article's score
975 default: The default article score.
976 default-high: The default score for high scored articles.
977 default-low: The default score for low scored articles.
978 below: The score below which articles are automatically marked as read.
979 mark: The article's mark.
980 uncached: Non-nil if the article is uncached."
981 :group 'gnus-summary-visual
982 :type '(repeat (cons (sexp :tag "Form" nil)
983 face)))
984
985 (defcustom gnus-alter-header-function nil
986 "Function called to allow alteration of article header structures.
987 The function is called with one parameter, the article header vector,
988 which it may alter in any way."
989 :type '(choice (const :tag "None" nil)
990 function)
991 :group 'gnus-summary)
992
993 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
994 "Variable that says which function should be used to decode a string with encoded words.")
995
996 (defcustom gnus-extra-headers '(To Newsgroups)
997 "*Extra headers to parse."
998 :version "21.1"
999 :group 'gnus-summary
1000 :type '(repeat symbol))
1001
1002 (defcustom gnus-ignored-from-addresses
1003 (and user-mail-address (regexp-quote user-mail-address))
1004 "*Regexp of From headers that may be suppressed in favor of To headers."
1005 :version "21.1"
1006 :group 'gnus-summary
1007 :type 'regexp)
1008
1009 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1010 "List of charsets that should be ignored.
1011 When these charsets are used in the \"charset\" parameter, the
1012 default charset will be used instead."
1013 :version "21.1"
1014 :type '(repeat symbol)
1015 :group 'gnus-charset)
1016
1017 (gnus-define-group-parameter
1018 ignored-charsets
1019 :type list
1020 :function-document
1021 "Return the ignored charsets of GROUP."
1022 :variable gnus-group-ignored-charsets-alist
1023 :variable-default
1024 '(("alt\\.chinese\\.text" iso-8859-1))
1025 :variable-document
1026 "Alist of regexps (to match group names) and charsets that should be ignored.
1027 When these charsets are used in the \"charset\" parameter, the
1028 default charset will be used instead."
1029 :variable-group gnus-charset
1030 :variable-type '(repeat (cons (regexp :tag "Group")
1031 (repeat symbol)))
1032 :parameter-type '(choice :tag "Ignored charsets"
1033 :value nil
1034 (repeat (symbol)))
1035 :parameter-document "\
1036 List of charsets that should be ignored.
1037
1038 When these charsets are used in the \"charset\" parameter, the
1039 default charset will be used instead.")
1040
1041 (defcustom gnus-group-highlight-words-alist nil
1042 "Alist of group regexps and highlight regexps.
1043 This variable uses the same syntax as `gnus-emphasis-alist'."
1044 :version "21.1"
1045 :type '(repeat (cons (regexp :tag "Group")
1046 (repeat (list (regexp :tag "Highlight regexp")
1047 (number :tag "Group for entire word" 0)
1048 (number :tag "Group for displayed part" 0)
1049 (symbol :tag "Face"
1050 gnus-emphasis-highlight-words)))))
1051 :group 'gnus-summary-visual)
1052
1053 (defcustom gnus-summary-show-article-charset-alist
1054 nil
1055 "Alist of number and charset.
1056 The article will be shown with the charset corresponding to the
1057 numbered argument.
1058 For example: ((1 . cn-gb-2312) (2 . big5))."
1059 :version "21.1"
1060 :type '(repeat (cons (number :tag "Argument" 1)
1061 (symbol :tag "Charset")))
1062 :group 'gnus-charset)
1063
1064 (defcustom gnus-preserve-marks t
1065 "Whether marks are preserved when moving, copying and respooling messages."
1066 :version "21.1"
1067 :type 'boolean
1068 :group 'gnus-summary-marks)
1069
1070 (defcustom gnus-alter-articles-to-read-function nil
1071 "Function to be called to alter the list of articles to be selected."
1072 :type '(choice (const nil) function)
1073 :group 'gnus-summary)
1074
1075 (defcustom gnus-orphan-score nil
1076 "*All orphans get this score added. Set in the score file."
1077 :group 'gnus-score-default
1078 :type '(choice (const nil)
1079 integer))
1080
1081 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1082 "*A regexp to match MIME parts when saving multiple parts of a
1083 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1084 This regexp will be used by default when prompting the user for which
1085 type of files to save."
1086 :group 'gnus-summary
1087 :type 'regexp)
1088
1089 (defcustom gnus-read-all-available-headers nil
1090 "Whether Gnus should parse all headers made available to it.
1091 This is mostly relevant for slow back ends where the user may
1092 wish to widen the summary buffer to include all headers
1093 that were fetched. Say, for nnultimate groups."
1094 :version "22.1"
1095 :group 'gnus-summary
1096 :type '(choice boolean regexp))
1097
1098 (defcustom gnus-summary-muttprint-program "muttprint"
1099 "Command (and optional arguments) used to run Muttprint."
1100 :version "22.1"
1101 :group 'gnus-summary
1102 :type 'string)
1103
1104 (defcustom gnus-article-loose-mime nil
1105 "If non-nil, don't require MIME-Version header.
1106 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1107 supply the MIME-Version header or deliberately strip it from the mail.
1108 Set it to non-nil, Gnus will treat some articles as MIME even if
1109 the MIME-Version header is missed."
1110 :version "22.1"
1111 :type 'boolean
1112 :group 'gnus-article-mime)
1113
1114 (defcustom gnus-article-emulate-mime t
1115 "If non-nil, use MIME emulation for uuencode and the like.
1116 This means that Gnus will search message bodies for text that look
1117 like uuencoded bits, yEncoded bits, and so on, and present that using
1118 the normal Gnus MIME machinery."
1119 :version "22.1"
1120 :type 'boolean
1121 :group 'gnus-article-mime)
1122
1123 ;;; Internal variables
1124
1125 (defvar gnus-summary-display-cache nil)
1126 (defvar gnus-article-mime-handles nil)
1127 (defvar gnus-article-decoded-p nil)
1128 (defvar gnus-article-charset nil)
1129 (defvar gnus-article-ignored-charsets nil)
1130 (defvar gnus-scores-exclude-files nil)
1131 (defvar gnus-page-broken nil)
1132
1133 (defvar gnus-original-article nil)
1134 (defvar gnus-article-internal-prepare-hook nil)
1135 (defvar gnus-newsgroup-process-stack nil)
1136
1137 (defvar gnus-thread-indent-array nil)
1138 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1139 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1140 "Function called to sort the articles within a thread after it has been gathered together.")
1141
1142 (defvar gnus-summary-save-parts-type-history nil)
1143 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1144
1145 ;; Avoid highlighting in kill files.
1146 (defvar gnus-summary-inhibit-highlight nil)
1147 (defvar gnus-newsgroup-selected-overlay nil)
1148 (defvar gnus-inhibit-limiting nil)
1149 (defvar gnus-newsgroup-adaptive-score-file nil)
1150 (defvar gnus-current-score-file nil)
1151 (defvar gnus-current-move-group nil)
1152 (defvar gnus-current-copy-group nil)
1153 (defvar gnus-current-crosspost-group nil)
1154 (defvar gnus-newsgroup-display nil)
1155
1156 (defvar gnus-newsgroup-dependencies nil)
1157 (defvar gnus-newsgroup-adaptive nil)
1158 (defvar gnus-summary-display-article-function nil)
1159 (defvar gnus-summary-highlight-line-function nil
1160 "Function called after highlighting a summary line.")
1161
1162 (defvar gnus-summary-line-format-alist
1163 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1164 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1165 (?s gnus-tmp-subject-or-nil ?s)
1166 (?n gnus-tmp-name ?s)
1167 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1168 ?s)
1169 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1170 gnus-tmp-from) ?s)
1171 (?F gnus-tmp-from ?s)
1172 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1173 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1174 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1175 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1176 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1177 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1178 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1179 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1180 (?L gnus-tmp-lines ?s)
1181 (?O gnus-tmp-downloaded ?c)
1182 (?I gnus-tmp-indentation ?s)
1183 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1184 (?R gnus-tmp-replied ?c)
1185 (?\[ gnus-tmp-opening-bracket ?c)
1186 (?\] gnus-tmp-closing-bracket ?c)
1187 (?\> (make-string gnus-tmp-level ? ) ?s)
1188 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1189 (?i gnus-tmp-score ?d)
1190 (?z gnus-tmp-score-char ?c)
1191 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1192 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1193 (?U gnus-tmp-unread ?c)
1194 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1195 ?s)
1196 (?t (gnus-summary-number-of-articles-in-thread
1197 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1198 ?d)
1199 (?e (gnus-summary-number-of-articles-in-thread
1200 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1201 ?c)
1202 (?u gnus-tmp-user-defined ?s)
1203 (?P (gnus-pick-line-number) ?d)
1204 (?B gnus-tmp-thread-tree-header-string ?s)
1205 (user-date (gnus-user-date
1206 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1207 "An alist of format specifications that can appear in summary lines.
1208 These are paired with what variables they correspond with, along with
1209 the type of the variable (string, integer, character, etc).")
1210
1211 (defvar gnus-summary-dummy-line-format-alist
1212 `((?S gnus-tmp-subject ?s)
1213 (?N gnus-tmp-number ?d)
1214 (?u gnus-tmp-user-defined ?s)))
1215
1216 (defvar gnus-summary-mode-line-format-alist
1217 `((?G gnus-tmp-group-name ?s)
1218 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1219 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1220 (?A gnus-tmp-article-number ?d)
1221 (?Z gnus-tmp-unread-and-unselected ?s)
1222 (?V gnus-version ?s)
1223 (?U gnus-tmp-unread-and-unticked ?d)
1224 (?S gnus-tmp-subject ?s)
1225 (?e gnus-tmp-unselected ?d)
1226 (?u gnus-tmp-user-defined ?s)
1227 (?d (length gnus-newsgroup-dormant) ?d)
1228 (?t (length gnus-newsgroup-marked) ?d)
1229 (?h (length gnus-newsgroup-spam-marked) ?d)
1230 (?r (length gnus-newsgroup-reads) ?d)
1231 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1232 (?E gnus-newsgroup-expunged-tally ?d)
1233 (?s (gnus-current-score-file-nondirectory) ?s)))
1234
1235 (defvar gnus-last-search-regexp nil
1236 "Default regexp for article search command.")
1237
1238 (defvar gnus-last-shell-command nil
1239 "Default shell command on article.")
1240
1241 (defvar gnus-newsgroup-agentized nil
1242 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1243 (defvar gnus-newsgroup-begin nil)
1244 (defvar gnus-newsgroup-end nil)
1245 (defvar gnus-newsgroup-last-rmail nil)
1246 (defvar gnus-newsgroup-last-mail nil)
1247 (defvar gnus-newsgroup-last-folder nil)
1248 (defvar gnus-newsgroup-last-file nil)
1249 (defvar gnus-newsgroup-auto-expire nil)
1250 (defvar gnus-newsgroup-active nil)
1251
1252 (defvar gnus-newsgroup-data nil)
1253 (defvar gnus-newsgroup-data-reverse nil)
1254 (defvar gnus-newsgroup-limit nil)
1255 (defvar gnus-newsgroup-limits nil)
1256 (defvar gnus-summary-use-undownloaded-faces nil)
1257
1258 (defvar gnus-newsgroup-unreads nil
1259 "Sorted list of unread articles in the current newsgroup.")
1260
1261 (defvar gnus-newsgroup-unselected nil
1262 "Sorted list of unselected unread articles in the current newsgroup.")
1263
1264 (defvar gnus-newsgroup-reads nil
1265 "Alist of read articles and article marks in the current newsgroup.")
1266
1267 (defvar gnus-newsgroup-expunged-tally nil)
1268
1269 (defvar gnus-newsgroup-marked nil
1270 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1271
1272 (defvar gnus-newsgroup-spam-marked nil
1273 "List of ranges of articles that have been marked as spam.")
1274
1275 (defvar gnus-newsgroup-killed nil
1276 "List of ranges of articles that have been through the scoring process.")
1277
1278 (defvar gnus-newsgroup-cached nil
1279 "Sorted list of articles that come from the article cache.")
1280
1281 (defvar gnus-newsgroup-saved nil
1282 "List of articles that have been saved.")
1283
1284 (defvar gnus-newsgroup-kill-headers nil)
1285
1286 (defvar gnus-newsgroup-replied nil
1287 "List of articles that have been replied to in the current newsgroup.")
1288
1289 (defvar gnus-newsgroup-forwarded nil
1290 "List of articles that have been forwarded in the current newsgroup.")
1291
1292 (defvar gnus-newsgroup-recent nil
1293 "List of articles that have are recent in the current newsgroup.")
1294
1295 (defvar gnus-newsgroup-expirable nil
1296 "Sorted list of articles in the current newsgroup that can be expired.")
1297
1298 (defvar gnus-newsgroup-processable nil
1299 "List of articles in the current newsgroup that can be processed.")
1300
1301 (defvar gnus-newsgroup-downloadable nil
1302 "Sorted list of articles in the current newsgroup that can be processed.")
1303
1304 (defvar gnus-newsgroup-unfetched nil
1305 "Sorted list of articles in the current newsgroup whose headers have
1306 not been fetched into the agent.
1307
1308 This list will always be a subset of gnus-newsgroup-undownloaded.")
1309
1310 (defvar gnus-newsgroup-undownloaded nil
1311 "List of articles in the current newsgroup that haven't been downloaded.")
1312
1313 (defvar gnus-newsgroup-unsendable nil
1314 "List of articles in the current newsgroup that won't be sent.")
1315
1316 (defvar gnus-newsgroup-bookmarks nil
1317 "List of articles in the current newsgroup that have bookmarks.")
1318
1319 (defvar gnus-newsgroup-dormant nil
1320 "Sorted list of dormant articles in the current newsgroup.")
1321
1322 (defvar gnus-newsgroup-unseen nil
1323 "List of unseen articles in the current newsgroup.")
1324
1325 (defvar gnus-newsgroup-seen nil
1326 "Range of seen articles in the current newsgroup.")
1327
1328 (defvar gnus-newsgroup-articles nil
1329 "List of articles in the current newsgroup.")
1330
1331 (defvar gnus-newsgroup-scored nil
1332 "List of scored articles in the current newsgroup.")
1333
1334 (defvar gnus-newsgroup-headers nil
1335 "List of article headers in the current newsgroup.")
1336
1337 (defvar gnus-newsgroup-threads nil)
1338
1339 (defvar gnus-newsgroup-prepared nil
1340 "Whether the current group has been prepared properly.")
1341
1342 (defvar gnus-newsgroup-ancient nil
1343 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1344
1345 (defvar gnus-newsgroup-sparse nil)
1346
1347 (defvar gnus-current-article nil)
1348 (defvar gnus-article-current nil)
1349 (defvar gnus-current-headers nil)
1350 (defvar gnus-have-all-headers nil)
1351 (defvar gnus-last-article nil)
1352 (defvar gnus-newsgroup-history nil)
1353 (defvar gnus-newsgroup-charset nil)
1354 (defvar gnus-newsgroup-ephemeral-charset nil)
1355 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1356
1357 (defvar gnus-article-before-search nil)
1358
1359 (defvar gnus-summary-local-variables
1360 '(gnus-newsgroup-name
1361 gnus-newsgroup-begin gnus-newsgroup-end
1362 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1363 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1364 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1365 gnus-newsgroup-unselected gnus-newsgroup-marked
1366 gnus-newsgroup-spam-marked
1367 gnus-newsgroup-reads gnus-newsgroup-saved
1368 gnus-newsgroup-replied gnus-newsgroup-forwarded
1369 gnus-newsgroup-recent
1370 gnus-newsgroup-expirable
1371 gnus-newsgroup-processable gnus-newsgroup-killed
1372 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1373 gnus-newsgroup-unfetched
1374 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1375 gnus-newsgroup-seen gnus-newsgroup-articles
1376 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1377 gnus-newsgroup-headers gnus-newsgroup-threads
1378 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1379 gnus-current-article gnus-current-headers gnus-have-all-headers
1380 gnus-last-article gnus-article-internal-prepare-hook
1381 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1382 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1383 gnus-thread-expunge-below
1384 gnus-score-alist gnus-current-score-file
1385 (gnus-summary-expunge-below . global)
1386 (gnus-summary-mark-below . global)
1387 (gnus-orphan-score . global)
1388 gnus-newsgroup-active gnus-scores-exclude-files
1389 gnus-newsgroup-history gnus-newsgroup-ancient
1390 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1391 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1392 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1393 (gnus-newsgroup-expunged-tally . 0)
1394 gnus-cache-removable-articles gnus-newsgroup-cached
1395 gnus-newsgroup-data gnus-newsgroup-data-reverse
1396 gnus-newsgroup-limit gnus-newsgroup-limits
1397 gnus-newsgroup-charset gnus-newsgroup-display
1398 gnus-summary-use-undownloaded-faces)
1399 "Variables that are buffer-local to the summary buffers.")
1400
1401 (defvar gnus-newsgroup-variables nil
1402 "A list of variables that have separate values in different newsgroups.
1403 A list of newsgroup (summary buffer) local variables, or cons of
1404 variables and their default expressions to be evalled (when the default
1405 values are not nil), that should be made global while the summary buffer
1406 is active.
1407
1408 Note: The default expressions will be evaluated (using function `eval')
1409 before assignment to the local variable rather than just assigned to it.
1410 If the default expression is the symbol `global', that symbol will not
1411 be evaluated but the global value of the local variable will be used
1412 instead.
1413
1414 These variables can be used to set variables in the group parameters
1415 while still allowing them to affect operations done in other buffers.
1416 For example:
1417
1418 \(setq gnus-newsgroup-variables
1419 '(message-use-followup-to
1420 (gnus-visible-headers .
1421 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1422 ")
1423
1424 ;; Byte-compiler warning.
1425 (eval-when-compile
1426 ;; Bind features so that require will believe that gnus-sum has
1427 ;; already been loaded (avoids infinite recursion)
1428 (let ((features (cons 'gnus-sum features)))
1429 ;; Several of the declarations in gnus-sum are needed to load the
1430 ;; following files. Right now, these definitions have been
1431 ;; compiled but not defined (evaluated). We could either do a
1432 ;; eval-and-compile about all of the declarations or evaluate the
1433 ;; source file.
1434 (if (boundp 'gnus-newsgroup-variables)
1435 nil
1436 (load "gnus-sum.el" t t t))
1437 (require 'gnus)
1438 (require 'gnus-agent)
1439 (require 'gnus-art)))
1440
1441 ;; MIME stuff.
1442
1443 (defvar gnus-decode-encoded-word-methods
1444 '(mail-decode-encoded-word-string)
1445 "List of methods used to decode encoded words.
1446
1447 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1448 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1449 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1450 whose names match REGEXP.
1451
1452 For example:
1453 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1454 mail-decode-encoded-word-string
1455 (\"chinese\" . rfc1843-decode-string))")
1456
1457 (defvar gnus-decode-encoded-word-methods-cache nil)
1458
1459 (defun gnus-multi-decode-encoded-word-string (string)
1460 "Apply the functions from `gnus-encoded-word-methods' that match."
1461 (unless (and gnus-decode-encoded-word-methods-cache
1462 (eq gnus-newsgroup-name
1463 (car gnus-decode-encoded-word-methods-cache)))
1464 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1465 (mapcar (lambda (x)
1466 (if (symbolp x)
1467 (nconc gnus-decode-encoded-word-methods-cache (list x))
1468 (if (and gnus-newsgroup-name
1469 (string-match (car x) gnus-newsgroup-name))
1470 (nconc gnus-decode-encoded-word-methods-cache
1471 (list (cdr x))))))
1472 gnus-decode-encoded-word-methods))
1473 (let ((xlist gnus-decode-encoded-word-methods-cache))
1474 (pop xlist)
1475 (while xlist
1476 (setq string (funcall (pop xlist) string))))
1477 string)
1478
1479 ;; Subject simplification.
1480
1481 (defun gnus-simplify-whitespace (str)
1482 "Remove excessive whitespace from STR."
1483 ;; Multiple spaces.
1484 (while (string-match "[ \t][ \t]+" str)
1485 (setq str (concat (substring str 0 (match-beginning 0))
1486 " "
1487 (substring str (match-end 0)))))
1488 ;; Leading spaces.
1489 (when (string-match "^[ \t]+" str)
1490 (setq str (substring str (match-end 0))))
1491 ;; Trailing spaces.
1492 (when (string-match "[ \t]+$" str)
1493 (setq str (substring str 0 (match-beginning 0))))
1494 str)
1495
1496 (defun gnus-simplify-all-whitespace (str)
1497 "Remove all whitespace from STR."
1498 (while (string-match "[ \t\n]+" str)
1499 (setq str (replace-match "" nil nil str)))
1500 str)
1501
1502 (defsubst gnus-simplify-subject-re (subject)
1503 "Remove \"Re:\" from subject lines."
1504 (if (string-match message-subject-re-regexp subject)
1505 (substring subject (match-end 0))
1506 subject))
1507
1508 (defun gnus-simplify-subject (subject &optional re-only)
1509 "Remove `Re:' and words in parentheses.
1510 If RE-ONLY is non-nil, strip leading `Re:'s only."
1511 (let ((case-fold-search t)) ;Ignore case.
1512 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1513 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1514 (setq subject (substring subject (match-end 0))))
1515 ;; Remove uninteresting prefixes.
1516 (when (and (not re-only)
1517 gnus-simplify-ignored-prefixes
1518 (string-match gnus-simplify-ignored-prefixes subject))
1519 (setq subject (substring subject (match-end 0))))
1520 ;; Remove words in parentheses from end.
1521 (unless re-only
1522 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1523 (setq subject (substring subject 0 (match-beginning 0)))))
1524 ;; Return subject string.
1525 subject))
1526
1527 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1528 ;; all whitespace.
1529 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1530 (goto-char (point-min))
1531 (while (re-search-forward regexp nil t)
1532 (replace-match (or newtext ""))))
1533
1534 (defun gnus-simplify-buffer-fuzzy ()
1535 "Simplify string in the buffer fuzzily.
1536 The string in the accessible portion of the current buffer is simplified.
1537 It is assumed to be a single-line subject.
1538 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1539 matter is removed. Additional things can be deleted by setting
1540 `gnus-simplify-subject-fuzzy-regexp'."
1541 (let ((case-fold-search t)
1542 (modified-tick))
1543 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1544
1545 (while (not (eq modified-tick (buffer-modified-tick)))
1546 (setq modified-tick (buffer-modified-tick))
1547 (cond
1548 ((listp gnus-simplify-subject-fuzzy-regexp)
1549 (mapcar 'gnus-simplify-buffer-fuzzy-step
1550 gnus-simplify-subject-fuzzy-regexp))
1551 (gnus-simplify-subject-fuzzy-regexp
1552 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1553 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1554 (gnus-simplify-buffer-fuzzy-step
1555 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1556 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1557
1558 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1559 (gnus-simplify-buffer-fuzzy-step " +" " ")
1560 (gnus-simplify-buffer-fuzzy-step " $")
1561 (gnus-simplify-buffer-fuzzy-step "^ +")))
1562
1563 (defun gnus-simplify-subject-fuzzy (subject)
1564 "Simplify a subject string fuzzily.
1565 See `gnus-simplify-buffer-fuzzy' for details."
1566 (save-excursion
1567 (gnus-set-work-buffer)
1568 (let ((case-fold-search t))
1569 ;; Remove uninteresting prefixes.
1570 (when (and gnus-simplify-ignored-prefixes
1571 (string-match gnus-simplify-ignored-prefixes subject))
1572 (setq subject (substring subject (match-end 0))))
1573 (insert subject)
1574 (inline (gnus-simplify-buffer-fuzzy))
1575 (buffer-string))))
1576
1577 (defsubst gnus-simplify-subject-fully (subject)
1578 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1579 (cond
1580 (gnus-simplify-subject-functions
1581 (gnus-map-function gnus-simplify-subject-functions subject))
1582 ((null gnus-summary-gather-subject-limit)
1583 (gnus-simplify-subject-re subject))
1584 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1585 (gnus-simplify-subject-fuzzy subject))
1586 ((numberp gnus-summary-gather-subject-limit)
1587 (gnus-limit-string (gnus-simplify-subject-re subject)
1588 gnus-summary-gather-subject-limit))
1589 (t
1590 subject)))
1591
1592 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1593 "Check whether two subjects are equal.
1594 If optional argument SIMPLE-FIRST is t, first argument is already
1595 simplified."
1596 (cond
1597 ((null simple-first)
1598 (equal (gnus-simplify-subject-fully s1)
1599 (gnus-simplify-subject-fully s2)))
1600 (t
1601 (equal s1
1602 (gnus-simplify-subject-fully s2)))))
1603
1604 (defun gnus-summary-bubble-group ()
1605 "Increase the score of the current group.
1606 This is a handy function to add to `gnus-summary-exit-hook' to
1607 increase the score of each group you read."
1608 (gnus-group-add-score gnus-newsgroup-name))
1609
1610 \f
1611 ;;;
1612 ;;; Gnus summary mode
1613 ;;;
1614
1615 (put 'gnus-summary-mode 'mode-class 'special)
1616
1617 (defvar gnus-article-commands-menu)
1618
1619 ;; Non-orthogonal keys
1620
1621 (gnus-define-keys gnus-summary-mode-map
1622 " " gnus-summary-next-page
1623 "\177" gnus-summary-prev-page
1624 [delete] gnus-summary-prev-page
1625 [backspace] gnus-summary-prev-page
1626 "\r" gnus-summary-scroll-up
1627 "\M-\r" gnus-summary-scroll-down
1628 "n" gnus-summary-next-unread-article
1629 "p" gnus-summary-prev-unread-article
1630 "N" gnus-summary-next-article
1631 "P" gnus-summary-prev-article
1632 "\M-\C-n" gnus-summary-next-same-subject
1633 "\M-\C-p" gnus-summary-prev-same-subject
1634 "\M-n" gnus-summary-next-unread-subject
1635 "\M-p" gnus-summary-prev-unread-subject
1636 "." gnus-summary-first-unread-article
1637 "," gnus-summary-best-unread-article
1638 "\M-s" gnus-summary-search-article-forward
1639 "\M-r" gnus-summary-search-article-backward
1640 "<" gnus-summary-beginning-of-article
1641 ">" gnus-summary-end-of-article
1642 "j" gnus-summary-goto-article
1643 "^" gnus-summary-refer-parent-article
1644 "\M-^" gnus-summary-refer-article
1645 "u" gnus-summary-tick-article-forward
1646 "!" gnus-summary-tick-article-forward
1647 "U" gnus-summary-tick-article-backward
1648 "d" gnus-summary-mark-as-read-forward
1649 "D" gnus-summary-mark-as-read-backward
1650 "E" gnus-summary-mark-as-expirable
1651 "\M-u" gnus-summary-clear-mark-forward
1652 "\M-U" gnus-summary-clear-mark-backward
1653 "k" gnus-summary-kill-same-subject-and-select
1654 "\C-k" gnus-summary-kill-same-subject
1655 "\M-\C-k" gnus-summary-kill-thread
1656 "\M-\C-l" gnus-summary-lower-thread
1657 "e" gnus-summary-edit-article
1658 "#" gnus-summary-mark-as-processable
1659 "\M-#" gnus-summary-unmark-as-processable
1660 "\M-\C-t" gnus-summary-toggle-threads
1661 "\M-\C-s" gnus-summary-show-thread
1662 "\M-\C-h" gnus-summary-hide-thread
1663 "\M-\C-f" gnus-summary-next-thread
1664 "\M-\C-b" gnus-summary-prev-thread
1665 [(meta down)] gnus-summary-next-thread
1666 [(meta up)] gnus-summary-prev-thread
1667 "\M-\C-u" gnus-summary-up-thread
1668 "\M-\C-d" gnus-summary-down-thread
1669 "&" gnus-summary-execute-command
1670 "c" gnus-summary-catchup-and-exit
1671 "\C-w" gnus-summary-mark-region-as-read
1672 "\C-t" gnus-summary-toggle-truncation
1673 "?" gnus-summary-mark-as-dormant
1674 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1675 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1676 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1677 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1678 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1679 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1680 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1681 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1682 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1683 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1684 "=" gnus-summary-expand-window
1685 "\C-x\C-s" gnus-summary-reselect-current-group
1686 "\M-g" gnus-summary-rescan-group
1687 "w" gnus-summary-stop-page-breaking
1688 "\C-c\C-r" gnus-summary-caesar-message
1689 "f" gnus-summary-followup
1690 "F" gnus-summary-followup-with-original
1691 "C" gnus-summary-cancel-article
1692 "r" gnus-summary-reply
1693 "R" gnus-summary-reply-with-original
1694 "\C-c\C-f" gnus-summary-mail-forward
1695 "o" gnus-summary-save-article
1696 "\C-o" gnus-summary-save-article-mail
1697 "|" gnus-summary-pipe-output
1698 "\M-k" gnus-summary-edit-local-kill
1699 "\M-K" gnus-summary-edit-global-kill
1700 ;; "V" gnus-version
1701 "\C-c\C-d" gnus-summary-describe-group
1702 "q" gnus-summary-exit
1703 "Q" gnus-summary-exit-no-update
1704 "\C-c\C-i" gnus-info-find-node
1705 gnus-mouse-2 gnus-mouse-pick-article
1706 [follow-link] mouse-face
1707 "m" gnus-summary-mail-other-window
1708 "a" gnus-summary-post-news
1709 "i" gnus-summary-news-other-window
1710 "x" gnus-summary-limit-to-unread
1711 "s" gnus-summary-isearch-article
1712 "t" gnus-summary-toggle-header
1713 "g" gnus-summary-show-article
1714 "l" gnus-summary-goto-last-article
1715 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1716 "\C-d" gnus-summary-enter-digest-group
1717 "\M-\C-d" gnus-summary-read-document
1718 "\M-\C-e" gnus-summary-edit-parameters
1719 "\M-\C-a" gnus-summary-customize-parameters
1720 "\C-c\C-b" gnus-bug
1721 "*" gnus-cache-enter-article
1722 "\M-*" gnus-cache-remove-article
1723 "\M-&" gnus-summary-universal-argument
1724 "\C-l" gnus-recenter
1725 "I" gnus-summary-increase-score
1726 "L" gnus-summary-lower-score
1727 "\M-i" gnus-symbolic-argument
1728 "h" gnus-summary-select-article-buffer
1729
1730 "b" gnus-article-view-part
1731 "\M-t" gnus-summary-toggle-display-buttonized
1732
1733 "V" gnus-summary-score-map
1734 "X" gnus-uu-extract-map
1735 "S" gnus-summary-send-map)
1736
1737 ;; Sort of orthogonal keymap
1738 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1739 "t" gnus-summary-tick-article-forward
1740 "!" gnus-summary-tick-article-forward
1741 "d" gnus-summary-mark-as-read-forward
1742 "r" gnus-summary-mark-as-read-forward
1743 "c" gnus-summary-clear-mark-forward
1744 " " gnus-summary-clear-mark-forward
1745 "e" gnus-summary-mark-as-expirable
1746 "x" gnus-summary-mark-as-expirable
1747 "?" gnus-summary-mark-as-dormant
1748 "b" gnus-summary-set-bookmark
1749 "B" gnus-summary-remove-bookmark
1750 "#" gnus-summary-mark-as-processable
1751 "\M-#" gnus-summary-unmark-as-processable
1752 "S" gnus-summary-limit-include-expunged
1753 "C" gnus-summary-catchup
1754 "H" gnus-summary-catchup-to-here
1755 "h" gnus-summary-catchup-from-here
1756 "\C-c" gnus-summary-catchup-all
1757 "k" gnus-summary-kill-same-subject-and-select
1758 "K" gnus-summary-kill-same-subject
1759 "P" gnus-uu-mark-map)
1760
1761 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1762 "c" gnus-summary-clear-above
1763 "u" gnus-summary-tick-above
1764 "m" gnus-summary-mark-above
1765 "k" gnus-summary-kill-below)
1766
1767 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1768 "/" gnus-summary-limit-to-subject
1769 "n" gnus-summary-limit-to-articles
1770 "w" gnus-summary-pop-limit
1771 "s" gnus-summary-limit-to-subject
1772 "a" gnus-summary-limit-to-author
1773 "u" gnus-summary-limit-to-unread
1774 "m" gnus-summary-limit-to-marks
1775 "M" gnus-summary-limit-exclude-marks
1776 "v" gnus-summary-limit-to-score
1777 "*" gnus-summary-limit-include-cached
1778 "D" gnus-summary-limit-include-dormant
1779 "T" gnus-summary-limit-include-thread
1780 "d" gnus-summary-limit-exclude-dormant
1781 "t" gnus-summary-limit-to-age
1782 "." gnus-summary-limit-to-unseen
1783 "x" gnus-summary-limit-to-extra
1784 "p" gnus-summary-limit-to-display-predicate
1785 "E" gnus-summary-limit-include-expunged
1786 "c" gnus-summary-limit-exclude-childless-dormant
1787 "C" gnus-summary-limit-mark-excluded-as-read
1788 "o" gnus-summary-insert-old-articles
1789 "N" gnus-summary-insert-new-articles)
1790
1791 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1792 "n" gnus-summary-next-unread-article
1793 "p" gnus-summary-prev-unread-article
1794 "N" gnus-summary-next-article
1795 "P" gnus-summary-prev-article
1796 "\C-n" gnus-summary-next-same-subject
1797 "\C-p" gnus-summary-prev-same-subject
1798 "\M-n" gnus-summary-next-unread-subject
1799 "\M-p" gnus-summary-prev-unread-subject
1800 "f" gnus-summary-first-unread-article
1801 "b" gnus-summary-best-unread-article
1802 "j" gnus-summary-goto-article
1803 "g" gnus-summary-goto-subject
1804 "l" gnus-summary-goto-last-article
1805 "o" gnus-summary-pop-article)
1806
1807 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1808 "k" gnus-summary-kill-thread
1809 "l" gnus-summary-lower-thread
1810 "i" gnus-summary-raise-thread
1811 "T" gnus-summary-toggle-threads
1812 "t" gnus-summary-rethread-current
1813 "^" gnus-summary-reparent-thread
1814 "s" gnus-summary-show-thread
1815 "S" gnus-summary-show-all-threads
1816 "h" gnus-summary-hide-thread
1817 "H" gnus-summary-hide-all-threads
1818 "n" gnus-summary-next-thread
1819 "p" gnus-summary-prev-thread
1820 "u" gnus-summary-up-thread
1821 "o" gnus-summary-top-thread
1822 "d" gnus-summary-down-thread
1823 "#" gnus-uu-mark-thread
1824 "\M-#" gnus-uu-unmark-thread)
1825
1826 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1827 "g" gnus-summary-prepare
1828 "c" gnus-summary-insert-cached-articles
1829 "d" gnus-summary-insert-dormant-articles)
1830
1831 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1832 "c" gnus-summary-catchup-and-exit
1833 "C" gnus-summary-catchup-all-and-exit
1834 "E" gnus-summary-exit-no-update
1835 "Q" gnus-summary-exit
1836 "Z" gnus-summary-exit
1837 "n" gnus-summary-catchup-and-goto-next-group
1838 "R" gnus-summary-reselect-current-group
1839 "G" gnus-summary-rescan-group
1840 "N" gnus-summary-next-group
1841 "s" gnus-summary-save-newsrc
1842 "P" gnus-summary-prev-group)
1843
1844 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1845 " " gnus-summary-next-page
1846 "n" gnus-summary-next-page
1847 "\177" gnus-summary-prev-page
1848 [delete] gnus-summary-prev-page
1849 "p" gnus-summary-prev-page
1850 "\r" gnus-summary-scroll-up
1851 "\M-\r" gnus-summary-scroll-down
1852 "<" gnus-summary-beginning-of-article
1853 ">" gnus-summary-end-of-article
1854 "b" gnus-summary-beginning-of-article
1855 "e" gnus-summary-end-of-article
1856 "^" gnus-summary-refer-parent-article
1857 "r" gnus-summary-refer-parent-article
1858 "D" gnus-summary-enter-digest-group
1859 "R" gnus-summary-refer-references
1860 "T" gnus-summary-refer-thread
1861 "g" gnus-summary-show-article
1862 "s" gnus-summary-isearch-article
1863 "P" gnus-summary-print-article
1864 "M" gnus-mailing-list-insinuate
1865 "t" gnus-article-babel)
1866
1867 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1868 "b" gnus-article-add-buttons
1869 "B" gnus-article-add-buttons-to-head
1870 "o" gnus-article-treat-overstrike
1871 "e" gnus-article-emphasize
1872 "w" gnus-article-fill-cited-article
1873 "Q" gnus-article-fill-long-lines
1874 "C" gnus-article-capitalize-sentences
1875 "c" gnus-article-remove-cr
1876 "q" gnus-article-de-quoted-unreadable
1877 "6" gnus-article-de-base64-unreadable
1878 "Z" gnus-article-decode-HZ
1879 "h" gnus-article-wash-html
1880 "u" gnus-article-unsplit-urls
1881 "s" gnus-summary-force-verify-and-decrypt
1882 "f" gnus-article-display-x-face
1883 "l" gnus-summary-stop-page-breaking
1884 "r" gnus-summary-caesar-message
1885 "m" gnus-summary-morse-message
1886 "t" gnus-summary-toggle-header
1887 "g" gnus-treat-smiley
1888 "v" gnus-summary-verbose-headers
1889 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1890 "p" gnus-article-verify-x-pgp-sig
1891 "d" gnus-article-treat-dumbquotes)
1892
1893 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1894 ;; mnemonic: deuglif*Y*
1895 "u" gnus-article-outlook-unwrap-lines
1896 "a" gnus-article-outlook-repair-attribution
1897 "c" gnus-article-outlook-rearrange-citation
1898 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1899
1900 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1901 "a" gnus-article-hide
1902 "h" gnus-article-hide-headers
1903 "b" gnus-article-hide-boring-headers
1904 "s" gnus-article-hide-signature
1905 "c" gnus-article-hide-citation
1906 "C" gnus-article-hide-citation-in-followups
1907 "l" gnus-article-hide-list-identifiers
1908 "B" gnus-article-strip-banner
1909 "P" gnus-article-hide-pem
1910 "\C-c" gnus-article-hide-citation-maybe)
1911
1912 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1913 "a" gnus-article-highlight
1914 "h" gnus-article-highlight-headers
1915 "c" gnus-article-highlight-citation
1916 "s" gnus-article-highlight-signature)
1917
1918 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1919 "f" gnus-article-treat-fold-headers
1920 "u" gnus-article-treat-unfold-headers
1921 "n" gnus-article-treat-fold-newsgroups)
1922
1923 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1924 "x" gnus-article-display-x-face
1925 "d" gnus-article-display-face
1926 "s" gnus-treat-smiley
1927 "D" gnus-article-remove-images
1928 "f" gnus-treat-from-picon
1929 "m" gnus-treat-mail-picon
1930 "n" gnus-treat-newsgroups-picon)
1931
1932 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1933 "w" gnus-article-decode-mime-words
1934 "c" gnus-article-decode-charset
1935 "v" gnus-mime-view-all-parts
1936 "b" gnus-article-view-part)
1937
1938 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1939 "z" gnus-article-date-ut
1940 "u" gnus-article-date-ut
1941 "l" gnus-article-date-local
1942 "p" gnus-article-date-english
1943 "e" gnus-article-date-lapsed
1944 "o" gnus-article-date-original
1945 "i" gnus-article-date-iso8601
1946 "s" gnus-article-date-user)
1947
1948 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1949 "t" gnus-article-remove-trailing-blank-lines
1950 "l" gnus-article-strip-leading-blank-lines
1951 "m" gnus-article-strip-multiple-blank-lines
1952 "a" gnus-article-strip-blank-lines
1953 "A" gnus-article-strip-all-blank-lines
1954 "s" gnus-article-strip-leading-space
1955 "e" gnus-article-strip-trailing-space
1956 "w" gnus-article-remove-leading-whitespace)
1957
1958 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1959 "v" gnus-version
1960 "f" gnus-summary-fetch-faq
1961 "d" gnus-summary-describe-group
1962 "h" gnus-summary-describe-briefly
1963 "i" gnus-info-find-node
1964 "c" gnus-group-fetch-charter
1965 "C" gnus-group-fetch-control)
1966
1967 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1968 "e" gnus-summary-expire-articles
1969 "\M-\C-e" gnus-summary-expire-articles-now
1970 "\177" gnus-summary-delete-article
1971 [delete] gnus-summary-delete-article
1972 [backspace] gnus-summary-delete-article
1973 "m" gnus-summary-move-article
1974 "r" gnus-summary-respool-article
1975 "w" gnus-summary-edit-article
1976 "c" gnus-summary-copy-article
1977 "B" gnus-summary-crosspost-article
1978 "q" gnus-summary-respool-query
1979 "t" gnus-summary-respool-trace
1980 "i" gnus-summary-import-article
1981 "I" gnus-summary-create-article
1982 "p" gnus-summary-article-posted-p)
1983
1984 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1985 "o" gnus-summary-save-article
1986 "m" gnus-summary-save-article-mail
1987 "F" gnus-summary-write-article-file
1988 "r" gnus-summary-save-article-rmail
1989 "f" gnus-summary-save-article-file
1990 "b" gnus-summary-save-article-body-file
1991 "h" gnus-summary-save-article-folder
1992 "v" gnus-summary-save-article-vm
1993 "p" gnus-summary-pipe-output
1994 "P" gnus-summary-muttprint
1995 "s" gnus-soup-add-article)
1996
1997 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1998 "b" gnus-summary-display-buttonized
1999 "m" gnus-summary-repair-multipart
2000 "v" gnus-article-view-part
2001 "o" gnus-article-save-part
2002 "c" gnus-article-copy-part
2003 "C" gnus-article-view-part-as-charset
2004 "e" gnus-article-view-part-externally
2005 "E" gnus-article-encrypt-body
2006 "i" gnus-article-inline-part
2007 "|" gnus-article-pipe-part)
2008
2009 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2010 "p" gnus-summary-mark-as-processable
2011 "u" gnus-summary-unmark-as-processable
2012 "U" gnus-summary-unmark-all-processable
2013 "v" gnus-uu-mark-over
2014 "s" gnus-uu-mark-series
2015 "r" gnus-uu-mark-region
2016 "g" gnus-uu-unmark-region
2017 "R" gnus-uu-mark-by-regexp
2018 "G" gnus-uu-unmark-by-regexp
2019 "t" gnus-uu-mark-thread
2020 "T" gnus-uu-unmark-thread
2021 "a" gnus-uu-mark-all
2022 "b" gnus-uu-mark-buffer
2023 "S" gnus-uu-mark-sparse
2024 "k" gnus-summary-kill-process-mark
2025 "y" gnus-summary-yank-process-mark
2026 "w" gnus-summary-save-process-mark
2027 "i" gnus-uu-invert-processable)
2028
2029 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2030 ;;"x" gnus-uu-extract-any
2031 "m" gnus-summary-save-parts
2032 "u" gnus-uu-decode-uu
2033 "U" gnus-uu-decode-uu-and-save
2034 "s" gnus-uu-decode-unshar
2035 "S" gnus-uu-decode-unshar-and-save
2036 "o" gnus-uu-decode-save
2037 "O" gnus-uu-decode-save
2038 "b" gnus-uu-decode-binhex
2039 "B" gnus-uu-decode-binhex
2040 "p" gnus-uu-decode-postscript
2041 "P" gnus-uu-decode-postscript-and-save)
2042
2043 (gnus-define-keys
2044 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2045 "u" gnus-uu-decode-uu-view
2046 "U" gnus-uu-decode-uu-and-save-view
2047 "s" gnus-uu-decode-unshar-view
2048 "S" gnus-uu-decode-unshar-and-save-view
2049 "o" gnus-uu-decode-save-view
2050 "O" gnus-uu-decode-save-view
2051 "b" gnus-uu-decode-binhex-view
2052 "B" gnus-uu-decode-binhex-view
2053 "p" gnus-uu-decode-postscript-view
2054 "P" gnus-uu-decode-postscript-and-save-view)
2055
2056 (defvar gnus-article-post-menu nil)
2057
2058 (defconst gnus-summary-menu-maxlen 20)
2059
2060 (defun gnus-summary-menu-split (menu)
2061 ;; If we have lots of elements, divide them into groups of 20
2062 ;; and make a pane (or submenu) for each one.
2063 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2064 (let ((menu menu) sublists next
2065 (i 1))
2066 (while menu
2067 ;; Pull off the next gnus-summary-menu-maxlen elements
2068 ;; and make them the next element of sublist.
2069 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2070 (if next
2071 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2072 nil))
2073 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2074 (aref (car (last menu)) 0)) menu)
2075 sublists))
2076 (setq i (1+ i))
2077 (setq menu next))
2078 (nreverse sublists))
2079 ;; Few elements--put them all in one pane.
2080 menu))
2081
2082 (defun gnus-summary-make-menu-bar ()
2083 (gnus-turn-off-edit-menu 'summary)
2084
2085 (unless (boundp 'gnus-summary-misc-menu)
2086
2087 (easy-menu-define
2088 gnus-summary-kill-menu gnus-summary-mode-map ""
2089 (cons
2090 "Score"
2091 (nconc
2092 (list
2093 ["Customize" gnus-score-customize t])
2094 (gnus-make-score-map 'increase)
2095 (gnus-make-score-map 'lower)
2096 '(("Mark"
2097 ["Kill below" gnus-summary-kill-below t]
2098 ["Mark above" gnus-summary-mark-above t]
2099 ["Tick above" gnus-summary-tick-above t]
2100 ["Clear above" gnus-summary-clear-above t])
2101 ["Current score" gnus-summary-current-score t]
2102 ["Set score" gnus-summary-set-score t]
2103 ["Switch current score file..." gnus-score-change-score-file t]
2104 ["Set mark below..." gnus-score-set-mark-below t]
2105 ["Set expunge below..." gnus-score-set-expunge-below t]
2106 ["Edit current score file" gnus-score-edit-current-scores t]
2107 ["Edit score file" gnus-score-edit-file t]
2108 ["Trace score" gnus-score-find-trace t]
2109 ["Find words" gnus-score-find-favourite-words t]
2110 ["Rescore buffer" gnus-summary-rescore t]
2111 ["Increase score..." gnus-summary-increase-score t]
2112 ["Lower score..." gnus-summary-lower-score t]))))
2113
2114 ;; Define both the Article menu in the summary buffer and the
2115 ;; equivalent Commands menu in the article buffer here for
2116 ;; consistency.
2117 (let ((innards
2118 `(("Hide"
2119 ["All" gnus-article-hide t]
2120 ["Headers" gnus-article-hide-headers t]
2121 ["Signature" gnus-article-hide-signature t]
2122 ["Citation" gnus-article-hide-citation t]
2123 ["List identifiers" gnus-article-hide-list-identifiers t]
2124 ["Banner" gnus-article-strip-banner t]
2125 ["Boring headers" gnus-article-hide-boring-headers t])
2126 ("Highlight"
2127 ["All" gnus-article-highlight t]
2128 ["Headers" gnus-article-highlight-headers t]
2129 ["Signature" gnus-article-highlight-signature t]
2130 ["Citation" gnus-article-highlight-citation t])
2131 ("MIME"
2132 ["Words" gnus-article-decode-mime-words t]
2133 ["Charset" gnus-article-decode-charset t]
2134 ["QP" gnus-article-de-quoted-unreadable t]
2135 ["Base64" gnus-article-de-base64-unreadable t]
2136 ["View MIME buttons" gnus-summary-display-buttonized t]
2137 ["View all" gnus-mime-view-all-parts t]
2138 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2139 ["Encrypt body" gnus-article-encrypt-body
2140 :active (not (gnus-group-read-only-p))
2141 ,@(if (featurep 'xemacs) nil
2142 '(:help "Encrypt the message body on disk"))]
2143 ["Extract all parts..." gnus-summary-save-parts t]
2144 ("Multipart"
2145 ["Repair multipart" gnus-summary-repair-multipart t]
2146 ["Pipe part..." gnus-article-pipe-part t]
2147 ["Inline part" gnus-article-inline-part t]
2148 ["Encrypt body" gnus-article-encrypt-body
2149 :active (not (gnus-group-read-only-p))
2150 ,@(if (featurep 'xemacs) nil
2151 '(:help "Encrypt the message body on disk"))]
2152 ["View part externally" gnus-article-view-part-externally t]
2153 ["View part with charset..." gnus-article-view-part-as-charset t]
2154 ["Copy part" gnus-article-copy-part t]
2155 ["Save part..." gnus-article-save-part t]
2156 ["View part" gnus-article-view-part t]))
2157 ("Date"
2158 ["Local" gnus-article-date-local t]
2159 ["ISO8601" gnus-article-date-iso8601 t]
2160 ["UT" gnus-article-date-ut t]
2161 ["Original" gnus-article-date-original t]
2162 ["Lapsed" gnus-article-date-lapsed t]
2163 ["User-defined" gnus-article-date-user t])
2164 ("Display"
2165 ["Remove images" gnus-article-remove-images t]
2166 ["Toggle smiley" gnus-treat-smiley t]
2167 ["Show X-Face" gnus-article-display-x-face t]
2168 ["Show picons in From" gnus-treat-from-picon t]
2169 ["Show picons in mail headers" gnus-treat-mail-picon t]
2170 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2171 ("View as different encoding"
2172 ,@(gnus-summary-menu-split
2173 (mapcar
2174 (lambda (cs)
2175 ;; Since easymenu under Emacs doesn't allow
2176 ;; lambda forms for menu commands, we should
2177 ;; provide intern'ed function symbols.
2178 (let ((command (intern (format "\
2179 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2180 (fset command
2181 `(lambda ()
2182 (interactive)
2183 (let ((gnus-summary-show-article-charset-alist
2184 '((1 . ,cs))))
2185 (gnus-summary-show-article 1))))
2186 `[,(symbol-name cs) ,command t]))
2187 (sort (if (fboundp 'coding-system-list)
2188 (coding-system-list)
2189 (mapcar 'car mm-mime-mule-charset-alist))
2190 'string<)))))
2191 ("Washing"
2192 ("Remove Blanks"
2193 ["Leading" gnus-article-strip-leading-blank-lines t]
2194 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2195 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2196 ["All of the above" gnus-article-strip-blank-lines t]
2197 ["All" gnus-article-strip-all-blank-lines t]
2198 ["Leading space" gnus-article-strip-leading-space t]
2199 ["Trailing space" gnus-article-strip-trailing-space t]
2200 ["Leading space in headers"
2201 gnus-article-remove-leading-whitespace t])
2202 ["Overstrike" gnus-article-treat-overstrike t]
2203 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2204 ["Emphasis" gnus-article-emphasize t]
2205 ["Word wrap" gnus-article-fill-cited-article t]
2206 ["Fill long lines" gnus-article-fill-long-lines t]
2207 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2208 ["Remove CR" gnus-article-remove-cr t]
2209 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2210 ["Base64" gnus-article-de-base64-unreadable t]
2211 ["Rot 13" gnus-summary-caesar-message
2212 ,@(if (featurep 'xemacs) '(t)
2213 '(:help "\"Caesar rotate\" article by 13"))]
2214 ["Morse decode" gnus-summary-morse-message t]
2215 ["Unix pipe..." gnus-summary-pipe-message t]
2216 ["Add buttons" gnus-article-add-buttons t]
2217 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2218 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2219 ["Verbose header" gnus-summary-verbose-headers t]
2220 ["Toggle header" gnus-summary-toggle-header t]
2221 ["Unfold headers" gnus-article-treat-unfold-headers t]
2222 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2223 ["Html" gnus-article-wash-html t]
2224 ["Unsplit URLs" gnus-article-unsplit-urls t]
2225 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2226 ["Decode HZ" gnus-article-decode-HZ t]
2227 ("(Outlook) Deuglify"
2228 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2229 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2230 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2231 ["Full (Outlook) deuglify"
2232 gnus-article-outlook-deuglify-article t])
2233 )
2234 ("Output"
2235 ["Save in default format..." gnus-summary-save-article
2236 ,@(if (featurep 'xemacs) '(t)
2237 '(:help "Save article using default method"))]
2238 ["Save in file..." gnus-summary-save-article-file
2239 ,@(if (featurep 'xemacs) '(t)
2240 '(:help "Save article in file"))]
2241 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2242 ["Save in MH folder..." gnus-summary-save-article-folder t]
2243 ["Save in VM folder..." gnus-summary-save-article-vm t]
2244 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2245 ["Save body in file..." gnus-summary-save-article-body-file t]
2246 ["Pipe through a filter..." gnus-summary-pipe-output t]
2247 ["Add to SOUP packet" gnus-soup-add-article t]
2248 ["Print with Muttprint..." gnus-summary-muttprint t]
2249 ["Print" gnus-summary-print-article
2250 ,@(if (featurep 'xemacs) '(t)
2251 '(:help "Generate and print a PostScript image"))])
2252 ("Copy, move,... (Backend)"
2253 ,@(if (featurep 'xemacs) nil
2254 '(:help "Copying, moving, expiring articles..."))
2255 ["Respool article..." gnus-summary-respool-article t]
2256 ["Move article..." gnus-summary-move-article
2257 (gnus-check-backend-function
2258 'request-move-article gnus-newsgroup-name)]
2259 ["Copy article..." gnus-summary-copy-article t]
2260 ["Crosspost article..." gnus-summary-crosspost-article
2261 (gnus-check-backend-function
2262 'request-replace-article gnus-newsgroup-name)]
2263 ["Import file..." gnus-summary-import-article
2264 (gnus-check-backend-function
2265 'request-accept-article gnus-newsgroup-name)]
2266 ["Create article..." gnus-summary-create-article
2267 (gnus-check-backend-function
2268 'request-accept-article gnus-newsgroup-name)]
2269 ["Check if posted" gnus-summary-article-posted-p t]
2270 ["Edit article" gnus-summary-edit-article
2271 (not (gnus-group-read-only-p))]
2272 ["Delete article" gnus-summary-delete-article
2273 (gnus-check-backend-function
2274 'request-expire-articles gnus-newsgroup-name)]
2275 ["Query respool" gnus-summary-respool-query t]
2276 ["Trace respool" gnus-summary-respool-trace t]
2277 ["Delete expirable articles" gnus-summary-expire-articles-now
2278 (gnus-check-backend-function
2279 'request-expire-articles gnus-newsgroup-name)])
2280 ("Extract"
2281 ["Uudecode" gnus-uu-decode-uu
2282 ,@(if (featurep 'xemacs) '(t)
2283 '(:help "Decode uuencoded article(s)"))]
2284 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2285 ["Unshar" gnus-uu-decode-unshar t]
2286 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2287 ["Save" gnus-uu-decode-save t]
2288 ["Binhex" gnus-uu-decode-binhex t]
2289 ["Postscript" gnus-uu-decode-postscript t]
2290 ["All MIME parts" gnus-summary-save-parts t])
2291 ("Cache"
2292 ["Enter article" gnus-cache-enter-article t]
2293 ["Remove article" gnus-cache-remove-article t])
2294 ["Translate" gnus-article-babel t]
2295 ["Select article buffer" gnus-summary-select-article-buffer t]
2296 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2297 ["Isearch article..." gnus-summary-isearch-article t]
2298 ["Beginning of the article" gnus-summary-beginning-of-article t]
2299 ["End of the article" gnus-summary-end-of-article t]
2300 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2301 ["Fetch referenced articles" gnus-summary-refer-references t]
2302 ["Fetch current thread" gnus-summary-refer-thread t]
2303 ["Fetch article with id..." gnus-summary-refer-article t]
2304 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2305 ["Redisplay" gnus-summary-show-article t]
2306 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2307 (easy-menu-define
2308 gnus-summary-article-menu gnus-summary-mode-map ""
2309 (cons "Article" innards))
2310
2311 (if (not (keymapp gnus-summary-article-menu))
2312 (easy-menu-define
2313 gnus-article-commands-menu gnus-article-mode-map ""
2314 (cons "Commands" innards))
2315 ;; in Emacs, don't share menu.
2316 (setq gnus-article-commands-menu
2317 (copy-keymap gnus-summary-article-menu))
2318 (define-key gnus-article-mode-map [menu-bar commands]
2319 (cons "Commands" gnus-article-commands-menu))))
2320
2321 (easy-menu-define
2322 gnus-summary-thread-menu gnus-summary-mode-map ""
2323 '("Threads"
2324 ["Find all messages in thread" gnus-summary-refer-thread t]
2325 ["Toggle threading" gnus-summary-toggle-threads t]
2326 ["Hide threads" gnus-summary-hide-all-threads t]
2327 ["Show threads" gnus-summary-show-all-threads t]
2328 ["Hide thread" gnus-summary-hide-thread t]
2329 ["Show thread" gnus-summary-show-thread t]
2330 ["Go to next thread" gnus-summary-next-thread t]
2331 ["Go to previous thread" gnus-summary-prev-thread t]
2332 ["Go down thread" gnus-summary-down-thread t]
2333 ["Go up thread" gnus-summary-up-thread t]
2334 ["Top of thread" gnus-summary-top-thread t]
2335 ["Mark thread as read" gnus-summary-kill-thread t]
2336 ["Lower thread score" gnus-summary-lower-thread t]
2337 ["Raise thread score" gnus-summary-raise-thread t]
2338 ["Rethread current" gnus-summary-rethread-current t]))
2339
2340 (easy-menu-define
2341 gnus-summary-post-menu gnus-summary-mode-map ""
2342 `("Post"
2343 ["Send a message (mail or news)" gnus-summary-post-news
2344 ,@(if (featurep 'xemacs) '(t)
2345 '(:help "Compose a new message (mail or news)"))]
2346 ["Followup" gnus-summary-followup
2347 ,@(if (featurep 'xemacs) '(t)
2348 '(:help "Post followup to this article"))]
2349 ["Followup and yank" gnus-summary-followup-with-original
2350 ,@(if (featurep 'xemacs) '(t)
2351 '(:help "Post followup to this article, quoting its contents"))]
2352 ["Supersede article" gnus-summary-supersede-article t]
2353 ["Cancel article" gnus-summary-cancel-article
2354 ,@(if (featurep 'xemacs) '(t)
2355 '(:help "Cancel an article you posted"))]
2356 ["Reply" gnus-summary-reply t]
2357 ["Reply and yank" gnus-summary-reply-with-original t]
2358 ["Wide reply" gnus-summary-wide-reply t]
2359 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2360 ,@(if (featurep 'xemacs) '(t)
2361 '(:help "Mail a reply, quoting this article"))]
2362 ["Very wide reply" gnus-summary-very-wide-reply t]
2363 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2364 ,@(if (featurep 'xemacs) '(t)
2365 '(:help "Mail a very wide reply, quoting this article"))]
2366 ["Mail forward" gnus-summary-mail-forward t]
2367 ["Post forward" gnus-summary-post-forward t]
2368 ["Digest and mail" gnus-uu-digest-mail-forward t]
2369 ["Digest and post" gnus-uu-digest-post-forward t]
2370 ["Resend message" gnus-summary-resend-message t]
2371 ["Resend message edit" gnus-summary-resend-message-edit t]
2372 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2373 ["Send a mail" gnus-summary-mail-other-window t]
2374 ["Create a local message" gnus-summary-news-other-window t]
2375 ["Uuencode and post" gnus-uu-post-news
2376 ,@(if (featurep 'xemacs) '(t)
2377 '(:help "Post a uuencoded article"))]
2378 ["Followup via news" gnus-summary-followup-to-mail t]
2379 ["Followup via news and yank"
2380 gnus-summary-followup-to-mail-with-original t]
2381 ;;("Draft"
2382 ;;["Send" gnus-summary-send-draft t]
2383 ;;["Send bounced" gnus-resend-bounced-mail t])
2384 ))
2385
2386 (cond
2387 ((not (keymapp gnus-summary-post-menu))
2388 (setq gnus-article-post-menu gnus-summary-post-menu))
2389 ((not gnus-article-post-menu)
2390 ;; Don't share post menu.
2391 (setq gnus-article-post-menu
2392 (copy-keymap gnus-summary-post-menu))))
2393 (define-key gnus-article-mode-map [menu-bar post]
2394 (cons "Post" gnus-article-post-menu))
2395
2396 (easy-menu-define
2397 gnus-summary-misc-menu gnus-summary-mode-map ""
2398 `("Gnus"
2399 ("Mark Read"
2400 ["Mark as read" gnus-summary-mark-as-read-forward t]
2401 ["Mark same subject and select"
2402 gnus-summary-kill-same-subject-and-select t]
2403 ["Mark same subject" gnus-summary-kill-same-subject t]
2404 ["Catchup" gnus-summary-catchup
2405 ,@(if (featurep 'xemacs) '(t)
2406 '(:help "Mark unread articles in this group as read"))]
2407 ["Catchup all" gnus-summary-catchup-all t]
2408 ["Catchup to here" gnus-summary-catchup-to-here t]
2409 ["Catchup from here" gnus-summary-catchup-from-here t]
2410 ["Catchup region" gnus-summary-mark-region-as-read
2411 (gnus-mark-active-p)]
2412 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2413 ("Mark Various"
2414 ["Tick" gnus-summary-tick-article-forward t]
2415 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2416 ["Remove marks" gnus-summary-clear-mark-forward t]
2417 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2418 ["Set bookmark" gnus-summary-set-bookmark t]
2419 ["Remove bookmark" gnus-summary-remove-bookmark t])
2420 ("Limit to"
2421 ["Marks..." gnus-summary-limit-to-marks t]
2422 ["Subject..." gnus-summary-limit-to-subject t]
2423 ["Author..." gnus-summary-limit-to-author t]
2424 ["Age..." gnus-summary-limit-to-age t]
2425 ["Extra..." gnus-summary-limit-to-extra t]
2426 ["Score..." gnus-summary-limit-to-score t]
2427 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2428 ["Unread" gnus-summary-limit-to-unread t]
2429 ["Unseen" gnus-summary-limit-to-unseen t]
2430 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2431 ["Next articles" gnus-summary-limit-to-articles t]
2432 ["Pop limit" gnus-summary-pop-limit t]
2433 ["Show dormant" gnus-summary-limit-include-dormant t]
2434 ["Hide childless dormant"
2435 gnus-summary-limit-exclude-childless-dormant t]
2436 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2437 ["Hide marked" gnus-summary-limit-exclude-marks t]
2438 ["Show expunged" gnus-summary-limit-include-expunged t])
2439 ("Process Mark"
2440 ["Set mark" gnus-summary-mark-as-processable t]
2441 ["Remove mark" gnus-summary-unmark-as-processable t]
2442 ["Remove all marks" gnus-summary-unmark-all-processable t]
2443 ["Mark above" gnus-uu-mark-over t]
2444 ["Mark series" gnus-uu-mark-series t]
2445 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2446 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2447 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2448 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2449 ["Mark all" gnus-uu-mark-all t]
2450 ["Mark buffer" gnus-uu-mark-buffer t]
2451 ["Mark sparse" gnus-uu-mark-sparse t]
2452 ["Mark thread" gnus-uu-mark-thread t]
2453 ["Unmark thread" gnus-uu-unmark-thread t]
2454 ("Process Mark Sets"
2455 ["Kill" gnus-summary-kill-process-mark t]
2456 ["Yank" gnus-summary-yank-process-mark
2457 gnus-newsgroup-process-stack]
2458 ["Save" gnus-summary-save-process-mark t]
2459 ["Run command on marked..." gnus-summary-universal-argument t]))
2460 ("Scroll article"
2461 ["Page forward" gnus-summary-next-page
2462 ,@(if (featurep 'xemacs) '(t)
2463 '(:help "Show next page of article"))]
2464 ["Page backward" gnus-summary-prev-page
2465 ,@(if (featurep 'xemacs) '(t)
2466 '(:help "Show previous page of article"))]
2467 ["Line forward" gnus-summary-scroll-up t])
2468 ("Move"
2469 ["Next unread article" gnus-summary-next-unread-article t]
2470 ["Previous unread article" gnus-summary-prev-unread-article t]
2471 ["Next article" gnus-summary-next-article t]
2472 ["Previous article" gnus-summary-prev-article t]
2473 ["Next unread subject" gnus-summary-next-unread-subject t]
2474 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2475 ["Next article same subject" gnus-summary-next-same-subject t]
2476 ["Previous article same subject" gnus-summary-prev-same-subject t]
2477 ["First unread article" gnus-summary-first-unread-article t]
2478 ["Best unread article" gnus-summary-best-unread-article t]
2479 ["Go to subject number..." gnus-summary-goto-subject t]
2480 ["Go to article number..." gnus-summary-goto-article t]
2481 ["Go to the last article" gnus-summary-goto-last-article t]
2482 ["Pop article off history" gnus-summary-pop-article t])
2483 ("Sort"
2484 ["Sort by number" gnus-summary-sort-by-number t]
2485 ["Sort by author" gnus-summary-sort-by-author t]
2486 ["Sort by subject" gnus-summary-sort-by-subject t]
2487 ["Sort by date" gnus-summary-sort-by-date t]
2488 ["Sort by score" gnus-summary-sort-by-score t]
2489 ["Sort by lines" gnus-summary-sort-by-lines t]
2490 ["Sort by characters" gnus-summary-sort-by-chars t]
2491 ["Randomize" gnus-summary-sort-by-random t]
2492 ["Original sort" gnus-summary-sort-by-original t])
2493 ("Help"
2494 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2495 ["Describe group" gnus-summary-describe-group t]
2496 ["Fetch charter" gnus-group-fetch-charter
2497 ,@(if (featurep 'xemacs) nil
2498 '(:help "Display the charter of the current group"))]
2499 ["Fetch control message" gnus-group-fetch-control
2500 ,@(if (featurep 'xemacs) nil
2501 '(:help "Display the archived control message for the current group"))]
2502 ["Read manual" gnus-info-find-node t])
2503 ("Modes"
2504 ["Pick and read" gnus-pick-mode t]
2505 ["Binary" gnus-binary-mode t])
2506 ("Regeneration"
2507 ["Regenerate" gnus-summary-prepare t]
2508 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2509 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2510 ["Toggle threading" gnus-summary-toggle-threads t])
2511 ["See old articles" gnus-summary-insert-old-articles t]
2512 ["See new articles" gnus-summary-insert-new-articles t]
2513 ["Filter articles..." gnus-summary-execute-command t]
2514 ["Run command on articles..." gnus-summary-universal-argument t]
2515 ["Search articles forward..." gnus-summary-search-article-forward t]
2516 ["Search articles backward..." gnus-summary-search-article-backward t]
2517 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2518 ["Expand window" gnus-summary-expand-window t]
2519 ["Expire expirable articles" gnus-summary-expire-articles
2520 (gnus-check-backend-function
2521 'request-expire-articles gnus-newsgroup-name)]
2522 ["Edit local kill file" gnus-summary-edit-local-kill t]
2523 ["Edit main kill file" gnus-summary-edit-global-kill t]
2524 ["Edit group parameters" gnus-summary-edit-parameters t]
2525 ["Customize group parameters" gnus-summary-customize-parameters t]
2526 ["Send a bug report" gnus-bug t]
2527 ("Exit"
2528 ["Catchup and exit" gnus-summary-catchup-and-exit
2529 ,@(if (featurep 'xemacs) '(t)
2530 '(:help "Mark unread articles in this group as read, then exit"))]
2531 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2532 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2533 ["Exit group" gnus-summary-exit
2534 ,@(if (featurep 'xemacs) '(t)
2535 '(:help "Exit current group, return to group selection mode"))]
2536 ["Exit group without updating" gnus-summary-exit-no-update t]
2537 ["Exit and goto next group" gnus-summary-next-group t]
2538 ["Exit and goto prev group" gnus-summary-prev-group t]
2539 ["Reselect group" gnus-summary-reselect-current-group t]
2540 ["Rescan group" gnus-summary-rescan-group t]
2541 ["Update dribble" gnus-summary-save-newsrc t])))
2542
2543 (gnus-run-hooks 'gnus-summary-menu-hook)))
2544
2545 (defvar gnus-summary-tool-bar-map nil)
2546
2547 ;; Emacs 21 tool bar. Should be no-op otherwise.
2548 (defun gnus-summary-make-tool-bar ()
2549 (if (and (fboundp 'tool-bar-add-item-from-menu)
2550 (default-value 'tool-bar-mode)
2551 (not gnus-summary-tool-bar-map))
2552 (setq gnus-summary-tool-bar-map
2553 (let ((tool-bar-map (make-sparse-keymap))
2554 (load-path (mm-image-load-path)))
2555 (tool-bar-add-item-from-menu
2556 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2557 (tool-bar-add-item-from-menu
2558 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2559 (tool-bar-add-item-from-menu
2560 'gnus-summary-post-news "post" gnus-summary-mode-map)
2561 (tool-bar-add-item-from-menu
2562 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2563 (tool-bar-add-item-from-menu
2564 'gnus-summary-followup "followup" gnus-summary-mode-map)
2565 (tool-bar-add-item-from-menu
2566 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2567 (tool-bar-add-item-from-menu
2568 'gnus-summary-reply "reply" gnus-summary-mode-map)
2569 (tool-bar-add-item-from-menu
2570 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2571 (tool-bar-add-item-from-menu
2572 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2573 (tool-bar-add-item-from-menu
2574 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2575 (tool-bar-add-item-from-menu
2576 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2577 (tool-bar-add-item-from-menu
2578 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2579 (tool-bar-add-item-from-menu
2580 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2581 (tool-bar-add-item-from-menu
2582 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2583 (tool-bar-add-item-from-menu
2584 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2585 tool-bar-map)))
2586 (if gnus-summary-tool-bar-map
2587 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2588
2589 (defun gnus-score-set-default (var value)
2590 "A version of set that updates the GNU Emacs menu-bar."
2591 (set var value)
2592 ;; It is the message that forces the active status to be updated.
2593 (message ""))
2594
2595 (defun gnus-make-score-map (type)
2596 "Make a summary score map of type TYPE."
2597 (if t
2598 nil
2599 (let ((headers '(("author" "from" string)
2600 ("subject" "subject" string)
2601 ("article body" "body" string)
2602 ("article head" "head" string)
2603 ("xref" "xref" string)
2604 ("extra header" "extra" string)
2605 ("lines" "lines" number)
2606 ("followups to author" "followup" string)))
2607 (types '((number ("less than" <)
2608 ("greater than" >)
2609 ("equal" =))
2610 (string ("substring" s)
2611 ("exact string" e)
2612 ("fuzzy string" f)
2613 ("regexp" r))))
2614 (perms '(("temporary" (current-time-string))
2615 ("permanent" nil)
2616 ("immediate" now)))
2617 header)
2618 (list
2619 (apply
2620 'nconc
2621 (list
2622 (if (eq type 'lower)
2623 "Lower score"
2624 "Increase score"))
2625 (let (outh)
2626 (while headers
2627 (setq header (car headers))
2628 (setq outh
2629 (cons
2630 (apply
2631 'nconc
2632 (list (car header))
2633 (let ((ts (cdr (assoc (nth 2 header) types)))
2634 outt)
2635 (while ts
2636 (setq outt
2637 (cons
2638 (apply
2639 'nconc
2640 (list (caar ts))
2641 (let ((ps perms)
2642 outp)
2643 (while ps
2644 (setq outp
2645 (cons
2646 (vector
2647 (caar ps)
2648 (list
2649 'gnus-summary-score-entry
2650 (nth 1 header)
2651 (if (or (string= (nth 1 header)
2652 "head")
2653 (string= (nth 1 header)
2654 "body"))
2655 ""
2656 (list 'gnus-summary-header
2657 (nth 1 header)))
2658 (list 'quote (nth 1 (car ts)))
2659 (list 'gnus-score-delta-default
2660 nil)
2661 (nth 1 (car ps))
2662 t)
2663 t)
2664 outp))
2665 (setq ps (cdr ps)))
2666 (list (nreverse outp))))
2667 outt))
2668 (setq ts (cdr ts)))
2669 (list (nreverse outt))))
2670 outh))
2671 (setq headers (cdr headers)))
2672 (list (nreverse outh))))))))
2673
2674 \f
2675
2676 (defun gnus-summary-mode (&optional group)
2677 "Major mode for reading articles.
2678
2679 All normal editing commands are switched off.
2680 \\<gnus-summary-mode-map>
2681 Each line in this buffer represents one article. To read an
2682 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2683 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2684 respectively.
2685
2686 You can also post articles and send mail from this buffer. To
2687 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2688 of an article, type `\\[gnus-summary-reply]'.
2689
2690 There are approx. one gazillion commands you can execute in this
2691 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2692
2693 The following commands are available:
2694
2695 \\{gnus-summary-mode-map}"
2696 (interactive)
2697 (kill-all-local-variables)
2698 (when (gnus-visual-p 'summary-menu 'menu)
2699 (gnus-summary-make-menu-bar)
2700 (gnus-summary-make-tool-bar))
2701 (gnus-summary-make-local-variables)
2702 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2703 (gnus-summary-make-local-variables))
2704 (gnus-make-thread-indent-array)
2705 (gnus-simplify-mode-line)
2706 (setq major-mode 'gnus-summary-mode)
2707 (setq mode-name "Summary")
2708 (make-local-variable 'minor-mode-alist)
2709 (use-local-map gnus-summary-mode-map)
2710 (buffer-disable-undo)
2711 (setq buffer-read-only t) ;Disable modification
2712 (setq truncate-lines t)
2713 (setq selective-display t)
2714 (setq selective-display-ellipses t) ;Display `...'
2715 (gnus-summary-set-display-table)
2716 (gnus-set-default-directory)
2717 (setq gnus-newsgroup-name group)
2718 (make-local-variable 'gnus-summary-line-format)
2719 (make-local-variable 'gnus-summary-line-format-spec)
2720 (make-local-variable 'gnus-summary-dummy-line-format)
2721 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2722 (make-local-variable 'gnus-summary-mark-positions)
2723 (gnus-make-local-hook 'pre-command-hook)
2724 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2725 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2726 (turn-on-gnus-mailing-list-mode)
2727 (mm-enable-multibyte)
2728 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2729 (gnus-update-summary-mark-positions))
2730
2731 (defun gnus-summary-make-local-variables ()
2732 "Make all the local summary buffer variables."
2733 (let (global)
2734 (dolist (local gnus-summary-local-variables)
2735 (if (consp local)
2736 (progn
2737 (if (eq (cdr local) 'global)
2738 ;; Copy the global value of the variable.
2739 (setq global (symbol-value (car local)))
2740 ;; Use the value from the list.
2741 (setq global (eval (cdr local))))
2742 (set (make-local-variable (car local)) global))
2743 ;; Simple nil-valued local variable.
2744 (set (make-local-variable local) nil)))))
2745
2746 (defun gnus-summary-clear-local-variables ()
2747 (let ((locals gnus-summary-local-variables))
2748 (while locals
2749 (if (consp (car locals))
2750 (and (vectorp (caar locals))
2751 (set (caar locals) nil))
2752 (and (vectorp (car locals))
2753 (set (car locals) nil)))
2754 (setq locals (cdr locals)))))
2755
2756 ;; Summary data functions.
2757
2758 (defmacro gnus-data-number (data)
2759 `(car ,data))
2760
2761 (defmacro gnus-data-set-number (data number)
2762 `(setcar ,data ,number))
2763
2764 (defmacro gnus-data-mark (data)
2765 `(nth 1 ,data))
2766
2767 (defmacro gnus-data-set-mark (data mark)
2768 `(setcar (nthcdr 1 ,data) ,mark))
2769
2770 (defmacro gnus-data-pos (data)
2771 `(nth 2 ,data))
2772
2773 (defmacro gnus-data-set-pos (data pos)
2774 `(setcar (nthcdr 2 ,data) ,pos))
2775
2776 (defmacro gnus-data-header (data)
2777 `(nth 3 ,data))
2778
2779 (defmacro gnus-data-set-header (data header)
2780 `(setf (nth 3 ,data) ,header))
2781
2782 (defmacro gnus-data-level (data)
2783 `(nth 4 ,data))
2784
2785 (defmacro gnus-data-unread-p (data)
2786 `(= (nth 1 ,data) gnus-unread-mark))
2787
2788 (defmacro gnus-data-read-p (data)
2789 `(/= (nth 1 ,data) gnus-unread-mark))
2790
2791 (defmacro gnus-data-pseudo-p (data)
2792 `(consp (nth 3 ,data)))
2793
2794 (defmacro gnus-data-find (number)
2795 `(assq ,number gnus-newsgroup-data))
2796
2797 (defmacro gnus-data-find-list (number &optional data)
2798 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2799 (memq (assq ,number bdata)
2800 bdata)))
2801
2802 (defmacro gnus-data-make (number mark pos header level)
2803 `(list ,number ,mark ,pos ,header ,level))
2804
2805 (defun gnus-data-enter (after-article number mark pos header level offset)
2806 (let ((data (gnus-data-find-list after-article)))
2807 (unless data
2808 (error "No such article: %d" after-article))
2809 (setcdr data (cons (gnus-data-make number mark pos header level)
2810 (cdr data)))
2811 (setq gnus-newsgroup-data-reverse nil)
2812 (gnus-data-update-list (cddr data) offset)))
2813
2814 (defun gnus-data-enter-list (after-article list &optional offset)
2815 (when list
2816 (let ((data (and after-article (gnus-data-find-list after-article)))
2817 (ilist list))
2818 (if (not (or data
2819 after-article))
2820 (let ((odata gnus-newsgroup-data))
2821 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2822 (when offset
2823 (gnus-data-update-list odata offset)))
2824 ;; Find the last element in the list to be spliced into the main
2825 ;; list.
2826 (while (cdr list)
2827 (setq list (cdr list)))
2828 (if (not data)
2829 (progn
2830 (setcdr list gnus-newsgroup-data)
2831 (setq gnus-newsgroup-data ilist)
2832 (when offset
2833 (gnus-data-update-list (cdr list) offset)))
2834 (setcdr list (cdr data))
2835 (setcdr data ilist)
2836 (when offset
2837 (gnus-data-update-list (cdr list) offset))))
2838 (setq gnus-newsgroup-data-reverse nil))))
2839
2840 (defun gnus-data-remove (article &optional offset)
2841 (let ((data gnus-newsgroup-data))
2842 (if (= (gnus-data-number (car data)) article)
2843 (progn
2844 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2845 gnus-newsgroup-data-reverse nil)
2846 (when offset
2847 (gnus-data-update-list gnus-newsgroup-data offset)))
2848 (while (cdr data)
2849 (when (= (gnus-data-number (cadr data)) article)
2850 (setcdr data (cddr data))
2851 (when offset
2852 (gnus-data-update-list (cdr data) offset))
2853 (setq data nil
2854 gnus-newsgroup-data-reverse nil))
2855 (setq data (cdr data))))))
2856
2857 (defmacro gnus-data-list (backward)
2858 `(if ,backward
2859 (or gnus-newsgroup-data-reverse
2860 (setq gnus-newsgroup-data-reverse
2861 (reverse gnus-newsgroup-data)))
2862 gnus-newsgroup-data))
2863
2864 (defun gnus-data-update-list (data offset)
2865 "Add OFFSET to the POS of all data entries in DATA."
2866 (setq gnus-newsgroup-data-reverse nil)
2867 (while data
2868 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2869 (setq data (cdr data))))
2870
2871 (defun gnus-summary-article-pseudo-p (article)
2872 "Say whether this article is a pseudo article or not."
2873 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2874
2875 (defmacro gnus-summary-article-sparse-p (article)
2876 "Say whether this article is a sparse article or not."
2877 `(memq ,article gnus-newsgroup-sparse))
2878
2879 (defmacro gnus-summary-article-ancient-p (article)
2880 "Say whether this article is a sparse article or not."
2881 `(memq ,article gnus-newsgroup-ancient))
2882
2883 (defun gnus-article-parent-p (number)
2884 "Say whether this article is a parent or not."
2885 (let ((data (gnus-data-find-list number)))
2886 (and (cdr data) ; There has to be an article after...
2887 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2888 (gnus-data-level (nth 1 data))))))
2889
2890 (defun gnus-article-children (number)
2891 "Return a list of all children to NUMBER."
2892 (let* ((data (gnus-data-find-list number))
2893 (level (gnus-data-level (car data)))
2894 children)
2895 (setq data (cdr data))
2896 (while (and data
2897 (= (gnus-data-level (car data)) (1+ level)))
2898 (push (gnus-data-number (car data)) children)
2899 (setq data (cdr data)))
2900 children))
2901
2902 (defmacro gnus-summary-skip-intangible ()
2903 "If the current article is intangible, then jump to a different article."
2904 '(let ((to (get-text-property (point) 'gnus-intangible)))
2905 (and to (gnus-summary-goto-subject to))))
2906
2907 (defmacro gnus-summary-article-intangible-p ()
2908 "Say whether this article is intangible or not."
2909 '(get-text-property (point) 'gnus-intangible))
2910
2911 (defun gnus-article-read-p (article)
2912 "Say whether ARTICLE is read or not."
2913 (not (or (memq article gnus-newsgroup-marked)
2914 (memq article gnus-newsgroup-spam-marked)
2915 (memq article gnus-newsgroup-unreads)
2916 (memq article gnus-newsgroup-unselected)
2917 (memq article gnus-newsgroup-dormant))))
2918
2919 ;; Some summary mode macros.
2920
2921 (defmacro gnus-summary-article-number ()
2922 "The article number of the article on the current line.
2923 If there isn't an article number here, then we return the current
2924 article number."
2925 '(progn
2926 (gnus-summary-skip-intangible)
2927 (or (get-text-property (point) 'gnus-number)
2928 (gnus-summary-last-subject))))
2929
2930 (defmacro gnus-summary-article-header (&optional number)
2931 "Return the header of article NUMBER."
2932 `(gnus-data-header (gnus-data-find
2933 ,(or number '(gnus-summary-article-number)))))
2934
2935 (defmacro gnus-summary-thread-level (&optional number)
2936 "Return the level of thread that starts with article NUMBER."
2937 `(if (and (eq gnus-summary-make-false-root 'dummy)
2938 (get-text-property (point) 'gnus-intangible))
2939 0
2940 (gnus-data-level (gnus-data-find
2941 ,(or number '(gnus-summary-article-number))))))
2942
2943 (defmacro gnus-summary-article-mark (&optional number)
2944 "Return the mark of article NUMBER."
2945 `(gnus-data-mark (gnus-data-find
2946 ,(or number '(gnus-summary-article-number)))))
2947
2948 (defmacro gnus-summary-article-pos (&optional number)
2949 "Return the position of the line of article NUMBER."
2950 `(gnus-data-pos (gnus-data-find
2951 ,(or number '(gnus-summary-article-number)))))
2952
2953 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2954 (defmacro gnus-summary-article-subject (&optional number)
2955 "Return current subject string or nil if nothing."
2956 `(let ((headers
2957 ,(if number
2958 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2959 '(gnus-data-header (assq (gnus-summary-article-number)
2960 gnus-newsgroup-data)))))
2961 (and headers
2962 (vectorp headers)
2963 (mail-header-subject headers))))
2964
2965 (defmacro gnus-summary-article-score (&optional number)
2966 "Return current article score."
2967 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2968 gnus-newsgroup-scored))
2969 gnus-summary-default-score 0))
2970
2971 (defun gnus-summary-article-children (&optional number)
2972 "Return a list of article numbers that are children of article NUMBER."
2973 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2974 (level (gnus-data-level (car data)))
2975 l children)
2976 (while (and (setq data (cdr data))
2977 (> (setq l (gnus-data-level (car data))) level))
2978 (and (= (1+ level) l)
2979 (push (gnus-data-number (car data))
2980 children)))
2981 (nreverse children)))
2982
2983 (defun gnus-summary-article-parent (&optional number)
2984 "Return the article number of the parent of article NUMBER."
2985 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2986 (gnus-data-list t)))
2987 (level (gnus-data-level (car data))))
2988 (if (zerop level)
2989 () ; This is a root.
2990 ;; We search until we find an article with a level less than
2991 ;; this one. That function has to be the parent.
2992 (while (and (setq data (cdr data))
2993 (not (< (gnus-data-level (car data)) level))))
2994 (and data (gnus-data-number (car data))))))
2995
2996 (defun gnus-unread-mark-p (mark)
2997 "Say whether MARK is the unread mark."
2998 (= mark gnus-unread-mark))
2999
3000 (defun gnus-read-mark-p (mark)
3001 "Say whether MARK is one of the marks that mark as read.
3002 This is all marks except unread, ticked, dormant, and expirable."
3003 (not (or (= mark gnus-unread-mark)
3004 (= mark gnus-ticked-mark)
3005 (= mark gnus-spam-mark)
3006 (= mark gnus-dormant-mark)
3007 (= mark gnus-expirable-mark))))
3008
3009 (defmacro gnus-article-mark (number)
3010 "Return the MARK of article NUMBER.
3011 This macro should only be used when computing the mark the \"first\"
3012 time; i.e., when generating the summary lines. After that,
3013 `gnus-summary-article-mark' should be used to examine the
3014 marks of articles."
3015 `(cond
3016 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3017 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3018 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3019 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3020 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3021 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3022 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3023 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3024 gnus-ancient-mark))))
3025
3026 ;; Saving hidden threads.
3027
3028 (defmacro gnus-save-hidden-threads (&rest forms)
3029 "Save hidden threads, eval FORMS, and restore the hidden threads."
3030 (let ((config (make-symbol "config")))
3031 `(let ((,config (gnus-hidden-threads-configuration)))
3032 (unwind-protect
3033 (save-excursion
3034 ,@forms)
3035 (gnus-restore-hidden-threads-configuration ,config)))))
3036 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3037 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3038
3039 (defun gnus-data-compute-positions ()
3040 "Compute the positions of all articles."
3041 (setq gnus-newsgroup-data-reverse nil)
3042 (let ((data gnus-newsgroup-data))
3043 (save-excursion
3044 (gnus-save-hidden-threads
3045 (gnus-summary-show-all-threads)
3046 (goto-char (point-min))
3047 (while data
3048 (while (get-text-property (point) 'gnus-intangible)
3049 (forward-line 1))
3050 (gnus-data-set-pos (car data) (+ (point) 3))
3051 (setq data (cdr data))
3052 (forward-line 1))))))
3053
3054 (defun gnus-hidden-threads-configuration ()
3055 "Return the current hidden threads configuration."
3056 (save-excursion
3057 (let (config)
3058 (goto-char (point-min))
3059 (while (search-forward "\r" nil t)
3060 (push (1- (point)) config))
3061 config)))
3062
3063 (defun gnus-restore-hidden-threads-configuration (config)
3064 "Restore hidden threads configuration from CONFIG."
3065 (save-excursion
3066 (let (point buffer-read-only)
3067 (while (setq point (pop config))
3068 (when (and (< point (point-max))
3069 (goto-char point)
3070 (eq (char-after) ?\n))
3071 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3072
3073 ;; Various summary mode internalish functions.
3074
3075 (defun gnus-mouse-pick-article (e)
3076 (interactive "e")
3077 (mouse-set-point e)
3078 (gnus-summary-next-page nil t))
3079
3080 (defun gnus-summary-set-display-table ()
3081 "Change the display table.
3082 Odd characters have a tendency to mess
3083 up nicely formatted displays - we make all possible glyphs
3084 display only a single character."
3085
3086 ;; We start from the standard display table, if any.
3087 (let ((table (or (copy-sequence standard-display-table)
3088 (make-display-table)))
3089 (i 32))
3090 ;; Nix out all the control chars...
3091 (while (>= (setq i (1- i)) 0)
3092 (aset table i [??]))
3093 ;; ... but not newline and cr, of course. (cr is necessary for the
3094 ;; selective display).
3095 (aset table ?\n nil)
3096 (aset table ?\r nil)
3097 ;; We keep TAB as well.
3098 (aset table ?\t nil)
3099 ;; We nix out any glyphs over 126 that are not set already.
3100 (let ((i 256))
3101 (while (>= (setq i (1- i)) 127)
3102 ;; Only modify if the entry is nil.
3103 (unless (aref table i)
3104 (aset table i [??]))))
3105 (setq buffer-display-table table)))
3106
3107 (defun gnus-summary-set-article-display-arrow (pos)
3108 "Update the overlay arrow to point to line at position POS."
3109 (when (and gnus-summary-display-arrow
3110 (boundp 'overlay-arrow-position)
3111 (boundp 'overlay-arrow-string))
3112 (save-excursion
3113 (goto-char pos)
3114 (beginning-of-line)
3115 (unless overlay-arrow-position
3116 (setq overlay-arrow-position (make-marker)))
3117 (setq overlay-arrow-string "=>"
3118 overlay-arrow-position (set-marker overlay-arrow-position
3119 (point)
3120 (current-buffer))))))
3121
3122 (defun gnus-summary-setup-buffer (group)
3123 "Initialize summary buffer."
3124 (let ((buffer (gnus-summary-buffer-name group))
3125 (dead-name (concat "*Dead Summary "
3126 (gnus-group-decoded-name group) "*")))
3127 ;; If a dead summary buffer exists, we kill it.
3128 (when (gnus-buffer-live-p dead-name)
3129 (gnus-kill-buffer dead-name))
3130 (if (get-buffer buffer)
3131 (progn
3132 (set-buffer buffer)
3133 (setq gnus-summary-buffer (current-buffer))
3134 (not gnus-newsgroup-prepared))
3135 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3136 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3137 (gnus-summary-mode group)
3138 (when gnus-carpal
3139 (gnus-carpal-setup-buffer 'summary))
3140 (unless gnus-single-article-buffer
3141 (make-local-variable 'gnus-article-buffer)
3142 (make-local-variable 'gnus-article-current)
3143 (make-local-variable 'gnus-original-article-buffer))
3144 (setq gnus-newsgroup-name group)
3145 ;; Set any local variables in the group parameters.
3146 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3147 t)))
3148
3149 (defun gnus-set-global-variables ()
3150 "Set the global equivalents of the buffer-local variables.
3151 They are set to the latest values they had. These reflect the summary
3152 buffer that was in action when the last article was fetched."
3153 (when (eq major-mode 'gnus-summary-mode)
3154 (setq gnus-summary-buffer (current-buffer))
3155 (let ((name gnus-newsgroup-name)
3156 (marked gnus-newsgroup-marked)
3157 (spam gnus-newsgroup-spam-marked)
3158 (unread gnus-newsgroup-unreads)
3159 (headers gnus-current-headers)
3160 (data gnus-newsgroup-data)
3161 (summary gnus-summary-buffer)
3162 (article-buffer gnus-article-buffer)
3163 (original gnus-original-article-buffer)
3164 (gac gnus-article-current)
3165 (reffed gnus-reffed-article-number)
3166 (score-file gnus-current-score-file)
3167 (default-charset gnus-newsgroup-charset)
3168 vlist)
3169 (let ((locals gnus-newsgroup-variables))
3170 (while locals
3171 (if (consp (car locals))
3172 (push (eval (caar locals)) vlist)
3173 (push (eval (car locals)) vlist))
3174 (setq locals (cdr locals)))
3175 (setq vlist (nreverse vlist)))
3176 (save-excursion
3177 (set-buffer gnus-group-buffer)
3178 (setq gnus-newsgroup-name name
3179 gnus-newsgroup-marked marked
3180 gnus-newsgroup-spam-marked spam
3181 gnus-newsgroup-unreads unread
3182 gnus-current-headers headers
3183 gnus-newsgroup-data data
3184 gnus-article-current gac
3185 gnus-summary-buffer summary
3186 gnus-article-buffer article-buffer
3187 gnus-original-article-buffer original
3188 gnus-reffed-article-number reffed
3189 gnus-current-score-file score-file
3190 gnus-newsgroup-charset default-charset)
3191 (let ((locals gnus-newsgroup-variables))
3192 (while locals
3193 (if (consp (car locals))
3194 (set (caar locals) (pop vlist))
3195 (set (car locals) (pop vlist)))
3196 (setq locals (cdr locals))))
3197 ;; The article buffer also has local variables.
3198 (when (gnus-buffer-live-p gnus-article-buffer)
3199 (set-buffer gnus-article-buffer)
3200 (setq gnus-summary-buffer summary))))))
3201
3202 (defun gnus-summary-article-unread-p (article)
3203 "Say whether ARTICLE is unread or not."
3204 (memq article gnus-newsgroup-unreads))
3205
3206 (defun gnus-summary-first-article-p (&optional article)
3207 "Return whether ARTICLE is the first article in the buffer."
3208 (if (not (setq article (or article (gnus-summary-article-number))))
3209 nil
3210 (eq article (caar gnus-newsgroup-data))))
3211
3212 (defun gnus-summary-last-article-p (&optional article)
3213 "Return whether ARTICLE is the last article in the buffer."
3214 (if (not (setq article (or article (gnus-summary-article-number))))
3215 ;; All non-existent numbers are the last article. :-)
3216 t
3217 (not (cdr (gnus-data-find-list article)))))
3218
3219 (defun gnus-make-thread-indent-array ()
3220 (let ((n 200))
3221 (unless (and gnus-thread-indent-array
3222 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3223 (setq gnus-thread-indent-array (make-vector 201 "")
3224 gnus-thread-indent-array-level gnus-thread-indent-level)
3225 (while (>= n 0)
3226 (aset gnus-thread-indent-array n
3227 (make-string (* n gnus-thread-indent-level) ? ))
3228 (setq n (1- n))))))
3229
3230 (defun gnus-update-summary-mark-positions ()
3231 "Compute where the summary marks are to go."
3232 (save-excursion
3233 (when (gnus-buffer-exists-p gnus-summary-buffer)
3234 (set-buffer gnus-summary-buffer))
3235 (let ((spec gnus-summary-line-format-spec)
3236 pos)
3237 (save-excursion
3238 (gnus-set-work-buffer)
3239 (let ((gnus-tmp-unread ?Z)
3240 (gnus-replied-mark ?Z)
3241 (gnus-score-below-mark ?Z)
3242 (gnus-score-over-mark ?Z)
3243 (gnus-undownloaded-mark ?Z)
3244 (gnus-summary-line-format-spec spec)
3245 (gnus-newsgroup-downloadable '(0))
3246 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3247 case-fold-search ignores)
3248 ;; Here, all marks are bound to Z.
3249 (gnus-summary-insert-line header
3250 0 nil t gnus-tmp-unread t nil "" nil 1)
3251 (goto-char (point-min))
3252 ;; Memorize the positions of the same characters as dummy marks.
3253 (while (re-search-forward "[A-D]" nil t)
3254 (push (point) ignores))
3255 (erase-buffer)
3256 ;; We use A-D as dummy marks in order to know column positions
3257 ;; where marks should be inserted.
3258 (setq gnus-tmp-unread ?A
3259 gnus-replied-mark ?B
3260 gnus-score-below-mark ?C
3261 gnus-score-over-mark ?C
3262 gnus-undownloaded-mark ?D)
3263 (gnus-summary-insert-line header
3264 0 nil t gnus-tmp-unread t nil "" nil 1)
3265 ;; Ignore characters which aren't dummy marks.
3266 (dolist (p ignores)
3267 (delete-region (goto-char (1- p)) p)
3268 (insert ?Z))
3269 (goto-char (point-min))
3270 (setq pos (list (cons 'unread
3271 (and (search-forward "A" nil t)
3272 (- (point) (point-min) 1)))))
3273 (goto-char (point-min))
3274 (push (cons 'replied (and (search-forward "B" nil t)
3275 (- (point) (point-min) 1)))
3276 pos)
3277 (goto-char (point-min))
3278 (push (cons 'score (and (search-forward "C" nil t)
3279 (- (point) (point-min) 1)))
3280 pos)
3281 (goto-char (point-min))
3282 (push (cons 'download (and (search-forward "D" nil t)
3283 (- (point) (point-min) 1)))
3284 pos)))
3285 (setq gnus-summary-mark-positions pos))))
3286
3287 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3288 "Insert a dummy root in the summary buffer."
3289 (beginning-of-line)
3290 (gnus-add-text-properties
3291 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3292 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3293
3294 (defun gnus-summary-extract-address-component (from)
3295 (or (car (funcall gnus-extract-address-components from))
3296 from))
3297
3298 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3299 (let ((mail-parse-charset gnus-newsgroup-charset)
3300 ; Is it really necessary to do this next part for each summary line?
3301 ; Luckily, doesn't seem to slow things down much.
3302 (mail-parse-ignored-charsets
3303 (save-excursion (set-buffer gnus-summary-buffer)
3304 gnus-newsgroup-ignored-charsets)))
3305 (or
3306 (and gnus-ignored-from-addresses
3307 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3308 (let ((extra-headers (mail-header-extra header))
3309 to
3310 newsgroups)
3311 (cond
3312 ((setq to (cdr (assq 'To extra-headers)))
3313 (concat "-> "
3314 (inline
3315 (gnus-summary-extract-address-component
3316 (funcall gnus-decode-encoded-word-function to)))))
3317 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3318 (concat "=> " newsgroups)))))
3319 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3320
3321 (defun gnus-summary-insert-line (gnus-tmp-header
3322 gnus-tmp-level gnus-tmp-current
3323 undownloaded gnus-tmp-unread gnus-tmp-replied
3324 gnus-tmp-expirable gnus-tmp-subject-or-nil
3325 &optional gnus-tmp-dummy gnus-tmp-score
3326 gnus-tmp-process)
3327 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3328 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3329 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3330 (gnus-tmp-score-char
3331 (if (or (null gnus-summary-default-score)
3332 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3333 gnus-summary-zcore-fuzz))
3334 ? ;Whitespace
3335 (if (< gnus-tmp-score gnus-summary-default-score)
3336 gnus-score-below-mark gnus-score-over-mark)))
3337 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3338 (gnus-tmp-replied
3339 (cond (gnus-tmp-process gnus-process-mark)
3340 ((memq gnus-tmp-current gnus-newsgroup-cached)
3341 gnus-cached-mark)
3342 (gnus-tmp-replied gnus-replied-mark)
3343 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3344 gnus-forwarded-mark)
3345 ((memq gnus-tmp-current gnus-newsgroup-saved)
3346 gnus-saved-mark)
3347 ((memq gnus-tmp-number gnus-newsgroup-recent)
3348 gnus-recent-mark)
3349 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3350 gnus-unseen-mark)
3351 (t gnus-no-mark)))
3352 (gnus-tmp-downloaded
3353 (cond (undownloaded
3354 gnus-undownloaded-mark)
3355 (gnus-newsgroup-agentized
3356 gnus-downloaded-mark)
3357 (t
3358 gnus-no-mark)))
3359 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3360 (gnus-tmp-name
3361 (cond
3362 ((string-match "<[^>]+> *$" gnus-tmp-from)
3363 (let ((beg (match-beginning 0)))
3364 (or (and (string-match "^\".+\"" gnus-tmp-from)
3365 (substring gnus-tmp-from 1 (1- (match-end 0))))
3366 (substring gnus-tmp-from 0 beg))))
3367 ((string-match "(.+)" gnus-tmp-from)
3368 (substring gnus-tmp-from
3369 (1+ (match-beginning 0)) (1- (match-end 0))))
3370 (t gnus-tmp-from)))
3371 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3372 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3373 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3374 (buffer-read-only nil))
3375 (when (string= gnus-tmp-name "")
3376 (setq gnus-tmp-name gnus-tmp-from))
3377 (unless (numberp gnus-tmp-lines)
3378 (setq gnus-tmp-lines -1))
3379 (if (= gnus-tmp-lines -1)
3380 (setq gnus-tmp-lines "?")
3381 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3382 (gnus-put-text-property
3383 (point)
3384 (progn (eval gnus-summary-line-format-spec) (point))
3385 'gnus-number gnus-tmp-number)
3386 (when (gnus-visual-p 'summary-highlight 'highlight)
3387 (forward-line -1)
3388 (gnus-run-hooks 'gnus-summary-update-hook)
3389 (forward-line 1))))
3390
3391 (defun gnus-summary-update-line (&optional dont-update)
3392 "Update summary line after change."
3393 (when (and gnus-summary-default-score
3394 (not gnus-summary-inhibit-highlight))
3395 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3396 (article (gnus-summary-article-number))
3397 (score (gnus-summary-article-score article)))
3398 (unless dont-update
3399 (if (and gnus-summary-mark-below
3400 (< (gnus-summary-article-score)
3401 gnus-summary-mark-below))
3402 ;; This article has a low score, so we mark it as read.
3403 (when (memq article gnus-newsgroup-unreads)
3404 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3405 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3406 ;; This article was previously marked as read on account
3407 ;; of a low score, but now it has risen, so we mark it as
3408 ;; unread.
3409 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3410 (gnus-summary-update-mark
3411 (if (or (null gnus-summary-default-score)
3412 (<= (abs (- score gnus-summary-default-score))
3413 gnus-summary-zcore-fuzz))
3414 ? ;Whitespace
3415 (if (< score gnus-summary-default-score)
3416 gnus-score-below-mark gnus-score-over-mark))
3417 'score))
3418 ;; Do visual highlighting.
3419 (when (gnus-visual-p 'summary-highlight 'highlight)
3420 (gnus-run-hooks 'gnus-summary-update-hook)))))
3421
3422 (defvar gnus-tmp-new-adopts nil)
3423
3424 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3425 "Return the number of articles in THREAD.
3426 This may be 0 in some cases -- if none of the articles in
3427 the thread are to be displayed."
3428 (let* ((number
3429 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3430 (cond
3431 ((not (listp thread))
3432 1)
3433 ((and (consp thread) (cdr thread))
3434 (apply
3435 '+ 1 (mapcar
3436 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3437 ((null thread)
3438 1)
3439 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3440 1)
3441 (t 0))))
3442 (when (and level (zerop level) gnus-tmp-new-adopts)
3443 (incf number
3444 (apply '+ (mapcar
3445 'gnus-summary-number-of-articles-in-thread
3446 gnus-tmp-new-adopts))))
3447 (if char
3448 (if (> number 1) gnus-not-empty-thread-mark
3449 gnus-empty-thread-mark)
3450 number)))
3451
3452 (defsubst gnus-summary-line-message-size (head)
3453 "Return pretty-printed version of message size.
3454 This function is intended to be used in
3455 `gnus-summary-line-format-alist'."
3456 (let ((c (or (mail-header-chars head) -1)))
3457 (cond ((< c 0) "n/a") ; chars not available
3458 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3459 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3460 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3461 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3462
3463
3464 (defun gnus-summary-set-local-parameters (group)
3465 "Go through the local params of GROUP and set all variable specs in that list."
3466 (let ((params (gnus-group-find-parameter group))
3467 (vars '(quit-config)) ; Ignore quit-config.
3468 elem)
3469 (while params
3470 (setq elem (car params)
3471 params (cdr params))
3472 (and (consp elem) ; Has to be a cons.
3473 (consp (cdr elem)) ; The cdr has to be a list.
3474 (symbolp (car elem)) ; Has to be a symbol in there.
3475 (not (memq (car elem) vars))
3476 (ignore-errors ; So we set it.
3477 (push (car elem) vars)
3478 (make-local-variable (car elem))
3479 (set (car elem) (eval (nth 1 elem))))))))
3480
3481 (defun gnus-summary-read-group (group &optional show-all no-article
3482 kill-buffer no-display backward
3483 select-articles)
3484 "Start reading news in newsgroup GROUP.
3485 If SHOW-ALL is non-nil, already read articles are also listed.
3486 If NO-ARTICLE is non-nil, no article is selected initially.
3487 If NO-DISPLAY, don't generate a summary buffer."
3488 (let (result)
3489 (while (and group
3490 (null (setq result
3491 (let ((gnus-auto-select-next nil))
3492 (or (gnus-summary-read-group-1
3493 group show-all no-article
3494 kill-buffer no-display
3495 select-articles)
3496 (setq show-all nil
3497 select-articles nil)))))
3498 (eq gnus-auto-select-next 'quietly))
3499 (set-buffer gnus-group-buffer)
3500 ;; The entry function called above goes to the next
3501 ;; group automatically, so we go two groups back
3502 ;; if we are searching for the previous group.
3503 (when backward
3504 (gnus-group-prev-unread-group 2))
3505 (if (not (equal group (gnus-group-group-name)))
3506 (setq group (gnus-group-group-name))
3507 (setq group nil)))
3508 result))
3509
3510 (defun gnus-summary-read-group-1 (group show-all no-article
3511 kill-buffer no-display
3512 &optional select-articles)
3513 ;; Killed foreign groups can't be entered.
3514 ;; (when (and (not (gnus-group-native-p group))
3515 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3516 ;; (error "Dead non-native groups can't be entered"))
3517 (gnus-message 5 "Retrieving newsgroup: %s..."
3518 (gnus-group-decoded-name group))
3519 (let* ((new-group (gnus-summary-setup-buffer group))
3520 (quit-config (gnus-group-quit-config group))
3521 (did-select (and new-group (gnus-select-newsgroup
3522 group show-all select-articles))))
3523 (cond
3524 ;; This summary buffer exists already, so we just select it.
3525 ((not new-group)
3526 (gnus-set-global-variables)
3527 (when kill-buffer
3528 (gnus-kill-or-deaden-summary kill-buffer))
3529 (gnus-configure-windows 'summary 'force)
3530 (gnus-set-mode-line 'summary)
3531 (gnus-summary-position-point)
3532 (message "")
3533 t)
3534 ;; We couldn't select this group.
3535 ((null did-select)
3536 (when (and (eq major-mode 'gnus-summary-mode)
3537 (not (equal (current-buffer) kill-buffer)))
3538 (kill-buffer (current-buffer))
3539 (if (not quit-config)
3540 (progn
3541 ;; Update the info -- marks might need to be removed,
3542 ;; for instance.
3543 (gnus-summary-update-info)
3544 (set-buffer gnus-group-buffer)
3545 (gnus-group-jump-to-group group)
3546 (gnus-group-next-unread-group 1))
3547 (gnus-handle-ephemeral-exit quit-config)))
3548 (let ((grpinfo (gnus-get-info group)))
3549 (if (null (gnus-info-read grpinfo))
3550 (gnus-message 3 "Group %s contains no messages"
3551 (gnus-group-decoded-name group))
3552 (gnus-message 3 "Can't select group")))
3553 nil)
3554 ;; The user did a `C-g' while prompting for number of articles,
3555 ;; so we exit this group.
3556 ((eq did-select 'quit)
3557 (and (eq major-mode 'gnus-summary-mode)
3558 (not (equal (current-buffer) kill-buffer))
3559 (kill-buffer (current-buffer)))
3560 (when kill-buffer
3561 (gnus-kill-or-deaden-summary kill-buffer))
3562 (if (not quit-config)
3563 (progn
3564 (set-buffer gnus-group-buffer)
3565 (gnus-group-jump-to-group group)
3566 (gnus-group-next-unread-group 1)
3567 (gnus-configure-windows 'group 'force))
3568 (gnus-handle-ephemeral-exit quit-config))
3569 ;; Finally signal the quit.
3570 (signal 'quit nil))
3571 ;; The group was successfully selected.
3572 (t
3573 (gnus-set-global-variables)
3574 ;; Save the active value in effect when the group was entered.
3575 (setq gnus-newsgroup-active
3576 (gnus-copy-sequence
3577 (gnus-active gnus-newsgroup-name)))
3578 ;; You can change the summary buffer in some way with this hook.
3579 (gnus-run-hooks 'gnus-select-group-hook)
3580 (when (memq 'summary (gnus-update-format-specifications
3581 nil 'summary 'summary-mode 'summary-dummy))
3582 ;; The format specification for the summary line was updated,
3583 ;; so we need to update the mark positions as well.
3584 (gnus-update-summary-mark-positions))
3585 ;; Do score processing.
3586 (when gnus-use-scoring
3587 (gnus-possibly-score-headers))
3588 ;; Check whether to fill in the gaps in the threads.
3589 (when gnus-build-sparse-threads
3590 (gnus-build-sparse-threads))
3591 ;; Find the initial limit.
3592 (if gnus-show-threads
3593 (if show-all
3594 (let ((gnus-newsgroup-dormant nil))
3595 (gnus-summary-initial-limit show-all))
3596 (gnus-summary-initial-limit show-all))
3597 ;; When unthreaded, all articles are always shown.
3598 (setq gnus-newsgroup-limit
3599 (mapcar
3600 (lambda (header) (mail-header-number header))
3601 gnus-newsgroup-headers)))
3602 ;; Generate the summary buffer.
3603 (unless no-display
3604 (gnus-summary-prepare))
3605 (when gnus-use-trees
3606 (gnus-tree-open group)
3607 (setq gnus-summary-highlight-line-function
3608 'gnus-tree-highlight-article))
3609 ;; If the summary buffer is empty, but there are some low-scored
3610 ;; articles or some excluded dormants, we include these in the
3611 ;; buffer.
3612 (when (and (zerop (buffer-size))
3613 (not no-display))
3614 (cond (gnus-newsgroup-dormant
3615 (gnus-summary-limit-include-dormant))
3616 ((and gnus-newsgroup-scored show-all)
3617 (gnus-summary-limit-include-expunged t))))
3618 ;; Function `gnus-apply-kill-file' must be called in this hook.
3619 (gnus-run-hooks 'gnus-apply-kill-hook)
3620 (if (and (zerop (buffer-size))
3621 (not no-display))
3622 (progn
3623 ;; This newsgroup is empty.
3624 (gnus-summary-catchup-and-exit nil t)
3625 (gnus-message 6 "No unread news")
3626 (when kill-buffer
3627 (gnus-kill-or-deaden-summary kill-buffer))
3628 ;; Return nil from this function.
3629 nil)
3630 ;; Hide conversation thread subtrees. We cannot do this in
3631 ;; gnus-summary-prepare-hook since kill processing may not
3632 ;; work with hidden articles.
3633 (gnus-summary-maybe-hide-threads)
3634 (when kill-buffer
3635 (gnus-kill-or-deaden-summary kill-buffer))
3636 (gnus-summary-auto-select-subject)
3637 ;; Show first unread article if requested.
3638 (if (and (not no-article)
3639 (not no-display)
3640 gnus-newsgroup-unreads
3641 gnus-auto-select-first)
3642 (progn
3643 (gnus-configure-windows 'summary)
3644 (let ((art (gnus-summary-article-number)))
3645 (unless (and (not gnus-plugged)
3646 (or (memq art gnus-newsgroup-undownloaded)
3647 (memq art gnus-newsgroup-downloadable)))
3648 (gnus-summary-goto-article art))))
3649 ;; Don't select any articles.
3650 (gnus-summary-position-point)
3651 (gnus-configure-windows 'summary 'force)
3652 (gnus-set-mode-line 'summary))
3653 (when (and gnus-auto-center-group
3654 (get-buffer-window gnus-group-buffer t))
3655 ;; Gotta use windows, because recenter does weird stuff if
3656 ;; the current buffer ain't the displayed window.
3657 (let ((owin (selected-window)))
3658 (select-window (get-buffer-window gnus-group-buffer t))
3659 (when (gnus-group-goto-group group)
3660 (recenter))
3661 (select-window owin)))
3662 ;; Mark this buffer as "prepared".
3663 (setq gnus-newsgroup-prepared t)
3664 (gnus-run-hooks 'gnus-summary-prepared-hook)
3665 (unless (gnus-ephemeral-group-p group)
3666 (gnus-group-update-group group))
3667 t)))))
3668
3669 (defun gnus-summary-auto-select-subject ()
3670 "Select the subject line on initial group entry."
3671 (goto-char (point-min))
3672 (cond
3673 ((eq gnus-auto-select-subject 'best)
3674 (gnus-summary-best-unread-subject))
3675 ((eq gnus-auto-select-subject 'unread)
3676 (gnus-summary-first-unread-subject))
3677 ((eq gnus-auto-select-subject 'unseen)
3678 (gnus-summary-first-unseen-subject))
3679 ((eq gnus-auto-select-subject 'unseen-or-unread)
3680 (gnus-summary-first-unseen-or-unread-subject))
3681 ((eq gnus-auto-select-subject 'first)
3682 ;; Do nothing.
3683 )
3684 ((functionp gnus-auto-select-subject)
3685 (funcall gnus-auto-select-subject))))
3686
3687 (defun gnus-summary-prepare ()
3688 "Generate the summary buffer."
3689 (interactive)
3690 (let ((buffer-read-only nil))
3691 (erase-buffer)
3692 (setq gnus-newsgroup-data nil
3693 gnus-newsgroup-data-reverse nil)
3694 (gnus-run-hooks 'gnus-summary-generate-hook)
3695 ;; Generate the buffer, either with threads or without.
3696 (when gnus-newsgroup-headers
3697 (gnus-summary-prepare-threads
3698 (if gnus-show-threads
3699 (gnus-sort-gathered-threads
3700 (funcall gnus-summary-thread-gathering-function
3701 (gnus-sort-threads
3702 (gnus-cut-threads (gnus-make-threads)))))
3703 ;; Unthreaded display.
3704 (gnus-sort-articles gnus-newsgroup-headers))))
3705 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3706 ;; Call hooks for modifying summary buffer.
3707 (goto-char (point-min))
3708 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3709
3710 (defsubst gnus-general-simplify-subject (subject)
3711 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3712 (setq subject
3713 (cond
3714 ;; Truncate the subject.
3715 (gnus-simplify-subject-functions
3716 (gnus-map-function gnus-simplify-subject-functions subject))
3717 ((numberp gnus-summary-gather-subject-limit)
3718 (setq subject (gnus-simplify-subject-re subject))
3719 (if (> (length subject) gnus-summary-gather-subject-limit)
3720 (substring subject 0 gnus-summary-gather-subject-limit)
3721 subject))
3722 ;; Fuzzily simplify it.
3723 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3724 (gnus-simplify-subject-fuzzy subject))
3725 ;; Just remove the leading "Re:".
3726 (t
3727 (gnus-simplify-subject-re subject))))
3728
3729 (if (and gnus-summary-gather-exclude-subject
3730 (string-match gnus-summary-gather-exclude-subject subject))
3731 nil ; This article shouldn't be gathered
3732 subject))
3733
3734 (defun gnus-summary-simplify-subject-query ()
3735 "Query where the respool algorithm would put this article."
3736 (interactive)
3737 (gnus-summary-select-article)
3738 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3739
3740 (defun gnus-gather-threads-by-subject (threads)
3741 "Gather threads by looking at Subject headers."
3742 (if (not gnus-summary-make-false-root)
3743 threads
3744 (let ((hashtb (gnus-make-hashtable 1024))
3745 (prev threads)
3746 (result threads)
3747 subject hthread whole-subject)
3748 (while threads
3749 (setq subject (gnus-general-simplify-subject
3750 (setq whole-subject (mail-header-subject
3751 (caar threads)))))
3752 (when subject
3753 (if (setq hthread (gnus-gethash subject hashtb))
3754 (progn
3755 ;; We enter a dummy root into the thread, if we
3756 ;; haven't done that already.
3757 (unless (stringp (caar hthread))
3758 (setcar hthread (list whole-subject (car hthread))))
3759 ;; We add this new gathered thread to this gathered
3760 ;; thread.
3761 (setcdr (car hthread)
3762 (nconc (cdar hthread) (list (car threads))))
3763 ;; Remove it from the list of threads.
3764 (setcdr prev (cdr threads))
3765 (setq threads prev))
3766 ;; Enter this thread into the hash table.
3767 (gnus-sethash subject
3768 (if gnus-summary-make-false-root-always
3769 (progn
3770 ;; If you want a dummy root above all
3771 ;; threads...
3772 (setcar threads (list whole-subject
3773 (car threads)))
3774 threads)
3775 threads)
3776 hashtb)))
3777 (setq prev threads)
3778 (setq threads (cdr threads)))
3779 result)))
3780
3781 (defun gnus-gather-threads-by-references (threads)
3782 "Gather threads by looking at References headers."
3783 (let ((idhashtb (gnus-make-hashtable 1024))
3784 (thhashtb (gnus-make-hashtable 1024))
3785 (prev threads)
3786 (result threads)
3787 ids references id gthread gid entered ref)
3788 (while threads
3789 (when (setq references (mail-header-references (caar threads)))
3790 (setq id (mail-header-id (caar threads))
3791 ids (inline (gnus-split-references references))
3792 entered nil)
3793 (while (setq ref (pop ids))
3794 (setq ids (delete ref ids))
3795 (if (not (setq gid (gnus-gethash ref idhashtb)))
3796 (progn
3797 (gnus-sethash ref id idhashtb)
3798 (gnus-sethash id threads thhashtb))
3799 (setq gthread (gnus-gethash gid thhashtb))
3800 (unless entered
3801 ;; We enter a dummy root into the thread, if we
3802 ;; haven't done that already.
3803 (unless (stringp (caar gthread))
3804 (setcar gthread (list (mail-header-subject (caar gthread))
3805 (car gthread))))
3806 ;; We add this new gathered thread to this gathered
3807 ;; thread.
3808 (setcdr (car gthread)
3809 (nconc (cdar gthread) (list (car threads)))))
3810 ;; Add it into the thread hash table.
3811 (gnus-sethash id gthread thhashtb)
3812 (setq entered t)
3813 ;; Remove it from the list of threads.
3814 (setcdr prev (cdr threads))
3815 (setq threads prev))))
3816 (setq prev threads)
3817 (setq threads (cdr threads)))
3818 result))
3819
3820 (defun gnus-sort-gathered-threads (threads)
3821 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3822 (let ((result threads))
3823 (while threads
3824 (when (stringp (caar threads))
3825 (setcdr (car threads)
3826 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3827 (setq threads (cdr threads)))
3828 result))
3829
3830 (defun gnus-thread-loop-p (root thread)
3831 "Say whether ROOT is in THREAD."
3832 (let ((stack (list thread))
3833 (infloop 0)
3834 th)
3835 (while (setq thread (pop stack))
3836 (setq th (cdr thread))
3837 (while (and th
3838 (not (eq (caar th) root)))
3839 (pop th))
3840 (if th
3841 ;; We have found a loop.
3842 (let (ref-dep)
3843 (setcdr thread (delq (car th) (cdr thread)))
3844 (if (boundp (setq ref-dep (intern "none"
3845 gnus-newsgroup-dependencies)))
3846 (setcdr (symbol-value ref-dep)
3847 (nconc (cdr (symbol-value ref-dep))
3848 (list (car th))))
3849 (set ref-dep (list nil (car th))))
3850 (setq infloop 1
3851 stack nil))
3852 ;; Push all the subthreads onto the stack.
3853 (push (cdr thread) stack)))
3854 infloop))
3855
3856 (defun gnus-make-threads ()
3857 "Go through the dependency hashtb and find the roots. Return all threads."
3858 (let (threads)
3859 (while (catch 'infloop
3860 (mapatoms
3861 (lambda (refs)
3862 ;; Deal with self-referencing References loops.
3863 (when (and (car (symbol-value refs))
3864 (not (zerop
3865 (apply
3866 '+
3867 (mapcar
3868 (lambda (thread)
3869 (gnus-thread-loop-p
3870 (car (symbol-value refs)) thread))
3871 (cdr (symbol-value refs)))))))
3872 (setq threads nil)
3873 (throw 'infloop t))
3874 (unless (car (symbol-value refs))
3875 ;; These threads do not refer back to any other
3876 ;; articles, so they're roots.
3877 (setq threads (append (cdr (symbol-value refs)) threads))))
3878 gnus-newsgroup-dependencies)))
3879 threads))
3880
3881 ;; Build the thread tree.
3882 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3883 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3884
3885 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3886 if it was already present.
3887
3888 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3889 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3890 Message-IDs will be renamed to a unique Message-ID before being
3891 entered.
3892
3893 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3894 (let* ((id (mail-header-id header))
3895 (id-dep (and id (intern id dependencies)))
3896 parent-id ref ref-dep ref-header replaced)
3897 ;; Enter this `header' in the `dependencies' table.
3898 (cond
3899 ((not id-dep)
3900 (setq header nil))
3901 ;; The first two cases do the normal part: enter a new `header'
3902 ;; in the `dependencies' table.
3903 ((not (boundp id-dep))
3904 (set id-dep (list header)))
3905 ((null (car (symbol-value id-dep)))
3906 (setcar (symbol-value id-dep) header))
3907
3908 ;; From here the `header' was already present in the
3909 ;; `dependencies' table.
3910 (force-new
3911 ;; Overrides an existing entry;
3912 ;; just set the header part of the entry.
3913 (setcar (symbol-value id-dep) header)
3914 (setq replaced t))
3915
3916 ;; Renames the existing `header' to a unique Message-ID.
3917 ((not gnus-summary-ignore-duplicates)
3918 ;; An article with this Message-ID has already been seen.
3919 ;; We rename the Message-ID.
3920 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3921 (list header))
3922 (mail-header-set-id header id))
3923
3924 ;; The last case ignores an existing entry, except it adds any
3925 ;; additional Xrefs (in case the two articles came from different
3926 ;; servers.
3927 ;; Also sets `header' to `nil' meaning that the `dependencies'
3928 ;; table was *not* modified.
3929 (t
3930 (mail-header-set-xref
3931 (car (symbol-value id-dep))
3932 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3933 "")
3934 (or (mail-header-xref header) "")))
3935 (setq header nil)))
3936
3937 (when (and header (not replaced))
3938 ;; First check that we are not creating a References loop.
3939 (setq parent-id (gnus-parent-id (mail-header-references header)))
3940 (setq ref parent-id)
3941 (while (and ref
3942 (setq ref-dep (intern-soft ref dependencies))
3943 (boundp ref-dep)
3944 (setq ref-header (car (symbol-value ref-dep))))
3945 (if (string= id ref)
3946 ;; Yuk! This is a reference loop. Make the article be a
3947 ;; root article.
3948 (progn
3949 (mail-header-set-references (car (symbol-value id-dep)) "none")
3950 (setq ref nil)
3951 (setq parent-id nil))
3952 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3953 (setq ref-dep (intern (or parent-id "none") dependencies))
3954 (if (boundp ref-dep)
3955 (setcdr (symbol-value ref-dep)
3956 (nconc (cdr (symbol-value ref-dep))
3957 (list (symbol-value id-dep))))
3958 (set ref-dep (list nil (symbol-value id-dep)))))
3959 header))
3960
3961 (defun gnus-extract-message-id-from-in-reply-to (string)
3962 (if (string-match "<[^>]+>" string)
3963 (substring string (match-beginning 0) (match-end 0))
3964 nil))
3965
3966 (defun gnus-build-sparse-threads ()
3967 (let ((headers gnus-newsgroup-headers)
3968 (mail-parse-charset gnus-newsgroup-charset)
3969 (gnus-summary-ignore-duplicates t)
3970 header references generation relations
3971 subject child end new-child date)
3972 ;; First we create an alist of generations/relations, where
3973 ;; generations is how much we trust the relation, and the relation
3974 ;; is parent/child.
3975 (gnus-message 7 "Making sparse threads...")
3976 (save-excursion
3977 (nnheader-set-temp-buffer " *gnus sparse threads*")
3978 (while (setq header (pop headers))
3979 (when (and (setq references (mail-header-references header))
3980 (not (string= references "")))
3981 (insert references)
3982 (setq child (mail-header-id header)
3983 subject (mail-header-subject header)
3984 date (mail-header-date header)
3985 generation 0)
3986 (while (search-backward ">" nil t)
3987 (setq end (1+ (point)))
3988 (when (search-backward "<" nil t)
3989 (setq new-child (buffer-substring (point) end))
3990 (push (list (incf generation)
3991 child (setq child new-child)
3992 subject date)
3993 relations)))
3994 (when child
3995 (push (list (1+ generation) child nil subject) relations))
3996 (erase-buffer)))
3997 (kill-buffer (current-buffer)))
3998 ;; Sort over trustworthiness.
3999 (mapcar
4000 (lambda (relation)
4001 (when (gnus-dependencies-add-header
4002 (make-full-mail-header
4003 gnus-reffed-article-number
4004 (nth 3 relation) "" (or (nth 4 relation) "")
4005 (nth 1 relation)
4006 (or (nth 2 relation) "") 0 0 "")
4007 gnus-newsgroup-dependencies nil)
4008 (push gnus-reffed-article-number gnus-newsgroup-limit)
4009 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4010 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4011 gnus-newsgroup-reads)
4012 (decf gnus-reffed-article-number)))
4013 (sort relations 'car-less-than-car))
4014 (gnus-message 7 "Making sparse threads...done")))
4015
4016 (defun gnus-build-old-threads ()
4017 ;; Look at all the articles that refer back to old articles, and
4018 ;; fetch the headers for the articles that aren't there. This will
4019 ;; build complete threads - if the roots haven't been expired by the
4020 ;; server, that is.
4021 (let ((mail-parse-charset gnus-newsgroup-charset)
4022 id heads)
4023 (mapatoms
4024 (lambda (refs)
4025 (when (not (car (symbol-value refs)))
4026 (setq heads (cdr (symbol-value refs)))
4027 (while heads
4028 (if (memq (mail-header-number (caar heads))
4029 gnus-newsgroup-dormant)
4030 (setq heads (cdr heads))
4031 (setq id (symbol-name refs))
4032 (while (and (setq id (gnus-build-get-header id))
4033 (not (car (gnus-id-to-thread id)))))
4034 (setq heads nil)))))
4035 gnus-newsgroup-dependencies)))
4036
4037 (defsubst gnus-remove-odd-characters (string)
4038 "Translate STRING into something that doesn't contain weird characters."
4039 (mm-subst-char-in-string
4040 ?\r ?\-
4041 (mm-subst-char-in-string
4042 ?\n ?\- string)))
4043
4044 ;; This function has to be called with point after the article number
4045 ;; on the beginning of the line.
4046 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4047 (let ((eol (gnus-point-at-eol))
4048 (buffer (current-buffer))
4049 header references in-reply-to)
4050
4051 ;; overview: [num subject from date id refs chars lines misc]
4052 (unwind-protect
4053 (let (x)
4054 (narrow-to-region (point) eol)
4055 (unless (eobp)
4056 (forward-char))
4057
4058 (setq header
4059 (make-full-mail-header
4060 number ; number
4061 (condition-case () ; subject
4062 (gnus-remove-odd-characters
4063 (funcall gnus-decode-encoded-word-function
4064 (setq x (nnheader-nov-field))))
4065 (error x))
4066 (condition-case () ; from
4067 (gnus-remove-odd-characters
4068 (funcall gnus-decode-encoded-word-function
4069 (setq x (nnheader-nov-field))))
4070 (error x))
4071 (nnheader-nov-field) ; date
4072 (nnheader-nov-read-message-id) ; id
4073 (setq references (nnheader-nov-field)) ; refs
4074 (nnheader-nov-read-integer) ; chars
4075 (nnheader-nov-read-integer) ; lines
4076 (unless (eobp)
4077 (if (looking-at "Xref: ")
4078 (goto-char (match-end 0)))
4079 (nnheader-nov-field)) ; Xref
4080 (nnheader-nov-parse-extra)))) ; extra
4081
4082 (widen))
4083
4084 (when (and (string= references "")
4085 (setq in-reply-to (mail-header-extra header))
4086 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4087 (mail-header-set-references
4088 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4089
4090 (when gnus-alter-header-function
4091 (funcall gnus-alter-header-function header))
4092 (gnus-dependencies-add-header header dependencies force-new)))
4093
4094 (defun gnus-build-get-header (id)
4095 "Look through the buffer of NOV lines and find the header to ID.
4096 Enter this line into the dependencies hash table, and return
4097 the id of the parent article (if any)."
4098 (let ((deps gnus-newsgroup-dependencies)
4099 found header)
4100 (prog1
4101 (save-excursion
4102 (set-buffer nntp-server-buffer)
4103 (let ((case-fold-search nil))
4104 (goto-char (point-min))
4105 (while (and (not found)
4106 (search-forward id nil t))
4107 (beginning-of-line)
4108 (setq found (looking-at
4109 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4110 (regexp-quote id))))
4111 (or found (beginning-of-line 2)))
4112 (when found
4113 (beginning-of-line)
4114 (and
4115 (setq header (gnus-nov-parse-line
4116 (read (current-buffer)) deps))
4117 (gnus-parent-id (mail-header-references header))))))
4118 (when header
4119 (let ((number (mail-header-number header)))
4120 (push number gnus-newsgroup-limit)
4121 (push header gnus-newsgroup-headers)
4122 (if (memq number gnus-newsgroup-unselected)
4123 (progn
4124 (setq gnus-newsgroup-unreads
4125 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4126 number))
4127 (setq gnus-newsgroup-unselected
4128 (delq number gnus-newsgroup-unselected)))
4129 (push number gnus-newsgroup-ancient)))))))
4130
4131 (defun gnus-build-all-threads ()
4132 "Read all the headers."
4133 (let ((gnus-summary-ignore-duplicates t)
4134 (mail-parse-charset gnus-newsgroup-charset)
4135 (dependencies gnus-newsgroup-dependencies)
4136 header article)
4137 (save-excursion
4138 (set-buffer nntp-server-buffer)
4139 (let ((case-fold-search nil))
4140 (goto-char (point-min))
4141 (while (not (eobp))
4142 (ignore-errors
4143 (setq article (read (current-buffer))
4144 header (gnus-nov-parse-line article dependencies)))
4145 (when header
4146 (save-excursion
4147 (set-buffer gnus-summary-buffer)
4148 (push header gnus-newsgroup-headers)
4149 (if (memq (setq article (mail-header-number header))
4150 gnus-newsgroup-unselected)
4151 (progn
4152 (setq gnus-newsgroup-unreads
4153 (gnus-add-to-sorted-list
4154 gnus-newsgroup-unreads article))
4155 (setq gnus-newsgroup-unselected
4156 (delq article gnus-newsgroup-unselected)))
4157 (push article gnus-newsgroup-ancient)))
4158 (forward-line 1)))))))
4159
4160 (defun gnus-summary-update-article-line (article header)
4161 "Update the line for ARTICLE using HEADER."
4162 (let* ((id (mail-header-id header))
4163 (thread (gnus-id-to-thread id)))
4164 (unless thread
4165 (error "Article in no thread"))
4166 ;; Update the thread.
4167 (setcar thread header)
4168 (gnus-summary-goto-subject article)
4169 (let* ((datal (gnus-data-find-list article))
4170 (data (car datal))
4171 (buffer-read-only nil)
4172 (level (gnus-summary-thread-level)))
4173 (gnus-delete-line)
4174 (let ((inserted (- (point)
4175 (progn
4176 (gnus-summary-insert-line
4177 header level nil
4178 (memq article gnus-newsgroup-undownloaded)
4179 (gnus-article-mark article)
4180 (memq article gnus-newsgroup-replied)
4181 (memq article gnus-newsgroup-expirable)
4182 ;; Only insert the Subject string when it's different
4183 ;; from the previous Subject string.
4184 (if (and
4185 gnus-show-threads
4186 (gnus-subject-equal
4187 (condition-case ()
4188 (mail-header-subject
4189 (gnus-data-header
4190 (cadr
4191 (gnus-data-find-list
4192 article
4193 (gnus-data-list t)))))
4194 ;; Error on the side of excessive subjects.
4195 (error ""))
4196 (mail-header-subject header)))
4197 ""
4198 (mail-header-subject header))
4199 nil (cdr (assq article gnus-newsgroup-scored))
4200 (memq article gnus-newsgroup-processable))
4201 (point)))))
4202 (when (cdr datal)
4203 (gnus-data-update-list
4204 (cdr datal)
4205 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4206
4207 (defun gnus-summary-update-article (article &optional iheader)
4208 "Update ARTICLE in the summary buffer."
4209 (set-buffer gnus-summary-buffer)
4210 (let* ((header (gnus-summary-article-header article))
4211 (id (mail-header-id header))
4212 (data (gnus-data-find article))
4213 (thread (gnus-id-to-thread id))
4214 (references (mail-header-references header))
4215 (parent
4216 (gnus-id-to-thread
4217 (or (gnus-parent-id
4218 (when (and references
4219 (not (equal "" references)))
4220 references))
4221 "none")))
4222 (buffer-read-only nil)
4223 (old (car thread)))
4224 (when thread
4225 (unless iheader
4226 (setcar thread nil)
4227 (when parent
4228 (delq thread parent)))
4229 (if (gnus-summary-insert-subject id header)
4230 ;; Set the (possibly) new article number in the data structure.
4231 (gnus-data-set-number data (gnus-id-to-article id))
4232 (setcar thread old)
4233 nil))))
4234
4235 (defun gnus-rebuild-thread (id &optional line)
4236 "Rebuild the thread containing ID.
4237 If LINE, insert the rebuilt thread starting on line LINE."
4238 (let ((buffer-read-only nil)
4239 old-pos current thread data)
4240 (if (not gnus-show-threads)
4241 (setq thread (list (car (gnus-id-to-thread id))))
4242 ;; Get the thread this article is part of.
4243 (setq thread (gnus-remove-thread id)))
4244 (setq old-pos (gnus-point-at-bol))
4245 (setq current (save-excursion
4246 (and (re-search-backward "[\r\n]" nil t)
4247 (gnus-summary-article-number))))
4248 ;; If this is a gathered thread, we have to go some re-gathering.
4249 (when (stringp (car thread))
4250 (let ((subject (car thread))
4251 roots thr)
4252 (setq thread (cdr thread))
4253 (while thread
4254 (unless (memq (setq thr (gnus-id-to-thread
4255 (gnus-root-id
4256 (mail-header-id (caar thread)))))
4257 roots)
4258 (push thr roots))
4259 (setq thread (cdr thread)))
4260 ;; We now have all (unique) roots.
4261 (if (= (length roots) 1)
4262 ;; All the loose roots are now one solid root.
4263 (setq thread (car roots))
4264 (setq thread (cons subject (gnus-sort-threads roots))))))
4265 (let (threads)
4266 ;; We then insert this thread into the summary buffer.
4267 (when line
4268 (goto-char (point-min))
4269 (forward-line (1- line)))
4270 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4271 (if gnus-show-threads
4272 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4273 (gnus-summary-prepare-unthreaded thread))
4274 (setq data (nreverse gnus-newsgroup-data))
4275 (setq threads gnus-newsgroup-threads))
4276 ;; We splice the new data into the data structure.
4277 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4278 ;;!!! then we want to insert at the beginning of the buffer.
4279 ;;!!! That happens to be true with Gnus now, but that may
4280 ;;!!! change in the future. Perhaps.
4281 (gnus-data-enter-list
4282 (if line nil current) data (- (point) old-pos))
4283 (setq gnus-newsgroup-threads
4284 (nconc threads gnus-newsgroup-threads))
4285 (gnus-data-compute-positions))))
4286
4287 (defun gnus-number-to-header (number)
4288 "Return the header for article NUMBER."
4289 (let ((headers gnus-newsgroup-headers))
4290 (while (and headers
4291 (not (= number (mail-header-number (car headers)))))
4292 (pop headers))
4293 (when headers
4294 (car headers))))
4295
4296 (defun gnus-parent-headers (in-headers &optional generation)
4297 "Return the headers of the GENERATIONeth parent of HEADERS."
4298 (unless generation
4299 (setq generation 1))
4300 (let ((parent t)
4301 (headers in-headers)
4302 references)
4303 (while (and parent
4304 (not (zerop generation))
4305 (setq references (mail-header-references headers)))
4306 (setq headers (if (and references
4307 (setq parent (gnus-parent-id references)))
4308 (car (gnus-id-to-thread parent))
4309 nil))
4310 (decf generation))
4311 (and (not (eq headers in-headers))
4312 headers)))
4313
4314 (defun gnus-id-to-thread (id)
4315 "Return the (sub-)thread where ID appears."
4316 (gnus-gethash id gnus-newsgroup-dependencies))
4317
4318 (defun gnus-id-to-article (id)
4319 "Return the article number of ID."
4320 (let ((thread (gnus-id-to-thread id)))
4321 (when (and thread
4322 (car thread))
4323 (mail-header-number (car thread)))))
4324
4325 (defun gnus-id-to-header (id)
4326 "Return the article headers of ID."
4327 (car (gnus-id-to-thread id)))
4328
4329 (defun gnus-article-displayed-root-p (article)
4330 "Say whether ARTICLE is a root(ish) article."
4331 (let ((level (gnus-summary-thread-level article))
4332 (refs (mail-header-references (gnus-summary-article-header article)))
4333 particle)
4334 (cond
4335 ((null level) nil)
4336 ((zerop level) t)
4337 ((null refs) t)
4338 ((null (gnus-parent-id refs)) t)
4339 ((and (= 1 level)
4340 (null (setq particle (gnus-id-to-article
4341 (gnus-parent-id refs))))
4342 (null (gnus-summary-thread-level particle)))))))
4343
4344 (defun gnus-root-id (id)
4345 "Return the id of the root of the thread where ID appears."
4346 (let (last-id prev)
4347 (while (and id (setq prev (car (gnus-id-to-thread id))))
4348 (setq last-id id
4349 id (gnus-parent-id (mail-header-references prev))))
4350 last-id))
4351
4352 (defun gnus-articles-in-thread (thread)
4353 "Return the list of articles in THREAD."
4354 (cons (mail-header-number (car thread))
4355 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4356
4357 (defun gnus-remove-thread (id &optional dont-remove)
4358 "Remove the thread that has ID in it."
4359 (let (headers thread last-id)
4360 ;; First go up in this thread until we find the root.
4361 (setq last-id (gnus-root-id id)
4362 headers (message-flatten-list (gnus-id-to-thread last-id)))
4363 ;; We have now found the real root of this thread. It might have
4364 ;; been gathered into some loose thread, so we have to search
4365 ;; through the threads to find the thread we wanted.
4366 (let ((threads gnus-newsgroup-threads)
4367 sub)
4368 (while threads
4369 (setq sub (car threads))
4370 (if (stringp (car sub))
4371 ;; This is a gathered thread, so we look at the roots
4372 ;; below it to find whether this article is in this
4373 ;; gathered root.
4374 (progn
4375 (setq sub (cdr sub))
4376 (while sub
4377 (when (member (caar sub) headers)
4378 (setq thread (car threads)
4379 threads nil
4380 sub nil))
4381 (setq sub (cdr sub))))
4382 ;; It's an ordinary thread, so we check it.
4383 (when (eq (car sub) (car headers))
4384 (setq thread sub
4385 threads nil)))
4386 (setq threads (cdr threads)))
4387 ;; If this article is in no thread, then it's a root.
4388 (if thread
4389 (unless dont-remove
4390 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4391 (setq thread (gnus-id-to-thread last-id)))
4392 (when thread
4393 (prog1
4394 thread ; We return this thread.
4395 (unless dont-remove
4396 (if (stringp (car thread))
4397 (progn
4398 ;; If we use dummy roots, then we have to remove the
4399 ;; dummy root as well.
4400 (when (eq gnus-summary-make-false-root 'dummy)
4401 ;; We go to the dummy root by going to
4402 ;; the first sub-"thread", and then one line up.
4403 (gnus-summary-goto-article
4404 (mail-header-number (caadr thread)))
4405 (forward-line -1)
4406 (gnus-delete-line)
4407 (gnus-data-compute-positions))
4408 (setq thread (cdr thread))
4409 (while thread
4410 (gnus-remove-thread-1 (car thread))
4411 (setq thread (cdr thread))))
4412 (gnus-remove-thread-1 thread))))))))
4413
4414 (defun gnus-remove-thread-1 (thread)
4415 "Remove the thread THREAD recursively."
4416 (let ((number (mail-header-number (pop thread)))
4417 d)
4418 (setq thread (reverse thread))
4419 (while thread
4420 (gnus-remove-thread-1 (pop thread)))
4421 (when (setq d (gnus-data-find number))
4422 (goto-char (gnus-data-pos d))
4423 (gnus-summary-show-thread)
4424 (gnus-data-remove
4425 number
4426 (- (gnus-point-at-bol)
4427 (prog1
4428 (1+ (gnus-point-at-eol))
4429 (gnus-delete-line)))))))
4430
4431 (defun gnus-sort-threads-1 (threads func)
4432 (sort (mapcar (lambda (thread)
4433 (cons (car thread)
4434 (and (cdr thread)
4435 (gnus-sort-threads-1 (cdr thread) func))))
4436 threads) func))
4437
4438 (defun gnus-sort-threads (threads)
4439 "Sort THREADS."
4440 (if (not gnus-thread-sort-functions)
4441 threads
4442 (gnus-message 8 "Sorting threads...")
4443 (let ((max-lisp-eval-depth 5000))
4444 (prog1 (gnus-sort-threads-1
4445 threads
4446 (gnus-make-sort-function gnus-thread-sort-functions))
4447 (gnus-message 8 "Sorting threads...done")))))
4448
4449 (defun gnus-sort-articles (articles)
4450 "Sort ARTICLES."
4451 (when gnus-article-sort-functions
4452 (gnus-message 7 "Sorting articles...")
4453 (prog1
4454 (setq gnus-newsgroup-headers
4455 (sort articles (gnus-make-sort-function
4456 gnus-article-sort-functions)))
4457 (gnus-message 7 "Sorting articles...done"))))
4458
4459 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4460 (defmacro gnus-thread-header (thread)
4461 "Return header of first article in THREAD.
4462 Note that THREAD must never, ever be anything else than a variable -
4463 using some other form will lead to serious barfage."
4464 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4465 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4466 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4467 (vector thread) 2))
4468
4469 (defsubst gnus-article-sort-by-number (h1 h2)
4470 "Sort articles by article number."
4471 (< (mail-header-number h1)
4472 (mail-header-number h2)))
4473
4474 (defun gnus-thread-sort-by-number (h1 h2)
4475 "Sort threads by root article number."
4476 (gnus-article-sort-by-number
4477 (gnus-thread-header h1) (gnus-thread-header h2)))
4478
4479 (defsubst gnus-article-sort-by-random (h1 h2)
4480 "Sort articles by article number."
4481 (zerop (random 2)))
4482
4483 (defun gnus-thread-sort-by-random (h1 h2)
4484 "Sort threads by root article number."
4485 (gnus-article-sort-by-random
4486 (gnus-thread-header h1) (gnus-thread-header h2)))
4487
4488 (defsubst gnus-article-sort-by-lines (h1 h2)
4489 "Sort articles by article Lines header."
4490 (< (mail-header-lines h1)
4491 (mail-header-lines h2)))
4492
4493 (defun gnus-thread-sort-by-lines (h1 h2)
4494 "Sort threads by root article Lines header."
4495 (gnus-article-sort-by-lines
4496 (gnus-thread-header h1) (gnus-thread-header h2)))
4497
4498 (defsubst gnus-article-sort-by-chars (h1 h2)
4499 "Sort articles by octet length."
4500 (< (mail-header-chars h1)
4501 (mail-header-chars h2)))
4502
4503 (defun gnus-thread-sort-by-chars (h1 h2)
4504 "Sort threads by root article octet length."
4505 (gnus-article-sort-by-chars
4506 (gnus-thread-header h1) (gnus-thread-header h2)))
4507
4508 (defsubst gnus-article-sort-by-author (h1 h2)
4509 "Sort articles by root author."
4510 (string-lessp
4511 (let ((extract (funcall
4512 gnus-extract-address-components
4513 (mail-header-from h1))))
4514 (or (car extract) (cadr extract) ""))
4515 (let ((extract (funcall
4516 gnus-extract-address-components
4517 (mail-header-from h2))))
4518 (or (car extract) (cadr extract) ""))))
4519
4520 (defun gnus-thread-sort-by-author (h1 h2)
4521 "Sort threads by root author."
4522 (gnus-article-sort-by-author
4523 (gnus-thread-header h1) (gnus-thread-header h2)))
4524
4525 (defsubst gnus-article-sort-by-subject (h1 h2)
4526 "Sort articles by root subject."
4527 (string-lessp
4528 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4529 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4530
4531 (defun gnus-thread-sort-by-subject (h1 h2)
4532 "Sort threads by root subject."
4533 (gnus-article-sort-by-subject
4534 (gnus-thread-header h1) (gnus-thread-header h2)))
4535
4536 (defsubst gnus-article-sort-by-date (h1 h2)
4537 "Sort articles by root article date."
4538 (time-less-p
4539 (gnus-date-get-time (mail-header-date h1))
4540 (gnus-date-get-time (mail-header-date h2))))
4541
4542 (defun gnus-thread-sort-by-date (h1 h2)
4543 "Sort threads by root article date."
4544 (gnus-article-sort-by-date
4545 (gnus-thread-header h1) (gnus-thread-header h2)))
4546
4547 (defsubst gnus-article-sort-by-score (h1 h2)
4548 "Sort articles by root article score.
4549 Unscored articles will be counted as having a score of zero."
4550 (> (or (cdr (assq (mail-header-number h1)
4551 gnus-newsgroup-scored))
4552 gnus-summary-default-score 0)
4553 (or (cdr (assq (mail-header-number h2)
4554 gnus-newsgroup-scored))
4555 gnus-summary-default-score 0)))
4556
4557 (defun gnus-thread-sort-by-score (h1 h2)
4558 "Sort threads by root article score."
4559 (gnus-article-sort-by-score
4560 (gnus-thread-header h1) (gnus-thread-header h2)))
4561
4562 (defun gnus-thread-sort-by-total-score (h1 h2)
4563 "Sort threads by the sum of all scores in the thread.
4564 Unscored articles will be counted as having a score of zero."
4565 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4566
4567 (defun gnus-thread-total-score (thread)
4568 ;; This function find the total score of THREAD.
4569 (cond
4570 ((null thread)
4571 0)
4572 ((consp thread)
4573 (if (stringp (car thread))
4574 (apply gnus-thread-score-function 0
4575 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4576 (gnus-thread-total-score-1 thread)))
4577 (t
4578 (gnus-thread-total-score-1 (list thread)))))
4579
4580 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4581 "Sort threads such that the thread with the most recently arrived article comes first."
4582 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4583
4584 (defun gnus-thread-highest-number (thread)
4585 "Return the highest article number in THREAD."
4586 (apply 'max (mapcar (lambda (header)
4587 (mail-header-number header))
4588 (message-flatten-list thread))))
4589
4590 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4591 "Sort threads such that the thread with the most recently dated article comes first."
4592 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4593
4594 (defun gnus-thread-latest-date (thread)
4595 "Return the highest article date in THREAD."
4596 (let ((previous-time 0))
4597 (apply 'max
4598 (mapcar
4599 (lambda (header)
4600 (setq previous-time
4601 (condition-case ()
4602 (time-to-seconds (mail-header-parse-date
4603 (mail-header-date header)))
4604 (error previous-time))))
4605 (sort
4606 (message-flatten-list thread)
4607 (lambda (h1 h2)
4608 (< (mail-header-number h1)
4609 (mail-header-number h2))))))))
4610
4611 (defun gnus-thread-total-score-1 (root)
4612 ;; This function find the total score of the thread below ROOT.
4613 (setq root (car root))
4614 (apply gnus-thread-score-function
4615 (or (append
4616 (mapcar 'gnus-thread-total-score
4617 (cdr (gnus-id-to-thread (mail-header-id root))))
4618 (when (> (mail-header-number root) 0)
4619 (list (or (cdr (assq (mail-header-number root)
4620 gnus-newsgroup-scored))
4621 gnus-summary-default-score 0))))
4622 (list gnus-summary-default-score)
4623 '(0))))
4624
4625 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4626 (defvar gnus-tmp-prev-subject nil)
4627 (defvar gnus-tmp-false-parent nil)
4628 (defvar gnus-tmp-root-expunged nil)
4629 (defvar gnus-tmp-dummy-line nil)
4630
4631 (eval-when-compile (defvar gnus-tmp-header))
4632 (defun gnus-extra-header (type &optional header)
4633 "Return the extra header of TYPE."
4634 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4635 ""))
4636
4637 (defvar gnus-tmp-thread-tree-header-string "")
4638
4639 (defcustom gnus-sum-thread-tree-root "> "
4640 "With %B spec, used for the root of a thread.
4641 If nil, use subject instead."
4642 :version "22.1"
4643 :type '(radio (const :format "%v " nil) string)
4644 :group 'gnus-thread)
4645 (defcustom gnus-sum-thread-tree-false-root "> "
4646 "With %B spec, used for a false root of a thread.
4647 If nil, use subject instead."
4648 :version "22.1"
4649 :type '(radio (const :format "%v " nil) string)
4650 :group 'gnus-thread)
4651 (defcustom gnus-sum-thread-tree-single-indent ""
4652 "With %B spec, used for a thread with just one message.
4653 If nil, use subject instead."
4654 :version "22.1"
4655 :type '(radio (const :format "%v " nil) string)
4656 :group 'gnus-thread)
4657 (defcustom gnus-sum-thread-tree-vertical "| "
4658 "With %B spec, used for drawing a vertical line."
4659 :version "22.1"
4660 :type 'string
4661 :group 'gnus-thread)
4662 (defcustom gnus-sum-thread-tree-indent " "
4663 "With %B spec, used for indenting."
4664 :version "22.1"
4665 :type 'string
4666 :group 'gnus-thread)
4667 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4668 "With %B spec, used for a leaf with brothers."
4669 :version "22.1"
4670 :type 'string
4671 :group 'gnus-thread)
4672 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4673 "With %B spec, used for a leaf without brothers."
4674 :version "22.1"
4675 :type 'string
4676 :group 'gnus-thread)
4677
4678 (defun gnus-summary-prepare-threads (threads)
4679 "Prepare summary buffer from THREADS and indentation LEVEL.
4680 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4681 or a straight list of headers."
4682 (gnus-message 7 "Generating summary...")
4683
4684 (setq gnus-newsgroup-threads threads)
4685 (beginning-of-line)
4686
4687 (let ((gnus-tmp-level 0)
4688 (default-score (or gnus-summary-default-score 0))
4689 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4690 (building-line-count gnus-summary-display-while-building)
4691 (building-count (integerp gnus-summary-display-while-building))
4692 thread number subject stack state gnus-tmp-gathered beg-match
4693 new-roots gnus-tmp-new-adopts thread-end simp-subject
4694 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4695 gnus-tmp-replied gnus-tmp-subject-or-nil
4696 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4697 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4698 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4699 tree-stack)
4700
4701 (setq gnus-tmp-prev-subject nil
4702 gnus-tmp-thread-tree-header-string "")
4703
4704 (if (vectorp (car threads))
4705 ;; If this is a straight (sic) list of headers, then a
4706 ;; threaded summary display isn't required, so we just create
4707 ;; an unthreaded one.
4708 (gnus-summary-prepare-unthreaded threads)
4709
4710 ;; Do the threaded display.
4711
4712 (if gnus-summary-display-while-building
4713 (switch-to-buffer (buffer-name)))
4714 (while (or threads stack gnus-tmp-new-adopts new-roots)
4715
4716 (if (and (= gnus-tmp-level 0)
4717 (or (not stack)
4718 (= (caar stack) 0))
4719 (not gnus-tmp-false-parent)
4720 (or gnus-tmp-new-adopts new-roots))
4721 (if gnus-tmp-new-adopts
4722 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4723 thread (list (car gnus-tmp-new-adopts))
4724 gnus-tmp-header (caar thread)
4725 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4726 (when new-roots
4727 (setq thread (list (car new-roots))
4728 gnus-tmp-header (caar thread)
4729 new-roots (cdr new-roots))))
4730
4731 (if threads
4732 ;; If there are some threads, we do them before the
4733 ;; threads on the stack.
4734 (setq thread threads
4735 gnus-tmp-header (caar thread))
4736 ;; There were no current threads, so we pop something off
4737 ;; the stack.
4738 (setq state (car stack)
4739 gnus-tmp-level (car state)
4740 tree-stack (cadr state)
4741 thread (caddr state)
4742 stack (cdr stack)
4743 gnus-tmp-header (caar thread))))
4744
4745 (setq gnus-tmp-false-parent nil)
4746 (setq gnus-tmp-root-expunged nil)
4747 (setq thread-end nil)
4748
4749 (if (stringp gnus-tmp-header)
4750 ;; The header is a dummy root.
4751 (cond
4752 ((eq gnus-summary-make-false-root 'adopt)
4753 ;; We let the first article adopt the rest.
4754 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4755 (cddar thread)))
4756 (setq gnus-tmp-gathered
4757 (nconc (mapcar
4758 (lambda (h) (mail-header-number (car h)))
4759 (cddar thread))
4760 gnus-tmp-gathered))
4761 (setq thread (cons (list (caar thread)
4762 (cadar thread))
4763 (cdr thread)))
4764 (setq gnus-tmp-level -1
4765 gnus-tmp-false-parent t))
4766 ((eq gnus-summary-make-false-root 'empty)
4767 ;; We print adopted articles with empty subject fields.
4768 (setq gnus-tmp-gathered
4769 (nconc (mapcar
4770 (lambda (h) (mail-header-number (car h)))
4771 (cddar thread))
4772 gnus-tmp-gathered))
4773 (setq gnus-tmp-level -1))
4774 ((eq gnus-summary-make-false-root 'dummy)
4775 ;; We remember that we probably want to output a dummy
4776 ;; root.
4777 (setq gnus-tmp-dummy-line gnus-tmp-header)
4778 (setq gnus-tmp-prev-subject gnus-tmp-header))
4779 (t
4780 ;; We do not make a root for the gathered
4781 ;; sub-threads at all.
4782 (setq gnus-tmp-level -1)))
4783
4784 (setq number (mail-header-number gnus-tmp-header)
4785 subject (mail-header-subject gnus-tmp-header)
4786 simp-subject (gnus-simplify-subject-fully subject))
4787
4788 (cond
4789 ;; If the thread has changed subject, we might want to make
4790 ;; this subthread into a root.
4791 ((and (null gnus-thread-ignore-subject)
4792 (not (zerop gnus-tmp-level))
4793 gnus-tmp-prev-subject
4794 (not (string= gnus-tmp-prev-subject simp-subject)))
4795 (setq new-roots (nconc new-roots (list (car thread)))
4796 thread-end t
4797 gnus-tmp-header nil))
4798 ;; If the article lies outside the current limit,
4799 ;; then we do not display it.
4800 ((not (memq number gnus-newsgroup-limit))
4801 (setq gnus-tmp-gathered
4802 (nconc (mapcar
4803 (lambda (h) (mail-header-number (car h)))
4804 (cdar thread))
4805 gnus-tmp-gathered))
4806 (setq gnus-tmp-new-adopts (if (cdar thread)
4807 (append gnus-tmp-new-adopts
4808 (cdar thread))
4809 gnus-tmp-new-adopts)
4810 thread-end t
4811 gnus-tmp-header nil)
4812 (when (zerop gnus-tmp-level)
4813 (setq gnus-tmp-root-expunged t)))
4814 ;; Perhaps this article is to be marked as read?
4815 ((and gnus-summary-mark-below
4816 (< (or (cdr (assq number gnus-newsgroup-scored))
4817 default-score)
4818 gnus-summary-mark-below)
4819 ;; Don't touch sparse articles.
4820 (not (gnus-summary-article-sparse-p number))
4821 (not (gnus-summary-article-ancient-p number)))
4822 (setq gnus-newsgroup-unreads
4823 (delq number gnus-newsgroup-unreads))
4824 (if gnus-newsgroup-auto-expire
4825 (setq gnus-newsgroup-expirable
4826 (gnus-add-to-sorted-list
4827 gnus-newsgroup-expirable number))
4828 (push (cons number gnus-low-score-mark)
4829 gnus-newsgroup-reads))))
4830
4831 (when gnus-tmp-header
4832 ;; We may have an old dummy line to output before this
4833 ;; article.
4834 (when (and gnus-tmp-dummy-line
4835 (gnus-subject-equal
4836 gnus-tmp-dummy-line
4837 (mail-header-subject gnus-tmp-header)))
4838 (gnus-summary-insert-dummy-line
4839 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4840 (setq gnus-tmp-dummy-line nil))
4841
4842 ;; Compute the mark.
4843 (setq gnus-tmp-unread (gnus-article-mark number))
4844
4845 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4846 gnus-tmp-header gnus-tmp-level)
4847 gnus-newsgroup-data)
4848
4849 ;; Actually insert the line.
4850 (setq
4851 gnus-tmp-subject-or-nil
4852 (cond
4853 ((and gnus-thread-ignore-subject
4854 gnus-tmp-prev-subject
4855 (not (string= gnus-tmp-prev-subject simp-subject)))
4856 subject)
4857 ((zerop gnus-tmp-level)
4858 (if (and (eq gnus-summary-make-false-root 'empty)
4859 (memq number gnus-tmp-gathered)
4860 gnus-tmp-prev-subject
4861 (string= gnus-tmp-prev-subject simp-subject))
4862 gnus-summary-same-subject
4863 subject))
4864 (t gnus-summary-same-subject)))
4865 (if (and (eq gnus-summary-make-false-root 'adopt)
4866 (= gnus-tmp-level 1)
4867 (memq number gnus-tmp-gathered))
4868 (setq gnus-tmp-opening-bracket ?\<
4869 gnus-tmp-closing-bracket ?\>)
4870 (setq gnus-tmp-opening-bracket ?\[
4871 gnus-tmp-closing-bracket ?\]))
4872 (setq
4873 gnus-tmp-indentation
4874 (aref gnus-thread-indent-array gnus-tmp-level)
4875 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4876 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4877 gnus-summary-default-score 0)
4878 gnus-tmp-score-char
4879 (if (or (null gnus-summary-default-score)
4880 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4881 gnus-summary-zcore-fuzz))
4882 ? ;Whitespace
4883 (if (< gnus-tmp-score gnus-summary-default-score)
4884 gnus-score-below-mark gnus-score-over-mark))
4885 gnus-tmp-replied
4886 (cond ((memq number gnus-newsgroup-processable)
4887 gnus-process-mark)
4888 ((memq number gnus-newsgroup-cached)
4889 gnus-cached-mark)
4890 ((memq number gnus-newsgroup-replied)
4891 gnus-replied-mark)
4892 ((memq number gnus-newsgroup-forwarded)
4893 gnus-forwarded-mark)
4894 ((memq number gnus-newsgroup-saved)
4895 gnus-saved-mark)
4896 ((memq number gnus-newsgroup-recent)
4897 gnus-recent-mark)
4898 ((memq number gnus-newsgroup-unseen)
4899 gnus-unseen-mark)
4900 (t gnus-no-mark))
4901 gnus-tmp-downloaded
4902 (cond ((memq number gnus-newsgroup-undownloaded)
4903 gnus-undownloaded-mark)
4904 (gnus-newsgroup-agentized
4905 gnus-downloaded-mark)
4906 (t
4907 gnus-no-mark))
4908 gnus-tmp-from (mail-header-from gnus-tmp-header)
4909 gnus-tmp-name
4910 (cond
4911 ((string-match "<[^>]+> *$" gnus-tmp-from)
4912 (setq beg-match (match-beginning 0))
4913 (or (and (string-match "^\".+\"" gnus-tmp-from)
4914 (substring gnus-tmp-from 1 (1- (match-end 0))))
4915 (substring gnus-tmp-from 0 beg-match)))
4916 ((string-match "(.+)" gnus-tmp-from)
4917 (substring gnus-tmp-from
4918 (1+ (match-beginning 0)) (1- (match-end 0))))
4919 (t gnus-tmp-from))
4920
4921 ;; Do the %B string
4922 gnus-tmp-thread-tree-header-string
4923 (cond
4924 ((not gnus-show-threads) "")
4925 ((zerop gnus-tmp-level)
4926 (cond ((cdar thread)
4927 (or gnus-sum-thread-tree-root subject))
4928 (gnus-tmp-new-adopts
4929 (or gnus-sum-thread-tree-false-root subject))
4930 (t
4931 (or gnus-sum-thread-tree-single-indent subject))))
4932 (t
4933 (concat (apply 'concat
4934 (mapcar (lambda (item)
4935 (if (= item 1)
4936 gnus-sum-thread-tree-vertical
4937 gnus-sum-thread-tree-indent))
4938 (cdr (reverse tree-stack))))
4939 (if (nth 1 thread)
4940 gnus-sum-thread-tree-leaf-with-other
4941 gnus-sum-thread-tree-single-leaf)))))
4942 (when (string= gnus-tmp-name "")
4943 (setq gnus-tmp-name gnus-tmp-from))
4944 (unless (numberp gnus-tmp-lines)
4945 (setq gnus-tmp-lines -1))
4946 (if (= gnus-tmp-lines -1)
4947 (setq gnus-tmp-lines "?")
4948 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4949 (gnus-put-text-property
4950 (point)
4951 (progn (eval gnus-summary-line-format-spec) (point))
4952 'gnus-number number)
4953 (when gnus-visual-p
4954 (forward-line -1)
4955 (gnus-run-hooks 'gnus-summary-update-hook)
4956 (forward-line 1))
4957
4958 (setq gnus-tmp-prev-subject simp-subject)))
4959
4960 (when (nth 1 thread)
4961 (push (list (max 0 gnus-tmp-level)
4962 (copy-sequence tree-stack)
4963 (nthcdr 1 thread))
4964 stack))
4965 (push (if (nth 1 thread) 1 0) tree-stack)
4966 (incf gnus-tmp-level)
4967 (setq threads (if thread-end nil (cdar thread)))
4968 (if gnus-summary-display-while-building
4969 (if building-count
4970 (progn
4971 ;; use a set frequency
4972 (setq building-line-count (1- building-line-count))
4973 (when (= building-line-count 0)
4974 (sit-for 0)
4975 (setq building-line-count
4976 gnus-summary-display-while-building)))
4977 ;; always
4978 (sit-for 0)))
4979 (unless threads
4980 (setq gnus-tmp-level 0)))))
4981 (gnus-message 7 "Generating summary...done"))
4982
4983 (defun gnus-summary-prepare-unthreaded (headers)
4984 "Generate an unthreaded summary buffer based on HEADERS."
4985 (let (header number mark)
4986
4987 (beginning-of-line)
4988
4989 (while headers
4990 ;; We may have to root out some bad articles...
4991 (when (memq (setq number (mail-header-number
4992 (setq header (pop headers))))
4993 gnus-newsgroup-limit)
4994 ;; Mark article as read when it has a low score.
4995 (when (and gnus-summary-mark-below
4996 (< (or (cdr (assq number gnus-newsgroup-scored))
4997 gnus-summary-default-score 0)
4998 gnus-summary-mark-below)
4999 (not (gnus-summary-article-ancient-p number)))
5000 (setq gnus-newsgroup-unreads
5001 (delq number gnus-newsgroup-unreads))
5002 (if gnus-newsgroup-auto-expire
5003 (push number gnus-newsgroup-expirable)
5004 (push (cons number gnus-low-score-mark)
5005 gnus-newsgroup-reads)))
5006
5007 (setq mark (gnus-article-mark number))
5008 (push (gnus-data-make number mark (1+ (point)) header 0)
5009 gnus-newsgroup-data)
5010 (gnus-summary-insert-line
5011 header 0 number
5012 (memq number gnus-newsgroup-undownloaded)
5013 mark (memq number gnus-newsgroup-replied)
5014 (memq number gnus-newsgroup-expirable)
5015 (mail-header-subject header) nil
5016 (cdr (assq number gnus-newsgroup-scored))
5017 (memq number gnus-newsgroup-processable))))))
5018
5019 (defun gnus-summary-remove-list-identifiers ()
5020 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5021 (let ((regexp (if (consp gnus-list-identifiers)
5022 (mapconcat 'identity gnus-list-identifiers " *\\|")
5023 gnus-list-identifiers))
5024 changed subject)
5025 (when regexp
5026 (dolist (header gnus-newsgroup-headers)
5027 (setq subject (mail-header-subject header)
5028 changed nil)
5029 (while (string-match
5030 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
5031 subject)
5032 (setq subject
5033 (concat (substring subject 0 (match-beginning 2))
5034 (substring subject (match-end 0)))
5035 changed t))
5036 (when (and changed
5037 (string-match
5038 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
5039 (setq subject
5040 (concat (substring subject 0 (match-beginning 1))
5041 (substring subject (match-end 1)))))
5042 (when changed
5043 (mail-header-set-subject header subject))))))
5044
5045 (defun gnus-fetch-headers (articles)
5046 "Fetch headers of ARTICLES."
5047 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5048 (gnus-message 5 "Fetching headers for %s..." name)
5049 (prog1
5050 (if (eq 'nov
5051 (setq gnus-headers-retrieved-by
5052 (gnus-retrieve-headers
5053 articles gnus-newsgroup-name
5054 ;; We might want to fetch old headers, but
5055 ;; not if there is only 1 article.
5056 (and (or (and
5057 (not (eq gnus-fetch-old-headers 'some))
5058 (not (numberp gnus-fetch-old-headers)))
5059 (> (length articles) 1))
5060 gnus-fetch-old-headers))))
5061 (gnus-get-newsgroup-headers-xover
5062 articles nil nil gnus-newsgroup-name t)
5063 (gnus-get-newsgroup-headers))
5064 (gnus-message 5 "Fetching headers for %s...done" name))))
5065
5066 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5067 "Select newsgroup GROUP.
5068 If READ-ALL is non-nil, all articles in the group are selected.
5069 If SELECT-ARTICLES, only select those articles from GROUP."
5070 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5071 ;;!!! Dirty hack; should be removed.
5072 (gnus-summary-ignore-duplicates
5073 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5074 t
5075 gnus-summary-ignore-duplicates))
5076 (info (nth 2 entry))
5077 articles fetched-articles cached)
5078
5079 (unless (gnus-check-server
5080 (set (make-local-variable 'gnus-current-select-method)
5081 (gnus-find-method-for-group group)))
5082 (error "Couldn't open server"))
5083
5084 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5085 (gnus-activate-group group) ; Or we can activate it...
5086 (progn ; Or we bug out.
5087 (when (equal major-mode 'gnus-summary-mode)
5088 (gnus-kill-buffer (current-buffer)))
5089 (error "Couldn't activate group %s: %s"
5090 group (gnus-status-message group))))
5091
5092 (unless (gnus-request-group group t)
5093 (when (equal major-mode 'gnus-summary-mode)
5094 (gnus-kill-buffer (current-buffer)))
5095 (error "Couldn't request group %s: %s"
5096 group (gnus-status-message group)))
5097
5098 (when gnus-agent
5099 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5100
5101 (setq gnus-summary-use-undownloaded-faces
5102 (gnus-agent-find-parameter
5103 group
5104 'agent-enable-undownloaded-faces)))
5105
5106 (setq gnus-newsgroup-name group
5107 gnus-newsgroup-unselected nil
5108 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5109
5110 (let ((display (gnus-group-find-parameter group 'display)))
5111 (setq gnus-newsgroup-display
5112 (cond
5113 ((not (zerop (or (car-safe read-all) 0)))
5114 ;; The user entered the group with C-u SPC/RET, let's show
5115 ;; all articles.
5116 'gnus-not-ignore)
5117 ((eq display 'all)
5118 'gnus-not-ignore)
5119 ((arrayp display)
5120 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5121 ((numberp display)
5122 ;; The following is probably the "correct" solution, but
5123 ;; it makes Gnus fetch all headers and then limit the
5124 ;; articles (which is slow), so instead we hack the
5125 ;; select-articles parameter instead. -- Simon Josefsson
5126 ;; <jas@kth.se>
5127 ;;
5128 ;; (gnus-byte-compile
5129 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5130 ;; display)))))
5131 (setq select-articles
5132 (gnus-uncompress-range
5133 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5134 (if (> tmp 0)
5135 tmp
5136 1))
5137 (cdr (gnus-active group)))))
5138 nil)
5139 (t
5140 nil))))
5141
5142 (gnus-summary-setup-default-charset)
5143
5144 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5145 (when (gnus-virtual-group-p group)
5146 (setq cached gnus-newsgroup-cached))
5147
5148 (setq gnus-newsgroup-unreads
5149 (gnus-sorted-ndifference
5150 (gnus-sorted-ndifference gnus-newsgroup-unreads
5151 gnus-newsgroup-marked)
5152 gnus-newsgroup-dormant))
5153
5154 (setq gnus-newsgroup-processable nil)
5155
5156 (gnus-update-read-articles group gnus-newsgroup-unreads)
5157
5158 ;; Adjust and set lists of article marks.
5159 (when info
5160 (gnus-adjust-marked-articles info))
5161 (if (setq articles select-articles)
5162 (setq gnus-newsgroup-unselected
5163 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5164 (setq articles (gnus-articles-to-read group read-all)))
5165
5166 (cond
5167 ((null articles)
5168 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5169 'quit)
5170 ((eq articles 0) nil)
5171 (t
5172 ;; Init the dependencies hash table.
5173 (setq gnus-newsgroup-dependencies
5174 (gnus-make-hashtable (length articles)))
5175 (gnus-set-global-variables)
5176 ;; Retrieve the headers and read them in.
5177
5178 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5179
5180 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5181 (when cached
5182 (setq gnus-newsgroup-cached cached))
5183
5184 ;; Suppress duplicates?
5185 (when gnus-suppress-duplicates
5186 (gnus-dup-suppress-articles))
5187
5188 ;; Set the initial limit.
5189 (setq gnus-newsgroup-limit (copy-sequence articles))
5190 ;; Remove canceled articles from the list of unread articles.
5191 (setq fetched-articles
5192 (mapcar (lambda (headers) (mail-header-number headers))
5193 gnus-newsgroup-headers))
5194 (setq gnus-newsgroup-articles fetched-articles)
5195 (setq gnus-newsgroup-unreads
5196 (gnus-sorted-nintersection
5197 gnus-newsgroup-unreads fetched-articles))
5198 (gnus-compute-unseen-list)
5199
5200 ;; Removed marked articles that do not exist.
5201 (gnus-update-missing-marks
5202 (gnus-sorted-difference articles fetched-articles))
5203 ;; We might want to build some more threads first.
5204 (when (and gnus-fetch-old-headers
5205 (eq gnus-headers-retrieved-by 'nov))
5206 (if (eq gnus-fetch-old-headers 'invisible)
5207 (gnus-build-all-threads)
5208 (gnus-build-old-threads)))
5209 ;; Let the Gnus agent mark articles as read.
5210 (when gnus-agent
5211 (gnus-agent-get-undownloaded-list))
5212 ;; Remove list identifiers from subject
5213 (when gnus-list-identifiers
5214 (gnus-summary-remove-list-identifiers))
5215 ;; Check whether auto-expire is to be done in this group.
5216 (setq gnus-newsgroup-auto-expire
5217 (gnus-group-auto-expirable-p group))
5218 ;; Set up the article buffer now, if necessary.
5219 (unless gnus-single-article-buffer
5220 (gnus-article-setup-buffer))
5221 ;; First and last article in this newsgroup.
5222 (when gnus-newsgroup-headers
5223 (setq gnus-newsgroup-begin
5224 (mail-header-number (car gnus-newsgroup-headers))
5225 gnus-newsgroup-end
5226 (mail-header-number
5227 (gnus-last-element gnus-newsgroup-headers))))
5228 ;; GROUP is successfully selected.
5229 (or gnus-newsgroup-headers t)))))
5230
5231 (defun gnus-compute-unseen-list ()
5232 ;; The `seen' marks are treated specially.
5233 (if (not gnus-newsgroup-seen)
5234 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5235 (setq gnus-newsgroup-unseen
5236 (gnus-inverse-list-range-intersection
5237 gnus-newsgroup-articles gnus-newsgroup-seen))))
5238
5239 (defun gnus-summary-display-make-predicate (display)
5240 (require 'gnus-agent)
5241 (when (= (length display) 1)
5242 (setq display (car display)))
5243 (unless gnus-summary-display-cache
5244 (dolist (elem (append '((unread . unread)
5245 (read . read)
5246 (unseen . unseen))
5247 gnus-article-mark-lists))
5248 (push (cons (cdr elem)
5249 (gnus-byte-compile
5250 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5251 gnus-summary-display-cache)))
5252 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5253 (gnus-category-predicate-cache gnus-summary-display-cache))
5254 (gnus-get-predicate display)))
5255
5256 ;; Uses the dynamically bound `number' variable.
5257 (eval-when-compile
5258 (defvar number))
5259 (defun gnus-article-marked-p (type &optional article)
5260 (let ((article (or article number)))
5261 (cond
5262 ((eq type 'tick)
5263 (memq article gnus-newsgroup-marked))
5264 ((eq type 'spam)
5265 (memq article gnus-newsgroup-spam-marked))
5266 ((eq type 'unsend)
5267 (memq article gnus-newsgroup-unsendable))
5268 ((eq type 'undownload)
5269 (memq article gnus-newsgroup-undownloaded))
5270 ((eq type 'download)
5271 (memq article gnus-newsgroup-downloadable))
5272 ((eq type 'unread)
5273 (memq article gnus-newsgroup-unreads))
5274 ((eq type 'read)
5275 (memq article gnus-newsgroup-reads))
5276 ((eq type 'dormant)
5277 (memq article gnus-newsgroup-dormant) )
5278 ((eq type 'expire)
5279 (memq article gnus-newsgroup-expirable))
5280 ((eq type 'reply)
5281 (memq article gnus-newsgroup-replied))
5282 ((eq type 'killed)
5283 (memq article gnus-newsgroup-killed))
5284 ((eq type 'bookmark)
5285 (assq article gnus-newsgroup-bookmarks))
5286 ((eq type 'score)
5287 (assq article gnus-newsgroup-scored))
5288 ((eq type 'save)
5289 (memq article gnus-newsgroup-saved))
5290 ((eq type 'cache)
5291 (memq article gnus-newsgroup-cached))
5292 ((eq type 'forward)
5293 (memq article gnus-newsgroup-forwarded))
5294 ((eq type 'seen)
5295 (not (memq article gnus-newsgroup-unseen)))
5296 ((eq type 'recent)
5297 (memq article gnus-newsgroup-recent))
5298 (t t))))
5299
5300 (defun gnus-articles-to-read (group &optional read-all)
5301 "Find out what articles the user wants to read."
5302 (let* ((display (gnus-group-find-parameter group 'display))
5303 (articles
5304 ;; Select all articles if `read-all' is non-nil, or if there
5305 ;; are no unread articles.
5306 (if (or read-all
5307 (and (zerop (length gnus-newsgroup-marked))
5308 (zerop (length gnus-newsgroup-unreads)))
5309 ;; Fetch all if the predicate is non-nil.
5310 gnus-newsgroup-display)
5311 ;; We want to select the headers for all the articles in
5312 ;; the group, so we select either all the active
5313 ;; articles in the group, or (if that's nil), the
5314 ;; articles in the cache.
5315 (or
5316 (gnus-uncompress-range (gnus-active group))
5317 (gnus-cache-articles-in-group group))
5318 ;; Select only the "normal" subset of articles.
5319 (gnus-sorted-nunion
5320 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5321 gnus-newsgroup-unreads)))
5322 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5323 (scored (length scored-list))
5324 (number (length articles))
5325 (marked (+ (length gnus-newsgroup-marked)
5326 (length gnus-newsgroup-dormant)))
5327 (select
5328 (cond
5329 ((numberp read-all)
5330 read-all)
5331 ((numberp gnus-newsgroup-display)
5332 gnus-newsgroup-display)
5333 (t
5334 (condition-case ()
5335 (cond
5336 ((and (or (<= scored marked) (= scored number))
5337 (numberp gnus-large-newsgroup)
5338 (> number gnus-large-newsgroup))
5339 (let* ((cursor-in-echo-area nil)
5340 (initial (gnus-parameter-large-newsgroup-initial
5341 gnus-newsgroup-name))
5342 (input
5343 (read-string
5344 (format
5345 "How many articles from %s (%s %d): "
5346 (gnus-limit-string
5347 (gnus-group-decoded-name gnus-newsgroup-name)
5348 35)
5349 (if initial "max" "default")
5350 number)
5351 (if initial
5352 (cons (number-to-string initial)
5353 0)))))
5354 (if (string-match "^[ \t]*$" input) number input)))
5355 ((and (> scored marked) (< scored number)
5356 (> (- scored number) 20))
5357 (let ((input
5358 (read-string
5359 (format "%s %s (%d scored, %d total): "
5360 "How many articles from"
5361 (gnus-group-decoded-name group)
5362 scored number))))
5363 (if (string-match "^[ \t]*$" input)
5364 number input)))
5365 (t number))
5366 (quit
5367 (message "Quit getting the articles to read")
5368 nil))))))
5369 (setq select (if (stringp select) (string-to-number select) select))
5370 (if (or (null select) (zerop select))
5371 select
5372 (if (and (not (zerop scored)) (<= (abs select) scored))
5373 (progn
5374 (setq articles (sort scored-list '<))
5375 (setq number (length articles)))
5376 (setq articles (copy-sequence articles)))
5377
5378 (when (< (abs select) number)
5379 (if (< select 0)
5380 ;; Select the N oldest articles.
5381 (setcdr (nthcdr (1- (abs select)) articles) nil)
5382 ;; Select the N most recent articles.
5383 (setq articles (nthcdr (- number select) articles))))
5384 (setq gnus-newsgroup-unselected
5385 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5386 (when gnus-alter-articles-to-read-function
5387 (setq articles
5388 (sort
5389 (funcall gnus-alter-articles-to-read-function
5390 gnus-newsgroup-name articles)
5391 '<)))
5392 articles)))
5393
5394 (defun gnus-killed-articles (killed articles)
5395 (let (out)
5396 (while articles
5397 (when (inline (gnus-member-of-range (car articles) killed))
5398 (push (car articles) out))
5399 (setq articles (cdr articles)))
5400 out))
5401
5402 (defun gnus-uncompress-marks (marks)
5403 "Uncompress the mark ranges in MARKS."
5404 (let ((uncompressed '(score bookmark))
5405 out)
5406 (while marks
5407 (if (memq (caar marks) uncompressed)
5408 (push (car marks) out)
5409 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5410 (setq marks (cdr marks)))
5411 out))
5412
5413 (defun gnus-article-mark-to-type (mark)
5414 "Return the type of MARK."
5415 (or (cadr (assq mark gnus-article-special-mark-lists))
5416 'list))
5417
5418 (defun gnus-article-unpropagatable-p (mark)
5419 "Return whether MARK should be propagated to back end."
5420 (memq mark gnus-article-unpropagated-mark-lists))
5421
5422 (defun gnus-adjust-marked-articles (info)
5423 "Set all article lists and remove all marks that are no longer valid."
5424 (let* ((marked-lists (gnus-info-marks info))
5425 (active (gnus-active (gnus-info-group info)))
5426 (min (car active))
5427 (max (cdr active))
5428 (types gnus-article-mark-lists)
5429 marks var articles article mark mark-type
5430 bgn end)
5431
5432 (dolist (marks marked-lists)
5433 (setq mark (car marks)
5434 mark-type (gnus-article-mark-to-type mark)
5435 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5436
5437 ;; We set the variable according to the type of the marks list,
5438 ;; and then adjust the marks to a subset of the active articles.
5439 (cond
5440 ;; Adjust "simple" lists - compressed yet unsorted
5441 ((eq mark-type 'list)
5442 ;; Simultaneously uncompress and clip to active range
5443 ;; See gnus-uncompress-range for a description of possible marks
5444 (let (l lh)
5445 (if (not (cadr marks))
5446 (set var nil)
5447 (setq articles (if (numberp (cddr marks))
5448 (list (cdr marks))
5449 (cdr marks))
5450 lh (cons nil nil)
5451 l lh)
5452
5453 (while (setq article (pop articles))
5454 (cond ((consp article)
5455 (setq bgn (max (car article) min)
5456 end (min (cdr article) max))
5457 (while (<= bgn end)
5458 (setq l (setcdr l (cons bgn nil))
5459 bgn (1+ bgn))))
5460 ((and (<= min article)
5461 (>= max article))
5462 (setq l (setcdr l (cons article nil))))))
5463 (set var (cdr lh)))))
5464 ;; Adjust assocs.
5465 ((eq mark-type 'tuple)
5466 (set var (setq articles (cdr marks)))
5467 (when (not (listp (cdr (symbol-value var))))
5468 (set var (list (symbol-value var))))
5469 (when (not (listp (cdr articles)))
5470 (setq articles (list articles)))
5471 (while articles
5472 (when (or (not (consp (setq article (pop articles))))
5473 (< (car article) min)
5474 (> (car article) max))
5475 (set var (delq article (symbol-value var))))))
5476 ;; Adjust ranges (sloppily).
5477 ((eq mark-type 'range)
5478 (cond
5479 ((eq mark 'seen)
5480 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5481 ;; It should be (seen (NUM1 . NUM2)).
5482 (when (numberp (cddr marks))
5483 (setcdr marks (list (cdr marks))))
5484 (setq articles (cdr marks))
5485 (while (and articles
5486 (or (and (consp (car articles))
5487 (> min (cdar articles)))
5488 (and (numberp (car articles))
5489 (> min (car articles)))))
5490 (pop articles))
5491 (set var articles))))))))
5492
5493 (defun gnus-update-missing-marks (missing)
5494 "Go through the list of MISSING articles and remove them from the mark lists."
5495 (when missing
5496 (let (var m)
5497 ;; Go through all types.
5498 (dolist (elem gnus-article-mark-lists)
5499 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5500 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5501 (when (symbol-value var)
5502 ;; This list has articles. So we delete all missing
5503 ;; articles from it.
5504 (setq m missing)
5505 (while m
5506 (set var (delq (pop m) (symbol-value var))))))))))
5507
5508 (defun gnus-update-marks ()
5509 "Enter the various lists of marked articles into the newsgroup info list."
5510 (let ((types gnus-article-mark-lists)
5511 (info (gnus-get-info gnus-newsgroup-name))
5512 type list newmarked symbol delta-marks)
5513 (when info
5514 ;; Add all marks lists to the list of marks lists.
5515 (while (setq type (pop types))
5516 (setq list (symbol-value
5517 (setq symbol
5518 (intern (format "gnus-newsgroup-%s" (car type))))))
5519
5520 (when list
5521 ;; Get rid of the entries of the articles that have the
5522 ;; default score.
5523 (when (and (eq (cdr type) 'score)
5524 gnus-save-score
5525 list)
5526 (let* ((arts list)
5527 (prev (cons nil list))
5528 (all prev))
5529 (while arts
5530 (if (or (not (consp (car arts)))
5531 (= (cdar arts) gnus-summary-default-score))
5532 (setcdr prev (cdr arts))
5533 (setq prev arts))
5534 (setq arts (cdr arts)))
5535 (setq list (cdr all)))))
5536
5537 (when (eq (cdr type) 'seen)
5538 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5539
5540 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5541 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5542
5543 (when (and (gnus-check-backend-function
5544 'request-set-mark gnus-newsgroup-name)
5545 (not (gnus-article-unpropagatable-p (cdr type))))
5546 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5547 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5548 (add (gnus-remove-from-range
5549 (gnus-copy-sequence list) old)))
5550 (when add
5551 (push (list add 'add (list (cdr type))) delta-marks))
5552 (when del
5553 (push (list del 'del (list (cdr type))) delta-marks))))
5554
5555 (when list
5556 (push (cons (cdr type) list) newmarked)))
5557
5558 (when delta-marks
5559 (unless (gnus-check-group gnus-newsgroup-name)
5560 (error "Can't open server for %s" gnus-newsgroup-name))
5561 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5562
5563 ;; Enter these new marks into the info of the group.
5564 (if (nthcdr 3 info)
5565 (setcar (nthcdr 3 info) newmarked)
5566 ;; Add the marks lists to the end of the info.
5567 (when newmarked
5568 (setcdr (nthcdr 2 info) (list newmarked))))
5569
5570 ;; Cut off the end of the info if there's nothing else there.
5571 (let ((i 5))
5572 (while (and (> i 2)
5573 (not (nth i info)))
5574 (when (nthcdr (decf i) info)
5575 (setcdr (nthcdr i info) nil)))))))
5576
5577 (defun gnus-set-mode-line (where)
5578 "Set the mode line of the article or summary buffers.
5579 If WHERE is `summary', the summary mode line format will be used."
5580 ;; Is this mode line one we keep updated?
5581 (when (and (memq where gnus-updated-mode-lines)
5582 (symbol-value
5583 (intern (format "gnus-%s-mode-line-format-spec" where))))
5584 (let (mode-string)
5585 (save-excursion
5586 ;; We evaluate this in the summary buffer since these
5587 ;; variables are buffer-local to that buffer.
5588 (set-buffer gnus-summary-buffer)
5589 ;; We bind all these variables that are used in the `eval' form
5590 ;; below.
5591 (let* ((mformat (symbol-value
5592 (intern
5593 (format "gnus-%s-mode-line-format-spec" where))))
5594 (gnus-tmp-group-name (gnus-group-decoded-name
5595 gnus-newsgroup-name))
5596 (gnus-tmp-article-number (or gnus-current-article 0))
5597 (gnus-tmp-unread gnus-newsgroup-unreads)
5598 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5599 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5600 (gnus-tmp-unread-and-unselected
5601 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5602 (zerop gnus-tmp-unselected))
5603 "")
5604 ((zerop gnus-tmp-unselected)
5605 (format "{%d more}" gnus-tmp-unread-and-unticked))
5606 (t (format "{%d(+%d) more}"
5607 gnus-tmp-unread-and-unticked
5608 gnus-tmp-unselected))))
5609 (gnus-tmp-subject
5610 (if (and gnus-current-headers
5611 (vectorp gnus-current-headers))
5612 (gnus-mode-string-quote
5613 (mail-header-subject gnus-current-headers))
5614 ""))
5615 bufname-length max-len
5616 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5617 (setq mode-string (eval mformat))
5618 (setq bufname-length (if (string-match "%b" mode-string)
5619 (- (length
5620 (buffer-name
5621 (if (eq where 'summary)
5622 nil
5623 (get-buffer gnus-article-buffer))))
5624 2)
5625 0))
5626 (setq max-len (max 4 (if gnus-mode-non-string-length
5627 (- (window-width)
5628 gnus-mode-non-string-length
5629 bufname-length)
5630 (length mode-string))))
5631 ;; We might have to chop a bit of the string off...
5632 (when (> (length mode-string) max-len)
5633 (setq mode-string
5634 (concat (truncate-string-to-width mode-string (- max-len 3))
5635 "...")))
5636 ;; Pad the mode string a bit.
5637 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5638 ;; Update the mode line.
5639 (setq mode-line-buffer-identification
5640 (gnus-mode-line-buffer-identification (list mode-string)))
5641 (set-buffer-modified-p t))))
5642
5643 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5644 "Go through the HEADERS list and add all Xrefs to a hash table.
5645 The resulting hash table is returned, or nil if no Xrefs were found."
5646 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5647 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5648 (xref-hashtb (gnus-make-hashtable))
5649 start group entry number xrefs header)
5650 (while headers
5651 (setq header (pop headers))
5652 (when (and (setq xrefs (mail-header-xref header))
5653 (not (memq (setq number (mail-header-number header))
5654 unreads)))
5655 (setq start 0)
5656 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5657 (setq start (match-end 0))
5658 (setq group (if prefix
5659 (concat prefix (substring xrefs (match-beginning 1)
5660 (match-end 1)))
5661 (substring xrefs (match-beginning 1) (match-end 1))))
5662 (setq number
5663 (string-to-number (substring xrefs (match-beginning 2)
5664 (match-end 2))))
5665 (if (setq entry (gnus-gethash group xref-hashtb))
5666 (setcdr entry (cons number (cdr entry)))
5667 (gnus-sethash group (cons number nil) xref-hashtb)))))
5668 (and start xref-hashtb)))
5669
5670 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5671 "Look through all the headers and mark the Xrefs as read."
5672 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5673 name entry info xref-hashtb idlist method nth4)
5674 (save-excursion
5675 (set-buffer gnus-group-buffer)
5676 (when (setq xref-hashtb
5677 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5678 (mapatoms
5679 (lambda (group)
5680 (unless (string= from-newsgroup (setq name (symbol-name group)))
5681 (setq idlist (symbol-value group))
5682 ;; Dead groups are not updated.
5683 (and (prog1
5684 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5685 info (nth 2 entry))
5686 (when (stringp (setq nth4 (gnus-info-method info)))
5687 (setq nth4 (gnus-server-to-method nth4))))
5688 ;; Only do the xrefs if the group has the same
5689 ;; select method as the group we have just read.
5690 (or (gnus-methods-equal-p
5691 nth4 (gnus-find-method-for-group from-newsgroup))
5692 virtual
5693 (equal nth4 (setq method (gnus-find-method-for-group
5694 from-newsgroup)))
5695 (and (equal (car nth4) (car method))
5696 (equal (nth 1 nth4) (nth 1 method))))
5697 gnus-use-cross-reference
5698 (or (not (eq gnus-use-cross-reference t))
5699 virtual
5700 ;; Only do cross-references on subscribed
5701 ;; groups, if that is what is wanted.
5702 (<= (gnus-info-level info) gnus-level-subscribed))
5703 (gnus-group-make-articles-read name idlist))))
5704 xref-hashtb)))))
5705
5706 (defun gnus-compute-read-articles (group articles)
5707 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5708 (info (nth 2 entry))
5709 (active (gnus-active group))
5710 ninfo)
5711 (when entry
5712 ;; First peel off all invalid article numbers.
5713 (when active
5714 (let ((ids articles)
5715 id first)
5716 (while (setq id (pop ids))
5717 (when (and first (> id (cdr active)))
5718 ;; We'll end up in this situation in one particular
5719 ;; obscure situation. If you re-scan a group and get
5720 ;; a new article that is cross-posted to a different
5721 ;; group that has not been re-scanned, you might get
5722 ;; crossposted article that has a higher number than
5723 ;; Gnus believes possible. So we re-activate this
5724 ;; group as well. This might mean doing the
5725 ;; crossposting thingy will *increase* the number
5726 ;; of articles in some groups. Tsk, tsk.
5727 (setq active (or (gnus-activate-group group) active)))
5728 (when (or (> id (cdr active))
5729 (< id (car active)))
5730 (setq articles (delq id articles))))))
5731 ;; If the read list is nil, we init it.
5732 (if (and active
5733 (null (gnus-info-read info))
5734 (> (car active) 1))
5735 (setq ninfo (cons 1 (1- (car active))))
5736 (setq ninfo (gnus-info-read info)))
5737 ;; Then we add the read articles to the range.
5738 (gnus-add-to-range
5739 ninfo (setq articles (sort articles '<))))))
5740
5741 (defun gnus-group-make-articles-read (group articles)
5742 "Update the info of GROUP to say that ARTICLES are read."
5743 (let* ((num 0)
5744 (entry (gnus-gethash group gnus-newsrc-hashtb))
5745 (info (nth 2 entry))
5746 (active (gnus-active group))
5747 range)
5748 (when entry
5749 (setq range (gnus-compute-read-articles group articles))
5750 (save-excursion
5751 (set-buffer gnus-group-buffer)
5752 (gnus-undo-register
5753 `(progn
5754 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5755 (gnus-info-set-read ',info ',(gnus-info-read info))
5756 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5757 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5758 (gnus-group-update-group ,group t))))
5759 ;; Add the read articles to the range.
5760 (gnus-info-set-read info range)
5761 (gnus-request-set-mark group (list (list range 'add '(read))))
5762 ;; Then we have to re-compute how many unread
5763 ;; articles there are in this group.
5764 (when active
5765 (cond
5766 ((not range)
5767 (setq num (- (1+ (cdr active)) (car active))))
5768 ((not (listp (cdr range)))
5769 (setq num (- (cdr active) (- (1+ (cdr range))
5770 (car range)))))
5771 (t
5772 (while range
5773 (if (numberp (car range))
5774 (setq num (1+ num))
5775 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5776 (setq range (cdr range)))
5777 (setq num (- (cdr active) num))))
5778 ;; Update the number of unread articles.
5779 (setcar entry num)
5780 ;; Update the group buffer.
5781 (unless (gnus-ephemeral-group-p group)
5782 (gnus-group-update-group group t))))))
5783
5784 (defvar gnus-newsgroup-none-id 0)
5785
5786 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5787 (let ((cur nntp-server-buffer)
5788 (dependencies
5789 (or dependencies
5790 (save-excursion (set-buffer gnus-summary-buffer)
5791 gnus-newsgroup-dependencies)))
5792 headers id end ref
5793 (mail-parse-charset gnus-newsgroup-charset)
5794 (mail-parse-ignored-charsets
5795 (save-excursion (condition-case nil
5796 (set-buffer gnus-summary-buffer)
5797 (error))
5798 gnus-newsgroup-ignored-charsets)))
5799 (save-excursion
5800 (set-buffer nntp-server-buffer)
5801 ;; Translate all TAB characters into SPACE characters.
5802 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5803 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5804 (ietf-drums-unfold-fws)
5805 (gnus-run-hooks 'gnus-parse-headers-hook)
5806 (let ((case-fold-search t)
5807 in-reply-to header p lines chars)
5808 (goto-char (point-min))
5809 ;; Search to the beginning of the next header. Error messages
5810 ;; do not begin with 2 or 3.
5811 (while (re-search-forward "^[23][0-9]+ " nil t)
5812 (setq id nil
5813 ref nil)
5814 ;; This implementation of this function, with nine
5815 ;; search-forwards instead of the one re-search-forward and
5816 ;; a case (which basically was the old function) is actually
5817 ;; about twice as fast, even though it looks messier. You
5818 ;; can't have everything, I guess. Speed and elegance
5819 ;; doesn't always go hand in hand.
5820 (setq
5821 header
5822 (vector
5823 ;; Number.
5824 (prog1
5825 (read cur)
5826 (end-of-line)
5827 (setq p (point))
5828 (narrow-to-region (point)
5829 (or (and (search-forward "\n.\n" nil t)
5830 (- (point) 2))
5831 (point))))
5832 ;; Subject.
5833 (progn
5834 (goto-char p)
5835 (if (search-forward "\nsubject:" nil t)
5836 (funcall gnus-decode-encoded-word-function
5837 (nnheader-header-value))
5838 "(none)"))
5839 ;; From.
5840 (progn
5841 (goto-char p)
5842 (if (search-forward "\nfrom:" nil t)
5843 (funcall gnus-decode-encoded-word-function
5844 (nnheader-header-value))
5845 "(nobody)"))
5846 ;; Date.
5847 (progn
5848 (goto-char p)
5849 (if (search-forward "\ndate:" nil t)
5850 (nnheader-header-value) ""))
5851 ;; Message-ID.
5852 (progn
5853 (goto-char p)
5854 (setq id (if (re-search-forward
5855 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5856 ;; We do it this way to make sure the Message-ID
5857 ;; is (somewhat) syntactically valid.
5858 (buffer-substring (match-beginning 1)
5859 (match-end 1))
5860 ;; If there was no message-id, we just fake one
5861 ;; to make subsequent routines simpler.
5862 (nnheader-generate-fake-message-id))))
5863 ;; References.
5864 (progn
5865 (goto-char p)
5866 (if (search-forward "\nreferences:" nil t)
5867 (progn
5868 (setq end (point))
5869 (prog1
5870 (nnheader-header-value)
5871 (setq ref
5872 (buffer-substring
5873 (progn
5874 (end-of-line)
5875 (search-backward ">" end t)
5876 (1+ (point)))
5877 (progn
5878 (search-backward "<" end t)
5879 (point))))))
5880 ;; Get the references from the in-reply-to header if there
5881 ;; were no references and the in-reply-to header looks
5882 ;; promising.
5883 (if (and (search-forward "\nin-reply-to:" nil t)
5884 (setq in-reply-to (nnheader-header-value))
5885 (string-match "<[^>]+>" in-reply-to))
5886 (let (ref2)
5887 (setq ref (substring in-reply-to (match-beginning 0)
5888 (match-end 0)))
5889 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5890 (setq ref2 (substring in-reply-to (match-beginning 0)
5891 (match-end 0)))
5892 (when (> (length ref2) (length ref))
5893 (setq ref ref2)))
5894 ref)
5895 (setq ref nil))))
5896 ;; Chars.
5897 (progn
5898 (goto-char p)
5899 (if (search-forward "\nchars: " nil t)
5900 (if (numberp (setq chars (ignore-errors (read cur))))
5901 chars -1)
5902 -1))
5903 ;; Lines.
5904 (progn
5905 (goto-char p)
5906 (if (search-forward "\nlines: " nil t)
5907 (if (numberp (setq lines (ignore-errors (read cur))))
5908 lines -1)
5909 -1))
5910 ;; Xref.
5911 (progn
5912 (goto-char p)
5913 (and (search-forward "\nxref:" nil t)
5914 (nnheader-header-value)))
5915 ;; Extra.
5916 (when gnus-extra-headers
5917 (let ((extra gnus-extra-headers)
5918 out)
5919 (while extra
5920 (goto-char p)
5921 (when (search-forward
5922 (concat "\n" (symbol-name (car extra)) ":") nil t)
5923 (push (cons (car extra) (nnheader-header-value))
5924 out))
5925 (pop extra))
5926 out))))
5927 (when (equal id ref)
5928 (setq ref nil))
5929
5930 (when gnus-alter-header-function
5931 (funcall gnus-alter-header-function header)
5932 (setq id (mail-header-id header)
5933 ref (gnus-parent-id (mail-header-references header))))
5934
5935 (when (setq header
5936 (gnus-dependencies-add-header
5937 header dependencies force-new))
5938 (push header headers))
5939 (goto-char (point-max))
5940 (widen))
5941 (nreverse headers)))))
5942
5943 ;; Goes through the xover lines and returns a list of vectors
5944 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5945 force-new dependencies
5946 group also-fetch-heads)
5947 "Parse the news overview data in the server buffer.
5948 Return a list of headers that match SEQUENCE (see
5949 `nntp-retrieve-headers')."
5950 ;; Get the Xref when the users reads the articles since most/some
5951 ;; NNTP servers do not include Xrefs when using XOVER.
5952 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5953 (let ((mail-parse-charset gnus-newsgroup-charset)
5954 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5955 (cur nntp-server-buffer)
5956 (dependencies (or dependencies gnus-newsgroup-dependencies))
5957 (allp (cond
5958 ((eq gnus-read-all-available-headers t)
5959 t)
5960 ((stringp gnus-read-all-available-headers)
5961 (string-match gnus-read-all-available-headers group))
5962 (t
5963 nil)))
5964 number headers header)
5965 (save-excursion
5966 (set-buffer nntp-server-buffer)
5967 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5968 ;; Allow the user to mangle the headers before parsing them.
5969 (gnus-run-hooks 'gnus-parse-headers-hook)
5970 (goto-char (point-min))
5971 (gnus-parse-without-error
5972 (while (and (or sequence allp)
5973 (not (eobp)))
5974 (setq number (read cur))
5975 (when (not allp)
5976 (while (and sequence
5977 (< (car sequence) number))
5978 (setq sequence (cdr sequence))))
5979 (when (and (or allp
5980 (and sequence
5981 (eq number (car sequence))))
5982 (progn
5983 (setq sequence (cdr sequence))
5984 (setq header (inline
5985 (gnus-nov-parse-line
5986 number dependencies force-new)))))
5987 (push header headers))
5988 (forward-line 1)))
5989 ;; A common bug in inn is that if you have posted an article and
5990 ;; then retrieves the active file, it will answer correctly --
5991 ;; the new article is included. However, a NOV entry for the
5992 ;; article may not have been generated yet, so this may fail.
5993 ;; We work around this problem by retrieving the last few
5994 ;; headers using HEAD.
5995 (if (or (not also-fetch-heads)
5996 (not sequence))
5997 ;; We (probably) got all the headers.
5998 (nreverse headers)
5999 (let ((gnus-nov-is-evil t))
6000 (nconc
6001 (nreverse headers)
6002 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6003 (gnus-get-newsgroup-headers))))))))
6004
6005 (defun gnus-article-get-xrefs ()
6006 "Fill in the Xref value in `gnus-current-headers', if necessary.
6007 This is meant to be called in `gnus-article-internal-prepare-hook'."
6008 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6009 gnus-current-headers)))
6010 (or (not gnus-use-cross-reference)
6011 (not headers)
6012 (and (mail-header-xref headers)
6013 (not (string= (mail-header-xref headers) "")))
6014 (let ((case-fold-search t)
6015 xref)
6016 (save-restriction
6017 (nnheader-narrow-to-headers)
6018 (goto-char (point-min))
6019 (when (or (and (not (eobp))
6020 (eq (downcase (char-after)) ?x)
6021 (looking-at "Xref:"))
6022 (search-forward "\nXref:" nil t))
6023 (goto-char (1+ (match-end 0)))
6024 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
6025 (mail-header-set-xref headers xref)))))))
6026
6027 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6028 "Find article ID and insert the summary line for that article.
6029 OLD-HEADER can either be a header or a line number to insert
6030 the subject line on."
6031 (let* ((line (and (numberp old-header) old-header))
6032 (old-header (and (vectorp old-header) old-header))
6033 (header (cond ((and old-header use-old-header)
6034 old-header)
6035 ((and (numberp id)
6036 (gnus-number-to-header id))
6037 (gnus-number-to-header id))
6038 (t
6039 (gnus-read-header id))))
6040 (number (and (numberp id) id))
6041 d)
6042 (when header
6043 ;; Rebuild the thread that this article is part of and go to the
6044 ;; article we have fetched.
6045 (when (and (not gnus-show-threads)
6046 old-header)
6047 (when (and number
6048 (setq d (gnus-data-find (mail-header-number old-header))))
6049 (goto-char (gnus-data-pos d))
6050 (gnus-data-remove
6051 number
6052 (- (gnus-point-at-bol)
6053 (prog1
6054 (1+ (gnus-point-at-eol))
6055 (gnus-delete-line))))))
6056 ;; Remove list identifiers from subject.
6057 (when gnus-list-identifiers
6058 (let ((gnus-newsgroup-headers (list header)))
6059 (gnus-summary-remove-list-identifiers)))
6060 (when old-header
6061 (mail-header-set-number header (mail-header-number old-header)))
6062 (setq gnus-newsgroup-sparse
6063 (delq (setq number (mail-header-number header))
6064 gnus-newsgroup-sparse))
6065 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6066 (push number gnus-newsgroup-limit)
6067 (gnus-rebuild-thread (mail-header-id header) line)
6068 (gnus-summary-goto-subject number nil t))
6069 (when (and (numberp number)
6070 (> number 0))
6071 ;; We have to update the boundaries even if we can't fetch the
6072 ;; article if ID is a number -- so that the next `P' or `N'
6073 ;; command will fetch the previous (or next) article even
6074 ;; if the one we tried to fetch this time has been canceled.
6075 (when (> number gnus-newsgroup-end)
6076 (setq gnus-newsgroup-end number))
6077 (when (< number gnus-newsgroup-begin)
6078 (setq gnus-newsgroup-begin number))
6079 (setq gnus-newsgroup-unselected
6080 (delq number gnus-newsgroup-unselected)))
6081 ;; Report back a success?
6082 (and header (mail-header-number header))))
6083
6084 ;;; Process/prefix in the summary buffer
6085
6086 (defun gnus-summary-work-articles (n)
6087 "Return a list of articles to be worked upon.
6088 The prefix argument, the list of process marked articles, and the
6089 current article will be taken into consideration."
6090 (save-excursion
6091 (set-buffer gnus-summary-buffer)
6092 (cond
6093 (n
6094 ;; A numerical prefix has been given.
6095 (setq n (prefix-numeric-value n))
6096 (let ((backward (< n 0))
6097 (n (abs (prefix-numeric-value n)))
6098 articles article)
6099 (save-excursion
6100 (while
6101 (and (> n 0)
6102 (push (setq article (gnus-summary-article-number))
6103 articles)
6104 (if backward
6105 (gnus-summary-find-prev nil article)
6106 (gnus-summary-find-next nil article)))
6107 (decf n)))
6108 (nreverse articles)))
6109 ((and (gnus-region-active-p) (mark))
6110 (message "region active")
6111 ;; Work on the region between point and mark.
6112 (let ((max (max (point) (mark)))
6113 articles article)
6114 (save-excursion
6115 (goto-char (min (min (point) (mark))))
6116 (while
6117 (and
6118 (push (setq article (gnus-summary-article-number)) articles)
6119 (gnus-summary-find-next nil article)
6120 (< (point) max)))
6121 (nreverse articles))))
6122 (gnus-newsgroup-processable
6123 ;; There are process-marked articles present.
6124 ;; Save current state.
6125 (gnus-summary-save-process-mark)
6126 ;; Return the list.
6127 (reverse gnus-newsgroup-processable))
6128 (t
6129 ;; Just return the current article.
6130 (list (gnus-summary-article-number))))))
6131
6132 (defmacro gnus-summary-iterate (arg &rest forms)
6133 "Iterate over the process/prefixed articles and do FORMS.
6134 ARG is the interactive prefix given to the command. FORMS will be
6135 executed with point over the summary line of the articles."
6136 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6137 `(let ((,articles (gnus-summary-work-articles ,arg)))
6138 (while ,articles
6139 (gnus-summary-goto-subject (car ,articles))
6140 ,@forms
6141 (pop ,articles)))))
6142
6143 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6144 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6145
6146 (defun gnus-summary-save-process-mark ()
6147 "Push the current set of process marked articles on the stack."
6148 (interactive)
6149 (push (copy-sequence gnus-newsgroup-processable)
6150 gnus-newsgroup-process-stack))
6151
6152 (defun gnus-summary-kill-process-mark ()
6153 "Push the current set of process marked articles on the stack and unmark."
6154 (interactive)
6155 (gnus-summary-save-process-mark)
6156 (gnus-summary-unmark-all-processable))
6157
6158 (defun gnus-summary-yank-process-mark ()
6159 "Pop the last process mark state off the stack and restore it."
6160 (interactive)
6161 (unless gnus-newsgroup-process-stack
6162 (error "Empty mark stack"))
6163 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6164
6165 (defun gnus-summary-process-mark-set (set)
6166 "Make SET into the current process marked articles."
6167 (gnus-summary-unmark-all-processable)
6168 (while set
6169 (gnus-summary-set-process-mark (pop set))))
6170
6171 ;;; Searching and stuff
6172
6173 (defun gnus-summary-search-group (&optional backward use-level)
6174 "Search for next unread newsgroup.
6175 If optional argument BACKWARD is non-nil, search backward instead."
6176 (save-excursion
6177 (set-buffer gnus-group-buffer)
6178 (when (gnus-group-search-forward
6179 backward nil (if use-level (gnus-group-group-level) nil))
6180 (gnus-group-group-name))))
6181
6182 (defun gnus-summary-best-group (&optional exclude-group)
6183 "Find the name of the best unread group.
6184 If EXCLUDE-GROUP, do not go to this group."
6185 (save-excursion
6186 (set-buffer gnus-group-buffer)
6187 (save-excursion
6188 (gnus-group-best-unread-group exclude-group))))
6189
6190 (defun gnus-summary-find-next (&optional unread article backward)
6191 (if backward
6192 (gnus-summary-find-prev unread article)
6193 (let* ((dummy (gnus-summary-article-intangible-p))
6194 (article (or article (gnus-summary-article-number)))
6195 (data (gnus-data-find-list article))
6196 result)
6197 (when (and (not dummy)
6198 (or (not gnus-summary-check-current)
6199 (not unread)
6200 (not (gnus-data-unread-p (car data)))))
6201 (setq data (cdr data)))
6202 (when (setq result
6203 (if unread
6204 (progn
6205 (while data
6206 (unless (memq (gnus-data-number (car data))
6207 (cond
6208 ((eq gnus-auto-goto-ignores
6209 'always-undownloaded)
6210 gnus-newsgroup-undownloaded)
6211 (gnus-plugged
6212 nil)
6213 ((eq gnus-auto-goto-ignores
6214 'unfetched)
6215 gnus-newsgroup-unfetched)
6216 ((eq gnus-auto-goto-ignores
6217 'undownloaded)
6218 gnus-newsgroup-undownloaded)))
6219 (when (gnus-data-unread-p (car data))
6220 (setq result (car data)
6221 data nil)))
6222 (setq data (cdr data)))
6223 result)
6224 (car data)))
6225 (goto-char (gnus-data-pos result))
6226 (gnus-data-number result)))))
6227
6228 (defun gnus-summary-find-prev (&optional unread article)
6229 (let* ((eobp (eobp))
6230 (article (or article (gnus-summary-article-number)))
6231 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6232 result)
6233 (when (and (not eobp)
6234 (or (not gnus-summary-check-current)
6235 (not unread)
6236 (not (gnus-data-unread-p (car data)))))
6237 (setq data (cdr data)))
6238 (when (setq result
6239 (if unread
6240 (progn
6241 (while data
6242 (unless (memq (gnus-data-number (car data))
6243 (cond
6244 ((eq gnus-auto-goto-ignores
6245 'always-undownloaded)
6246 gnus-newsgroup-undownloaded)
6247 (gnus-plugged
6248 nil)
6249 ((eq gnus-auto-goto-ignores
6250 'unfetched)
6251 gnus-newsgroup-unfetched)
6252 ((eq gnus-auto-goto-ignores
6253 'undownloaded)
6254 gnus-newsgroup-undownloaded)))
6255 (when (gnus-data-unread-p (car data))
6256 (setq result (car data)
6257 data nil)))
6258 (setq data (cdr data)))
6259 result)
6260 (car data)))
6261 (goto-char (gnus-data-pos result))
6262 (gnus-data-number result))))
6263
6264 (defun gnus-summary-find-subject (subject &optional unread backward article)
6265 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6266 (article (or article (gnus-summary-article-number)))
6267 (articles (gnus-data-list backward))
6268 (arts (gnus-data-find-list article articles))
6269 result)
6270 (when (or (not gnus-summary-check-current)
6271 (not unread)
6272 (not (gnus-data-unread-p (car arts))))
6273 (setq arts (cdr arts)))
6274 (while arts
6275 (and (or (not unread)
6276 (gnus-data-unread-p (car arts)))
6277 (vectorp (gnus-data-header (car arts)))
6278 (gnus-subject-equal
6279 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6280 (setq result (car arts)
6281 arts nil))
6282 (setq arts (cdr arts)))
6283 (and result
6284 (goto-char (gnus-data-pos result))
6285 (gnus-data-number result))))
6286
6287 (defun gnus-summary-search-forward (&optional unread subject backward)
6288 "Search forward for an article.
6289 If UNREAD, look for unread articles. If SUBJECT, look for
6290 articles with that subject. If BACKWARD, search backward instead."
6291 (cond (subject (gnus-summary-find-subject subject unread backward))
6292 (backward (gnus-summary-find-prev unread))
6293 (t (gnus-summary-find-next unread))))
6294
6295 (defun gnus-recenter (&optional n)
6296 "Center point in window and redisplay frame.
6297 Also do horizontal recentering."
6298 (interactive "P")
6299 (when (and gnus-auto-center-summary
6300 (not (eq gnus-auto-center-summary 'vertical)))
6301 (gnus-horizontal-recenter))
6302 (recenter n))
6303
6304 (defun gnus-summary-recenter ()
6305 "Center point in the summary window.
6306 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6307 displayed, no centering will be performed."
6308 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6309 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6310 (interactive)
6311 ;; The user has to want it.
6312 (when gnus-auto-center-summary
6313 (let* ((top (cond ((< (window-height) 4) 0)
6314 ((< (window-height) 7) 1)
6315 (t (if (numberp gnus-auto-center-summary)
6316 gnus-auto-center-summary
6317 2))))
6318 (height (1- (window-height)))
6319 (bottom (save-excursion (goto-char (point-max))
6320 (forward-line (- height))
6321 (point)))
6322 (window (get-buffer-window (current-buffer))))
6323 (when (get-buffer-window gnus-article-buffer)
6324 ;; Only do recentering when the article buffer is displayed,
6325 ;; Set the window start to either `bottom', which is the biggest
6326 ;; possible valid number, or the second line from the top,
6327 ;; whichever is the least.
6328 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6329 (if (> bottom top-pos)
6330 ;; Keep the second line from the top visible
6331 (set-window-start window top-pos t)
6332 ;; Try to keep the bottom line visible; if it's partially
6333 ;; obscured, either scroll one more line to make it fully
6334 ;; visible, or revert to using TOP-POS.
6335 (save-excursion
6336 (goto-char (point-max))
6337 (forward-line -1)
6338 (let ((last-line-start (point)))
6339 (goto-char bottom)
6340 (set-window-start window (point) t)
6341 (when (not (pos-visible-in-window-p last-line-start window))
6342 (forward-line 1)
6343 (set-window-start window (min (point) top-pos) t)))))))
6344 ;; Do horizontal recentering while we're at it.
6345 (when (and (get-buffer-window (current-buffer) t)
6346 (not (eq gnus-auto-center-summary 'vertical)))
6347 (let ((selected (selected-window)))
6348 (select-window (get-buffer-window (current-buffer) t))
6349 (gnus-summary-position-point)
6350 (gnus-horizontal-recenter)
6351 (select-window selected))))))
6352
6353 (defun gnus-summary-jump-to-group (newsgroup)
6354 "Move point to NEWSGROUP in group mode buffer."
6355 ;; Keep update point of group mode buffer if visible.
6356 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6357 (save-window-excursion
6358 ;; Take care of tree window mode.
6359 (when (get-buffer-window gnus-group-buffer)
6360 (pop-to-buffer gnus-group-buffer))
6361 (gnus-group-jump-to-group newsgroup))
6362 (save-excursion
6363 ;; Take care of tree window mode.
6364 (if (get-buffer-window gnus-group-buffer)
6365 (pop-to-buffer gnus-group-buffer)
6366 (set-buffer gnus-group-buffer))
6367 (gnus-group-jump-to-group newsgroup))))
6368
6369 ;; This function returns a list of article numbers based on the
6370 ;; difference between the ranges of read articles in this group and
6371 ;; the range of active articles.
6372 (defun gnus-list-of-unread-articles (group)
6373 (let* ((read (gnus-info-read (gnus-get-info group)))
6374 (active (or (gnus-active group) (gnus-activate-group group)))
6375 (last (cdr active))
6376 first nlast unread)
6377 ;; If none are read, then all are unread.
6378 (if (not read)
6379 (setq first (car active))
6380 ;; If the range of read articles is a single range, then the
6381 ;; first unread article is the article after the last read
6382 ;; article. Sounds logical, doesn't it?
6383 (if (and (not (listp (cdr read)))
6384 (or (< (car read) (car active))
6385 (progn (setq read (list read))
6386 nil)))
6387 (setq first (max (car active) (1+ (cdr read))))
6388 ;; `read' is a list of ranges.
6389 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6390 (caar read)))
6391 1)
6392 (setq first (car active)))
6393 (while read
6394 (when first
6395 (while (< first nlast)
6396 (setq unread (cons first unread)
6397 first (1+ first))))
6398 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6399 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6400 (setq read (cdr read)))))
6401 ;; And add the last unread articles.
6402 (while (<= first last)
6403 (setq unread (cons first unread)
6404 first (1+ first)))
6405 ;; Return the list of unread articles.
6406 (delq 0 (nreverse unread))))
6407
6408 (defun gnus-list-of-read-articles (group)
6409 "Return a list of unread, unticked and non-dormant articles."
6410 (let* ((info (gnus-get-info group))
6411 (marked (gnus-info-marks info))
6412 (active (gnus-active group)))
6413 (and info active
6414 (gnus-list-range-difference
6415 (gnus-list-range-difference
6416 (gnus-sorted-complement
6417 (gnus-uncompress-range active)
6418 (gnus-list-of-unread-articles group))
6419 (cdr (assq 'dormant marked)))
6420 (cdr (assq 'tick marked))))))
6421
6422 ;; This function returns a sequence of article numbers based on the
6423 ;; difference between the ranges of read articles in this group and
6424 ;; the range of active articles.
6425 (defun gnus-sequence-of-unread-articles (group)
6426 (let* ((read (gnus-info-read (gnus-get-info group)))
6427 (active (or (gnus-active group) (gnus-activate-group group)))
6428 (last (cdr active))
6429 first nlast unread)
6430 ;; If none are read, then all are unread.
6431 (if (not read)
6432 (setq first (car active))
6433 ;; If the range of read articles is a single range, then the
6434 ;; first unread article is the article after the last read
6435 ;; article. Sounds logical, doesn't it?
6436 (if (and (not (listp (cdr read)))
6437 (or (< (car read) (car active))
6438 (progn (setq read (list read))
6439 nil)))
6440 (setq first (max (car active) (1+ (cdr read))))
6441 ;; `read' is a list of ranges.
6442 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6443 (caar read)))
6444 1)
6445 (setq first (car active)))
6446 (while read
6447 (when first
6448 (push (cons first nlast) unread))
6449 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6450 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6451 (setq read (cdr read)))))
6452 ;; And add the last unread articles.
6453 (cond ((< first last)
6454 (push (cons first last) unread))
6455 ((= first last)
6456 (push first unread)))
6457 ;; Return the sequence of unread articles.
6458 (delq 0 (nreverse unread))))
6459
6460 ;; Various summary commands
6461
6462 (defun gnus-summary-select-article-buffer ()
6463 "Reconfigure windows to show article buffer."
6464 (interactive)
6465 (if (not (gnus-buffer-live-p gnus-article-buffer))
6466 (error "There is no article buffer for this summary buffer")
6467 (gnus-configure-windows 'article)
6468 (select-window (get-buffer-window gnus-article-buffer))))
6469
6470 (defun gnus-summary-universal-argument (arg)
6471 "Perform any operation on all articles that are process/prefixed."
6472 (interactive "P")
6473 (let ((articles (gnus-summary-work-articles arg))
6474 func article)
6475 (if (eq
6476 (setq
6477 func
6478 (key-binding
6479 (read-key-sequence
6480 (substitute-command-keys
6481 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6482 'undefined)
6483 (gnus-error 1 "Undefined key")
6484 (save-excursion
6485 (while articles
6486 (gnus-summary-goto-subject (setq article (pop articles)))
6487 (let (gnus-newsgroup-processable)
6488 (command-execute func))
6489 (gnus-summary-remove-process-mark article)))))
6490 (gnus-summary-position-point))
6491
6492 (defun gnus-summary-toggle-truncation (&optional arg)
6493 "Toggle truncation of summary lines.
6494 With ARG, turn line truncation on if ARG is positive."
6495 (interactive "P")
6496 (setq truncate-lines
6497 (if (null arg) (not truncate-lines)
6498 (> (prefix-numeric-value arg) 0)))
6499 (redraw-display))
6500
6501 (defun gnus-summary-find-for-reselect ()
6502 "Return the number of an article to stay on across a reselect.
6503 The current article is considered, then following articles, then previous
6504 articles. An article is sought which is not cancelled and isn't a temporary
6505 insertion from another group. If there's no such then return a dummy 0."
6506 (let (found)
6507 (dolist (rev '(nil t))
6508 (unless found ; don't demand the reverse list if we don't need it
6509 (let ((data (gnus-data-find-list
6510 (gnus-summary-article-number) (gnus-data-list rev))))
6511 (while (and data (not found))
6512 (if (and (< 0 (gnus-data-number (car data)))
6513 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6514 (setq found (gnus-data-number (car data))))
6515 (setq data (cdr data))))))
6516 (or found 0)))
6517
6518 (defun gnus-summary-reselect-current-group (&optional all rescan)
6519 "Exit and then reselect the current newsgroup.
6520 The prefix argument ALL means to select all articles."
6521 (interactive "P")
6522 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6523 (error "Ephemeral groups can't be reselected"))
6524 (let ((current-subject (gnus-summary-find-for-reselect))
6525 (group gnus-newsgroup-name))
6526 (setq gnus-newsgroup-begin nil)
6527 (gnus-summary-exit nil 'leave-hidden)
6528 ;; We have to adjust the point of group mode buffer because
6529 ;; point was moved to the next unread newsgroup by exiting.
6530 (gnus-summary-jump-to-group group)
6531 (when rescan
6532 (save-excursion
6533 (gnus-group-get-new-news-this-group 1)))
6534 (gnus-group-read-group all t)
6535 (gnus-summary-goto-subject current-subject nil t)))
6536
6537 (defun gnus-summary-rescan-group (&optional all)
6538 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6539 (interactive "P")
6540 (gnus-summary-reselect-current-group all t))
6541
6542 (defun gnus-summary-update-info (&optional non-destructive)
6543 (save-excursion
6544 (let ((group gnus-newsgroup-name))
6545 (when group
6546 (when gnus-newsgroup-kill-headers
6547 (setq gnus-newsgroup-killed
6548 (gnus-compress-sequence
6549 (gnus-sorted-union
6550 (gnus-list-range-intersection
6551 gnus-newsgroup-unselected gnus-newsgroup-killed)
6552 gnus-newsgroup-unreads)
6553 t)))
6554 (unless (listp (cdr gnus-newsgroup-killed))
6555 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6556 (let ((headers gnus-newsgroup-headers))
6557 ;; Set the new ranges of read articles.
6558 (save-excursion
6559 (set-buffer gnus-group-buffer)
6560 (gnus-undo-force-boundary))
6561 (gnus-update-read-articles
6562 group (gnus-sorted-union
6563 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6564 ;; Set the current article marks.
6565 (let ((gnus-newsgroup-scored
6566 (if (and (not gnus-save-score)
6567 (not non-destructive))
6568 nil
6569 gnus-newsgroup-scored)))
6570 (save-excursion
6571 (gnus-update-marks)))
6572 ;; Do the cross-ref thing.
6573 (when gnus-use-cross-reference
6574 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6575 ;; Do not switch windows but change the buffer to work.
6576 (set-buffer gnus-group-buffer)
6577 (unless (gnus-ephemeral-group-p group)
6578 (gnus-group-update-group group)))))))
6579
6580 (defun gnus-summary-save-newsrc (&optional force)
6581 "Save the current number of read/marked articles in the dribble buffer.
6582 The dribble buffer will then be saved.
6583 If FORCE (the prefix), also save the .newsrc file(s)."
6584 (interactive "P")
6585 (gnus-summary-update-info t)
6586 (if force
6587 (gnus-save-newsrc-file)
6588 (gnus-dribble-save)))
6589
6590 (defun gnus-summary-exit (&optional temporary leave-hidden)
6591 "Exit reading current newsgroup, and then return to group selection mode.
6592 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6593 (interactive)
6594 (gnus-set-global-variables)
6595 (when (gnus-buffer-live-p gnus-article-buffer)
6596 (save-excursion
6597 (set-buffer gnus-article-buffer)
6598 (mm-destroy-parts gnus-article-mime-handles)
6599 ;; Set it to nil for safety reason.
6600 (setq gnus-article-mime-handle-alist nil)
6601 (setq gnus-article-mime-handles nil)))
6602 (gnus-kill-save-kill-buffer)
6603 (gnus-async-halt-prefetch)
6604 (let* ((group gnus-newsgroup-name)
6605 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6606 (gnus-group-is-exiting-p t)
6607 (mode major-mode)
6608 (group-point nil)
6609 (buf (current-buffer)))
6610 (unless quit-config
6611 ;; Do adaptive scoring, and possibly save score files.
6612 (when gnus-newsgroup-adaptive
6613 (gnus-score-adaptive))
6614 (when gnus-use-scoring
6615 (gnus-score-save)))
6616 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6617 ;; If we have several article buffers, we kill them at exit.
6618 (unless gnus-single-article-buffer
6619 (gnus-kill-buffer gnus-original-article-buffer)
6620 (setq gnus-article-current nil))
6621 (when gnus-use-cache
6622 (gnus-cache-possibly-remove-articles)
6623 (gnus-cache-save-buffers))
6624 (gnus-async-prefetch-remove-group group)
6625 (when gnus-suppress-duplicates
6626 (gnus-dup-enter-articles))
6627 (when gnus-use-trees
6628 (gnus-tree-close group))
6629 (when gnus-use-cache
6630 (gnus-cache-write-active))
6631 ;; Remove entries for this group.
6632 (nnmail-purge-split-history (gnus-group-real-name group))
6633 ;; Make all changes in this group permanent.
6634 (unless quit-config
6635 (gnus-run-hooks 'gnus-exit-group-hook)
6636 (gnus-summary-update-info))
6637 (gnus-close-group group)
6638 ;; Make sure where we were, and go to next newsgroup.
6639 (set-buffer gnus-group-buffer)
6640 (unless quit-config
6641 (gnus-group-jump-to-group group))
6642 (gnus-run-hooks 'gnus-summary-exit-hook)
6643 (unless (or quit-config
6644 ;; If this group has disappeared from the summary
6645 ;; buffer, don't skip forwards.
6646 (not (string= group (gnus-group-group-name))))
6647 (gnus-group-next-unread-group 1))
6648 (setq group-point (point))
6649 (if temporary
6650 nil ;Nothing to do.
6651 ;; If we have several article buffers, we kill them at exit.
6652 (unless gnus-single-article-buffer
6653 (gnus-kill-buffer gnus-article-buffer)
6654 (gnus-kill-buffer gnus-original-article-buffer)
6655 (setq gnus-article-current nil))
6656 (set-buffer buf)
6657 (if (not gnus-kill-summary-on-exit)
6658 (progn
6659 (gnus-deaden-summary)
6660 (setq mode nil))
6661 ;; We set all buffer-local variables to nil. It is unclear why
6662 ;; this is needed, but if we don't, buffer-local variables are
6663 ;; not garbage-collected, it seems. This would the lead to en
6664 ;; ever-growing Emacs.
6665 (gnus-summary-clear-local-variables)
6666 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6667 (gnus-summary-clear-local-variables))
6668 (when (get-buffer gnus-article-buffer)
6669 (bury-buffer gnus-article-buffer))
6670 ;; We clear the global counterparts of the buffer-local
6671 ;; variables as well, just to be on the safe side.
6672 (set-buffer gnus-group-buffer)
6673 (gnus-summary-clear-local-variables)
6674 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6675 (gnus-summary-clear-local-variables))
6676 ;; Return to group mode buffer.
6677 (when (eq mode 'gnus-summary-mode)
6678 (gnus-kill-buffer buf)))
6679 (setq gnus-current-select-method gnus-select-method)
6680 (set-buffer gnus-group-buffer)
6681 (if quit-config
6682 (gnus-handle-ephemeral-exit quit-config)
6683 (goto-char group-point)
6684 ;; If gnus-group-buffer is already displayed, make sure we also move
6685 ;; the cursor in the window that displays it.
6686 (let ((win (get-buffer-window (current-buffer) 0)))
6687 (if win (set-window-point win (point))))
6688 (unless leave-hidden
6689 (gnus-configure-windows 'group 'force)))
6690 ;; Clear the current group name.
6691 (unless quit-config
6692 (setq gnus-newsgroup-name nil)))))
6693
6694 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6695 (defun gnus-summary-exit-no-update (&optional no-questions)
6696 "Quit reading current newsgroup without updating read article info."
6697 (interactive)
6698 (let* ((group gnus-newsgroup-name)
6699 (gnus-group-is-exiting-p t)
6700 (gnus-group-is-exiting-without-update-p t)
6701 (quit-config (gnus-group-quit-config group)))
6702 (when (or no-questions
6703 gnus-expert-user
6704 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6705 (gnus-async-halt-prefetch)
6706 (run-hooks 'gnus-summary-prepare-exit-hook)
6707 (when (gnus-buffer-live-p gnus-article-buffer)
6708 (save-excursion
6709 (set-buffer gnus-article-buffer)
6710 (mm-destroy-parts gnus-article-mime-handles)
6711 ;; Set it to nil for safety reason.
6712 (setq gnus-article-mime-handle-alist nil)
6713 (setq gnus-article-mime-handles nil)))
6714 ;; If we have several article buffers, we kill them at exit.
6715 (unless gnus-single-article-buffer
6716 (gnus-kill-buffer gnus-article-buffer)
6717 (gnus-kill-buffer gnus-original-article-buffer)
6718 (setq gnus-article-current nil))
6719 (if (not gnus-kill-summary-on-exit)
6720 (gnus-deaden-summary)
6721 (gnus-close-group group)
6722 (gnus-summary-clear-local-variables)
6723 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6724 (gnus-summary-clear-local-variables))
6725 (set-buffer gnus-group-buffer)
6726 (gnus-summary-clear-local-variables)
6727 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6728 (gnus-summary-clear-local-variables))
6729 (gnus-kill-buffer gnus-summary-buffer))
6730 (unless gnus-single-article-buffer
6731 (setq gnus-article-current nil))
6732 (when gnus-use-trees
6733 (gnus-tree-close group))
6734 (gnus-async-prefetch-remove-group group)
6735 (when (get-buffer gnus-article-buffer)
6736 (bury-buffer gnus-article-buffer))
6737 ;; Return to the group buffer.
6738 (gnus-configure-windows 'group 'force)
6739 ;; Clear the current group name.
6740 (setq gnus-newsgroup-name nil)
6741 (unless (gnus-ephemeral-group-p group)
6742 (gnus-group-update-group group))
6743 (when (equal (gnus-group-group-name) group)
6744 (gnus-group-next-unread-group 1))
6745 (when quit-config
6746 (gnus-handle-ephemeral-exit quit-config)))))
6747
6748 (defun gnus-handle-ephemeral-exit (quit-config)
6749 "Handle movement when leaving an ephemeral group.
6750 The state which existed when entering the ephemeral is reset."
6751 (if (not (buffer-name (car quit-config)))
6752 (gnus-configure-windows 'group 'force)
6753 (set-buffer (car quit-config))
6754 (cond ((eq major-mode 'gnus-summary-mode)
6755 (gnus-set-global-variables))
6756 ((eq major-mode 'gnus-article-mode)
6757 (save-excursion
6758 ;; The `gnus-summary-buffer' variable may point
6759 ;; to the old summary buffer when using a single
6760 ;; article buffer.
6761 (unless (gnus-buffer-live-p gnus-summary-buffer)
6762 (set-buffer gnus-group-buffer))
6763 (set-buffer gnus-summary-buffer)
6764 (gnus-set-global-variables))))
6765 (if (or (eq (cdr quit-config) 'article)
6766 (eq (cdr quit-config) 'pick))
6767 (progn
6768 ;; The current article may be from the ephemeral group
6769 ;; thus it is best that we reload this article
6770 ;;
6771 ;; If we're exiting from a large digest, this can be
6772 ;; extremely slow. So, it's better not to reload it. -- jh.
6773 ;;(gnus-summary-show-article)
6774 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6775 (gnus-configure-windows 'pick 'force)
6776 (gnus-configure-windows (cdr quit-config) 'force)))
6777 (gnus-configure-windows (cdr quit-config) 'force))
6778 (when (eq major-mode 'gnus-summary-mode)
6779 (gnus-summary-next-subject 1 nil t)
6780 (gnus-summary-recenter)
6781 (gnus-summary-position-point))))
6782
6783 ;;; Dead summaries.
6784
6785 (defvar gnus-dead-summary-mode-map nil)
6786
6787 (unless gnus-dead-summary-mode-map
6788 (setq gnus-dead-summary-mode-map (make-keymap))
6789 (suppress-keymap gnus-dead-summary-mode-map)
6790 (substitute-key-definition
6791 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6792 (dolist (key '("\C-d" "\r" "\177" [delete]))
6793 (define-key gnus-dead-summary-mode-map
6794 key 'gnus-summary-wake-up-the-dead))
6795 (dolist (key '("q" "Q"))
6796 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6797
6798 (defvar gnus-dead-summary-mode nil
6799 "Minor mode for Gnus summary buffers.")
6800
6801 (defun gnus-dead-summary-mode (&optional arg)
6802 "Minor mode for Gnus summary buffers."
6803 (interactive "P")
6804 (when (eq major-mode 'gnus-summary-mode)
6805 (make-local-variable 'gnus-dead-summary-mode)
6806 (setq gnus-dead-summary-mode
6807 (if (null arg) (not gnus-dead-summary-mode)
6808 (> (prefix-numeric-value arg) 0)))
6809 (when gnus-dead-summary-mode
6810 (gnus-add-minor-mode
6811 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6812
6813 (defun gnus-deaden-summary ()
6814 "Make the current summary buffer into a dead summary buffer."
6815 ;; Kill any previous dead summary buffer.
6816 (when (and gnus-dead-summary
6817 (buffer-name gnus-dead-summary))
6818 (save-excursion
6819 (set-buffer gnus-dead-summary)
6820 (when gnus-dead-summary-mode
6821 (kill-buffer (current-buffer)))))
6822 ;; Make this the current dead summary.
6823 (setq gnus-dead-summary (current-buffer))
6824 (gnus-dead-summary-mode 1)
6825 (let ((name (buffer-name)))
6826 (when (string-match "Summary" name)
6827 (rename-buffer
6828 (concat (substring name 0 (match-beginning 0)) "Dead "
6829 (substring name (match-beginning 0)))
6830 t)
6831 (bury-buffer))))
6832
6833 (defun gnus-kill-or-deaden-summary (buffer)
6834 "Kill or deaden the summary BUFFER."
6835 (save-excursion
6836 (when (and (buffer-name buffer)
6837 (not gnus-single-article-buffer))
6838 (save-excursion
6839 (set-buffer buffer)
6840 (gnus-kill-buffer gnus-article-buffer)
6841 (gnus-kill-buffer gnus-original-article-buffer)))
6842 (cond
6843 ;; Kill the buffer.
6844 (gnus-kill-summary-on-exit
6845 (when (and gnus-use-trees
6846 (gnus-buffer-exists-p buffer))
6847 (save-excursion
6848 (set-buffer buffer)
6849 (gnus-tree-close gnus-newsgroup-name)))
6850 (gnus-kill-buffer buffer))
6851 ;; Deaden the buffer.
6852 ((gnus-buffer-exists-p buffer)
6853 (save-excursion
6854 (set-buffer buffer)
6855 (gnus-deaden-summary))))))
6856
6857 (defun gnus-summary-wake-up-the-dead (&rest args)
6858 "Wake up the dead summary buffer."
6859 (interactive)
6860 (gnus-dead-summary-mode -1)
6861 (let ((name (buffer-name)))
6862 (when (string-match "Dead " name)
6863 (rename-buffer
6864 (concat (substring name 0 (match-beginning 0))
6865 (substring name (match-end 0)))
6866 t)))
6867 (gnus-message 3 "This dead summary is now alive again"))
6868
6869 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6870 (defun gnus-summary-fetch-faq (&optional faq-dir)
6871 "Fetch the FAQ for the current group.
6872 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6873 in."
6874 (interactive
6875 (list
6876 (when current-prefix-arg
6877 (completing-read
6878 "FAQ dir: " (and (listp gnus-group-faq-directory)
6879 (mapcar (lambda (file) (list file))
6880 gnus-group-faq-directory))))))
6881 (let (gnus-faq-buffer)
6882 (when (setq gnus-faq-buffer
6883 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6884 (gnus-configure-windows 'summary-faq))))
6885
6886 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6887 (defun gnus-summary-describe-group (&optional force)
6888 "Describe the current newsgroup."
6889 (interactive "P")
6890 (gnus-group-describe-group force gnus-newsgroup-name))
6891
6892 (defun gnus-summary-describe-briefly ()
6893 "Describe summary mode commands briefly."
6894 (interactive)
6895 (gnus-message 6 (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")))
6896
6897 ;; Walking around group mode buffer from summary mode.
6898
6899 (defun gnus-summary-next-group (&optional no-article target-group backward)
6900 "Exit current newsgroup and then select next unread newsgroup.
6901 If prefix argument NO-ARTICLE is non-nil, no article is selected
6902 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6903 previous group instead."
6904 (interactive "P")
6905 ;; Stop pre-fetching.
6906 (gnus-async-halt-prefetch)
6907 (let ((current-group gnus-newsgroup-name)
6908 (current-buffer (current-buffer))
6909 entered)
6910 ;; First we semi-exit this group to update Xrefs and all variables.
6911 ;; We can't do a real exit, because the window conf must remain
6912 ;; the same in case the user is prompted for info, and we don't
6913 ;; want the window conf to change before that...
6914 (gnus-summary-exit t)
6915 (while (not entered)
6916 ;; Then we find what group we are supposed to enter.
6917 (set-buffer gnus-group-buffer)
6918 (gnus-group-jump-to-group current-group)
6919 (setq target-group
6920 (or target-group
6921 (if (eq gnus-keep-same-level 'best)
6922 (gnus-summary-best-group gnus-newsgroup-name)
6923 (gnus-summary-search-group backward gnus-keep-same-level))))
6924 (if (not target-group)
6925 ;; There are no further groups, so we return to the group
6926 ;; buffer.
6927 (progn
6928 (gnus-message 5 "Returning to the group buffer")
6929 (setq entered t)
6930 (when (gnus-buffer-live-p current-buffer)
6931 (set-buffer current-buffer)
6932 (gnus-summary-exit))
6933 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6934 ;; We try to enter the target group.
6935 (gnus-group-jump-to-group target-group)
6936 (let ((unreads (gnus-group-group-unread)))
6937 (if (and (or (eq t unreads)
6938 (and unreads (not (zerop unreads))))
6939 (gnus-summary-read-group
6940 target-group nil no-article
6941 (and (buffer-name current-buffer) current-buffer)
6942 nil backward))
6943 (setq entered t)
6944 (setq current-group target-group
6945 target-group nil)))))))
6946
6947 (defun gnus-summary-prev-group (&optional no-article)
6948 "Exit current newsgroup and then select previous unread newsgroup.
6949 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6950 (interactive "P")
6951 (gnus-summary-next-group no-article nil t))
6952
6953 ;; Walking around summary lines.
6954
6955 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6956 "Go to the first subject satisfying any non-nil constraint.
6957 If UNREAD is non-nil, the article should be unread.
6958 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6959 If UNSEEN is non-nil, the article should be unseen.
6960 Returns the article selected or nil if there are no matching articles."
6961 (interactive "P")
6962 (cond
6963 ;; Empty summary.
6964 ((null gnus-newsgroup-data)
6965 (gnus-message 3 "No articles in the group")
6966 nil)
6967 ;; Pick the first article.
6968 ((not (or unread undownloaded unseen))
6969 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6970 (gnus-data-number (car gnus-newsgroup-data)))
6971 ;; Find the first unread article.
6972 (t
6973 (let ((data gnus-newsgroup-data))
6974 (while (and data
6975 (let ((num (gnus-data-number (car data))))
6976 (or (memq num gnus-newsgroup-unfetched)
6977 (not (or (and unread
6978 (memq num gnus-newsgroup-unreads))
6979 (and undownloaded
6980 (memq num gnus-newsgroup-undownloaded))
6981 (and unseen
6982 (memq num gnus-newsgroup-unseen)))))))
6983 (setq data (cdr data)))
6984 (prog1
6985 (if data
6986 (progn
6987 (goto-char (gnus-data-pos (car data)))
6988 (gnus-data-number (car data)))
6989 (gnus-message 3 "No more%s articles"
6990 (let* ((r (when unread " unread"))
6991 (d (when undownloaded " undownloaded"))
6992 (s (when unseen " unseen"))
6993 (l (delq nil (list r d s))))
6994 (cond ((= 3 (length l))
6995 (concat r "," d ", or" s))
6996 ((= 2 (length l))
6997 (concat (car l) ", or" (cadr l)))
6998 ((= 1 (length l))
6999 (car l))
7000 (t
7001 ""))))
7002 nil
7003 )
7004 (gnus-summary-position-point))))))
7005
7006 (defun gnus-summary-next-subject (n &optional unread dont-display)
7007 "Go to next N'th summary line.
7008 If N is negative, go to the previous N'th subject line.
7009 If UNREAD is non-nil, only unread articles are selected.
7010 The difference between N and the actual number of steps taken is
7011 returned."
7012 (interactive "p")
7013 (let ((backward (< n 0))
7014 (n (abs n)))
7015 (while (and (> n 0)
7016 (if backward
7017 (gnus-summary-find-prev unread)
7018 (gnus-summary-find-next unread)))
7019 (unless (zerop (setq n (1- n)))
7020 (gnus-summary-show-thread)))
7021 (when (/= 0 n)
7022 (gnus-message 7 "No more%s articles"
7023 (if unread " unread" "")))
7024 (unless dont-display
7025 (gnus-summary-recenter)
7026 (gnus-summary-position-point))
7027 n))
7028
7029 (defun gnus-summary-next-unread-subject (n)
7030 "Go to next N'th unread summary line."
7031 (interactive "p")
7032 (gnus-summary-next-subject n t))
7033
7034 (defun gnus-summary-prev-subject (n &optional unread)
7035 "Go to previous N'th summary line.
7036 If optional argument UNREAD is non-nil, only unread article is selected."
7037 (interactive "p")
7038 (gnus-summary-next-subject (- n) unread))
7039
7040 (defun gnus-summary-prev-unread-subject (n)
7041 "Go to previous N'th unread summary line."
7042 (interactive "p")
7043 (gnus-summary-next-subject (- n) t))
7044
7045 (defun gnus-summary-goto-subjects (articles)
7046 "Insert the subject header for ARTICLES in the current buffer."
7047 (save-excursion
7048 (dolist (article articles)
7049 (gnus-summary-goto-subject article t)))
7050 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7051 (gnus-summary-position-point))
7052
7053 (defun gnus-summary-goto-subject (article &optional force silent)
7054 "Go the subject line of ARTICLE.
7055 If FORCE, also allow jumping to articles not currently shown."
7056 (interactive "nArticle number: ")
7057 (unless (numberp article)
7058 (error "Article %s is not a number" article))
7059 (let ((b (point))
7060 (data (gnus-data-find article)))
7061 ;; We read in the article if we have to.
7062 (and (not data)
7063 force
7064 (gnus-summary-insert-subject
7065 article
7066 (if (or (numberp force) (vectorp force)) force)
7067 t)
7068 (setq data (gnus-data-find article)))
7069 (goto-char b)
7070 (if (not data)
7071 (progn
7072 (unless silent
7073 (gnus-message 3 "Can't find article %d" article))
7074 nil)
7075 (let ((pt (gnus-data-pos data)))
7076 (goto-char pt)
7077 (gnus-summary-set-article-display-arrow pt))
7078 (gnus-summary-position-point)
7079 article)))
7080
7081 ;; Walking around summary lines with displaying articles.
7082
7083 (defun gnus-summary-expand-window (&optional arg)
7084 "Make the summary buffer take up the entire Emacs frame.
7085 Given a prefix, will force an `article' buffer configuration."
7086 (interactive "P")
7087 (if arg
7088 (gnus-configure-windows 'article 'force)
7089 (gnus-configure-windows 'summary 'force)))
7090
7091 (defun gnus-summary-display-article (article &optional all-header)
7092 "Display ARTICLE in article buffer."
7093 (when (gnus-buffer-live-p gnus-article-buffer)
7094 (with-current-buffer gnus-article-buffer
7095 (mm-enable-multibyte)))
7096 (gnus-set-global-variables)
7097 (when (gnus-buffer-live-p gnus-article-buffer)
7098 (with-current-buffer gnus-article-buffer
7099 (setq gnus-article-charset gnus-newsgroup-charset)
7100 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7101 (mm-enable-multibyte)))
7102 (if (null article)
7103 nil
7104 (prog1
7105 (if gnus-summary-display-article-function
7106 (funcall gnus-summary-display-article-function article all-header)
7107 (gnus-article-prepare article all-header))
7108 (gnus-run-hooks 'gnus-select-article-hook)
7109 (when (and gnus-current-article
7110 (not (zerop gnus-current-article)))
7111 (gnus-summary-goto-subject gnus-current-article))
7112 (gnus-summary-recenter)
7113 (when (and gnus-use-trees gnus-show-threads)
7114 (gnus-possibly-generate-tree article)
7115 (gnus-highlight-selected-tree article))
7116 ;; Successfully display article.
7117 (gnus-article-set-window-start
7118 (cdr (assq article gnus-newsgroup-bookmarks))))))
7119
7120 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7121 "Select the current article.
7122 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7123 non-nil, the article will be re-fetched even if it already present in
7124 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7125 be displayed."
7126 ;; Make sure we are in the summary buffer to work around bbdb bug.
7127 (unless (eq major-mode 'gnus-summary-mode)
7128 (set-buffer gnus-summary-buffer))
7129 (let ((article (or article (gnus-summary-article-number)))
7130 (all-headers (not (not all-headers))) ;Must be t or nil.
7131 gnus-summary-display-article-function)
7132 (and (not pseudo)
7133 (gnus-summary-article-pseudo-p article)
7134 (error "This is a pseudo-article"))
7135 (save-excursion
7136 (set-buffer gnus-summary-buffer)
7137 (if (or (and gnus-single-article-buffer
7138 (or (null gnus-current-article)
7139 (null gnus-article-current)
7140 (null (get-buffer gnus-article-buffer))
7141 (not (eq article (cdr gnus-article-current)))
7142 (not (equal (car gnus-article-current)
7143 gnus-newsgroup-name))))
7144 (and (not gnus-single-article-buffer)
7145 (or (null gnus-current-article)
7146 (not (eq gnus-current-article article))))
7147 force)
7148 ;; The requested article is different from the current article.
7149 (progn
7150 (gnus-summary-display-article article all-headers)
7151 (when (gnus-buffer-live-p gnus-article-buffer)
7152 (with-current-buffer gnus-article-buffer
7153 (if (not gnus-article-decoded-p) ;; a local variable
7154 (mm-disable-multibyte))))
7155 (gnus-article-set-window-start
7156 (cdr (assq article gnus-newsgroup-bookmarks)))
7157 article)
7158 'old))))
7159
7160 (defun gnus-summary-force-verify-and-decrypt ()
7161 "Display buttons for signed/encrypted parts and verify/decrypt them."
7162 (interactive)
7163 (let ((mm-verify-option 'known)
7164 (mm-decrypt-option 'known)
7165 (gnus-article-emulate-mime t)
7166 (gnus-buttonized-mime-types (append (list "multipart/signed"
7167 "multipart/encrypted")
7168 gnus-buttonized-mime-types)))
7169 (gnus-summary-select-article nil 'force)))
7170
7171 (defun gnus-summary-set-current-mark (&optional current-mark)
7172 "Obsolete function."
7173 nil)
7174
7175 (defun gnus-summary-next-article (&optional unread subject backward push)
7176 "Select the next article.
7177 If UNREAD, only unread articles are selected.
7178 If SUBJECT, only articles with SUBJECT are selected.
7179 If BACKWARD, the previous article is selected instead of the next."
7180 (interactive "P")
7181 (cond
7182 ;; Is there such an article?
7183 ((and (gnus-summary-search-forward unread subject backward)
7184 (or (gnus-summary-display-article (gnus-summary-article-number))
7185 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7186 (gnus-summary-position-point))
7187 ;; If not, we try the first unread, if that is wanted.
7188 ((and subject
7189 gnus-auto-select-same
7190 (gnus-summary-first-unread-article))
7191 (gnus-summary-position-point)
7192 (gnus-message 6 "Wrapped"))
7193 ;; Try to get next/previous article not displayed in this group.
7194 ((and gnus-auto-extend-newsgroup
7195 (not unread) (not subject))
7196 (gnus-summary-goto-article
7197 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7198 nil (count-lines (point-min) (point))))
7199 ;; Go to next/previous group.
7200 (t
7201 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7202 (gnus-summary-jump-to-group gnus-newsgroup-name))
7203 (let ((cmd last-command-char)
7204 (point
7205 (save-excursion
7206 (set-buffer gnus-group-buffer)
7207 (point)))
7208 (group
7209 (if (eq gnus-keep-same-level 'best)
7210 (gnus-summary-best-group gnus-newsgroup-name)
7211 (gnus-summary-search-group backward gnus-keep-same-level))))
7212 ;; For some reason, the group window gets selected. We change
7213 ;; it back.
7214 (select-window (get-buffer-window (current-buffer)))
7215 ;; Select next unread newsgroup automagically.
7216 (cond
7217 ((or (not gnus-auto-select-next)
7218 (not cmd))
7219 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7220 ((or (eq gnus-auto-select-next 'quietly)
7221 (and (eq gnus-auto-select-next 'slightly-quietly)
7222 push)
7223 (and (eq gnus-auto-select-next 'almost-quietly)
7224 (gnus-summary-last-article-p)))
7225 ;; Select quietly.
7226 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7227 (gnus-summary-exit)
7228 (gnus-message 7 "No more%s articles (%s)..."
7229 (if unread " unread" "")
7230 (if group (concat "selecting " group)
7231 "exiting"))
7232 (gnus-summary-next-group nil group backward)))
7233 (t
7234 (when (gnus-key-press-event-p last-input-event)
7235 (gnus-summary-walk-group-buffer
7236 gnus-newsgroup-name cmd unread backward point))))))))
7237
7238 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7239 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7240 (?\C-p (gnus-group-prev-unread-group 1))))
7241 (cursor-in-echo-area t)
7242 keve key group ended prompt)
7243 (save-excursion
7244 (set-buffer gnus-group-buffer)
7245 (goto-char start)
7246 (setq group
7247 (if (eq gnus-keep-same-level 'best)
7248 (gnus-summary-best-group gnus-newsgroup-name)
7249 (gnus-summary-search-group backward gnus-keep-same-level))))
7250 (while (not ended)
7251 (setq prompt
7252 (format
7253 "No more%s articles%s " (if unread " unread" "")
7254 (if (and group
7255 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7256 (format " (Type %s for %s [%s])"
7257 (single-key-description cmd)
7258 (gnus-group-decoded-name group)
7259 (car (gnus-gethash group gnus-newsrc-hashtb)))
7260 (format " (Type %s to exit %s)"
7261 (single-key-description cmd)
7262 (gnus-group-decoded-name gnus-newsgroup-name)))))
7263 ;; Confirm auto selection.
7264 (setq key (car (setq keve (gnus-read-event-char prompt)))
7265 ended t)
7266 (cond
7267 ((assq key keystrokes)
7268 (let ((obuf (current-buffer)))
7269 (switch-to-buffer gnus-group-buffer)
7270 (when group
7271 (gnus-group-jump-to-group group))
7272 (eval (cadr (assq key keystrokes)))
7273 (setq group (gnus-group-group-name))
7274 (switch-to-buffer obuf))
7275 (setq ended nil))
7276 ((equal key cmd)
7277 (if (or (not group)
7278 (gnus-ephemeral-group-p gnus-newsgroup-name))
7279 (gnus-summary-exit)
7280 (gnus-summary-next-group nil group backward)))
7281 (t
7282 (push (cdr keve) unread-command-events))))))
7283
7284 (defun gnus-summary-next-unread-article ()
7285 "Select unread article after current one."
7286 (interactive)
7287 (gnus-summary-next-article
7288 (or (not (eq gnus-summary-goto-unread 'never))
7289 (gnus-summary-last-article-p (gnus-summary-article-number)))
7290 (and gnus-auto-select-same
7291 (gnus-summary-article-subject))))
7292
7293 (defun gnus-summary-prev-article (&optional unread subject)
7294 "Select the article after the current one.
7295 If UNREAD is non-nil, only unread articles are selected."
7296 (interactive "P")
7297 (gnus-summary-next-article unread subject t))
7298
7299 (defun gnus-summary-prev-unread-article ()
7300 "Select unread article before current one."
7301 (interactive)
7302 (gnus-summary-prev-article
7303 (or (not (eq gnus-summary-goto-unread 'never))
7304 (gnus-summary-first-article-p (gnus-summary-article-number)))
7305 (and gnus-auto-select-same
7306 (gnus-summary-article-subject))))
7307
7308 (defun gnus-summary-next-page (&optional lines circular stop)
7309 "Show next page of the selected article.
7310 If at the end of the current article, select the next article.
7311 LINES says how many lines should be scrolled up.
7312
7313 If CIRCULAR is non-nil, go to the start of the article instead of
7314 selecting the next article when reaching the end of the current
7315 article.
7316
7317 If STOP is non-nil, just stop when reaching the end of the message.
7318
7319 Also see the variable `gnus-article-skip-boring'."
7320 (interactive "P")
7321 (setq gnus-summary-buffer (current-buffer))
7322 (gnus-set-global-variables)
7323 (let ((article (gnus-summary-article-number))
7324 (article-window (get-buffer-window gnus-article-buffer t))
7325 endp)
7326 ;; If the buffer is empty, we have no article.
7327 (unless article
7328 (error "No article to select"))
7329 (gnus-configure-windows 'article)
7330 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7331 (if (and (eq gnus-summary-goto-unread 'never)
7332 (not (gnus-summary-last-article-p article)))
7333 (gnus-summary-next-article)
7334 (gnus-summary-next-unread-article))
7335 (if (or (null gnus-current-article)
7336 (null gnus-article-current)
7337 (/= article (cdr gnus-article-current))
7338 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7339 ;; Selected subject is different from current article's.
7340 (gnus-summary-display-article article)
7341 (when article-window
7342 (gnus-eval-in-buffer-window gnus-article-buffer
7343 (setq endp (or (gnus-article-next-page lines)
7344 (gnus-article-only-boring-p))))
7345 (when endp
7346 (cond (stop
7347 (gnus-message 3 "End of message"))
7348 (circular
7349 (gnus-summary-beginning-of-article))
7350 (lines
7351 (gnus-message 3 "End of message"))
7352 ((null lines)
7353 (if (and (eq gnus-summary-goto-unread 'never)
7354 (not (gnus-summary-last-article-p article)))
7355 (gnus-summary-next-article)
7356 (gnus-summary-next-unread-article))))))))
7357 (gnus-summary-recenter)
7358 (gnus-summary-position-point)))
7359
7360 (defun gnus-summary-prev-page (&optional lines move)
7361 "Show previous page of selected article.
7362 Argument LINES specifies lines to be scrolled down.
7363 If MOVE, move to the previous unread article if point is at
7364 the beginning of the buffer."
7365 (interactive "P")
7366 (let ((article (gnus-summary-article-number))
7367 (article-window (get-buffer-window gnus-article-buffer t))
7368 endp)
7369 (gnus-configure-windows 'article)
7370 (if (or (null gnus-current-article)
7371 (null gnus-article-current)
7372 (/= article (cdr gnus-article-current))
7373 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7374 ;; Selected subject is different from current article's.
7375 (gnus-summary-display-article article)
7376 (gnus-summary-recenter)
7377 (when article-window
7378 (gnus-eval-in-buffer-window gnus-article-buffer
7379 (setq endp (gnus-article-prev-page lines)))
7380 (when (and move endp)
7381 (cond (lines
7382 (gnus-message 3 "Beginning of message"))
7383 ((null lines)
7384 (if (and (eq gnus-summary-goto-unread 'never)
7385 (not (gnus-summary-first-article-p article)))
7386 (gnus-summary-prev-article)
7387 (gnus-summary-prev-unread-article))))))))
7388 (gnus-summary-position-point))
7389
7390 (defun gnus-summary-prev-page-or-article (&optional lines)
7391 "Show previous page of selected article.
7392 Argument LINES specifies lines to be scrolled down.
7393 If at the beginning of the article, go to the next article."
7394 (interactive "P")
7395 (gnus-summary-prev-page lines t))
7396
7397 (defun gnus-summary-scroll-up (lines)
7398 "Scroll up (or down) one line current article.
7399 Argument LINES specifies lines to be scrolled up (or down if negative)."
7400 (interactive "p")
7401 (gnus-configure-windows 'article)
7402 (gnus-summary-show-thread)
7403 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7404 (gnus-eval-in-buffer-window gnus-article-buffer
7405 (cond ((> lines 0)
7406 (when (gnus-article-next-page lines)
7407 (gnus-message 3 "End of message")))
7408 ((< lines 0)
7409 (gnus-article-prev-page (- lines))))))
7410 (gnus-summary-recenter)
7411 (gnus-summary-position-point))
7412
7413 (defun gnus-summary-scroll-down (lines)
7414 "Scroll down (or up) one line current article.
7415 Argument LINES specifies lines to be scrolled down (or up if negative)."
7416 (interactive "p")
7417 (gnus-summary-scroll-up (- lines)))
7418
7419 (defun gnus-summary-next-same-subject ()
7420 "Select next article which has the same subject as current one."
7421 (interactive)
7422 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7423
7424 (defun gnus-summary-prev-same-subject ()
7425 "Select previous article which has the same subject as current one."
7426 (interactive)
7427 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7428
7429 (defun gnus-summary-next-unread-same-subject ()
7430 "Select next unread article which has the same subject as current one."
7431 (interactive)
7432 (gnus-summary-next-article t (gnus-summary-article-subject)))
7433
7434 (defun gnus-summary-prev-unread-same-subject ()
7435 "Select previous unread article which has the same subject as current one."
7436 (interactive)
7437 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7438
7439 (defun gnus-summary-first-unread-article ()
7440 "Select the first unread article.
7441 Return nil if there are no unread articles."
7442 (interactive)
7443 (prog1
7444 (when (gnus-summary-first-subject t)
7445 (gnus-summary-show-thread)
7446 (gnus-summary-first-subject t)
7447 (gnus-summary-display-article (gnus-summary-article-number)))
7448 (gnus-summary-position-point)))
7449
7450 (defun gnus-summary-first-unread-subject ()
7451 "Place the point on the subject line of the first unread article.
7452 Return nil if there are no unread articles."
7453 (interactive)
7454 (prog1
7455 (when (gnus-summary-first-subject t)
7456 (gnus-summary-show-thread)
7457 (gnus-summary-first-subject t))
7458 (gnus-summary-position-point)))
7459
7460 (defun gnus-summary-first-unseen-subject ()
7461 "Place the point on the subject line of the first unseen article.
7462 Return nil if there are no unseen articles."
7463 (interactive)
7464 (prog1
7465 (when (gnus-summary-first-subject nil nil t)
7466 (gnus-summary-show-thread)
7467 (gnus-summary-first-subject nil nil t))
7468 (gnus-summary-position-point)))
7469
7470 (defun gnus-summary-first-unseen-or-unread-subject ()
7471 "Place the point on the subject line of the first unseen article or,
7472 if all article have been seen, on the subject line of the first unread
7473 article."
7474 (interactive)
7475 (prog1
7476 (unless (when (gnus-summary-first-subject nil nil t)
7477 (gnus-summary-show-thread)
7478 (gnus-summary-first-subject nil nil t))
7479 (when (gnus-summary-first-subject t)
7480 (gnus-summary-show-thread)
7481 (gnus-summary-first-subject t)))
7482 (gnus-summary-position-point)))
7483
7484 (defun gnus-summary-first-article ()
7485 "Select the first article.
7486 Return nil if there are no articles."
7487 (interactive)
7488 (prog1
7489 (when (gnus-summary-first-subject)
7490 (gnus-summary-show-thread)
7491 (gnus-summary-first-subject)
7492 (gnus-summary-display-article (gnus-summary-article-number)))
7493 (gnus-summary-position-point)))
7494
7495 (defun gnus-summary-best-unread-article (&optional arg)
7496 "Select the unread article with the highest score.
7497 If given a prefix argument, select the next unread article that has a
7498 score higher than the default score."
7499 (interactive "P")
7500 (let ((article (if arg
7501 (gnus-summary-better-unread-subject)
7502 (gnus-summary-best-unread-subject))))
7503 (if article
7504 (gnus-summary-goto-article article)
7505 (error "No unread articles"))))
7506
7507 (defun gnus-summary-best-unread-subject ()
7508 "Select the unread subject with the highest score."
7509 (interactive)
7510 (let ((best -1000000)
7511 (data gnus-newsgroup-data)
7512 article score)
7513 (while data
7514 (and (gnus-data-unread-p (car data))
7515 (> (setq score
7516 (gnus-summary-article-score (gnus-data-number (car data))))
7517 best)
7518 (setq best score
7519 article (gnus-data-number (car data))))
7520 (setq data (cdr data)))
7521 (when article
7522 (gnus-summary-goto-subject article))
7523 (gnus-summary-position-point)
7524 article))
7525
7526 (defun gnus-summary-better-unread-subject ()
7527 "Select the first unread subject that has a score over the default score."
7528 (interactive)
7529 (let ((data gnus-newsgroup-data)
7530 article score)
7531 (while (and (setq article (gnus-data-number (car data)))
7532 (or (gnus-data-read-p (car data))
7533 (not (> (gnus-summary-article-score article)
7534 gnus-summary-default-score))))
7535 (setq data (cdr data)))
7536 (when article
7537 (gnus-summary-goto-subject article))
7538 (gnus-summary-position-point)
7539 article))
7540
7541 (defun gnus-summary-last-subject ()
7542 "Go to the last displayed subject line in the group."
7543 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7544 (when article
7545 (gnus-summary-goto-subject article))))
7546
7547 (defun gnus-summary-goto-article (article &optional all-headers force)
7548 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7549 If ALL-HEADERS is non-nil, no header lines are hidden.
7550 If FORCE, go to the article even if it isn't displayed. If FORCE
7551 is a number, it is the line the article is to be displayed on."
7552 (interactive
7553 (list
7554 (completing-read
7555 "Article number or Message-ID: "
7556 (mapcar (lambda (number) (list (int-to-string number)))
7557 gnus-newsgroup-limit))
7558 current-prefix-arg
7559 t))
7560 (prog1
7561 (if (and (stringp article)
7562 (string-match "@\\|%40" article))
7563 (gnus-summary-refer-article article)
7564 (when (stringp article)
7565 (setq article (string-to-number article)))
7566 (if (gnus-summary-goto-subject article force)
7567 (gnus-summary-display-article article all-headers)
7568 (gnus-message 4 "Couldn't go to article %s" article) nil))
7569 (gnus-summary-position-point)))
7570
7571 (defun gnus-summary-goto-last-article ()
7572 "Go to the previously read article."
7573 (interactive)
7574 (prog1
7575 (when gnus-last-article
7576 (gnus-summary-goto-article gnus-last-article nil t))
7577 (gnus-summary-position-point)))
7578
7579 (defun gnus-summary-pop-article (number)
7580 "Pop one article off the history and go to the previous.
7581 NUMBER articles will be popped off."
7582 (interactive "p")
7583 (let (to)
7584 (setq gnus-newsgroup-history
7585 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7586 (if to
7587 (gnus-summary-goto-article (car to) nil t)
7588 (error "Article history empty")))
7589 (gnus-summary-position-point))
7590
7591 ;; Summary commands and functions for limiting the summary buffer.
7592
7593 (defun gnus-summary-limit-to-articles (n)
7594 "Limit the summary buffer to the next N articles.
7595 If not given a prefix, use the process marked articles instead."
7596 (interactive "P")
7597 (prog1
7598 (let ((articles (gnus-summary-work-articles n)))
7599 (setq gnus-newsgroup-processable nil)
7600 (gnus-summary-limit articles))
7601 (gnus-summary-position-point)))
7602
7603 (defun gnus-summary-pop-limit (&optional total)
7604 "Restore the previous limit.
7605 If given a prefix, remove all limits."
7606 (interactive "P")
7607 (when total
7608 (setq gnus-newsgroup-limits
7609 (list (mapcar (lambda (h) (mail-header-number h))
7610 gnus-newsgroup-headers))))
7611 (unless gnus-newsgroup-limits
7612 (error "No limit to pop"))
7613 (prog1
7614 (gnus-summary-limit nil 'pop)
7615 (gnus-summary-position-point)))
7616
7617 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7618 "Limit the summary buffer to articles that have subjects that match a regexp.
7619 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7620 (interactive
7621 (list (read-string (if current-prefix-arg
7622 "Exclude subject (regexp): "
7623 "Limit to subject (regexp): "))
7624 nil current-prefix-arg))
7625 (unless header
7626 (setq header "subject"))
7627 (when (not (equal "" subject))
7628 (prog1
7629 (let ((articles (gnus-summary-find-matching
7630 (or header "subject") subject 'all nil nil
7631 not-matching)))
7632 (unless articles
7633 (error "Found no matches for \"%s\"" subject))
7634 (gnus-summary-limit articles))
7635 (gnus-summary-position-point))))
7636
7637 (defun gnus-summary-limit-to-author (from &optional not-matching)
7638 "Limit the summary buffer to articles that have authors that match a regexp.
7639 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7640 (interactive
7641 (list (read-string (if current-prefix-arg
7642 "Exclude author (regexp): "
7643 "Limit to author (regexp): "))
7644 current-prefix-arg))
7645 (gnus-summary-limit-to-subject from "from" not-matching))
7646
7647 (defun gnus-summary-limit-to-age (age &optional younger-p)
7648 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7649 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7650 articles that are younger than AGE days."
7651 (interactive
7652 (let ((younger current-prefix-arg)
7653 (days-got nil)
7654 days)
7655 (while (not days-got)
7656 (setq days (if younger
7657 (read-string "Limit to articles younger than (in days, older when negative): ")
7658 (read-string
7659 "Limit to articles older than (in days, younger when negative): ")))
7660 (when (> (length days) 0)
7661 (setq days (read days)))
7662 (if (numberp days)
7663 (progn
7664 (setq days-got t)
7665 (if (< days 0)
7666 (progn
7667 (setq younger (not younger))
7668 (setq days (* days -1)))))
7669 (message "Please enter a number.")
7670 (sleep-for 1)))
7671 (list days younger)))
7672 (prog1
7673 (let ((data gnus-newsgroup-data)
7674 (cutoff (days-to-time age))
7675 articles d date is-younger)
7676 (while (setq d (pop data))
7677 (when (and (vectorp (gnus-data-header d))
7678 (setq date (mail-header-date (gnus-data-header d))))
7679 (setq is-younger (time-less-p
7680 (time-since (condition-case ()
7681 (date-to-time date)
7682 (error '(0 0))))
7683 cutoff))
7684 (when (if younger-p
7685 is-younger
7686 (not is-younger))
7687 (push (gnus-data-number d) articles))))
7688 (gnus-summary-limit (nreverse articles)))
7689 (gnus-summary-position-point)))
7690
7691 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7692 "Limit the summary buffer to articles that match an 'extra' header."
7693 (interactive
7694 (let ((header
7695 (intern
7696 (gnus-completing-read-with-default
7697 (symbol-name (car gnus-extra-headers))
7698 (if current-prefix-arg
7699 "Exclude extra header:"
7700 "Limit extra header:")
7701 (mapcar (lambda (x)
7702 (cons (symbol-name x) x))
7703 gnus-extra-headers)
7704 nil
7705 t))))
7706 (list header
7707 (read-string (format "%s header %s (regexp): "
7708 (if current-prefix-arg "Exclude" "Limit to")
7709 header))
7710 current-prefix-arg)))
7711 (when (not (equal "" regexp))
7712 (prog1
7713 (let ((articles (gnus-summary-find-matching
7714 (cons 'extra header) regexp 'all nil nil
7715 not-matching)))
7716 (unless articles
7717 (error "Found no matches for \"%s\"" regexp))
7718 (gnus-summary-limit articles))
7719 (gnus-summary-position-point))))
7720
7721 (defun gnus-summary-limit-to-display-predicate ()
7722 "Limit the summary buffer to the predicated in the `display' group parameter."
7723 (interactive)
7724 (unless gnus-newsgroup-display
7725 (error "There is no `display' group parameter"))
7726 (let (articles)
7727 (dolist (number gnus-newsgroup-articles)
7728 (when (funcall gnus-newsgroup-display)
7729 (push number articles)))
7730 (gnus-summary-limit articles))
7731 (gnus-summary-position-point))
7732
7733 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7734 (make-obsolete
7735 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7736
7737 (defun gnus-summary-limit-to-unread (&optional all)
7738 "Limit the summary buffer to articles that are not marked as read.
7739 If ALL is non-nil, limit strictly to unread articles."
7740 (interactive "P")
7741 (if all
7742 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7743 (gnus-summary-limit-to-marks
7744 ;; Concat all the marks that say that an article is read and have
7745 ;; those removed.
7746 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7747 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7748 gnus-low-score-mark gnus-expirable-mark
7749 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7750 gnus-duplicate-mark gnus-souped-mark)
7751 'reverse)))
7752
7753 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7754 (make-obsolete 'gnus-summary-delete-marked-with
7755 'gnus-summary-limit-exclude-marks)
7756
7757 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7758 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7759 If REVERSE, limit the summary buffer to articles that are marked
7760 with MARKS. MARKS can either be a string of marks or a list of marks.
7761 Returns how many articles were removed."
7762 (interactive "sMarks: ")
7763 (gnus-summary-limit-to-marks marks t))
7764
7765 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7766 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7767 If REVERSE (the prefix), limit the summary buffer to articles that are
7768 not marked with MARKS. MARKS can either be a string of marks or a
7769 list of marks.
7770 Returns how many articles were removed."
7771 (interactive "sMarks: \nP")
7772 (prog1
7773 (let ((data gnus-newsgroup-data)
7774 (marks (if (listp marks) marks
7775 (append marks nil))) ; Transform to list.
7776 articles)
7777 (while data
7778 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7779 (memq (gnus-data-mark (car data)) marks))
7780 (push (gnus-data-number (car data)) articles))
7781 (setq data (cdr data)))
7782 (gnus-summary-limit articles))
7783 (gnus-summary-position-point)))
7784
7785 (defun gnus-summary-limit-to-score (score)
7786 "Limit to articles with score at or above SCORE."
7787 (interactive "NLimit to articles with score of at least: ")
7788 (let ((data gnus-newsgroup-data)
7789 articles)
7790 (while data
7791 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7792 score)
7793 (push (gnus-data-number (car data)) articles))
7794 (setq data (cdr data)))
7795 (prog1
7796 (gnus-summary-limit articles)
7797 (gnus-summary-position-point))))
7798
7799 (defun gnus-summary-limit-to-unseen ()
7800 "Limit to unseen articles."
7801 (interactive)
7802 (prog1
7803 (gnus-summary-limit gnus-newsgroup-unseen)
7804 (gnus-summary-position-point)))
7805
7806 (defun gnus-summary-limit-include-thread (id)
7807 "Display all the hidden articles that is in the thread with ID in it.
7808 When called interactively, ID is the Message-ID of the current
7809 article."
7810 (interactive (list (mail-header-id (gnus-summary-article-header))))
7811 (let ((articles (gnus-articles-in-thread
7812 (gnus-id-to-thread (gnus-root-id id)))))
7813 (prog1
7814 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7815 (gnus-summary-limit-include-matching-articles
7816 "subject"
7817 (regexp-quote (gnus-simplify-subject-re
7818 (mail-header-subject (gnus-id-to-header id)))))
7819 (gnus-summary-position-point))))
7820
7821 (defun gnus-summary-limit-include-matching-articles (header regexp)
7822 "Display all the hidden articles that have HEADERs that match REGEXP."
7823 (interactive (list (read-string "Match on header: ")
7824 (read-string "Regexp: ")))
7825 (let ((articles (gnus-find-matching-articles header regexp)))
7826 (prog1
7827 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7828 (gnus-summary-position-point))))
7829
7830 (defun gnus-summary-insert-dormant-articles ()
7831 "Insert all the dormant articles for this group into the current buffer."
7832 (interactive)
7833 (let ((gnus-verbose (max 6 gnus-verbose)))
7834 (if (not gnus-newsgroup-dormant)
7835 (gnus-message 3 "No cached articles for this group")
7836 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7837
7838 (defun gnus-summary-limit-include-dormant ()
7839 "Display all the hidden articles that are marked as dormant.
7840 Note that this command only works on a subset of the articles currently
7841 fetched for this group."
7842 (interactive)
7843 (unless gnus-newsgroup-dormant
7844 (error "There are no dormant articles in this group"))
7845 (prog1
7846 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7847 (gnus-summary-position-point)))
7848
7849 (defun gnus-summary-limit-exclude-dormant ()
7850 "Hide all dormant articles."
7851 (interactive)
7852 (prog1
7853 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7854 (gnus-summary-position-point)))
7855
7856 (defun gnus-summary-limit-exclude-childless-dormant ()
7857 "Hide all dormant articles that have no children."
7858 (interactive)
7859 (let ((data (gnus-data-list t))
7860 articles d children)
7861 ;; Find all articles that are either not dormant or have
7862 ;; children.
7863 (while (setq d (pop data))
7864 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7865 (and (setq children
7866 (gnus-article-children (gnus-data-number d)))
7867 (let (found)
7868 (while children
7869 (when (memq (car children) articles)
7870 (setq children nil
7871 found t))
7872 (pop children))
7873 found)))
7874 (push (gnus-data-number d) articles)))
7875 ;; Do the limiting.
7876 (prog1
7877 (gnus-summary-limit articles)
7878 (gnus-summary-position-point))))
7879
7880 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7881 "Mark all unread excluded articles as read.
7882 If ALL, mark even excluded ticked and dormants as read."
7883 (interactive "P")
7884 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7885 (let ((articles (gnus-sorted-ndifference
7886 (sort
7887 (mapcar (lambda (h) (mail-header-number h))
7888 gnus-newsgroup-headers)
7889 '<)
7890 gnus-newsgroup-limit))
7891 article)
7892 (setq gnus-newsgroup-unreads
7893 (gnus-sorted-intersection gnus-newsgroup-unreads
7894 gnus-newsgroup-limit))
7895 (if all
7896 (setq gnus-newsgroup-dormant nil
7897 gnus-newsgroup-marked nil
7898 gnus-newsgroup-reads
7899 (nconc
7900 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7901 gnus-newsgroup-reads))
7902 (while (setq article (pop articles))
7903 (unless (or (memq article gnus-newsgroup-dormant)
7904 (memq article gnus-newsgroup-marked))
7905 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7906
7907 (defun gnus-summary-limit (articles &optional pop)
7908 (if pop
7909 ;; We pop the previous limit off the stack and use that.
7910 (setq articles (car gnus-newsgroup-limits)
7911 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7912 ;; We use the new limit, so we push the old limit on the stack.
7913 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7914 ;; Set the limit.
7915 (setq gnus-newsgroup-limit articles)
7916 (let ((total (length gnus-newsgroup-data))
7917 (data (gnus-data-find-list (gnus-summary-article-number)))
7918 (gnus-summary-mark-below nil) ; Inhibit this.
7919 found)
7920 ;; This will do all the work of generating the new summary buffer
7921 ;; according to the new limit.
7922 (gnus-summary-prepare)
7923 ;; Hide any threads, possibly.
7924 (gnus-summary-maybe-hide-threads)
7925 ;; Try to return to the article you were at, or one in the
7926 ;; neighborhood.
7927 (when data
7928 ;; We try to find some article after the current one.
7929 (while data
7930 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7931 (setq data nil
7932 found t))
7933 (setq data (cdr data))))
7934 (unless found
7935 ;; If there is no data, that means that we were after the last
7936 ;; article. The same goes when we can't find any articles
7937 ;; after the current one.
7938 (goto-char (point-max))
7939 (gnus-summary-find-prev))
7940 (gnus-set-mode-line 'summary)
7941 ;; We return how many articles were removed from the summary
7942 ;; buffer as a result of the new limit.
7943 (- total (length gnus-newsgroup-data))))
7944
7945 (defsubst gnus-invisible-cut-children (threads)
7946 (let ((num 0))
7947 (while threads
7948 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7949 (incf num))
7950 (pop threads))
7951 (< num 2)))
7952
7953 (defsubst gnus-cut-thread (thread)
7954 "Go forwards in the thread until we find an article that we want to display."
7955 (when (or (eq gnus-fetch-old-headers 'some)
7956 (eq gnus-fetch-old-headers 'invisible)
7957 (numberp gnus-fetch-old-headers)
7958 (eq gnus-build-sparse-threads 'some)
7959 (eq gnus-build-sparse-threads 'more))
7960 ;; Deal with old-fetched headers and sparse threads.
7961 (while (and
7962 thread
7963 (or
7964 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7965 (gnus-summary-article-ancient-p
7966 (mail-header-number (car thread))))
7967 (if (or (<= (length (cdr thread)) 1)
7968 (eq gnus-fetch-old-headers 'invisible))
7969 (setq gnus-newsgroup-limit
7970 (delq (mail-header-number (car thread))
7971 gnus-newsgroup-limit)
7972 thread (cadr thread))
7973 (when (gnus-invisible-cut-children (cdr thread))
7974 (let ((th (cdr thread)))
7975 (while th
7976 (if (memq (mail-header-number (caar th))
7977 gnus-newsgroup-limit)
7978 (setq thread (car th)
7979 th nil)
7980 (setq th (cdr th))))))))))
7981 thread)
7982
7983 (defun gnus-cut-threads (threads)
7984 "Cut off all uninteresting articles from the beginning of THREADS."
7985 (when (or (eq gnus-fetch-old-headers 'some)
7986 (eq gnus-fetch-old-headers 'invisible)
7987 (numberp gnus-fetch-old-headers)
7988 (eq gnus-build-sparse-threads 'some)
7989 (eq gnus-build-sparse-threads 'more))
7990 (let ((th threads))
7991 (while th
7992 (setcar th (gnus-cut-thread (car th)))
7993 (setq th (cdr th)))))
7994 ;; Remove nixed out threads.
7995 (delq nil threads))
7996
7997 (defun gnus-summary-initial-limit (&optional show-if-empty)
7998 "Figure out what the initial limit is supposed to be on group entry.
7999 This entails weeding out unwanted dormants, low-scored articles,
8000 fetch-old-headers verbiage, and so on."
8001 ;; Most groups have nothing to remove.
8002 (if (or gnus-inhibit-limiting
8003 (and (null gnus-newsgroup-dormant)
8004 (eq gnus-newsgroup-display 'gnus-not-ignore)
8005 (not (eq gnus-fetch-old-headers 'some))
8006 (not (numberp gnus-fetch-old-headers))
8007 (not (eq gnus-fetch-old-headers 'invisible))
8008 (null gnus-summary-expunge-below)
8009 (not (eq gnus-build-sparse-threads 'some))
8010 (not (eq gnus-build-sparse-threads 'more))
8011 (null gnus-thread-expunge-below)
8012 (not gnus-use-nocem)))
8013 () ; Do nothing.
8014 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8015 (setq gnus-newsgroup-limit nil)
8016 (mapatoms
8017 (lambda (node)
8018 (unless (car (symbol-value node))
8019 ;; These threads have no parents -- they are roots.
8020 (let ((nodes (cdr (symbol-value node)))
8021 thread)
8022 (while nodes
8023 (if (and gnus-thread-expunge-below
8024 (< (gnus-thread-total-score (car nodes))
8025 gnus-thread-expunge-below))
8026 (gnus-expunge-thread (pop nodes))
8027 (setq thread (pop nodes))
8028 (gnus-summary-limit-children thread))))))
8029 gnus-newsgroup-dependencies)
8030 ;; If this limitation resulted in an empty group, we might
8031 ;; pop the previous limit and use it instead.
8032 (when (and (not gnus-newsgroup-limit)
8033 show-if-empty)
8034 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8035 gnus-newsgroup-limit))
8036
8037 (defun gnus-summary-limit-children (thread)
8038 "Return 1 if this subthread is visible and 0 if it is not."
8039 ;; First we get the number of visible children to this thread. This
8040 ;; is done by recursing down the thread using this function, so this
8041 ;; will really go down to a leaf article first, before slowly
8042 ;; working its way up towards the root.
8043 (when thread
8044 (let* ((max-lisp-eval-depth 5000)
8045 (children
8046 (if (cdr thread)
8047 (apply '+ (mapcar 'gnus-summary-limit-children
8048 (cdr thread)))
8049 0))
8050 (number (mail-header-number (car thread)))
8051 score)
8052 (if (and
8053 (not (memq number gnus-newsgroup-marked))
8054 (or
8055 ;; If this article is dormant and has absolutely no visible
8056 ;; children, then this article isn't visible.
8057 (and (memq number gnus-newsgroup-dormant)
8058 (zerop children))
8059 ;; If this is "fetch-old-headered" and there is no
8060 ;; visible children, then we don't want this article.
8061 (and (or (eq gnus-fetch-old-headers 'some)
8062 (numberp gnus-fetch-old-headers))
8063 (gnus-summary-article-ancient-p number)
8064 (zerop children))
8065 ;; If this is "fetch-old-headered" and `invisible', then
8066 ;; we don't want this article.
8067 (and (eq gnus-fetch-old-headers 'invisible)
8068 (gnus-summary-article-ancient-p number))
8069 ;; If this is a sparsely inserted article with no children,
8070 ;; we don't want it.
8071 (and (eq gnus-build-sparse-threads 'some)
8072 (gnus-summary-article-sparse-p number)
8073 (zerop children))
8074 ;; If we use expunging, and this article is really
8075 ;; low-scored, then we don't want this article.
8076 (when (and gnus-summary-expunge-below
8077 (< (setq score
8078 (or (cdr (assq number gnus-newsgroup-scored))
8079 gnus-summary-default-score))
8080 gnus-summary-expunge-below))
8081 ;; We increase the expunge-tally here, but that has
8082 ;; nothing to do with the limits, really.
8083 (incf gnus-newsgroup-expunged-tally)
8084 ;; We also mark as read here, if that's wanted.
8085 (when (and gnus-summary-mark-below
8086 (< score gnus-summary-mark-below))
8087 (setq gnus-newsgroup-unreads
8088 (delq number gnus-newsgroup-unreads))
8089 (if gnus-newsgroup-auto-expire
8090 (push number gnus-newsgroup-expirable)
8091 (push (cons number gnus-low-score-mark)
8092 gnus-newsgroup-reads)))
8093 t)
8094 ;; Do the `display' group parameter.
8095 (and gnus-newsgroup-display
8096 (not (funcall gnus-newsgroup-display)))
8097 ;; Check NoCeM things.
8098 (if (and gnus-use-nocem
8099 (gnus-nocem-unwanted-article-p
8100 (mail-header-id (car thread))))
8101 (progn
8102 (setq gnus-newsgroup-unreads
8103 (delq number gnus-newsgroup-unreads))
8104 t))))
8105 ;; Nope, invisible article.
8106 0
8107 ;; Ok, this article is to be visible, so we add it to the limit
8108 ;; and return 1.
8109 (push number gnus-newsgroup-limit)
8110 1))))
8111
8112 (defun gnus-expunge-thread (thread)
8113 "Mark all articles in THREAD as read."
8114 (let* ((number (mail-header-number (car thread))))
8115 (incf gnus-newsgroup-expunged-tally)
8116 ;; We also mark as read here, if that's wanted.
8117 (setq gnus-newsgroup-unreads
8118 (delq number gnus-newsgroup-unreads))
8119 (if gnus-newsgroup-auto-expire
8120 (push number gnus-newsgroup-expirable)
8121 (push (cons number gnus-low-score-mark)
8122 gnus-newsgroup-reads)))
8123 ;; Go recursively through all subthreads.
8124 (mapcar 'gnus-expunge-thread (cdr thread)))
8125
8126 ;; Summary article oriented commands
8127
8128 (defun gnus-summary-refer-parent-article (n)
8129 "Refer parent article N times.
8130 If N is negative, go to ancestor -N instead.
8131 The difference between N and the number of articles fetched is returned."
8132 (interactive "p")
8133 (let ((skip 1)
8134 error header ref)
8135 (when (not (natnump n))
8136 (setq skip (abs n)
8137 n 1))
8138 (while (and (> n 0)
8139 (not error))
8140 (setq header (gnus-summary-article-header))
8141 (if (and (eq (mail-header-number header)
8142 (cdr gnus-article-current))
8143 (equal gnus-newsgroup-name
8144 (car gnus-article-current)))
8145 ;; If we try to find the parent of the currently
8146 ;; displayed article, then we take a look at the actual
8147 ;; References header, since this is slightly more
8148 ;; reliable than the References field we got from the
8149 ;; server.
8150 (save-excursion
8151 (set-buffer gnus-original-article-buffer)
8152 (nnheader-narrow-to-headers)
8153 (unless (setq ref (message-fetch-field "references"))
8154 (when (setq ref (message-fetch-field "in-reply-to"))
8155 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8156 (widen))
8157 (setq ref
8158 ;; It's not the current article, so we take a bet on
8159 ;; the value we got from the server.
8160 (mail-header-references header)))
8161 (if (and ref
8162 (not (equal ref "")))
8163 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8164 (gnus-message 1 "Couldn't find parent"))
8165 (gnus-message 1 "No references in article %d"
8166 (gnus-summary-article-number))
8167 (setq error t))
8168 (decf n))
8169 (gnus-summary-position-point)
8170 n))
8171
8172 (defun gnus-summary-refer-references ()
8173 "Fetch all articles mentioned in the References header.
8174 Return the number of articles fetched."
8175 (interactive)
8176 (let ((ref (mail-header-references (gnus-summary-article-header)))
8177 (current (gnus-summary-article-number))
8178 (n 0))
8179 (if (or (not ref)
8180 (equal ref ""))
8181 (error "No References in the current article")
8182 ;; For each Message-ID in the References header...
8183 (while (string-match "<[^>]*>" ref)
8184 (incf n)
8185 ;; ... fetch that article.
8186 (gnus-summary-refer-article
8187 (prog1 (match-string 0 ref)
8188 (setq ref (substring ref (match-end 0))))))
8189 (gnus-summary-goto-subject current)
8190 (gnus-summary-position-point)
8191 n)))
8192
8193 (defun gnus-summary-refer-thread (&optional limit)
8194 "Fetch all articles in the current thread.
8195 If LIMIT (the numerical prefix), fetch that many old headers instead
8196 of what's specified by the `gnus-refer-thread-limit' variable."
8197 (interactive "P")
8198 (let ((id (mail-header-id (gnus-summary-article-header)))
8199 (limit (if limit (prefix-numeric-value limit)
8200 gnus-refer-thread-limit)))
8201 (unless (eq gnus-fetch-old-headers 'invisible)
8202 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8203 ;; Retrieve the headers and read them in.
8204 (if (eq (if (numberp limit)
8205 (gnus-retrieve-headers
8206 (list (min
8207 (+ (mail-header-number
8208 (gnus-summary-article-header))
8209 limit)
8210 gnus-newsgroup-end))
8211 gnus-newsgroup-name (* limit 2))
8212 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8213 ;; headers.
8214 (gnus-retrieve-headers (list gnus-newsgroup-end)
8215 gnus-newsgroup-name limit))
8216 'nov)
8217 (gnus-build-all-threads)
8218 (error "Can't fetch thread from back ends that don't support NOV"))
8219 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8220 (gnus-summary-limit-include-thread id)))
8221
8222 (defun gnus-summary-refer-article (message-id)
8223 "Fetch an article specified by MESSAGE-ID."
8224 (interactive "sMessage-ID: ")
8225 (when (and (stringp message-id)
8226 (not (zerop (length message-id))))
8227 (setq message-id (gnus-replace-in-string message-id " " ""))
8228 ;; Construct the correct Message-ID if necessary.
8229 ;; Suggested by tale@pawl.rpi.edu.
8230 (unless (string-match "^<" message-id)
8231 (setq message-id (concat "<" message-id)))
8232 (unless (string-match ">$" message-id)
8233 (setq message-id (concat message-id ">")))
8234 ;; People often post MIDs from URLs, so unhex it:
8235 (unless (string-match "@" message-id)
8236 (setq message-id (gnus-url-unhex-string message-id)))
8237 (let* ((header (gnus-id-to-header message-id))
8238 (sparse (and header
8239 (gnus-summary-article-sparse-p
8240 (mail-header-number header))
8241 (memq (mail-header-number header)
8242 gnus-newsgroup-limit)))
8243 number)
8244 (cond
8245 ;; If the article is present in the buffer we just go to it.
8246 ((and header
8247 (or (not (gnus-summary-article-sparse-p
8248 (mail-header-number header)))
8249 sparse))
8250 (prog1
8251 (gnus-summary-goto-article
8252 (mail-header-number header) nil t)
8253 (when sparse
8254 (gnus-summary-update-article (mail-header-number header)))))
8255 (t
8256 ;; We fetch the article.
8257 (catch 'found
8258 (dolist (gnus-override-method (gnus-refer-article-methods))
8259 (when (and (gnus-check-server gnus-override-method)
8260 ;; Fetch the header,
8261 (setq number (gnus-summary-insert-subject message-id)))
8262 ;; and display the article.
8263 (gnus-summary-select-article nil nil nil number)
8264 (throw 'found t)))
8265 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8266
8267 (defun gnus-refer-article-methods ()
8268 "Return a list of referable methods."
8269 (cond
8270 ;; No method, so we default to current and native.
8271 ((null gnus-refer-article-method)
8272 (list gnus-current-select-method gnus-select-method))
8273 ;; Current.
8274 ((eq 'current gnus-refer-article-method)
8275 (list gnus-current-select-method))
8276 ;; List of select methods.
8277 ((not (and (symbolp (car gnus-refer-article-method))
8278 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8279 (let (out)
8280 (dolist (method gnus-refer-article-method)
8281 (push (if (eq 'current method)
8282 gnus-current-select-method
8283 method)
8284 out))
8285 (nreverse out)))
8286 ;; One single select method.
8287 (t
8288 (list gnus-refer-article-method))))
8289
8290 (defun gnus-summary-edit-parameters ()
8291 "Edit the group parameters of the current group."
8292 (interactive)
8293 (gnus-group-edit-group gnus-newsgroup-name 'params))
8294
8295 (defun gnus-summary-customize-parameters ()
8296 "Customize the group parameters of the current group."
8297 (interactive)
8298 (gnus-group-customize gnus-newsgroup-name))
8299
8300 (defun gnus-summary-enter-digest-group (&optional force)
8301 "Enter an nndoc group based on the current article.
8302 If FORCE, force a digest interpretation. If not, try
8303 to guess what the document format is."
8304 (interactive "P")
8305 (let ((conf gnus-current-window-configuration))
8306 (save-window-excursion
8307 (save-excursion
8308 (let (gnus-article-prepare-hook
8309 gnus-display-mime-function
8310 gnus-break-pages)
8311 (gnus-summary-select-article))))
8312 (setq gnus-current-window-configuration conf)
8313 (let* ((name (format "%s-%d"
8314 (gnus-group-prefixed-name
8315 gnus-newsgroup-name (list 'nndoc ""))
8316 (save-excursion
8317 (set-buffer gnus-summary-buffer)
8318 gnus-current-article)))
8319 (ogroup gnus-newsgroup-name)
8320 (params (append (gnus-info-params (gnus-get-info ogroup))
8321 (list (cons 'to-group ogroup))
8322 (list (cons 'parent-group ogroup))
8323 (list (cons 'save-article-group ogroup))))
8324 (case-fold-search t)
8325 (buf (current-buffer))
8326 dig to-address)
8327 (save-excursion
8328 (set-buffer gnus-original-article-buffer)
8329 ;; Have the digest group inherit the main mail address of
8330 ;; the parent article.
8331 (when (setq to-address (or (gnus-fetch-field "reply-to")
8332 (gnus-fetch-field "from")))
8333 (setq params (append
8334 (list (cons 'to-address
8335 (funcall gnus-decode-encoded-word-function
8336 to-address))))))
8337 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8338 (insert-buffer-substring gnus-original-article-buffer)
8339 ;; Remove lines that may lead nndoc to misinterpret the
8340 ;; document type.
8341 (narrow-to-region
8342 (goto-char (point-min))
8343 (or (search-forward "\n\n" nil t) (point)))
8344 (goto-char (point-min))
8345 (delete-matching-lines "^Path:\\|^From ")
8346 (widen))
8347 (unwind-protect
8348 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8349 (gnus-newsgroup-ephemeral-ignored-charsets
8350 gnus-newsgroup-ignored-charsets))
8351 (gnus-group-read-ephemeral-group
8352 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8353 (nndoc-article-type
8354 ,(if force 'mbox 'guess)))
8355 t nil nil nil
8356 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8357 "ADAPT")))))
8358 ;; Make all postings to this group go to the parent group.
8359 (nconc (gnus-info-params (gnus-get-info name))
8360 params)
8361 ;; Couldn't select this doc group.
8362 (switch-to-buffer buf)
8363 (gnus-set-global-variables)
8364 (gnus-configure-windows 'summary)
8365 (gnus-message 3 "Article couldn't be entered?"))
8366 (kill-buffer dig)))))
8367
8368 (defun gnus-summary-read-document (n)
8369 "Open a new group based on the current article(s).
8370 This will allow you to read digests and other similar
8371 documents as newsgroups.
8372 Obeys the standard process/prefix convention."
8373 (interactive "P")
8374 (let* ((articles (gnus-summary-work-articles n))
8375 (ogroup gnus-newsgroup-name)
8376 (params (append (gnus-info-params (gnus-get-info ogroup))
8377 (list (cons 'to-group ogroup))))
8378 article group egroup groups vgroup)
8379 (while (setq article (pop articles))
8380 (setq group (format "%s-%d" gnus-newsgroup-name article))
8381 (gnus-summary-remove-process-mark article)
8382 (when (gnus-summary-display-article article)
8383 (save-excursion
8384 (with-temp-buffer
8385 (insert-buffer-substring gnus-original-article-buffer)
8386 ;; Remove some headers that may lead nndoc to make
8387 ;; the wrong guess.
8388 (message-narrow-to-head)
8389 (goto-char (point-min))
8390 (delete-matching-lines "^\\(Path\\):\\|^From ")
8391 (widen)
8392 (if (setq egroup
8393 (gnus-group-read-ephemeral-group
8394 group `(nndoc ,group (nndoc-address ,(current-buffer))
8395 (nndoc-article-type guess))
8396 t nil t))
8397 (progn
8398 ;; Make all postings to this group go to the parent group.
8399 (nconc (gnus-info-params (gnus-get-info egroup))
8400 params)
8401 (push egroup groups))
8402 ;; Couldn't select this doc group.
8403 (gnus-error 3 "Article couldn't be entered"))))))
8404 ;; Now we have selected all the documents.
8405 (cond
8406 ((not groups)
8407 (error "None of the articles could be interpreted as documents"))
8408 ((gnus-group-read-ephemeral-group
8409 (setq vgroup (format
8410 "nnvirtual:%s-%s" gnus-newsgroup-name
8411 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8412 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8413 t
8414 (cons (current-buffer) 'summary)))
8415 (t
8416 (error "Couldn't select virtual nndoc group")))))
8417
8418 (defun gnus-summary-isearch-article (&optional regexp-p)
8419 "Do incremental search forward on the current article.
8420 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8421 (interactive "P")
8422 (gnus-summary-select-article)
8423 (gnus-configure-windows 'article)
8424 (gnus-eval-in-buffer-window gnus-article-buffer
8425 (save-restriction
8426 (widen)
8427 (isearch-forward regexp-p))))
8428
8429 (defun gnus-summary-search-article-forward (regexp &optional backward)
8430 "Search for an article containing REGEXP forward.
8431 If BACKWARD, search backward instead."
8432 (interactive
8433 (list (read-string
8434 (format "Search article %s (regexp%s): "
8435 (if current-prefix-arg "backward" "forward")
8436 (if gnus-last-search-regexp
8437 (concat ", default " gnus-last-search-regexp)
8438 "")))
8439 current-prefix-arg))
8440 (if (string-equal regexp "")
8441 (setq regexp (or gnus-last-search-regexp ""))
8442 (setq gnus-last-search-regexp regexp)
8443 (setq gnus-article-before-search gnus-current-article))
8444 ;; Intentionally set gnus-last-article.
8445 (setq gnus-last-article gnus-article-before-search)
8446 (let ((gnus-last-article gnus-last-article))
8447 (if (gnus-summary-search-article regexp backward)
8448 (gnus-summary-show-thread)
8449 (signal 'search-failed (list regexp)))))
8450
8451 (defun gnus-summary-search-article-backward (regexp)
8452 "Search for an article containing REGEXP backward."
8453 (interactive
8454 (list (read-string
8455 (format "Search article backward (regexp%s): "
8456 (if gnus-last-search-regexp
8457 (concat ", default " gnus-last-search-regexp)
8458 "")))))
8459 (gnus-summary-search-article-forward regexp 'backward))
8460
8461 (defun gnus-summary-search-article (regexp &optional backward)
8462 "Search for an article containing REGEXP.
8463 Optional argument BACKWARD means do search for backward.
8464 `gnus-select-article-hook' is not called during the search."
8465 ;; We have to require this here to make sure that the following
8466 ;; dynamic binding isn't shadowed by autoloading.
8467 (require 'gnus-async)
8468 (require 'gnus-art)
8469 (let ((gnus-select-article-hook nil) ;Disable hook.
8470 (gnus-article-prepare-hook nil)
8471 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8472 (gnus-use-article-prefetch nil)
8473 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8474 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8475 (gnus-visual nil)
8476 (gnus-keep-backlog nil)
8477 (gnus-break-pages nil)
8478 (gnus-summary-display-arrow nil)
8479 (gnus-updated-mode-lines nil)
8480 (gnus-auto-center-summary nil)
8481 (sum (current-buffer))
8482 (gnus-display-mime-function nil)
8483 (found nil)
8484 point)
8485 (gnus-save-hidden-threads
8486 (gnus-summary-select-article)
8487 (set-buffer gnus-article-buffer)
8488 (goto-char (window-point (get-buffer-window (current-buffer))))
8489 (when backward
8490 (forward-line -1))
8491 (while (not found)
8492 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8493 (if (if backward
8494 (re-search-backward regexp nil t)
8495 (re-search-forward regexp nil t))
8496 ;; We found the regexp.
8497 (progn
8498 (setq found 'found)
8499 (beginning-of-line)
8500 (set-window-start
8501 (get-buffer-window (current-buffer))
8502 (point))
8503 (forward-line 1)
8504 (set-window-point
8505 (get-buffer-window (current-buffer))
8506 (point))
8507 (set-buffer sum)
8508 (setq point (point)))
8509 ;; We didn't find it, so we go to the next article.
8510 (set-buffer sum)
8511 (setq found 'not)
8512 (while (eq found 'not)
8513 (if (not (if backward (gnus-summary-find-prev)
8514 (gnus-summary-find-next)))
8515 ;; No more articles.
8516 (setq found t)
8517 ;; Select the next article and adjust point.
8518 (unless (gnus-summary-article-sparse-p
8519 (gnus-summary-article-number))
8520 (setq found nil)
8521 (gnus-summary-select-article)
8522 (set-buffer gnus-article-buffer)
8523 (widen)
8524 (goto-char (if backward (point-max) (point-min))))))))
8525 (gnus-message 7 ""))
8526 ;; Return whether we found the regexp.
8527 (when (eq found 'found)
8528 (goto-char point)
8529 (gnus-summary-show-thread)
8530 (gnus-summary-goto-subject gnus-current-article)
8531 (gnus-summary-position-point)
8532 t)))
8533
8534 (defun gnus-find-matching-articles (header regexp)
8535 "Return a list of all articles that match REGEXP on HEADER.
8536 This search includes all articles in the current group that Gnus has
8537 fetched headers for, whether they are displayed or not."
8538 (let ((articles nil)
8539 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8540 (case-fold-search t))
8541 (dolist (header gnus-newsgroup-headers)
8542 (when (string-match regexp (funcall func header))
8543 (push (mail-header-number header) articles)))
8544 (nreverse articles)))
8545
8546 (defun gnus-summary-find-matching (header regexp &optional backward unread
8547 not-case-fold not-matching)
8548 "Return a list of all articles that match REGEXP on HEADER.
8549 The search stars on the current article and goes forwards unless
8550 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8551 If UNREAD is non-nil, only unread articles will
8552 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8553 in the comparisons. If NOT-MATCHING, return a list of all articles that
8554 not match REGEXP on HEADER."
8555 (let ((case-fold-search (not not-case-fold))
8556 articles d func)
8557 (if (consp header)
8558 (if (eq (car header) 'extra)
8559 (setq func
8560 `(lambda (h)
8561 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8562 "")))
8563 (error "%s is an invalid header" header))
8564 (unless (fboundp (intern (concat "mail-header-" header)))
8565 (error "%s is not a valid header" header))
8566 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8567 (dolist (d (if (eq backward 'all)
8568 gnus-newsgroup-data
8569 (gnus-data-find-list
8570 (gnus-summary-article-number)
8571 (gnus-data-list backward))))
8572 (when (and (or (not unread) ; We want all articles...
8573 (gnus-data-unread-p d)) ; Or just unreads.
8574 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8575 (if not-matching
8576 (not (string-match
8577 regexp
8578 (funcall func (gnus-data-header d))))
8579 (string-match regexp
8580 (funcall func (gnus-data-header d)))))
8581 (push (gnus-data-number d) articles))) ; Success!
8582 (nreverse articles)))
8583
8584 (defun gnus-summary-execute-command (header regexp command &optional backward)
8585 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8586 If HEADER is an empty string (or nil), the match is done on the entire
8587 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8588 (interactive
8589 (list (let ((completion-ignore-case t))
8590 (completing-read
8591 "Header name: "
8592 (mapcar (lambda (header) (list (format "%s" header)))
8593 (append
8594 '("Number" "Subject" "From" "Lines" "Date"
8595 "Message-ID" "Xref" "References" "Body")
8596 gnus-extra-headers))
8597 nil 'require-match))
8598 (read-string "Regexp: ")
8599 (read-key-sequence "Command: ")
8600 current-prefix-arg))
8601 (when (equal header "Body")
8602 (setq header ""))
8603 ;; Hidden thread subtrees must be searched as well.
8604 (gnus-summary-show-all-threads)
8605 ;; We don't want to change current point nor window configuration.
8606 (save-excursion
8607 (save-window-excursion
8608 (let (gnus-visual
8609 gnus-treat-strip-trailing-blank-lines
8610 gnus-treat-strip-leading-blank-lines
8611 gnus-treat-strip-multiple-blank-lines
8612 gnus-treat-hide-boring-headers
8613 gnus-treat-fold-newsgroups
8614 gnus-article-prepare-hook)
8615 (gnus-message 6 "Executing %s..." (key-description command))
8616 ;; We'd like to execute COMMAND interactively so as to give arguments.
8617 (gnus-execute header regexp
8618 `(call-interactively ',(key-binding command))
8619 backward)
8620 (gnus-message 6 "Executing %s...done" (key-description command))))))
8621
8622 (defun gnus-summary-beginning-of-article ()
8623 "Scroll the article back to the beginning."
8624 (interactive)
8625 (gnus-summary-select-article)
8626 (gnus-configure-windows 'article)
8627 (gnus-eval-in-buffer-window gnus-article-buffer
8628 (widen)
8629 (goto-char (point-min))
8630 (when gnus-break-pages
8631 (gnus-narrow-to-page))))
8632
8633 (defun gnus-summary-end-of-article ()
8634 "Scroll to the end of the article."
8635 (interactive)
8636 (gnus-summary-select-article)
8637 (gnus-configure-windows 'article)
8638 (gnus-eval-in-buffer-window gnus-article-buffer
8639 (widen)
8640 (goto-char (point-max))
8641 (recenter -3)
8642 (when gnus-break-pages
8643 (when (re-search-backward page-delimiter nil t)
8644 (narrow-to-region (match-end 0) (point-max)))
8645 (gnus-narrow-to-page))))
8646
8647 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8648 "Truncate to LEN and quote all \"(\"'s in STRING."
8649 (gnus-replace-in-string (if (and len (> (length string) len))
8650 (substring string 0 len)
8651 string)
8652 "[()]" "\\\\\\&"))
8653
8654 (defun gnus-summary-print-article (&optional filename n)
8655 "Generate and print a PostScript image of the process-marked (mail) articles.
8656
8657 If used interactively, print the current article if none are
8658 process-marked. With prefix arg, prompt the user for the name of the
8659 file to save in.
8660
8661 When used from Lisp, accept two optional args FILENAME and N. N means
8662 to print the next N articles. If N is negative, print the N previous
8663 articles. If N is nil and articles have been marked with the process
8664 mark, print these instead.
8665
8666 If the optional first argument FILENAME is nil, send the image to the
8667 printer. If FILENAME is a string, save the PostScript image in a file with
8668 that name. If FILENAME is a number, prompt the user for the name of the file
8669 to save in."
8670 (interactive (list (ps-print-preprint current-prefix-arg)))
8671 (dolist (article (gnus-summary-work-articles n))
8672 (gnus-summary-select-article nil nil 'pseudo article)
8673 (gnus-eval-in-buffer-window gnus-article-buffer
8674 (gnus-print-buffer))
8675 (gnus-summary-remove-process-mark article))
8676 (ps-despool filename))
8677
8678 (defun gnus-print-buffer ()
8679 (let ((buffer (generate-new-buffer " *print*")))
8680 (unwind-protect
8681 (progn
8682 (copy-to-buffer buffer (point-min) (point-max))
8683 (set-buffer buffer)
8684 (gnus-remove-text-with-property 'gnus-decoration)
8685 (when (gnus-visual-p 'article-highlight 'highlight)
8686 ;; Copy-to-buffer doesn't copy overlay. So redo
8687 ;; highlight.
8688 (let ((gnus-article-buffer buffer))
8689 (gnus-article-highlight-citation t)
8690 (gnus-article-highlight-signature)
8691 (gnus-article-emphasize)
8692 (gnus-article-delete-invisible-text)))
8693 (let ((ps-left-header
8694 (list
8695 (concat "("
8696 (gnus-summary-print-truncate-and-quote
8697 (mail-header-subject gnus-current-headers)
8698 66) ")")
8699 (concat "("
8700 (gnus-summary-print-truncate-and-quote
8701 (mail-header-from gnus-current-headers)
8702 45) ")")))
8703 (ps-right-header
8704 (list
8705 "/pagenumberstring load"
8706 (concat "("
8707 (mail-header-date gnus-current-headers) ")"))))
8708 (gnus-run-hooks 'gnus-ps-print-hook)
8709 (save-excursion
8710 (if window-system
8711 (ps-spool-buffer-with-faces)
8712 (ps-spool-buffer)))))
8713 (kill-buffer buffer))))
8714
8715 (defun gnus-summary-show-article (&optional arg)
8716 "Force redisplaying of the current article.
8717 If ARG (the prefix) is a number, show the article with the charset
8718 defined in `gnus-summary-show-article-charset-alist', or the charset
8719 input.
8720 If ARG (the prefix) is non-nil and not a number, show the raw article
8721 without any article massaging functions being run. Normally, the key
8722 strokes are `C-u g'."
8723 (interactive "P")
8724 (cond
8725 ((numberp arg)
8726 (gnus-summary-show-article t)
8727 (let ((gnus-newsgroup-charset
8728 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8729 (mm-read-coding-system
8730 "View as charset: " ;; actually it is coding system.
8731 (save-excursion
8732 (set-buffer gnus-article-buffer)
8733 (mm-detect-coding-region (point) (point-max))))))
8734 (gnus-newsgroup-ignored-charsets 'gnus-all))
8735 (gnus-summary-select-article nil 'force)
8736 (let ((deps gnus-newsgroup-dependencies)
8737 head header lines)
8738 (save-excursion
8739 (set-buffer gnus-original-article-buffer)
8740 (save-restriction
8741 (message-narrow-to-head)
8742 (setq head (buffer-string))
8743 (goto-char (point-min))
8744 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8745 (goto-char (point-max))
8746 (widen)
8747 (setq lines (1- (count-lines (point) (point-max))))))
8748 (with-temp-buffer
8749 (insert (format "211 %d Article retrieved.\n"
8750 (cdr gnus-article-current)))
8751 (insert head)
8752 (if lines (insert (format "Lines: %d\n" lines)))
8753 (insert ".\n")
8754 (let ((nntp-server-buffer (current-buffer)))
8755 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8756 (gnus-data-set-header
8757 (gnus-data-find (cdr gnus-article-current))
8758 header)
8759 (gnus-summary-update-article-line
8760 (cdr gnus-article-current) header)
8761 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8762 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8763 ((not arg)
8764 ;; Select the article the normal way.
8765 (gnus-summary-select-article nil 'force))
8766 (t
8767 ;; We have to require this here to make sure that the following
8768 ;; dynamic binding isn't shadowed by autoloading.
8769 (require 'gnus-async)
8770 (require 'gnus-art)
8771 ;; Bind the article treatment functions to nil.
8772 (let ((gnus-have-all-headers t)
8773 gnus-article-prepare-hook
8774 gnus-article-decode-hook
8775 gnus-display-mime-function
8776 gnus-break-pages)
8777 ;; Destroy any MIME parts.
8778 (when (gnus-buffer-live-p gnus-article-buffer)
8779 (save-excursion
8780 (set-buffer gnus-article-buffer)
8781 (mm-destroy-parts gnus-article-mime-handles)
8782 ;; Set it to nil for safety reason.
8783 (setq gnus-article-mime-handle-alist nil)
8784 (setq gnus-article-mime-handles nil)))
8785 (gnus-summary-select-article nil 'force))))
8786 (gnus-summary-goto-subject gnus-current-article)
8787 (gnus-summary-position-point))
8788
8789 (defun gnus-summary-show-raw-article ()
8790 "Show the raw article without any article massaging functions being run."
8791 (interactive)
8792 (gnus-summary-show-article t))
8793
8794 (defun gnus-summary-verbose-headers (&optional arg)
8795 "Toggle permanent full header display.
8796 If ARG is a positive number, turn header display on.
8797 If ARG is a negative number, turn header display off."
8798 (interactive "P")
8799 (setq gnus-show-all-headers
8800 (cond ((or (not (numberp arg))
8801 (zerop arg))
8802 (not gnus-show-all-headers))
8803 ((natnump arg)
8804 t)))
8805 (gnus-summary-show-article))
8806
8807 (defun gnus-summary-toggle-header (&optional arg)
8808 "Show the headers if they are hidden, or hide them if they are shown.
8809 If ARG is a positive number, show the entire header.
8810 If ARG is a negative number, hide the unwanted header lines."
8811 (interactive "P")
8812 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8813 (get-buffer-window gnus-article-buffer t))))
8814 (with-current-buffer gnus-article-buffer
8815 (widen)
8816 (article-narrow-to-head)
8817 (let* ((buffer-read-only nil)
8818 (inhibit-point-motion-hooks t)
8819 (hidden (if (numberp arg)
8820 (>= arg 0)
8821 (or (not (looking-at "[^ \t\n]+:"))
8822 (gnus-article-hidden-text-p 'headers))))
8823 s e)
8824 (delete-region (point-min) (point-max))
8825 (with-current-buffer gnus-original-article-buffer
8826 (goto-char (setq s (point-min)))
8827 (setq e (if (search-forward "\n\n" nil t)
8828 (1- (point))
8829 (point-max))))
8830 (insert-buffer-substring gnus-original-article-buffer s e)
8831 (run-hooks 'gnus-article-decode-hook)
8832 (if hidden
8833 (let ((gnus-treat-hide-headers nil)
8834 (gnus-treat-hide-boring-headers nil))
8835 (gnus-delete-wash-type 'headers)
8836 (gnus-treat-article 'head))
8837 (gnus-treat-article 'head))
8838 (widen)
8839 (if window
8840 (set-window-start window (goto-char (point-min))))
8841 (if gnus-break-pages
8842 (gnus-narrow-to-page)
8843 (when (gnus-visual-p 'page-marker)
8844 (let ((buffer-read-only nil))
8845 (gnus-remove-text-with-property 'gnus-prev)
8846 (gnus-remove-text-with-property 'gnus-next))))
8847 (gnus-set-mode-line 'article)))))
8848
8849 (defun gnus-summary-show-all-headers ()
8850 "Make all header lines visible."
8851 (interactive)
8852 (gnus-summary-toggle-header 1))
8853
8854 (defun gnus-summary-caesar-message (&optional arg)
8855 "Caesar rotate the current article by 13.
8856 The numerical prefix specifies how many places to rotate each letter
8857 forward."
8858 (interactive "P")
8859 (gnus-summary-select-article)
8860 (let ((mail-header-separator ""))
8861 (gnus-eval-in-buffer-window gnus-article-buffer
8862 (save-restriction
8863 (widen)
8864 (let ((start (window-start))
8865 buffer-read-only)
8866 (message-caesar-buffer-body arg)
8867 (set-window-start (get-buffer-window (current-buffer)) start)))))
8868 ;; Create buttons and stuff...
8869 (gnus-treat-article nil))
8870
8871 (autoload 'unmorse-region "morse"
8872 "Convert morse coded text in region to ordinary ASCII text."
8873 t)
8874
8875 (defun gnus-summary-morse-message (&optional arg)
8876 "Morse decode the current article."
8877 (interactive "P")
8878 (gnus-summary-select-article)
8879 (let ((mail-header-separator ""))
8880 (gnus-eval-in-buffer-window gnus-article-buffer
8881 (save-excursion
8882 (save-restriction
8883 (widen)
8884 (let ((pos (window-start))
8885 buffer-read-only)
8886 (goto-char (point-min))
8887 (when (message-goto-body)
8888 (gnus-narrow-to-body))
8889 (goto-char (point-min))
8890 (while (re-search-forward "·" (point-max) t)
8891 (replace-match "."))
8892 (unmorse-region (point-min) (point-max))
8893 (widen)
8894 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8895
8896 (defun gnus-summary-stop-page-breaking ()
8897 "Stop page breaking in the current article."
8898 (interactive)
8899 (gnus-summary-select-article)
8900 (gnus-eval-in-buffer-window gnus-article-buffer
8901 (widen)
8902 (when (gnus-visual-p 'page-marker)
8903 (let ((buffer-read-only nil))
8904 (gnus-remove-text-with-property 'gnus-prev)
8905 (gnus-remove-text-with-property 'gnus-next))
8906 (setq gnus-page-broken nil))))
8907
8908 (defun gnus-summary-move-article (&optional n to-newsgroup
8909 select-method action)
8910 "Move the current article to a different newsgroup.
8911 If N is a positive number, move the N next articles.
8912 If N is a negative number, move the N previous articles.
8913 If N is nil and any articles have been marked with the process mark,
8914 move those articles instead.
8915 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8916 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8917 re-spool using this method.
8918
8919 When called interactively with TO-NEWSGROUP being nil, the value of
8920 the variable `gnus-move-split-methods' is used for finding a default
8921 for the target newsgroup.
8922
8923 For this function to work, both the current newsgroup and the
8924 newsgroup that you want to move to have to support the `request-move'
8925 and `request-accept' functions.
8926
8927 ACTION can be either `move' (the default), `crosspost' or `copy'."
8928 (interactive "P")
8929 (unless action
8930 (setq action 'move))
8931 ;; Check whether the source group supports the required functions.
8932 (cond ((and (eq action 'move)
8933 (not (gnus-check-backend-function
8934 'request-move-article gnus-newsgroup-name)))
8935 (error "The current group does not support article moving"))
8936 ((and (eq action 'crosspost)
8937 (not (gnus-check-backend-function
8938 'request-replace-article gnus-newsgroup-name)))
8939 (error "The current group does not support article editing")))
8940 (let ((articles (gnus-summary-work-articles n))
8941 (prefix (if (gnus-check-backend-function
8942 'request-move-article gnus-newsgroup-name)
8943 (gnus-group-real-prefix gnus-newsgroup-name)
8944 ""))
8945 (names '((move "Move" "Moving")
8946 (copy "Copy" "Copying")
8947 (crosspost "Crosspost" "Crossposting")))
8948 (copy-buf (save-excursion
8949 (nnheader-set-temp-buffer " *copy article*")))
8950 art-group to-method new-xref article to-groups)
8951 (unless (assq action names)
8952 (error "Unknown action %s" action))
8953 ;; Read the newsgroup name.
8954 (when (and (not to-newsgroup)
8955 (not select-method))
8956 (if (and gnus-move-split-methods
8957 (not
8958 (and (memq gnus-current-article articles)
8959 (gnus-buffer-live-p gnus-original-article-buffer))))
8960 ;; When `gnus-move-split-methods' is non-nil, we have to
8961 ;; select an article to give `gnus-read-move-group-name' an
8962 ;; opportunity to suggest an appropriate default. However,
8963 ;; we needn't render or mark the article.
8964 (let ((gnus-display-mime-function nil)
8965 (gnus-article-prepare-hook nil)
8966 (gnus-mark-article-hook nil))
8967 (gnus-summary-select-article nil nil nil (car articles))))
8968 (setq to-newsgroup
8969 (gnus-read-move-group-name
8970 (cadr (assq action names))
8971 (symbol-value (intern (format "gnus-current-%s-group" action)))
8972 articles prefix))
8973 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8974 (setq to-method (or select-method
8975 (gnus-server-to-method
8976 (gnus-group-method to-newsgroup))))
8977 ;; Check the method we are to move this article to...
8978 (unless (gnus-check-backend-function
8979 'request-accept-article (car to-method))
8980 (error "%s does not support article copying" (car to-method)))
8981 (unless (gnus-check-server to-method)
8982 (error "Can't open server %s" (car to-method)))
8983 (gnus-message 6 "%s to %s: %s..."
8984 (caddr (assq action names))
8985 (or (car select-method) to-newsgroup) articles)
8986 (while articles
8987 (setq article (pop articles))
8988 (setq
8989 art-group
8990 (cond
8991 ;; Move the article.
8992 ((eq action 'move)
8993 ;; Remove this article from future suppression.
8994 (gnus-dup-unsuppress-article article)
8995 (gnus-request-move-article
8996 article ; Article to move
8997 gnus-newsgroup-name ; From newsgroup
8998 (nth 1 (gnus-find-method-for-group
8999 gnus-newsgroup-name)) ; Server
9000 (list 'gnus-request-accept-article
9001 to-newsgroup (list 'quote select-method)
9002 (not articles) t) ; Accept form
9003 (not articles))) ; Only save nov last time
9004 ;; Copy the article.
9005 ((eq action 'copy)
9006 (save-excursion
9007 (set-buffer copy-buf)
9008 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9009 (gnus-request-accept-article
9010 to-newsgroup select-method (not articles) t))))
9011 ;; Crosspost the article.
9012 ((eq action 'crosspost)
9013 (let ((xref (message-tokenize-header
9014 (mail-header-xref (gnus-summary-article-header article))
9015 " ")))
9016 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9017 ":" (number-to-string article)))
9018 (unless xref
9019 (setq xref (list (system-name))))
9020 (setq new-xref
9021 (concat
9022 (mapconcat 'identity
9023 (delete "Xref:" (delete new-xref xref))
9024 " ")
9025 " " new-xref))
9026 (save-excursion
9027 (set-buffer copy-buf)
9028 ;; First put the article in the destination group.
9029 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9030 (when (consp (setq art-group
9031 (gnus-request-accept-article
9032 to-newsgroup select-method (not articles))))
9033 (setq new-xref (concat new-xref " " (car art-group)
9034 ":"
9035 (number-to-string (cdr art-group))))
9036 ;; Now we have the new Xrefs header, so we insert
9037 ;; it and replace the new article.
9038 (nnheader-replace-header "Xref" new-xref)
9039 (gnus-request-replace-article
9040 (cdr art-group) to-newsgroup (current-buffer))
9041 art-group))))))
9042 (cond
9043 ((not art-group)
9044 (gnus-message 1 "Couldn't %s article %s: %s"
9045 (cadr (assq action names)) article
9046 (nnheader-get-report (car to-method))))
9047 ((eq art-group 'junk)
9048 (when (eq action 'move)
9049 (gnus-summary-mark-article article gnus-canceled-mark)
9050 (gnus-message 4 "Deleted article %s" article)
9051 ;; run the delete hook
9052 (run-hook-with-args 'gnus-summary-article-delete-hook
9053 action
9054 (gnus-data-header
9055 (assoc article (gnus-data-list nil)))
9056 gnus-newsgroup-name nil
9057 select-method)))
9058 (t
9059 (let* ((pto-group (gnus-group-prefixed-name
9060 (car art-group) to-method))
9061 (entry
9062 (gnus-gethash pto-group gnus-newsrc-hashtb))
9063 (info (nth 2 entry))
9064 (to-group (gnus-info-group info))
9065 to-marks)
9066 ;; Update the group that has been moved to.
9067 (when (and info
9068 (memq action '(move copy)))
9069 (unless (member to-group to-groups)
9070 (push to-group to-groups))
9071
9072 (unless (memq article gnus-newsgroup-unreads)
9073 (push 'read to-marks)
9074 (gnus-info-set-read
9075 info (gnus-add-to-range (gnus-info-read info)
9076 (list (cdr art-group)))))
9077
9078 ;; See whether the article is to be put in the cache.
9079 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9080 gnus-article-mark-lists
9081 (delete '(expirable . expire)
9082 (copy-sequence gnus-article-mark-lists))))
9083 (to-article (cdr art-group)))
9084
9085 ;; Enter the article into the cache in the new group,
9086 ;; if that is required.
9087 (when gnus-use-cache
9088 (gnus-cache-possibly-enter-article
9089 to-group to-article
9090 (memq article gnus-newsgroup-marked)
9091 (memq article gnus-newsgroup-dormant)
9092 (memq article gnus-newsgroup-unreads)))
9093
9094 (when gnus-preserve-marks
9095 ;; Copy any marks over to the new group.
9096 (when (and (equal to-group gnus-newsgroup-name)
9097 (not (memq article gnus-newsgroup-unreads)))
9098 ;; Mark this article as read in this group.
9099 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9100 (setcdr (gnus-active to-group) to-article)
9101 (setcdr gnus-newsgroup-active to-article))
9102
9103 (while marks
9104 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9105 (when (memq article (symbol-value
9106 (intern (format "gnus-newsgroup-%s"
9107 (caar marks)))))
9108 (push (cdar marks) to-marks)
9109 ;; If the other group is the same as this group,
9110 ;; then we have to add the mark to the list.
9111 (when (equal to-group gnus-newsgroup-name)
9112 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9113 (cons to-article
9114 (symbol-value
9115 (intern (format "gnus-newsgroup-%s"
9116 (caar marks)))))))
9117 ;; Copy the marks to other group.
9118 (gnus-add-marked-articles
9119 to-group (cdar marks) (list to-article) info)))
9120 (setq marks (cdr marks)))
9121
9122 (gnus-request-set-mark
9123 to-group (list (list (list to-article) 'add to-marks))))
9124
9125 (gnus-dribble-enter
9126 (concat "(gnus-group-set-info '"
9127 (gnus-prin1-to-string (gnus-get-info to-group))
9128 ")"))))
9129
9130 ;; Update the Xref header in this article to point to
9131 ;; the new crossposted article we have just created.
9132 (when (eq action 'crosspost)
9133 (save-excursion
9134 (set-buffer copy-buf)
9135 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9136 (nnheader-replace-header "Xref" new-xref)
9137 (gnus-request-replace-article
9138 article gnus-newsgroup-name (current-buffer))))
9139
9140 ;; run the move/copy/crosspost/respool hook
9141 (run-hook-with-args 'gnus-summary-article-move-hook
9142 action
9143 (gnus-data-header
9144 (assoc article (gnus-data-list nil)))
9145 gnus-newsgroup-name
9146 to-newsgroup
9147 select-method))
9148
9149 ;;;!!!Why is this necessary?
9150 (set-buffer gnus-summary-buffer)
9151
9152 (gnus-summary-goto-subject article)
9153 (when (eq action 'move)
9154 (gnus-summary-mark-article article gnus-canceled-mark))))
9155 (gnus-summary-remove-process-mark article))
9156 ;; Re-activate all groups that have been moved to.
9157 (save-excursion
9158 (set-buffer gnus-group-buffer)
9159 (let ((gnus-group-marked to-groups))
9160 (gnus-group-get-new-news-this-group nil t)))
9161
9162 (gnus-kill-buffer copy-buf)
9163 (gnus-summary-position-point)
9164 (gnus-set-mode-line 'summary)))
9165
9166 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9167 "Copy the current article to some other group.
9168 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9169 When called interactively, if TO-NEWSGROUP is nil, use the value of
9170 the variable `gnus-move-split-methods' for finding a default target
9171 newsgroup.
9172 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9173 re-spool using this method."
9174 (interactive "P")
9175 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9176
9177 (defun gnus-summary-crosspost-article (&optional n)
9178 "Crosspost the current article to some other group."
9179 (interactive "P")
9180 (gnus-summary-move-article n nil nil 'crosspost))
9181
9182 (defcustom gnus-summary-respool-default-method nil
9183 "Default method type for respooling an article.
9184 If nil, use to the current newsgroup method."
9185 :type 'symbol
9186 :group 'gnus-summary-mail)
9187
9188 (defcustom gnus-summary-display-while-building nil
9189 "If non-nil, show and update the summary buffer as it's being built.
9190 If the value is t, update the buffer after every line is inserted. If
9191 the value is an integer (N), update the display every N lines."
9192 :version "22.1"
9193 :group 'gnus-thread
9194 :type '(choice (const :tag "off" nil)
9195 number
9196 (const :tag "frequently" t)))
9197
9198 (defun gnus-summary-respool-article (&optional n method)
9199 "Respool the current article.
9200 The article will be squeezed through the mail spooling process again,
9201 which means that it will be put in some mail newsgroup or other
9202 depending on `nnmail-split-methods'.
9203 If N is a positive number, respool the N next articles.
9204 If N is a negative number, respool the N previous articles.
9205 If N is nil and any articles have been marked with the process mark,
9206 respool those articles instead.
9207
9208 Respooling can be done both from mail groups and \"real\" newsgroups.
9209 In the former case, the articles in question will be moved from the
9210 current group into whatever groups they are destined to. In the
9211 latter case, they will be copied into the relevant groups."
9212 (interactive
9213 (list current-prefix-arg
9214 (let* ((methods (gnus-methods-using 'respool))
9215 (methname
9216 (symbol-name (or gnus-summary-respool-default-method
9217 (car (gnus-find-method-for-group
9218 gnus-newsgroup-name)))))
9219 (method
9220 (gnus-completing-read-with-default
9221 methname "What backend do you want to use when respooling?"
9222 methods nil t nil 'gnus-mail-method-history))
9223 ms)
9224 (cond
9225 ((zerop (length (setq ms (gnus-servers-using-backend
9226 (intern method)))))
9227 (list (intern method) ""))
9228 ((= 1 (length ms))
9229 (car ms))
9230 (t
9231 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9232 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9233 ms-alist))))))))
9234 (unless method
9235 (error "No method given for respooling"))
9236 (if (assoc (symbol-name
9237 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9238 (gnus-methods-using 'respool))
9239 (gnus-summary-move-article n nil method)
9240 (gnus-summary-copy-article n nil method)))
9241
9242 (defun gnus-summary-import-article (file &optional edit)
9243 "Import an arbitrary file into a mail newsgroup."
9244 (interactive "fImport file: \nP")
9245 (let ((group gnus-newsgroup-name)
9246 (now (current-time))
9247 atts lines group-art)
9248 (unless (gnus-check-backend-function 'request-accept-article group)
9249 (error "%s does not support article importing" group))
9250 (or (file-readable-p file)
9251 (not (file-regular-p file))
9252 (error "Can't read %s" file))
9253 (save-excursion
9254 (set-buffer (gnus-get-buffer-create " *import file*"))
9255 (erase-buffer)
9256 (nnheader-insert-file-contents file)
9257 (goto-char (point-min))
9258 (if (nnheader-article-p)
9259 (save-restriction
9260 (goto-char (point-min))
9261 (search-forward "\n\n" nil t)
9262 (narrow-to-region (point-min) (1- (point)))
9263 (goto-char (point-min))
9264 (unless (re-search-forward "^date:" nil t)
9265 (goto-char (point-max))
9266 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9267 ;; This doesn't look like an article, so we fudge some headers.
9268 (setq atts (file-attributes file)
9269 lines (count-lines (point-min) (point-max)))
9270 (insert "From: " (read-string "From: ") "\n"
9271 "Subject: " (read-string "Subject: ") "\n"
9272 "Date: " (message-make-date (nth 5 atts)) "\n"
9273 "Message-ID: " (message-make-message-id) "\n"
9274 "Lines: " (int-to-string lines) "\n"
9275 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9276 (setq group-art (gnus-request-accept-article group nil t))
9277 (kill-buffer (current-buffer)))
9278 (setq gnus-newsgroup-active (gnus-activate-group group))
9279 (forward-line 1)
9280 (gnus-summary-goto-article (cdr group-art) nil t)
9281 (when edit
9282 (gnus-summary-edit-article))))
9283
9284 (defun gnus-summary-create-article ()
9285 "Create an article in a mail newsgroup."
9286 (interactive)
9287 (let ((group gnus-newsgroup-name)
9288 (now (current-time))
9289 group-art)
9290 (unless (gnus-check-backend-function 'request-accept-article group)
9291 (error "%s does not support article importing" group))
9292 (save-excursion
9293 (set-buffer (gnus-get-buffer-create " *import file*"))
9294 (erase-buffer)
9295 (goto-char (point-min))
9296 ;; This doesn't look like an article, so we fudge some headers.
9297 (insert "From: " (read-string "From: ") "\n"
9298 "Subject: " (read-string "Subject: ") "\n"
9299 "Date: " (message-make-date now) "\n"
9300 "Message-ID: " (message-make-message-id) "\n")
9301 (setq group-art (gnus-request-accept-article group nil t))
9302 (kill-buffer (current-buffer)))
9303 (setq gnus-newsgroup-active (gnus-activate-group group))
9304 (forward-line 1)
9305 (gnus-summary-goto-article (cdr group-art) nil t)
9306 (gnus-summary-edit-article)))
9307
9308 (defun gnus-summary-article-posted-p ()
9309 "Say whether the current (mail) article is available from news as well.
9310 This will be the case if the article has both been mailed and posted."
9311 (interactive)
9312 (let ((id (mail-header-references (gnus-summary-article-header)))
9313 (gnus-override-method (car (gnus-refer-article-methods))))
9314 (if (gnus-request-head id "")
9315 (gnus-message 2 "The current message was found on %s"
9316 gnus-override-method)
9317 (gnus-message 2 "The current message couldn't be found on %s"
9318 gnus-override-method)
9319 nil)))
9320
9321 (defun gnus-summary-expire-articles (&optional now)
9322 "Expire all articles that are marked as expirable in the current group."
9323 (interactive)
9324 (when (and (not gnus-group-is-exiting-without-update-p)
9325 (gnus-check-backend-function
9326 'request-expire-articles gnus-newsgroup-name))
9327 ;; This backend supports expiry.
9328 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9329 (expirable (if total
9330 (progn
9331 ;; We need to update the info for
9332 ;; this group for `gnus-list-of-read-articles'
9333 ;; to give us the right answer.
9334 (gnus-run-hooks 'gnus-exit-group-hook)
9335 (gnus-summary-update-info)
9336 (gnus-list-of-read-articles gnus-newsgroup-name))
9337 (setq gnus-newsgroup-expirable
9338 (sort gnus-newsgroup-expirable '<))))
9339 (expiry-wait (if now 'immediate
9340 (gnus-group-find-parameter
9341 gnus-newsgroup-name 'expiry-wait)))
9342 (nnmail-expiry-target
9343 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9344 nnmail-expiry-target))
9345 es)
9346 (when expirable
9347 ;; There are expirable articles in this group, so we run them
9348 ;; through the expiry process.
9349 (gnus-message 6 "Expiring articles...")
9350 (unless (gnus-check-group gnus-newsgroup-name)
9351 (error "Can't open server for %s" gnus-newsgroup-name))
9352 ;; The list of articles that weren't expired is returned.
9353 (save-excursion
9354 (if expiry-wait
9355 (let ((nnmail-expiry-wait-function nil)
9356 (nnmail-expiry-wait expiry-wait))
9357 (setq es (gnus-request-expire-articles
9358 expirable gnus-newsgroup-name)))
9359 (setq es (gnus-request-expire-articles
9360 expirable gnus-newsgroup-name)))
9361 (unless total
9362 (setq gnus-newsgroup-expirable es))
9363 ;; We go through the old list of expirable, and mark all
9364 ;; really expired articles as nonexistent.
9365 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9366 (let ((gnus-use-cache nil))
9367 (dolist (article expirable)
9368 (when (and (not (memq article es))
9369 (gnus-data-find article))
9370 (gnus-summary-mark-article article gnus-canceled-mark)
9371 (run-hook-with-args 'gnus-summary-article-expire-hook
9372 'delete
9373 (gnus-data-header
9374 (assoc article (gnus-data-list nil)))
9375 gnus-newsgroup-name
9376 nil
9377 nil))))))
9378 (gnus-message 6 "Expiring articles...done")))))
9379
9380 (defun gnus-summary-expire-articles-now ()
9381 "Expunge all expirable articles in the current group.
9382 This means that *all* articles that are marked as expirable will be
9383 deleted forever, right now."
9384 (interactive)
9385 (or gnus-expert-user
9386 (gnus-yes-or-no-p
9387 "Are you really, really, really sure you want to delete all these messages? ")
9388 (error "Phew!"))
9389 (gnus-summary-expire-articles t))
9390
9391 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9392 (defun gnus-summary-delete-article (&optional n)
9393 "Delete the N next (mail) articles.
9394 This command actually deletes articles. This is not a marking
9395 command. The article will disappear forever from your life, never to
9396 return.
9397
9398 If N is negative, delete backwards.
9399 If N is nil and articles have been marked with the process mark,
9400 delete these instead.
9401
9402 If `gnus-novice-user' is non-nil you will be asked for
9403 confirmation before the articles are deleted."
9404 (interactive "P")
9405 (unless (gnus-check-backend-function 'request-expire-articles
9406 gnus-newsgroup-name)
9407 (error "The current newsgroup does not support article deletion"))
9408 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9409 (error "Couldn't open server"))
9410 ;; Compute the list of articles to delete.
9411 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9412 (nnmail-expiry-target 'delete)
9413 not-deleted)
9414 (if (and gnus-novice-user
9415 (not (gnus-yes-or-no-p
9416 (format "Do you really want to delete %s forever? "
9417 (if (> (length articles) 1)
9418 (format "these %s articles" (length articles))
9419 "this article")))))
9420 ()
9421 ;; Delete the articles.
9422 (setq not-deleted (gnus-request-expire-articles
9423 articles gnus-newsgroup-name 'force))
9424 (while articles
9425 (gnus-summary-remove-process-mark (car articles))
9426 ;; The backend might not have been able to delete the article
9427 ;; after all.
9428 (unless (memq (car articles) not-deleted)
9429 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9430 (let* ((article (car articles))
9431 (id (mail-header-id (gnus-data-header
9432 (assoc article (gnus-data-list nil))))))
9433 (run-hook-with-args 'gnus-summary-article-delete-hook
9434 'delete id gnus-newsgroup-name nil
9435 nil))
9436 (setq articles (cdr articles)))
9437 (when not-deleted
9438 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9439 (gnus-summary-position-point)
9440 (gnus-set-mode-line 'summary)
9441 not-deleted))
9442
9443 (defun gnus-summary-edit-article (&optional arg)
9444 "Edit the current article.
9445 This will have permanent effect only in mail groups.
9446 If ARG is nil, edit the decoded articles.
9447 If ARG is 1, edit the raw articles.
9448 If ARG is 2, edit the raw articles even in read-only groups.
9449 If ARG is 3, edit the articles with the current handles.
9450 Otherwise, allow editing of articles even in read-only
9451 groups."
9452 (interactive "P")
9453 (let (force raw current-handles)
9454 (cond
9455 ((null arg))
9456 ((eq arg 1)
9457 (setq raw t))
9458 ((eq arg 2)
9459 (setq raw t
9460 force t))
9461 ((eq arg 3)
9462 (setq current-handles
9463 (and (gnus-buffer-live-p gnus-article-buffer)
9464 (with-current-buffer gnus-article-buffer
9465 (prog1
9466 gnus-article-mime-handles
9467 (setq gnus-article-mime-handles nil))))))
9468 (t
9469 (setq force t)))
9470 (when (and raw (not force)
9471 (member gnus-newsgroup-name '("nndraft:delayed"
9472 "nndraft:drafts"
9473 "nndraft:queue")))
9474 (error "Can't edit the raw article in group %s"
9475 gnus-newsgroup-name))
9476 (save-excursion
9477 (set-buffer gnus-summary-buffer)
9478 (let ((mail-parse-charset gnus-newsgroup-charset)
9479 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9480 (gnus-set-global-variables)
9481 (when (and (not force)
9482 (gnus-group-read-only-p))
9483 (error "The current newsgroup does not support article editing"))
9484 (gnus-summary-show-article t)
9485 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9486 (with-current-buffer gnus-article-buffer
9487 (mm-enable-multibyte)))
9488 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9489 (setq raw t))
9490 (gnus-article-edit-article
9491 (if raw 'ignore
9492 `(lambda ()
9493 (let ((mbl mml-buffer-list))
9494 (setq mml-buffer-list nil)
9495 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
9496 (mime-to-mml ,'current-handles))
9497 (let ((mbl1 mml-buffer-list))
9498 (setq mml-buffer-list mbl)
9499 (set (make-local-variable 'mml-buffer-list) mbl1))
9500 (gnus-make-local-hook 'kill-buffer-hook)
9501 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9502 `(lambda (no-highlight)
9503 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9504 (message-options message-options)
9505 (message-options-set-recipient)
9506 (mail-parse-ignored-charsets
9507 ',gnus-newsgroup-ignored-charsets))
9508 ,(if (not raw) '(progn
9509 (mml-to-mime)
9510 (mml-destroy-buffers)
9511 (remove-hook 'kill-buffer-hook
9512 'mml-destroy-buffers t)
9513 (kill-local-variable 'mml-buffer-list)))
9514 (gnus-summary-edit-article-done
9515 ,(or (mail-header-references gnus-current-headers) "")
9516 ,(gnus-group-read-only-p)
9517 ,gnus-summary-buffer no-highlight))))))))
9518
9519 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9520
9521 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9522 no-highlight)
9523 "Make edits to the current article permanent."
9524 (interactive)
9525 (save-excursion
9526 ;; The buffer restriction contains the entire article if it exists.
9527 (when (article-goto-body)
9528 (let ((lines (count-lines (point) (point-max)))
9529 (length (- (point-max) (point)))
9530 (case-fold-search t)
9531 (body (copy-marker (point))))
9532 (goto-char (point-min))
9533 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9534 (delete-region (match-beginning 1) (match-end 1))
9535 (insert (number-to-string length)))
9536 (goto-char (point-min))
9537 (when (re-search-forward
9538 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9539 (delete-region (match-beginning 1) (match-end 1))
9540 (insert (number-to-string length)))
9541 (goto-char (point-min))
9542 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9543 (delete-region (match-beginning 1) (match-end 1))
9544 (insert (number-to-string lines))))))
9545 ;; Replace the article.
9546 (let ((buf (current-buffer)))
9547 (with-temp-buffer
9548 (insert-buffer-substring buf)
9549
9550 (if (and (not read-only)
9551 (not (gnus-request-replace-article
9552 (cdr gnus-article-current) (car gnus-article-current)
9553 (current-buffer) t)))
9554 (error "Couldn't replace article")
9555 ;; Update the summary buffer.
9556 (if (and references
9557 (equal (message-tokenize-header references " ")
9558 (message-tokenize-header
9559 (or (message-fetch-field "references") "") " ")))
9560 ;; We only have to update this line.
9561 (save-excursion
9562 (save-restriction
9563 (message-narrow-to-head)
9564 (let ((head (buffer-string))
9565 header)
9566 (with-temp-buffer
9567 (insert (format "211 %d Article retrieved.\n"
9568 (cdr gnus-article-current)))
9569 (insert head)
9570 (insert ".\n")
9571 (let ((nntp-server-buffer (current-buffer)))
9572 (setq header (car (gnus-get-newsgroup-headers
9573 nil t))))
9574 (save-excursion
9575 (set-buffer gnus-summary-buffer)
9576 (gnus-data-set-header
9577 (gnus-data-find (cdr gnus-article-current))
9578 header)
9579 (gnus-summary-update-article-line
9580 (cdr gnus-article-current) header)
9581 (if (gnus-summary-goto-subject
9582 (cdr gnus-article-current) nil t)
9583 (gnus-summary-update-secondary-mark
9584 (cdr gnus-article-current))))))))
9585 ;; Update threads.
9586 (set-buffer (or buffer gnus-summary-buffer))
9587 (gnus-summary-update-article (cdr gnus-article-current))
9588 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9589 (gnus-summary-update-secondary-mark
9590 (cdr gnus-article-current))))
9591 ;; Prettify the article buffer again.
9592 (unless no-highlight
9593 (save-excursion
9594 (set-buffer gnus-article-buffer)
9595 ;;;!!! Fix this -- article should be rehighlighted.
9596 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9597 (set-buffer gnus-original-article-buffer)
9598 (gnus-request-article
9599 (cdr gnus-article-current)
9600 (car gnus-article-current) (current-buffer))))
9601 ;; Prettify the summary buffer line.
9602 (when (gnus-visual-p 'summary-highlight 'highlight)
9603 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9604
9605 (defun gnus-summary-edit-wash (key)
9606 "Perform editing command KEY in the article buffer."
9607 (interactive
9608 (list
9609 (progn
9610 (message "%s" (concat (this-command-keys) "- "))
9611 (read-char))))
9612 (message "")
9613 (gnus-summary-edit-article)
9614 (execute-kbd-macro (concat (this-command-keys) key))
9615 (gnus-article-edit-done))
9616
9617 ;;; Respooling
9618
9619 (defun gnus-summary-respool-query (&optional silent trace)
9620 "Query where the respool algorithm would put this article."
9621 (interactive)
9622 (let (gnus-mark-article-hook)
9623 (gnus-summary-select-article)
9624 (save-excursion
9625 (set-buffer gnus-original-article-buffer)
9626 (let ((groups (nnmail-article-group 'identity trace)))
9627 (unless silent
9628 (if groups
9629 (message "This message would go to %s"
9630 (mapconcat 'car groups ", "))
9631 (message "This message would go to no groups"))
9632 groups)))))
9633
9634 (defun gnus-summary-respool-trace ()
9635 "Trace where the respool algorithm would put this article.
9636 Display a buffer showing all fancy splitting patterns which matched."
9637 (interactive)
9638 (gnus-summary-respool-query nil t))
9639
9640 ;; Summary marking commands.
9641
9642 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9643 "Mark articles which has the same subject as read, and then select the next.
9644 If UNMARK is positive, remove any kind of mark.
9645 If UNMARK is negative, tick articles."
9646 (interactive "P")
9647 (when unmark
9648 (setq unmark (prefix-numeric-value unmark)))
9649 (let ((count
9650 (gnus-summary-mark-same-subject
9651 (gnus-summary-article-subject) unmark)))
9652 ;; Select next unread article. If auto-select-same mode, should
9653 ;; select the first unread article.
9654 (gnus-summary-next-article t (and gnus-auto-select-same
9655 (gnus-summary-article-subject)))
9656 (gnus-message 7 "%d article%s marked as %s"
9657 count (if (= count 1) " is" "s are")
9658 (if unmark "unread" "read"))))
9659
9660 (defun gnus-summary-kill-same-subject (&optional unmark)
9661 "Mark articles which has the same subject as read.
9662 If UNMARK is positive, remove any kind of mark.
9663 If UNMARK is negative, tick articles."
9664 (interactive "P")
9665 (when unmark
9666 (setq unmark (prefix-numeric-value unmark)))
9667 (let ((count
9668 (gnus-summary-mark-same-subject
9669 (gnus-summary-article-subject) unmark)))
9670 ;; If marked as read, go to next unread subject.
9671 (when (null unmark)
9672 ;; Go to next unread subject.
9673 (gnus-summary-next-subject 1 t))
9674 (gnus-message 7 "%d articles are marked as %s"
9675 count (if unmark "unread" "read"))))
9676
9677 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9678 "Mark articles with same SUBJECT as read, and return marked number.
9679 If optional argument UNMARK is positive, remove any kinds of marks.
9680 If optional argument UNMARK is negative, mark articles as unread instead."
9681 (let ((count 1))
9682 (save-excursion
9683 (cond
9684 ((null unmark) ; Mark as read.
9685 (while (and
9686 (progn
9687 (gnus-summary-mark-article-as-read gnus-killed-mark)
9688 (gnus-summary-show-thread) t)
9689 (gnus-summary-find-subject subject))
9690 (setq count (1+ count))))
9691 ((> unmark 0) ; Tick.
9692 (while (and
9693 (progn
9694 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9695 (gnus-summary-show-thread) t)
9696 (gnus-summary-find-subject subject))
9697 (setq count (1+ count))))
9698 (t ; Mark as unread.
9699 (while (and
9700 (progn
9701 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9702 (gnus-summary-show-thread) t)
9703 (gnus-summary-find-subject subject))
9704 (setq count (1+ count)))))
9705 (gnus-set-mode-line 'summary)
9706 ;; Return the number of marked articles.
9707 count)))
9708
9709 (defun gnus-summary-mark-as-processable (n &optional unmark)
9710 "Set the process mark on the next N articles.
9711 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9712 the process mark instead. The difference between N and the actual
9713 number of articles marked is returned."
9714 (interactive "P")
9715 (if (and (null n) (gnus-region-active-p))
9716 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9717 (setq n (prefix-numeric-value n))
9718 (let ((backward (< n 0))
9719 (n (abs n)))
9720 (while (and
9721 (> n 0)
9722 (if unmark
9723 (gnus-summary-remove-process-mark
9724 (gnus-summary-article-number))
9725 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9726 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9727 (setq n (1- n)))
9728 (when (/= 0 n)
9729 (gnus-message 7 "No more articles"))
9730 (gnus-summary-recenter)
9731 (gnus-summary-position-point)
9732 n)))
9733
9734 (defun gnus-summary-unmark-as-processable (n)
9735 "Remove the process mark from the next N articles.
9736 If N is negative, unmark backward instead. The difference between N and
9737 the actual number of articles unmarked is returned."
9738 (interactive "P")
9739 (gnus-summary-mark-as-processable n t))
9740
9741 (defun gnus-summary-unmark-all-processable ()
9742 "Remove the process mark from all articles."
9743 (interactive)
9744 (save-excursion
9745 (while gnus-newsgroup-processable
9746 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9747 (gnus-summary-position-point))
9748
9749 (defun gnus-summary-add-mark (article type)
9750 "Mark ARTICLE with a mark of TYPE."
9751 (let ((vtype (car (assq type gnus-article-mark-lists)))
9752 var)
9753 (if (not vtype)
9754 (error "No such mark type: %s" type)
9755 (setq var (intern (format "gnus-newsgroup-%s" type)))
9756 (set var (cons article (symbol-value var)))
9757 (if (memq type '(processable cached replied forwarded recent saved))
9758 (gnus-summary-update-secondary-mark article)
9759 ;;; !!! This is bogus. We should find out what primary
9760 ;;; !!! mark we want to set.
9761 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9762
9763 (defun gnus-summary-mark-as-expirable (n)
9764 "Mark N articles forward as expirable.
9765 If N is negative, mark backward instead. The difference between N and
9766 the actual number of articles marked is returned."
9767 (interactive "p")
9768 (gnus-summary-mark-forward n gnus-expirable-mark))
9769
9770 (defun gnus-summary-mark-as-spam (n)
9771 "Mark N articles forward as spam.
9772 If N is negative, mark backward instead. The difference between N and
9773 the actual number of articles marked is returned."
9774 (interactive "p")
9775 (gnus-summary-mark-forward n gnus-spam-mark))
9776
9777 (defun gnus-summary-mark-article-as-replied (article)
9778 "Mark ARTICLE as replied to and update the summary line.
9779 ARTICLE can also be a list of articles."
9780 (interactive (list (gnus-summary-article-number)))
9781 (let ((articles (if (listp article) article (list article))))
9782 (dolist (article articles)
9783 (unless (numberp article)
9784 (error "%s is not a number" article))
9785 (push article gnus-newsgroup-replied)
9786 (let ((buffer-read-only nil))
9787 (when (gnus-summary-goto-subject article nil t)
9788 (gnus-summary-update-secondary-mark article))))))
9789
9790 (defun gnus-summary-mark-article-as-forwarded (article)
9791 "Mark ARTICLE as forwarded and update the summary line.
9792 ARTICLE can also be a list of articles."
9793 (let ((articles (if (listp article) article (list article))))
9794 (dolist (article articles)
9795 (push article gnus-newsgroup-forwarded)
9796 (let ((buffer-read-only nil))
9797 (when (gnus-summary-goto-subject article nil t)
9798 (gnus-summary-update-secondary-mark article))))))
9799
9800 (defun gnus-summary-set-bookmark (article)
9801 "Set a bookmark in current article."
9802 (interactive (list (gnus-summary-article-number)))
9803 (when (or (not (get-buffer gnus-article-buffer))
9804 (not gnus-current-article)
9805 (not gnus-article-current)
9806 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9807 (error "No current article selected"))
9808 ;; Remove old bookmark, if one exists.
9809 (gnus-pull article gnus-newsgroup-bookmarks)
9810 ;; Set the new bookmark, which is on the form
9811 ;; (article-number . line-number-in-body).
9812 (push
9813 (cons article
9814 (save-excursion
9815 (set-buffer gnus-article-buffer)
9816 (count-lines
9817 (min (point)
9818 (save-excursion
9819 (article-goto-body)
9820 (point)))
9821 (point))))
9822 gnus-newsgroup-bookmarks)
9823 (gnus-message 6 "A bookmark has been added to the current article."))
9824
9825 (defun gnus-summary-remove-bookmark (article)
9826 "Remove the bookmark from the current article."
9827 (interactive (list (gnus-summary-article-number)))
9828 ;; Remove old bookmark, if one exists.
9829 (if (not (assq article gnus-newsgroup-bookmarks))
9830 (gnus-message 6 "No bookmark in current article.")
9831 (gnus-pull article gnus-newsgroup-bookmarks)
9832 (gnus-message 6 "Removed bookmark.")))
9833
9834 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9835 (defun gnus-summary-mark-as-dormant (n)
9836 "Mark N articles forward as dormant.
9837 If N is negative, mark backward instead. The difference between N and
9838 the actual number of articles marked is returned."
9839 (interactive "p")
9840 (gnus-summary-mark-forward n gnus-dormant-mark))
9841
9842 (defun gnus-summary-set-process-mark (article)
9843 "Set the process mark on ARTICLE and update the summary line."
9844 (setq gnus-newsgroup-processable
9845 (cons article
9846 (delq article gnus-newsgroup-processable)))
9847 (when (gnus-summary-goto-subject article)
9848 (gnus-summary-show-thread)
9849 (gnus-summary-goto-subject article)
9850 (gnus-summary-update-secondary-mark article)))
9851
9852 (defun gnus-summary-remove-process-mark (article)
9853 "Remove the process mark from ARTICLE and update the summary line."
9854 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9855 (when (gnus-summary-goto-subject article)
9856 (gnus-summary-show-thread)
9857 (gnus-summary-goto-subject article)
9858 (gnus-summary-update-secondary-mark article)))
9859
9860 (defun gnus-summary-set-saved-mark (article)
9861 "Set the process mark on ARTICLE and update the summary line."
9862 (push article gnus-newsgroup-saved)
9863 (when (gnus-summary-goto-subject article)
9864 (gnus-summary-update-secondary-mark article)))
9865
9866 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9867 "Mark N articles as read forwards.
9868 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9869 The difference between N and the actual number of articles marked is
9870 returned.
9871 If NO-EXPIRE, auto-expiry will be inhibited."
9872 (interactive "p")
9873 (gnus-summary-show-thread)
9874 (let ((backward (< n 0))
9875 (gnus-summary-goto-unread
9876 (and gnus-summary-goto-unread
9877 (not (eq gnus-summary-goto-unread 'never))
9878 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9879 gnus-ticked-mark gnus-dormant-mark)))))
9880 (n (abs n))
9881 (mark (or mark gnus-del-mark)))
9882 (while (and (> n 0)
9883 (gnus-summary-mark-article nil mark no-expire)
9884 (zerop (gnus-summary-next-subject
9885 (if backward -1 1)
9886 (and gnus-summary-goto-unread
9887 (not (eq gnus-summary-goto-unread 'never)))
9888 t)))
9889 (setq n (1- n)))
9890 (when (/= 0 n)
9891 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9892 (gnus-summary-recenter)
9893 (gnus-summary-position-point)
9894 (gnus-set-mode-line 'summary)
9895 n))
9896
9897 (defun gnus-summary-mark-article-as-read (mark)
9898 "Mark the current article quickly as read with MARK."
9899 (let ((article (gnus-summary-article-number)))
9900 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9901 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9902 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9903 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9904 (push (cons article mark) gnus-newsgroup-reads)
9905 ;; Possibly remove from cache, if that is used.
9906 (when gnus-use-cache
9907 (gnus-cache-enter-remove-article article))
9908 ;; Allow the backend to change the mark.
9909 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9910 ;; Check for auto-expiry.
9911 (when (and gnus-newsgroup-auto-expire
9912 (memq mark gnus-auto-expirable-marks))
9913 (setq mark gnus-expirable-mark)
9914 ;; Let the backend know about the mark change.
9915 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9916 (push article gnus-newsgroup-expirable))
9917 ;; Set the mark in the buffer.
9918 (gnus-summary-update-mark mark 'unread)
9919 t))
9920
9921 (defun gnus-summary-mark-article-as-unread (mark)
9922 "Mark the current article quickly as unread with MARK."
9923 (let* ((article (gnus-summary-article-number))
9924 (old-mark (gnus-summary-article-mark article)))
9925 ;; Allow the backend to change the mark.
9926 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9927 (if (eq mark old-mark)
9928 t
9929 (if (<= article 0)
9930 (progn
9931 (gnus-error 1 "Can't mark negative article numbers")
9932 nil)
9933 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9934 (setq gnus-newsgroup-spam-marked
9935 (delq article gnus-newsgroup-spam-marked))
9936 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9937 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9938 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9939 (cond ((= mark gnus-ticked-mark)
9940 (setq gnus-newsgroup-marked
9941 (gnus-add-to-sorted-list gnus-newsgroup-marked
9942 article)))
9943 ((= mark gnus-spam-mark)
9944 (setq gnus-newsgroup-spam-marked
9945 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9946 article)))
9947 ((= mark gnus-dormant-mark)
9948 (setq gnus-newsgroup-dormant
9949 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9950 article)))
9951 (t
9952 (setq gnus-newsgroup-unreads
9953 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9954 article))))
9955 (gnus-pull article gnus-newsgroup-reads)
9956
9957 ;; See whether the article is to be put in the cache.
9958 (and gnus-use-cache
9959 (vectorp (gnus-summary-article-header article))
9960 (save-excursion
9961 (gnus-cache-possibly-enter-article
9962 gnus-newsgroup-name article
9963 (= mark gnus-ticked-mark)
9964 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9965
9966 ;; Fix the mark.
9967 (gnus-summary-update-mark mark 'unread)
9968 t))))
9969
9970 (defun gnus-summary-mark-article (&optional article mark no-expire)
9971 "Mark ARTICLE with MARK. MARK can be any character.
9972 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9973 `??' (dormant) and `?E' (expirable).
9974 If MARK is nil, then the default character `?r' is used.
9975 If ARTICLE is nil, then the article on the current line will be
9976 marked.
9977 If NO-EXPIRE, auto-expiry will be inhibited."
9978 ;; The mark might be a string.
9979 (when (stringp mark)
9980 (setq mark (aref mark 0)))
9981 ;; If no mark is given, then we check auto-expiring.
9982 (when (null mark)
9983 (setq mark gnus-del-mark))
9984 (when (and (not no-expire)
9985 gnus-newsgroup-auto-expire
9986 (memq mark gnus-auto-expirable-marks))
9987 (setq mark gnus-expirable-mark))
9988 (let ((article (or article (gnus-summary-article-number)))
9989 (old-mark (gnus-summary-article-mark article)))
9990 ;; Allow the backend to change the mark.
9991 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9992 (if (eq mark old-mark)
9993 t
9994 (unless article
9995 (error "No article on current line"))
9996 (if (not (if (or (= mark gnus-unread-mark)
9997 (= mark gnus-ticked-mark)
9998 (= mark gnus-spam-mark)
9999 (= mark gnus-dormant-mark))
10000 (gnus-mark-article-as-unread article mark)
10001 (gnus-mark-article-as-read article mark)))
10002 t
10003 ;; See whether the article is to be put in the cache.
10004 (and gnus-use-cache
10005 (not (= mark gnus-canceled-mark))
10006 (vectorp (gnus-summary-article-header article))
10007 (save-excursion
10008 (gnus-cache-possibly-enter-article
10009 gnus-newsgroup-name article
10010 (= mark gnus-ticked-mark)
10011 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10012
10013 (when (gnus-summary-goto-subject article nil t)
10014 (let ((buffer-read-only nil))
10015 (gnus-summary-show-thread)
10016 ;; Fix the mark.
10017 (gnus-summary-update-mark mark 'unread)
10018 t))))))
10019
10020 (defun gnus-summary-update-secondary-mark (article)
10021 "Update the secondary (read, process, cache) mark."
10022 (gnus-summary-update-mark
10023 (cond ((memq article gnus-newsgroup-processable)
10024 gnus-process-mark)
10025 ((memq article gnus-newsgroup-cached)
10026 gnus-cached-mark)
10027 ((memq article gnus-newsgroup-replied)
10028 gnus-replied-mark)
10029 ((memq article gnus-newsgroup-forwarded)
10030 gnus-forwarded-mark)
10031 ((memq article gnus-newsgroup-saved)
10032 gnus-saved-mark)
10033 ((memq article gnus-newsgroup-recent)
10034 gnus-recent-mark)
10035 ((memq article gnus-newsgroup-unseen)
10036 gnus-unseen-mark)
10037 (t gnus-no-mark))
10038 'replied)
10039 (when (gnus-visual-p 'summary-highlight 'highlight)
10040 (gnus-run-hooks 'gnus-summary-update-hook))
10041 t)
10042
10043 (defun gnus-summary-update-download-mark (article)
10044 "Update the download mark."
10045 (gnus-summary-update-mark
10046 (cond ((memq article gnus-newsgroup-undownloaded)
10047 gnus-undownloaded-mark)
10048 (gnus-newsgroup-agentized
10049 gnus-downloaded-mark)
10050 (t
10051 gnus-no-mark))
10052 'download)
10053 (gnus-summary-update-line t)
10054 t)
10055
10056 (defun gnus-summary-update-mark (mark type)
10057 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10058 (buffer-read-only nil))
10059 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
10060 (when forward
10061 (when (looking-at "\r")
10062 (incf forward))
10063 (when (<= (+ forward (point)) (point-max))
10064 ;; Go to the right position on the line.
10065 (goto-char (+ forward (point)))
10066 ;; Replace the old mark with the new mark.
10067 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10068 ;; Optionally update the marks by some user rule.
10069 (when (eq type 'unread)
10070 (gnus-data-set-mark
10071 (gnus-data-find (gnus-summary-article-number)) mark)
10072 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10073
10074 (defun gnus-mark-article-as-read (article &optional mark)
10075 "Enter ARTICLE in the pertinent lists and remove it from others."
10076 ;; Make the article expirable.
10077 (let ((mark (or mark gnus-del-mark)))
10078 (setq gnus-newsgroup-expirable
10079 (if (= mark gnus-expirable-mark)
10080 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10081 (delq article gnus-newsgroup-expirable)))
10082 ;; Remove from unread and marked lists.
10083 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10084 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10085 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10086 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10087 (push (cons article mark) gnus-newsgroup-reads)
10088 ;; Possibly remove from cache, if that is used.
10089 (when gnus-use-cache
10090 (gnus-cache-enter-remove-article article))
10091 t))
10092
10093 (defun gnus-mark-article-as-unread (article &optional mark)
10094 "Enter ARTICLE in the pertinent lists and remove it from others."
10095 (let ((mark (or mark gnus-ticked-mark)))
10096 (if (<= article 0)
10097 (progn
10098 (gnus-error 1 "Can't mark negative article numbers")
10099 nil)
10100 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10101 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10102 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10103 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10104 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10105
10106 ;; Unsuppress duplicates?
10107 (when gnus-suppress-duplicates
10108 (gnus-dup-unsuppress-article article))
10109
10110 (cond ((= mark gnus-ticked-mark)
10111 (setq gnus-newsgroup-marked
10112 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10113 ((= mark gnus-spam-mark)
10114 (setq gnus-newsgroup-spam-marked
10115 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10116 article)))
10117 ((= mark gnus-dormant-mark)
10118 (setq gnus-newsgroup-dormant
10119 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10120 (t
10121 (setq gnus-newsgroup-unreads
10122 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10123 (gnus-pull article gnus-newsgroup-reads)
10124 t)))
10125
10126 (defalias 'gnus-summary-mark-as-unread-forward
10127 'gnus-summary-tick-article-forward)
10128 (make-obsolete 'gnus-summary-mark-as-unread-forward
10129 'gnus-summary-tick-article-forward)
10130 (defun gnus-summary-tick-article-forward (n)
10131 "Tick N articles forwards.
10132 If N is negative, tick backwards instead.
10133 The difference between N and the number of articles ticked is returned."
10134 (interactive "p")
10135 (gnus-summary-mark-forward n gnus-ticked-mark))
10136
10137 (defalias 'gnus-summary-mark-as-unread-backward
10138 'gnus-summary-tick-article-backward)
10139 (make-obsolete 'gnus-summary-mark-as-unread-backward
10140 'gnus-summary-tick-article-backward)
10141 (defun gnus-summary-tick-article-backward (n)
10142 "Tick N articles backwards.
10143 The difference between N and the number of articles ticked is returned."
10144 (interactive "p")
10145 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10146
10147 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10148 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10149 (defun gnus-summary-tick-article (&optional article clear-mark)
10150 "Mark current article as unread.
10151 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10152 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10153 (interactive)
10154 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10155 gnus-ticked-mark)))
10156
10157 (defun gnus-summary-mark-as-read-forward (n)
10158 "Mark N articles as read forwards.
10159 If N is negative, mark backwards instead.
10160 The difference between N and the actual number of articles marked is
10161 returned."
10162 (interactive "p")
10163 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10164
10165 (defun gnus-summary-mark-as-read-backward (n)
10166 "Mark the N articles as read backwards.
10167 The difference between N and the actual number of articles marked is
10168 returned."
10169 (interactive "p")
10170 (gnus-summary-mark-forward
10171 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10172
10173 (defun gnus-summary-mark-as-read (&optional article mark)
10174 "Mark current article as read.
10175 ARTICLE specifies the article to be marked as read.
10176 MARK specifies a string to be inserted at the beginning of the line."
10177 (gnus-summary-mark-article article mark))
10178
10179 (defun gnus-summary-clear-mark-forward (n)
10180 "Clear marks from N articles forward.
10181 If N is negative, clear backward instead.
10182 The difference between N and the number of marks cleared is returned."
10183 (interactive "p")
10184 (gnus-summary-mark-forward n gnus-unread-mark))
10185
10186 (defun gnus-summary-clear-mark-backward (n)
10187 "Clear marks from N articles backward.
10188 The difference between N and the number of marks cleared is returned."
10189 (interactive "p")
10190 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10191
10192 (defun gnus-summary-mark-unread-as-read ()
10193 "Intended to be used by `gnus-summary-mark-article-hook'."
10194 (when (memq gnus-current-article gnus-newsgroup-unreads)
10195 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10196
10197 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10198 "Intended to be used by `gnus-summary-mark-article-hook'."
10199 (let ((mark (gnus-summary-article-mark)))
10200 (when (or (gnus-unread-mark-p mark)
10201 (gnus-read-mark-p mark))
10202 (gnus-summary-mark-article gnus-current-article
10203 (or new-mark gnus-read-mark)))))
10204
10205 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10206 "Intended to be used by `gnus-summary-mark-article-hook'."
10207 (let ((mark (gnus-summary-article-mark)))
10208 (when (or (gnus-unread-mark-p mark)
10209 (gnus-read-mark-p mark))
10210 (gnus-summary-mark-article (gnus-summary-article-number)
10211 (or new-mark gnus-read-mark)))))
10212
10213 (defun gnus-summary-mark-unread-as-ticked ()
10214 "Intended to be used by `gnus-summary-mark-article-hook'."
10215 (when (memq gnus-current-article gnus-newsgroup-unreads)
10216 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10217
10218 (defun gnus-summary-mark-region-as-read (point mark all)
10219 "Mark all unread articles between point and mark as read.
10220 If given a prefix, mark all articles between point and mark as read,
10221 even ticked and dormant ones."
10222 (interactive "r\nP")
10223 (save-excursion
10224 (let (article)
10225 (goto-char point)
10226 (beginning-of-line)
10227 (while (and
10228 (< (point) mark)
10229 (progn
10230 (when (or all
10231 (memq (setq article (gnus-summary-article-number))
10232 gnus-newsgroup-unreads))
10233 (gnus-summary-mark-article article gnus-del-mark))
10234 t)
10235 (gnus-summary-find-next))))))
10236
10237 (defun gnus-summary-mark-below (score mark)
10238 "Mark articles with score less than SCORE with MARK."
10239 (interactive "P\ncMark: ")
10240 (setq score (if score
10241 (prefix-numeric-value score)
10242 (or gnus-summary-default-score 0)))
10243 (save-excursion
10244 (set-buffer gnus-summary-buffer)
10245 (goto-char (point-min))
10246 (while
10247 (progn
10248 (and (< (gnus-summary-article-score) score)
10249 (gnus-summary-mark-article nil mark))
10250 (gnus-summary-find-next)))))
10251
10252 (defun gnus-summary-kill-below (&optional score)
10253 "Mark articles with score below SCORE as read."
10254 (interactive "P")
10255 (gnus-summary-mark-below score gnus-killed-mark))
10256
10257 (defun gnus-summary-clear-above (&optional score)
10258 "Clear all marks from articles with score above SCORE."
10259 (interactive "P")
10260 (gnus-summary-mark-above score gnus-unread-mark))
10261
10262 (defun gnus-summary-tick-above (&optional score)
10263 "Tick all articles with score above SCORE."
10264 (interactive "P")
10265 (gnus-summary-mark-above score gnus-ticked-mark))
10266
10267 (defun gnus-summary-mark-above (score mark)
10268 "Mark articles with score over SCORE with MARK."
10269 (interactive "P\ncMark: ")
10270 (setq score (if score
10271 (prefix-numeric-value score)
10272 (or gnus-summary-default-score 0)))
10273 (save-excursion
10274 (set-buffer gnus-summary-buffer)
10275 (goto-char (point-min))
10276 (while (and (progn
10277 (when (> (gnus-summary-article-score) score)
10278 (gnus-summary-mark-article nil mark))
10279 t)
10280 (gnus-summary-find-next)))))
10281
10282 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10283 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10284 (defun gnus-summary-limit-include-expunged (&optional no-error)
10285 "Display all the hidden articles that were expunged for low scores."
10286 (interactive)
10287 (let ((buffer-read-only nil))
10288 (let ((scored gnus-newsgroup-scored)
10289 headers h)
10290 (while scored
10291 (unless (gnus-summary-article-header (caar scored))
10292 (and (setq h (gnus-number-to-header (caar scored)))
10293 (< (cdar scored) gnus-summary-expunge-below)
10294 (push h headers)))
10295 (setq scored (cdr scored)))
10296 (if (not headers)
10297 (when (not no-error)
10298 (error "No expunged articles hidden"))
10299 (goto-char (point-min))
10300 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10301 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10302 (mapcar (lambda (x) (push (mail-header-number x)
10303 gnus-newsgroup-limit))
10304 headers)
10305 (gnus-summary-prepare-unthreaded (nreverse headers))
10306 (goto-char (point-min))
10307 (gnus-summary-position-point)
10308 t))))
10309
10310 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10311 "Mark all unread articles in this newsgroup as read.
10312 If prefix argument ALL is non-nil, ticked and dormant articles will
10313 also be marked as read.
10314 If QUIETLY is non-nil, no questions will be asked.
10315
10316 If TO-HERE is non-nil, it should be a point in the buffer. All
10317 articles before (after, if REVERSE is set) this point will be marked
10318 as read.
10319
10320 Note that this function will only catch up the unread article
10321 in the current summary buffer limitation.
10322
10323 The number of articles marked as read is returned."
10324 (interactive "P")
10325 (prog1
10326 (save-excursion
10327 (when (or quietly
10328 (not gnus-interactive-catchup) ;Without confirmation?
10329 gnus-expert-user
10330 (gnus-y-or-n-p
10331 (if all
10332 "Mark absolutely all articles as read? "
10333 "Mark all unread articles as read? ")))
10334 (if (and not-mark
10335 (not gnus-newsgroup-adaptive)
10336 (not gnus-newsgroup-auto-expire)
10337 (not gnus-suppress-duplicates)
10338 (or (not gnus-use-cache)
10339 (eq gnus-use-cache 'passive)))
10340 (progn
10341 (when all
10342 (setq gnus-newsgroup-marked nil
10343 gnus-newsgroup-spam-marked nil
10344 gnus-newsgroup-dormant nil))
10345 (setq gnus-newsgroup-unreads
10346 (gnus-sorted-nunion
10347 (gnus-intersection gnus-newsgroup-unreads
10348 gnus-newsgroup-downloadable)
10349 gnus-newsgroup-unfetched)))
10350 ;; We actually mark all articles as canceled, which we
10351 ;; have to do when using auto-expiry or adaptive scoring.
10352 (gnus-summary-show-all-threads)
10353 (if (and to-here reverse)
10354 (progn
10355 (goto-char to-here)
10356 (gnus-summary-mark-current-read-and-unread-as-read
10357 gnus-catchup-mark)
10358 (while (gnus-summary-find-next (not all))
10359 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10360 (when (gnus-summary-first-subject (not all))
10361 (while (and
10362 (if to-here (< (point) to-here) t)
10363 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10364 (gnus-summary-find-next (not all))))))
10365 (gnus-set-mode-line 'summary))
10366 t))
10367 (gnus-summary-position-point)))
10368
10369 (defun gnus-summary-catchup-to-here (&optional all)
10370 "Mark all unticked articles before the current one as read.
10371 If ALL is non-nil, also mark ticked and dormant articles as read."
10372 (interactive "P")
10373 (save-excursion
10374 (gnus-save-hidden-threads
10375 (let ((beg (point)))
10376 ;; We check that there are unread articles.
10377 (when (or all (gnus-summary-find-prev))
10378 (gnus-summary-catchup all t beg)))))
10379 (gnus-summary-position-point))
10380
10381 (defun gnus-summary-catchup-from-here (&optional all)
10382 "Mark all unticked articles after (and including) the current one as read.
10383 If ALL is non-nil, also mark ticked and dormant articles as read."
10384 (interactive "P")
10385 (save-excursion
10386 (gnus-save-hidden-threads
10387 (let ((beg (point)))
10388 ;; We check that there are unread articles.
10389 (when (or all (gnus-summary-find-next))
10390 (gnus-summary-catchup all t beg nil t)))))
10391 (gnus-summary-position-point))
10392
10393 (defun gnus-summary-catchup-all (&optional quietly)
10394 "Mark all articles in this newsgroup as read.
10395 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10396 instead, which marks only unread articles as read."
10397 (interactive "P")
10398 (gnus-summary-catchup t quietly))
10399
10400 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10401 "Mark all unread articles in this group as read, then exit.
10402 If prefix argument ALL is non-nil, all articles are marked as read.
10403 If QUIETLY is non-nil, no questions will be asked."
10404 (interactive "P")
10405 (when (gnus-summary-catchup all quietly nil 'fast)
10406 ;; Select next newsgroup or exit.
10407 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10408 (eq gnus-auto-select-next 'quietly))
10409 (gnus-summary-next-group nil)
10410 (gnus-summary-exit))))
10411
10412 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10413 "Mark all articles in this newsgroup as read, and then exit.
10414 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10415 instead, which marks only unread articles as read."
10416 (interactive "P")
10417 (gnus-summary-catchup-and-exit t quietly))
10418
10419 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10420 "Mark all articles in this group as read and select the next group.
10421 If given a prefix, mark all articles, unread as well as ticked, as
10422 read."
10423 (interactive "P")
10424 (save-excursion
10425 (gnus-summary-catchup all))
10426 (gnus-summary-next-group))
10427
10428 ;;;
10429 ;;; with article
10430 ;;;
10431
10432 (defmacro gnus-with-article (article &rest forms)
10433 "Select ARTICLE and perform FORMS in the original article buffer.
10434 Then replace the article with the result."
10435 `(progn
10436 ;; We don't want the article to be marked as read.
10437 (let (gnus-mark-article-hook)
10438 (gnus-summary-select-article t t nil ,article))
10439 (set-buffer gnus-original-article-buffer)
10440 ,@forms
10441 (if (not (gnus-check-backend-function
10442 'request-replace-article (car gnus-article-current)))
10443 (gnus-message 5 "Read-only group; not replacing")
10444 (unless (gnus-request-replace-article
10445 ,article (car gnus-article-current)
10446 (current-buffer) t)
10447 (error "Couldn't replace article")))
10448 ;; The cache and backlog have to be flushed somewhat.
10449 (when gnus-keep-backlog
10450 (gnus-backlog-remove-article
10451 (car gnus-article-current) (cdr gnus-article-current)))
10452 (when gnus-use-cache
10453 (gnus-cache-update-article
10454 (car gnus-article-current) (cdr gnus-article-current)))))
10455
10456 (put 'gnus-with-article 'lisp-indent-function 1)
10457 (put 'gnus-with-article 'edebug-form-spec '(form body))
10458
10459 ;; Thread-based commands.
10460
10461 (defun gnus-summary-articles-in-thread (&optional article)
10462 "Return a list of all articles in the current thread.
10463 If ARTICLE is non-nil, return all articles in the thread that starts
10464 with that article."
10465 (let* ((article (or article (gnus-summary-article-number)))
10466 (data (gnus-data-find-list article))
10467 (top-level (gnus-data-level (car data)))
10468 (top-subject
10469 (cond ((null gnus-thread-operation-ignore-subject)
10470 (gnus-simplify-subject-re
10471 (mail-header-subject (gnus-data-header (car data)))))
10472 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10473 (gnus-simplify-subject-fuzzy
10474 (mail-header-subject (gnus-data-header (car data)))))
10475 (t nil)))
10476 (end-point (save-excursion
10477 (if (gnus-summary-go-to-next-thread)
10478 (point) (point-max))))
10479 articles)
10480 (while (and data
10481 (< (gnus-data-pos (car data)) end-point))
10482 (when (or (not top-subject)
10483 (string= top-subject
10484 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10485 (gnus-simplify-subject-fuzzy
10486 (mail-header-subject
10487 (gnus-data-header (car data))))
10488 (gnus-simplify-subject-re
10489 (mail-header-subject
10490 (gnus-data-header (car data)))))))
10491 (push (gnus-data-number (car data)) articles))
10492 (unless (and (setq data (cdr data))
10493 (> (gnus-data-level (car data)) top-level))
10494 (setq data nil)))
10495 ;; Return the list of articles.
10496 (nreverse articles)))
10497
10498 (defun gnus-summary-rethread-current ()
10499 "Rethread the thread the current article is part of."
10500 (interactive)
10501 (let* ((gnus-show-threads t)
10502 (article (gnus-summary-article-number))
10503 (id (mail-header-id (gnus-summary-article-header)))
10504 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10505 (unless id
10506 (error "No article on the current line"))
10507 (gnus-rebuild-thread id)
10508 (gnus-summary-goto-subject article)))
10509
10510 (defun gnus-summary-reparent-thread ()
10511 "Make the current article child of the marked (or previous) article.
10512
10513 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10514 is non-nil or the Subject: of both articles are the same."
10515 (interactive)
10516 (unless (not (gnus-group-read-only-p))
10517 (error "The current newsgroup does not support article editing"))
10518 (unless (<= (length gnus-newsgroup-processable) 1)
10519 (error "No more than one article may be marked"))
10520 (save-window-excursion
10521 (let ((gnus-article-buffer " *reparent*")
10522 (current-article (gnus-summary-article-number))
10523 ;; First grab the marked article, otherwise one line up.
10524 (parent-article (if (not (null gnus-newsgroup-processable))
10525 (car gnus-newsgroup-processable)
10526 (save-excursion
10527 (if (eq (forward-line -1) 0)
10528 (gnus-summary-article-number)
10529 (error "Beginning of summary buffer"))))))
10530 (unless (not (eq current-article parent-article))
10531 (error "An article may not be self-referential"))
10532 (let ((message-id (mail-header-id
10533 (gnus-summary-article-header parent-article))))
10534 (unless (and message-id (not (equal message-id "")))
10535 (error "No message-id in desired parent"))
10536 (gnus-with-article current-article
10537 (save-restriction
10538 (goto-char (point-min))
10539 (message-narrow-to-head)
10540 (if (re-search-forward "^References: " nil t)
10541 (progn
10542 (re-search-forward "^[^ \t]" nil t)
10543 (forward-line -1)
10544 (end-of-line)
10545 (insert " " message-id))
10546 (insert "References: " message-id "\n"))))
10547 (set-buffer gnus-summary-buffer)
10548 (gnus-summary-unmark-all-processable)
10549 (gnus-summary-update-article current-article)
10550 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10551 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10552 (gnus-summary-rethread-current)
10553 (gnus-message 3 "Article %d is now the child of article %d"
10554 current-article parent-article)))))
10555
10556 (defun gnus-summary-toggle-threads (&optional arg)
10557 "Toggle showing conversation threads.
10558 If ARG is positive number, turn showing conversation threads on."
10559 (interactive "P")
10560 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10561 (setq gnus-show-threads
10562 (if (null arg) (not gnus-show-threads)
10563 (> (prefix-numeric-value arg) 0)))
10564 (gnus-summary-prepare)
10565 (gnus-summary-goto-subject current)
10566 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10567 (gnus-summary-position-point)))
10568
10569 (defun gnus-summary-show-all-threads ()
10570 "Show all threads."
10571 (interactive)
10572 (save-excursion
10573 (let ((buffer-read-only nil))
10574 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10575 (gnus-summary-position-point))
10576
10577 (defun gnus-summary-show-thread ()
10578 "Show thread subtrees.
10579 Returns nil if no thread was there to be shown."
10580 (interactive)
10581 (let ((buffer-read-only nil)
10582 (orig (point))
10583 (end (gnus-point-at-eol))
10584 ;; Leave point at bol
10585 (beg (progn (beginning-of-line) (point))))
10586 (prog1
10587 ;; Any hidden lines here?
10588 (search-forward "\r" end t)
10589 (subst-char-in-region beg end ?\^M ?\n t)
10590 (goto-char orig)
10591 (gnus-summary-position-point))))
10592
10593 (defun gnus-summary-maybe-hide-threads ()
10594 "If requested, hide the threads that should be hidden."
10595 (when (and gnus-show-threads
10596 gnus-thread-hide-subtree)
10597 (gnus-summary-hide-all-threads
10598 (if (or (consp gnus-thread-hide-subtree)
10599 (functionp gnus-thread-hide-subtree))
10600 (gnus-make-predicate gnus-thread-hide-subtree)
10601 nil))))
10602
10603 ;;; Hiding predicates.
10604
10605 (defun gnus-article-unread-p (header)
10606 (memq (mail-header-number header) gnus-newsgroup-unreads))
10607
10608 (defun gnus-article-unseen-p (header)
10609 (memq (mail-header-number header) gnus-newsgroup-unseen))
10610
10611 (defun gnus-map-articles (predicate articles)
10612 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10613 (apply 'gnus-or (mapcar predicate
10614 (mapcar 'gnus-summary-article-header articles))))
10615
10616 (defun gnus-summary-hide-all-threads (&optional predicate)
10617 "Hide all thread subtrees.
10618 If PREDICATE is supplied, threads that satisfy this predicate
10619 will not be hidden."
10620 (interactive)
10621 (save-excursion
10622 (goto-char (point-min))
10623 (let ((end nil))
10624 (while (not end)
10625 (when (or (not predicate)
10626 (gnus-map-articles
10627 predicate (gnus-summary-article-children)))
10628 (gnus-summary-hide-thread))
10629 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10630 (gnus-summary-position-point))
10631
10632 (defun gnus-summary-hide-thread ()
10633 "Hide thread subtrees.
10634 If PREDICATE is supplied, threads that satisfy this predicate
10635 will not be hidden.
10636 Returns nil if no threads were there to be hidden."
10637 (interactive)
10638 (let ((buffer-read-only nil)
10639 (start (point))
10640 (article (gnus-summary-article-number)))
10641 (goto-char start)
10642 ;; Go forward until either the buffer ends or the subthread
10643 ;; ends.
10644 (when (and (not (eobp))
10645 (or (zerop (gnus-summary-next-thread 1 t))
10646 (goto-char (point-max))))
10647 (prog1
10648 (if (and (> (point) start)
10649 (search-backward "\n" start t))
10650 (progn
10651 (subst-char-in-region start (point) ?\n ?\^M)
10652 (gnus-summary-goto-subject article))
10653 (goto-char start)
10654 nil)))))
10655
10656 (defun gnus-summary-go-to-next-thread (&optional previous)
10657 "Go to the same level (or less) next thread.
10658 If PREVIOUS is non-nil, go to previous thread instead.
10659 Return the article number moved to, or nil if moving was impossible."
10660 (let ((level (gnus-summary-thread-level))
10661 (way (if previous -1 1))
10662 (beg (point)))
10663 (forward-line way)
10664 (while (and (not (eobp))
10665 (< level (gnus-summary-thread-level)))
10666 (forward-line way))
10667 (if (eobp)
10668 (progn
10669 (goto-char beg)
10670 nil)
10671 (setq beg (point))
10672 (prog1
10673 (gnus-summary-article-number)
10674 (goto-char beg)))))
10675
10676 (defun gnus-summary-next-thread (n &optional silent)
10677 "Go to the same level next N'th thread.
10678 If N is negative, search backward instead.
10679 Returns the difference between N and the number of skips actually
10680 done.
10681
10682 If SILENT, don't output messages."
10683 (interactive "p")
10684 (let ((backward (< n 0))
10685 (n (abs n)))
10686 (while (and (> n 0)
10687 (gnus-summary-go-to-next-thread backward))
10688 (decf n))
10689 (unless silent
10690 (gnus-summary-position-point))
10691 (when (and (not silent) (/= 0 n))
10692 (gnus-message 7 "No more threads"))
10693 n))
10694
10695 (defun gnus-summary-prev-thread (n)
10696 "Go to the same level previous N'th thread.
10697 Returns the difference between N and the number of skips actually
10698 done."
10699 (interactive "p")
10700 (gnus-summary-next-thread (- n)))
10701
10702 (defun gnus-summary-go-down-thread ()
10703 "Go down one level in the current thread."
10704 (let ((children (gnus-summary-article-children)))
10705 (when children
10706 (gnus-summary-goto-subject (car children)))))
10707
10708 (defun gnus-summary-go-up-thread ()
10709 "Go up one level in the current thread."
10710 (let ((parent (gnus-summary-article-parent)))
10711 (when parent
10712 (gnus-summary-goto-subject parent))))
10713
10714 (defun gnus-summary-down-thread (n)
10715 "Go down thread N steps.
10716 If N is negative, go up instead.
10717 Returns the difference between N and how many steps down that were
10718 taken."
10719 (interactive "p")
10720 (let ((up (< n 0))
10721 (n (abs n)))
10722 (while (and (> n 0)
10723 (if up (gnus-summary-go-up-thread)
10724 (gnus-summary-go-down-thread)))
10725 (setq n (1- n)))
10726 (gnus-summary-position-point)
10727 (when (/= 0 n)
10728 (gnus-message 7 "Can't go further"))
10729 n))
10730
10731 (defun gnus-summary-up-thread (n)
10732 "Go up thread N steps.
10733 If N is negative, go down instead.
10734 Returns the difference between N and how many steps down that were
10735 taken."
10736 (interactive "p")
10737 (gnus-summary-down-thread (- n)))
10738
10739 (defun gnus-summary-top-thread ()
10740 "Go to the top of the thread."
10741 (interactive)
10742 (while (gnus-summary-go-up-thread))
10743 (gnus-summary-article-number))
10744
10745 (defun gnus-summary-kill-thread (&optional unmark)
10746 "Mark articles under current thread as read.
10747 If the prefix argument is positive, remove any kinds of marks.
10748 If the prefix argument is negative, tick articles instead."
10749 (interactive "P")
10750 (when unmark
10751 (setq unmark (prefix-numeric-value unmark)))
10752 (let ((articles (gnus-summary-articles-in-thread)))
10753 (save-excursion
10754 ;; Expand the thread.
10755 (gnus-summary-show-thread)
10756 ;; Mark all the articles.
10757 (while articles
10758 (gnus-summary-goto-subject (car articles))
10759 (cond ((null unmark)
10760 (gnus-summary-mark-article-as-read gnus-killed-mark))
10761 ((> unmark 0)
10762 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10763 (t
10764 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10765 (setq articles (cdr articles))))
10766 ;; Hide killed subtrees.
10767 (and (null unmark)
10768 gnus-thread-hide-killed
10769 (gnus-summary-hide-thread))
10770 ;; If marked as read, go to next unread subject.
10771 (when (null unmark)
10772 ;; Go to next unread subject.
10773 (gnus-summary-next-subject 1 t)))
10774 (gnus-set-mode-line 'summary))
10775
10776 ;; Summary sorting commands
10777
10778 (defun gnus-summary-sort-by-number (&optional reverse)
10779 "Sort the summary buffer by article number.
10780 Argument REVERSE means reverse order."
10781 (interactive "P")
10782 (gnus-summary-sort 'number reverse))
10783
10784 (defun gnus-summary-sort-by-random (&optional reverse)
10785 "Randomize the order in the summary buffer.
10786 Argument REVERSE means to randomize in reverse order."
10787 (interactive "P")
10788 (gnus-summary-sort 'random reverse))
10789
10790 (defun gnus-summary-sort-by-author (&optional reverse)
10791 "Sort the summary buffer by author name alphabetically.
10792 If `case-fold-search' is non-nil, case of letters is ignored.
10793 Argument REVERSE means reverse order."
10794 (interactive "P")
10795 (gnus-summary-sort 'author reverse))
10796
10797 (defun gnus-summary-sort-by-subject (&optional reverse)
10798 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10799 If `case-fold-search' is non-nil, case of letters is ignored.
10800 Argument REVERSE means reverse order."
10801 (interactive "P")
10802 (gnus-summary-sort 'subject reverse))
10803
10804 (defun gnus-summary-sort-by-date (&optional reverse)
10805 "Sort the summary buffer by date.
10806 Argument REVERSE means reverse order."
10807 (interactive "P")
10808 (gnus-summary-sort 'date reverse))
10809
10810 (defun gnus-summary-sort-by-score (&optional reverse)
10811 "Sort the summary buffer by score.
10812 Argument REVERSE means reverse order."
10813 (interactive "P")
10814 (gnus-summary-sort 'score reverse))
10815
10816 (defun gnus-summary-sort-by-lines (&optional reverse)
10817 "Sort the summary buffer by the number of lines.
10818 Argument REVERSE means reverse order."
10819 (interactive "P")
10820 (gnus-summary-sort 'lines reverse))
10821
10822 (defun gnus-summary-sort-by-chars (&optional reverse)
10823 "Sort the summary buffer by article length.
10824 Argument REVERSE means reverse order."
10825 (interactive "P")
10826 (gnus-summary-sort 'chars reverse))
10827
10828 (defun gnus-summary-sort-by-original (&optional reverse)
10829 "Sort the summary buffer using the default sorting method.
10830 Argument REVERSE means reverse order."
10831 (interactive "P")
10832 (let* ((buffer-read-only)
10833 (gnus-summary-prepare-hook nil))
10834 ;; We do the sorting by regenerating the threads.
10835 (gnus-summary-prepare)
10836 ;; Hide subthreads if needed.
10837 (gnus-summary-maybe-hide-threads)))
10838
10839 (defun gnus-summary-sort (predicate reverse)
10840 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10841 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10842 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10843 (gnus-thread-sort-functions
10844 (if (not reverse)
10845 thread
10846 `(lambda (t1 t2)
10847 (,thread t2 t1))))
10848 (gnus-sort-gathered-threads-function
10849 gnus-thread-sort-functions)
10850 (gnus-article-sort-functions
10851 (if (not reverse)
10852 article
10853 `(lambda (t1 t2)
10854 (,article t2 t1))))
10855 (buffer-read-only)
10856 (gnus-summary-prepare-hook nil))
10857 ;; We do the sorting by regenerating the threads.
10858 (gnus-summary-prepare)
10859 ;; Hide subthreads if needed.
10860 (gnus-summary-maybe-hide-threads)))
10861
10862 ;; Summary saving commands.
10863
10864 (defun gnus-summary-save-article (&optional n not-saved)
10865 "Save the current article using the default saver function.
10866 If N is a positive number, save the N next articles.
10867 If N is a negative number, save the N previous articles.
10868 If N is nil and any articles have been marked with the process mark,
10869 save those articles instead.
10870 The variable `gnus-default-article-saver' specifies the saver function."
10871 (interactive "P")
10872 (let* ((articles (gnus-summary-work-articles n))
10873 (save-buffer (save-excursion
10874 (nnheader-set-temp-buffer " *Gnus Save*")))
10875 (num (length articles))
10876 header file)
10877 (dolist (article articles)
10878 (setq header (gnus-summary-article-header article))
10879 (if (not (vectorp header))
10880 ;; This is a pseudo-article.
10881 (if (assq 'name header)
10882 (gnus-copy-file (cdr (assq 'name header)))
10883 (gnus-message 1 "Article %d is unsaveable" article))
10884 ;; This is a real article.
10885 (save-window-excursion
10886 (let ((gnus-display-mime-function nil)
10887 (gnus-article-prepare-hook nil))
10888 (gnus-summary-select-article t nil nil article)))
10889 (save-excursion
10890 (set-buffer save-buffer)
10891 (erase-buffer)
10892 (insert-buffer-substring gnus-original-article-buffer))
10893 (setq file (gnus-article-save save-buffer file num))
10894 (gnus-summary-remove-process-mark article)
10895 (unless not-saved
10896 (gnus-summary-set-saved-mark article))))
10897 (gnus-kill-buffer save-buffer)
10898 (gnus-summary-position-point)
10899 (gnus-set-mode-line 'summary)
10900 n))
10901
10902 (defun gnus-summary-pipe-output (&optional arg headers)
10903 "Pipe the current article to a subprocess.
10904 If N is a positive number, pipe the N next articles.
10905 If N is a negative number, pipe the N previous articles.
10906 If N is nil and any articles have been marked with the process mark,
10907 pipe those articles instead.
10908 If HEADERS (the symbolic prefix), include the headers, too."
10909 (interactive (gnus-interactive "P\ny"))
10910 (require 'gnus-art)
10911 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10912 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10913 (gnus-summary-save-article arg t))
10914 (let ((buffer (get-buffer "*Shell Command Output*")))
10915 (when (and buffer
10916 (not (zerop (buffer-size buffer))))
10917 (gnus-configure-windows 'pipe))))
10918
10919 (defun gnus-summary-save-article-mail (&optional arg)
10920 "Append the current article to an mail file.
10921 If N is a positive number, save the N next articles.
10922 If N is a negative number, save the N previous articles.
10923 If N is nil and any articles have been marked with the process mark,
10924 save those articles instead."
10925 (interactive "P")
10926 (require 'gnus-art)
10927 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10928 (gnus-summary-save-article arg)))
10929
10930 (defun gnus-summary-save-article-rmail (&optional arg)
10931 "Append the current article to an rmail file.
10932 If N is a positive number, save the N next articles.
10933 If N is a negative number, save the N previous articles.
10934 If N is nil and any articles have been marked with the process mark,
10935 save those articles instead."
10936 (interactive "P")
10937 (require 'gnus-art)
10938 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10939 (gnus-summary-save-article arg)))
10940
10941 (defun gnus-summary-save-article-file (&optional arg)
10942 "Append the current article to a file.
10943 If N is a positive number, save the N next articles.
10944 If N is a negative number, save the N previous articles.
10945 If N is nil and any articles have been marked with the process mark,
10946 save those articles instead."
10947 (interactive "P")
10948 (require 'gnus-art)
10949 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10950 (gnus-summary-save-article arg)))
10951
10952 (defun gnus-summary-write-article-file (&optional arg)
10953 "Write the current article to a file, deleting the previous file.
10954 If N is a positive number, save the N next articles.
10955 If N is a negative number, save the N previous articles.
10956 If N is nil and any articles have been marked with the process mark,
10957 save those articles instead."
10958 (interactive "P")
10959 (require 'gnus-art)
10960 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10961 (gnus-summary-save-article arg)))
10962
10963 (defun gnus-summary-save-article-body-file (&optional arg)
10964 "Append the current article body to a file.
10965 If N is a positive number, save the N next articles.
10966 If N is a negative number, save the N previous articles.
10967 If N is nil and any articles have been marked with the process mark,
10968 save those articles instead."
10969 (interactive "P")
10970 (require 'gnus-art)
10971 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10972 (gnus-summary-save-article arg)))
10973
10974 (defun gnus-summary-muttprint (&optional arg)
10975 "Print the current article using Muttprint.
10976 If N is a positive number, save the N next articles.
10977 If N is a negative number, save the N previous articles.
10978 If N is nil and any articles have been marked with the process mark,
10979 save those articles instead."
10980 (interactive "P")
10981 (require 'gnus-art)
10982 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10983 (gnus-summary-save-article arg t)))
10984
10985 (defun gnus-summary-pipe-message (program)
10986 "Pipe the current article through PROGRAM."
10987 (interactive "sProgram: ")
10988 (gnus-summary-select-article)
10989 (let ((mail-header-separator ""))
10990 (gnus-eval-in-buffer-window gnus-article-buffer
10991 (save-restriction
10992 (widen)
10993 (let ((start (window-start))
10994 buffer-read-only)
10995 (message-pipe-buffer-body program)
10996 (set-window-start (get-buffer-window (current-buffer)) start))))))
10997
10998 (defun gnus-get-split-value (methods)
10999 "Return a value based on the split METHODS."
11000 (let (split-name method result match)
11001 (when methods
11002 (save-excursion
11003 (set-buffer gnus-original-article-buffer)
11004 (save-restriction
11005 (nnheader-narrow-to-headers)
11006 (while (and methods (not split-name))
11007 (goto-char (point-min))
11008 (setq method (pop methods))
11009 (setq match (car method))
11010 (when (cond
11011 ((stringp match)
11012 ;; Regular expression.
11013 (ignore-errors
11014 (re-search-forward match nil t)))
11015 ((functionp match)
11016 ;; Function.
11017 (save-restriction
11018 (widen)
11019 (setq result (funcall match gnus-newsgroup-name))))
11020 ((consp match)
11021 ;; Form.
11022 (save-restriction
11023 (widen)
11024 (setq result (eval match)))))
11025 (setq split-name (cdr method))
11026 (cond ((stringp result)
11027 (push (expand-file-name
11028 result gnus-article-save-directory)
11029 split-name))
11030 ((consp result)
11031 (setq split-name (append result split-name)))))))))
11032 (nreverse split-name)))
11033
11034 (defun gnus-valid-move-group-p (group)
11035 (and (boundp group)
11036 (symbol-name group)
11037 (symbol-value group)
11038 (gnus-get-function (gnus-find-method-for-group
11039 (symbol-name group)) 'request-accept-article t)))
11040
11041 (defun gnus-read-move-group-name (prompt default articles prefix)
11042 "Read a group name."
11043 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11044 (minibuffer-confirm-incomplete nil) ; XEmacs
11045 (prom
11046 (format "%s %s to:"
11047 prompt
11048 (if (> (length articles) 1)
11049 (format "these %d articles" (length articles))
11050 "this article")))
11051 (to-newsgroup
11052 (cond
11053 ((null split-name)
11054 (gnus-completing-read-with-default
11055 default prom
11056 gnus-active-hashtb
11057 'gnus-valid-move-group-p
11058 nil prefix
11059 'gnus-group-history))
11060 ((= 1 (length split-name))
11061 (gnus-completing-read-with-default
11062 (car split-name) prom
11063 gnus-active-hashtb
11064 'gnus-valid-move-group-p
11065 nil nil
11066 'gnus-group-history))
11067 (t
11068 (gnus-completing-read-with-default
11069 nil prom
11070 (mapcar (lambda (el) (list el))
11071 (nreverse split-name))
11072 nil nil nil
11073 'gnus-group-history))))
11074 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11075 (when to-newsgroup
11076 (if (or (string= to-newsgroup "")
11077 (string= to-newsgroup prefix))
11078 (setq to-newsgroup default))
11079 (unless to-newsgroup
11080 (error "No group name entered"))
11081 (or (gnus-active to-newsgroup)
11082 (gnus-activate-group to-newsgroup nil nil to-method)
11083 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11084 to-newsgroup))
11085 (or (and (gnus-request-create-group to-newsgroup to-method)
11086 (gnus-activate-group
11087 to-newsgroup nil nil to-method)
11088 (gnus-subscribe-group to-newsgroup))
11089 (error "Couldn't create group %s" to-newsgroup)))
11090 (error "No such group: %s" to-newsgroup)))
11091 to-newsgroup))
11092
11093 (defun gnus-summary-save-parts (type dir n &optional reverse)
11094 "Save parts matching TYPE to DIR.
11095 If REVERSE, save parts that do not match TYPE."
11096 (interactive
11097 (list (read-string "Save parts of type: "
11098 (or (car gnus-summary-save-parts-type-history)
11099 gnus-summary-save-parts-default-mime)
11100 'gnus-summary-save-parts-type-history)
11101 (setq gnus-summary-save-parts-last-directory
11102 (read-file-name "Save to directory: "
11103 gnus-summary-save-parts-last-directory
11104 nil t))
11105 current-prefix-arg))
11106 (gnus-summary-iterate n
11107 (let ((gnus-display-mime-function nil)
11108 (gnus-inhibit-treatment t))
11109 (gnus-summary-select-article))
11110 (save-excursion
11111 (set-buffer gnus-article-buffer)
11112 (let ((handles (or gnus-article-mime-handles
11113 (mm-dissect-buffer nil gnus-article-loose-mime)
11114 (and gnus-article-emulate-mime
11115 (mm-uu-dissect)))))
11116 (when handles
11117 (gnus-summary-save-parts-1 type dir handles reverse)
11118 (unless gnus-article-mime-handles ;; Don't destroy this case.
11119 (mm-destroy-parts handles)))))))
11120
11121 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11122 (if (stringp (car handle))
11123 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11124 (cdr handle))
11125 (when (if reverse
11126 (not (string-match type (mm-handle-media-type handle)))
11127 (string-match type (mm-handle-media-type handle)))
11128 (let ((file (expand-file-name
11129 (gnus-map-function
11130 mm-file-name-rewrite-functions
11131 (file-name-nondirectory
11132 (or
11133 (mail-content-type-get
11134 (mm-handle-disposition handle) 'filename)
11135 (mail-content-type-get
11136 (mm-handle-type handle) 'name)
11137 (concat gnus-newsgroup-name
11138 "." (number-to-string
11139 (cdr gnus-article-current))))))
11140 dir)))
11141 (unless (file-exists-p file)
11142 (mm-save-part-to-file handle file))))))
11143
11144 ;; Summary extract commands
11145
11146 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11147 (let ((buffer-read-only nil)
11148 (article (gnus-summary-article-number))
11149 after-article b e)
11150 (unless (gnus-summary-goto-subject article)
11151 (error "No such article: %d" article))
11152 (gnus-summary-position-point)
11153 ;; If all commands are to be bunched up on one line, we collect
11154 ;; them here.
11155 (unless gnus-view-pseudos-separately
11156 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11157 files action)
11158 (while ps
11159 (setq action (cdr (assq 'action (car ps))))
11160 (setq files (list (cdr (assq 'name (car ps)))))
11161 (while (and ps (cdr ps)
11162 (string= (or action "1")
11163 (or (cdr (assq 'action (cadr ps))) "2")))
11164 (push (cdr (assq 'name (cadr ps))) files)
11165 (setcdr ps (cddr ps)))
11166 (when files
11167 (when (not (string-match "%s" action))
11168 (push " " files))
11169 (push " " files)
11170 (when (assq 'execute (car ps))
11171 (setcdr (assq 'execute (car ps))
11172 (funcall (if (string-match "%s" action)
11173 'format 'concat)
11174 action
11175 (mapconcat
11176 (lambda (f)
11177 (if (equal f " ")
11178 f
11179 (mm-quote-arg f)))
11180 files " ")))))
11181 (setq ps (cdr ps)))))
11182 (if (and gnus-view-pseudos (not not-view))
11183 (while pslist
11184 (when (assq 'execute (car pslist))
11185 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11186 (eq gnus-view-pseudos 'not-confirm)))
11187 (setq pslist (cdr pslist)))
11188 (save-excursion
11189 (while pslist
11190 (setq after-article (or (cdr (assq 'article (car pslist)))
11191 (gnus-summary-article-number)))
11192 (gnus-summary-goto-subject after-article)
11193 (forward-line 1)
11194 (setq b (point))
11195 (insert " " (file-name-nondirectory
11196 (cdr (assq 'name (car pslist))))
11197 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11198 (setq e (point))
11199 (forward-line -1) ; back to `b'
11200 (gnus-add-text-properties
11201 b (1- e) (list 'gnus-number gnus-reffed-article-number
11202 gnus-mouse-face-prop gnus-mouse-face))
11203 (gnus-data-enter
11204 after-article gnus-reffed-article-number
11205 gnus-unread-mark b (car pslist) 0 (- e b))
11206 (setq gnus-newsgroup-unreads
11207 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11208 gnus-reffed-article-number))
11209 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11210 (setq pslist (cdr pslist)))))))
11211
11212 (defun gnus-pseudos< (p1 p2)
11213 (let ((c1 (cdr (assq 'action p1)))
11214 (c2 (cdr (assq 'action p2))))
11215 (and c1 c2 (string< c1 c2))))
11216
11217 (defun gnus-request-pseudo-article (props)
11218 (cond ((assq 'execute props)
11219 (gnus-execute-command (cdr (assq 'execute props)))))
11220 (let ((gnus-current-article (gnus-summary-article-number)))
11221 (gnus-run-hooks 'gnus-mark-article-hook)))
11222
11223 (defun gnus-execute-command (command &optional automatic)
11224 (save-excursion
11225 (gnus-article-setup-buffer)
11226 (set-buffer gnus-article-buffer)
11227 (setq buffer-read-only nil)
11228 (let ((command (if automatic command
11229 (read-string "Command: " (cons command 0)))))
11230 (erase-buffer)
11231 (insert "$ " command "\n\n")
11232 (if gnus-view-pseudo-asynchronously
11233 (start-process "gnus-execute" (current-buffer) shell-file-name
11234 shell-command-switch command)
11235 (call-process shell-file-name nil t nil
11236 shell-command-switch command)))))
11237
11238 ;; Summary kill commands.
11239
11240 (defun gnus-summary-edit-global-kill (article)
11241 "Edit the \"global\" kill file."
11242 (interactive (list (gnus-summary-article-number)))
11243 (gnus-group-edit-global-kill article))
11244
11245 (defun gnus-summary-edit-local-kill ()
11246 "Edit a local kill file applied to the current newsgroup."
11247 (interactive)
11248 (setq gnus-current-headers (gnus-summary-article-header))
11249 (gnus-group-edit-local-kill
11250 (gnus-summary-article-number) gnus-newsgroup-name))
11251
11252 ;;; Header reading.
11253
11254 (defun gnus-read-header (id &optional header)
11255 "Read the headers of article ID and enter them into the Gnus system."
11256 (let ((group gnus-newsgroup-name)
11257 (gnus-override-method
11258 (or
11259 gnus-override-method
11260 (and (gnus-news-group-p gnus-newsgroup-name)
11261 (car (gnus-refer-article-methods)))))
11262 where)
11263 ;; First we check to see whether the header in question is already
11264 ;; fetched.
11265 (if (stringp id)
11266 ;; This is a Message-ID.
11267 (setq header (or header (gnus-id-to-header id)))
11268 ;; This is an article number.
11269 (setq header (or header (gnus-summary-article-header id))))
11270 (if (and header
11271 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11272 ;; We have found the header.
11273 header
11274 ;; We have to really fetch the header to this article.
11275 (save-excursion
11276 (set-buffer nntp-server-buffer)
11277 (when (setq where (gnus-request-head id group))
11278 (nnheader-fold-continuation-lines)
11279 (goto-char (point-max))
11280 (insert ".\n")
11281 (goto-char (point-min))
11282 (insert "211 ")
11283 (princ (cond
11284 ((numberp id) id)
11285 ((cdr where) (cdr where))
11286 (header (mail-header-number header))
11287 (t gnus-reffed-article-number))
11288 (current-buffer))
11289 (insert " Article retrieved.\n"))
11290 (if (or (not where)
11291 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11292 () ; Malformed head.
11293 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11294 (when (and (stringp id)
11295 (not (string= (gnus-group-real-name group)
11296 (car where))))
11297 ;; If we fetched by Message-ID and the article came
11298 ;; from a different group, we fudge some bogus article
11299 ;; numbers for this article.
11300 (mail-header-set-number header gnus-reffed-article-number))
11301 (save-excursion
11302 (set-buffer gnus-summary-buffer)
11303 (decf gnus-reffed-article-number)
11304 (gnus-remove-header (mail-header-number header))
11305 (push header gnus-newsgroup-headers)
11306 (setq gnus-current-headers header)
11307 (push (mail-header-number header) gnus-newsgroup-limit)))
11308 header)))))
11309
11310 (defun gnus-remove-header (number)
11311 "Remove header NUMBER from `gnus-newsgroup-headers'."
11312 (if (and gnus-newsgroup-headers
11313 (= number (mail-header-number (car gnus-newsgroup-headers))))
11314 (pop gnus-newsgroup-headers)
11315 (let ((headers gnus-newsgroup-headers))
11316 (while (and (cdr headers)
11317 (not (= number (mail-header-number (cadr headers)))))
11318 (pop headers))
11319 (when (cdr headers)
11320 (setcdr headers (cddr headers))))))
11321
11322 ;;;
11323 ;;; summary highlights
11324 ;;;
11325
11326 (defun gnus-highlight-selected-summary ()
11327 "Highlight selected article in summary buffer."
11328 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11329 (when gnus-summary-selected-face
11330 (save-excursion
11331 (let* ((beg (gnus-point-at-bol))
11332 (end (gnus-point-at-eol))
11333 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11334 (from (if (get-text-property beg gnus-mouse-face-prop)
11335 beg
11336 (or (next-single-property-change
11337 beg gnus-mouse-face-prop nil end)
11338 beg)))
11339 (to
11340 (if (= from end)
11341 (- from 2)
11342 (or (next-single-property-change
11343 from gnus-mouse-face-prop nil end)
11344 end))))
11345 ;; If no mouse-face prop on line we will have to = from = end,
11346 ;; so we highlight the entire line instead.
11347 (when (= (+ to 2) from)
11348 (setq from beg)
11349 (setq to end))
11350 (if gnus-newsgroup-selected-overlay
11351 ;; Move old overlay.
11352 (gnus-move-overlay
11353 gnus-newsgroup-selected-overlay from to (current-buffer))
11354 ;; Create new overlay.
11355 (gnus-overlay-put
11356 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11357 'face gnus-summary-selected-face))))))
11358
11359 (defvar gnus-summary-highlight-line-cached nil)
11360 (defvar gnus-summary-highlight-line-trigger nil)
11361
11362 (defun gnus-summary-highlight-line-0 ()
11363 (if (and (eq gnus-summary-highlight-line-trigger
11364 gnus-summary-highlight)
11365 gnus-summary-highlight-line-cached)
11366 gnus-summary-highlight-line-cached
11367 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11368 gnus-summary-highlight-line-cached
11369 (let* ((cond (list 'cond))
11370 (c cond)
11371 (list gnus-summary-highlight))
11372 (while list
11373 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11374 nil))
11375 (setq c (cdr c)
11376 list (cdr list)))
11377 (gnus-byte-compile (list 'lambda nil cond))))))
11378
11379 (defun gnus-summary-highlight-line ()
11380 "Highlight current line according to `gnus-summary-highlight'."
11381 (let* ((beg (gnus-point-at-bol))
11382 (article (or (gnus-summary-article-number) gnus-current-article))
11383 (score (or (cdr (assq article
11384 gnus-newsgroup-scored))
11385 gnus-summary-default-score 0))
11386 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11387 (inhibit-read-only t)
11388 (default gnus-summary-default-score)
11389 (default-high gnus-summary-default-high-score)
11390 (default-low gnus-summary-default-low-score)
11391 (uncached (and gnus-summary-use-undownloaded-faces
11392 (memq article gnus-newsgroup-undownloaded)
11393 (not (memq article gnus-newsgroup-cached)))))
11394 (let ((face (funcall (gnus-summary-highlight-line-0))))
11395 (unless (eq face (get-text-property beg 'face))
11396 (gnus-put-text-property-excluding-characters-with-faces
11397 beg (gnus-point-at-eol) 'face
11398 (setq face (if (boundp face) (symbol-value face) face)))
11399 (when gnus-summary-highlight-line-function
11400 (funcall gnus-summary-highlight-line-function article face))))))
11401
11402 (defun gnus-update-read-articles (group unread &optional compute)
11403 "Update the list of read articles in GROUP.
11404 UNREAD is a sorted list."
11405 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11406 (entry (gnus-gethash group gnus-newsrc-hashtb))
11407 (info (nth 2 entry))
11408 (prev 1)
11409 read)
11410 (if (or (not info) (not active))
11411 ;; There is no info on this group if it was, in fact,
11412 ;; killed. Gnus stores no information on killed groups, so
11413 ;; there's nothing to be done.
11414 ;; One could store the information somewhere temporarily,
11415 ;; perhaps... Hmmm...
11416 ()
11417 ;; Remove any negative articles numbers.
11418 (while (and unread (< (car unread) 0))
11419 (setq unread (cdr unread)))
11420 ;; Remove any expired article numbers
11421 (while (and unread (< (car unread) (car active)))
11422 (setq unread (cdr unread)))
11423 ;; Compute the ranges of read articles by looking at the list of
11424 ;; unread articles.
11425 (while unread
11426 (when (/= (car unread) prev)
11427 (push (if (= prev (1- (car unread))) prev
11428 (cons prev (1- (car unread))))
11429 read))
11430 (setq prev (1+ (car unread)))
11431 (setq unread (cdr unread)))
11432 (when (<= prev (cdr active))
11433 (push (cons prev (cdr active)) read))
11434 (setq read (if (> (length read) 1) (nreverse read) read))
11435 (if compute
11436 read
11437 (save-excursion
11438 (let (setmarkundo)
11439 ;; Propagate the read marks to the backend.
11440 (when (gnus-check-backend-function 'request-set-mark group)
11441 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11442 (add (gnus-remove-from-range read (gnus-info-read info))))
11443 (when (or add del)
11444 (unless (gnus-check-group group)
11445 (error "Can't open server for %s" group))
11446 (gnus-request-set-mark
11447 group (delq nil (list (if add (list add 'add '(read)))
11448 (if del (list del 'del '(read))))))
11449 (setq setmarkundo
11450 `(gnus-request-set-mark
11451 ,group
11452 ',(delq nil (list
11453 (if del (list del 'add '(read)))
11454 (if add (list add 'del '(read))))))))))
11455 (set-buffer gnus-group-buffer)
11456 (gnus-undo-register
11457 `(progn
11458 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11459 (gnus-info-set-read ',info ',(gnus-info-read info))
11460 (gnus-get-unread-articles-in-group ',info
11461 (gnus-active ,group))
11462 (gnus-group-update-group ,group t)
11463 ,setmarkundo))))
11464 ;; Enter this list into the group info.
11465 (gnus-info-set-read info read)
11466 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11467 (gnus-get-unread-articles-in-group info (gnus-active group))
11468 t))))
11469
11470 (defun gnus-offer-save-summaries ()
11471 "Offer to save all active summary buffers."
11472 (let (buffers)
11473 ;; Go through all buffers and find all summaries.
11474 (dolist (buffer (buffer-list))
11475 (when (and (setq buffer (buffer-name buffer))
11476 (string-match "Summary" buffer)
11477 (save-excursion
11478 (set-buffer buffer)
11479 ;; We check that this is, indeed, a summary buffer.
11480 (and (eq major-mode 'gnus-summary-mode)
11481 ;; Also make sure this isn't bogus.
11482 gnus-newsgroup-prepared
11483 ;; Also make sure that this isn't a
11484 ;; dead summary buffer.
11485 (not gnus-dead-summary-mode))))
11486 (push buffer buffers)))
11487 ;; Go through all these summary buffers and offer to save them.
11488 (when buffers
11489 (save-excursion
11490 (map-y-or-n-p
11491 "Update summary buffer %s? "
11492 (lambda (buf)
11493 (switch-to-buffer buf)
11494 (gnus-summary-exit))
11495 buffers)))))
11496
11497 (defun gnus-summary-setup-default-charset ()
11498 "Setup newsgroup default charset."
11499 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11500 (setq gnus-newsgroup-charset nil)
11501 (let* ((ignored-charsets
11502 (or gnus-newsgroup-ephemeral-ignored-charsets
11503 (append
11504 (and gnus-newsgroup-name
11505 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11506 gnus-newsgroup-ignored-charsets))))
11507 (setq gnus-newsgroup-charset
11508 (or gnus-newsgroup-ephemeral-charset
11509 (and gnus-newsgroup-name
11510 (gnus-parameter-charset gnus-newsgroup-name))
11511 gnus-default-charset))
11512 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11513 ignored-charsets))))
11514
11515 ;;;
11516 ;;; Mime Commands
11517 ;;;
11518
11519 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11520 "Display the current article buffer fully MIME-buttonized.
11521 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11522 treated as multipart/mixed."
11523 (interactive "P")
11524 (require 'gnus-art)
11525 (let ((gnus-unbuttonized-mime-types nil)
11526 (gnus-mime-display-multipart-as-mixed show-all-parts))
11527 (gnus-summary-show-article)))
11528
11529 (defun gnus-summary-repair-multipart (article)
11530 "Add a Content-Type header to a multipart article without one."
11531 (interactive (list (gnus-summary-article-number)))
11532 (gnus-with-article article
11533 (message-narrow-to-head)
11534 (message-remove-header "Mime-Version")
11535 (goto-char (point-max))
11536 (insert "Mime-Version: 1.0\n")
11537 (widen)
11538 (when (search-forward "\n--" nil t)
11539 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11540 (message-narrow-to-head)
11541 (message-remove-header "Content-Type")
11542 (goto-char (point-max))
11543 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11544 separator))
11545 (widen))))
11546 (let (gnus-mark-article-hook)
11547 (gnus-summary-select-article t t nil article)))
11548
11549 (defun gnus-summary-toggle-display-buttonized ()
11550 "Toggle the buttonizing of the article buffer."
11551 (interactive)
11552 (require 'gnus-art)
11553 (if (setq gnus-inhibit-mime-unbuttonizing
11554 (not gnus-inhibit-mime-unbuttonizing))
11555 (let ((gnus-unbuttonized-mime-types nil))
11556 (gnus-summary-show-article))
11557 (gnus-summary-show-article)))
11558
11559 ;;;
11560 ;;; Generic summary marking commands
11561 ;;;
11562
11563 (defvar gnus-summary-marking-alist
11564 '((read gnus-del-mark "d")
11565 (unread gnus-unread-mark "u")
11566 (ticked gnus-ticked-mark "!")
11567 (dormant gnus-dormant-mark "?")
11568 (expirable gnus-expirable-mark "e"))
11569 "An alist of names/marks/keystrokes.")
11570
11571 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11572 (defvar gnus-summary-mark-map)
11573
11574 (defun gnus-summary-make-all-marking-commands ()
11575 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11576 (dolist (elem gnus-summary-marking-alist)
11577 (apply 'gnus-summary-make-marking-command elem)))
11578
11579 (defun gnus-summary-make-marking-command (name mark keystroke)
11580 (let ((map (make-sparse-keymap)))
11581 (define-key gnus-summary-generic-mark-map keystroke map)
11582 (dolist (lway `((next "next" next nil "n")
11583 (next-unread "next unread" next t "N")
11584 (prev "previous" prev nil "p")
11585 (prev-unread "previous unread" prev t "P")
11586 (nomove "" nil nil ,keystroke)))
11587 (let ((func (gnus-summary-make-marking-command-1
11588 mark (car lway) lway name)))
11589 (setq func (eval func))
11590 (define-key map (nth 4 lway) func)))))
11591
11592 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11593 `(defun ,(intern
11594 (format "gnus-summary-put-mark-as-%s%s"
11595 name (if (eq way 'nomove)
11596 ""
11597 (concat "-" (symbol-name way)))))
11598 (n)
11599 ,(format
11600 "Mark the current article as %s%s.
11601 If N, the prefix, then repeat N times.
11602 If N is negative, move in reverse order.
11603 The difference between N and the actual number of articles marked is
11604 returned."
11605 name (cadr lway))
11606 (interactive "p")
11607 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11608
11609 (defun gnus-summary-generic-mark (n mark move unread)
11610 "Mark N articles with MARK."
11611 (unless (eq major-mode 'gnus-summary-mode)
11612 (error "This command can only be used in the summary buffer"))
11613 (gnus-summary-show-thread)
11614 (let ((nummove
11615 (cond
11616 ((eq move 'next) 1)
11617 ((eq move 'prev) -1)
11618 (t 0))))
11619 (if (zerop nummove)
11620 (setq n 1)
11621 (when (< n 0)
11622 (setq n (abs n)
11623 nummove (* -1 nummove))))
11624 (while (and (> n 0)
11625 (gnus-summary-mark-article nil mark)
11626 (zerop (gnus-summary-next-subject nummove unread t)))
11627 (setq n (1- n)))
11628 (when (/= 0 n)
11629 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11630 (gnus-summary-recenter)
11631 (gnus-summary-position-point)
11632 (gnus-set-mode-line 'summary)
11633 n))
11634
11635 (defun gnus-summary-insert-articles (articles)
11636 (when (setq articles
11637 (gnus-sorted-difference articles
11638 (mapcar (lambda (h)
11639 (mail-header-number h))
11640 gnus-newsgroup-headers)))
11641 (setq gnus-newsgroup-headers
11642 (gnus-merge 'list
11643 gnus-newsgroup-headers
11644 (gnus-fetch-headers articles)
11645 'gnus-article-sort-by-number))
11646 ;; Suppress duplicates?
11647 (when gnus-suppress-duplicates
11648 (gnus-dup-suppress-articles))
11649
11650 ;; We might want to build some more threads first.
11651 (when (and gnus-fetch-old-headers
11652 (eq gnus-headers-retrieved-by 'nov))
11653 (if (eq gnus-fetch-old-headers 'invisible)
11654 (gnus-build-all-threads)
11655 (gnus-build-old-threads)))
11656 ;; Let the Gnus agent mark articles as read.
11657 (when gnus-agent
11658 (gnus-agent-get-undownloaded-list))
11659 ;; Remove list identifiers from subject
11660 (when gnus-list-identifiers
11661 (gnus-summary-remove-list-identifiers))
11662 ;; First and last article in this newsgroup.
11663 (when gnus-newsgroup-headers
11664 (setq gnus-newsgroup-begin
11665 (mail-header-number (car gnus-newsgroup-headers))
11666 gnus-newsgroup-end
11667 (mail-header-number
11668 (gnus-last-element gnus-newsgroup-headers))))
11669 (when gnus-use-scoring
11670 (gnus-possibly-score-headers))))
11671
11672 (defun gnus-summary-insert-old-articles (&optional all)
11673 "Insert all old articles in this group.
11674 If ALL is non-nil, already read articles become readable.
11675 If ALL is a number, fetch this number of articles."
11676 (interactive "P")
11677 (prog1
11678 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11679 older len)
11680 (setq older
11681 ;; Some nntp servers lie about their active range. When
11682 ;; this happens, the active range can be in the millions.
11683 ;; Use a compressed range to avoid creating a huge list.
11684 (gnus-range-difference (list gnus-newsgroup-active) old))
11685 (setq len (gnus-range-length older))
11686 (cond
11687 ((null older) nil)
11688 ((numberp all)
11689 (if (< all len)
11690 (let ((older-range (nreverse older)))
11691 (setq older nil)
11692
11693 (while (> all 0)
11694 (let* ((r (pop older-range))
11695 (min (if (numberp r) r (car r)))
11696 (max (if (numberp r) r (cdr r))))
11697 (while (and (<= min max)
11698 (> all 0))
11699 (push max older)
11700 (setq all (1- all)
11701 max (1- max))))))
11702 (setq older (gnus-uncompress-range older))))
11703 (all
11704 (setq older (gnus-uncompress-range older)))
11705 (t
11706 (when (and (numberp gnus-large-newsgroup)
11707 (> len gnus-large-newsgroup))
11708 (let* ((cursor-in-echo-area nil)
11709 (initial (gnus-parameter-large-newsgroup-initial
11710 gnus-newsgroup-name))
11711 (input
11712 (read-string
11713 (format
11714 "How many articles from %s (%s %d): "
11715 (gnus-limit-string
11716 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11717 (if initial "max" "default")
11718 len)
11719 (if initial
11720 (cons (number-to-string initial)
11721 0)))))
11722 (unless (string-match "^[ \t]*$" input)
11723 (setq all (string-to-number input))
11724 (if (< all len)
11725 (let ((older-range (nreverse older)))
11726 (setq older nil)
11727
11728 (while (> all 0)
11729 (let* ((r (pop older-range))
11730 (min (if (numberp r) r (car r)))
11731 (max (if (numberp r) r (cdr r))))
11732 (while (and (<= min max)
11733 (> all 0))
11734 (push max older)
11735 (setq all (1- all)
11736 max (1- max))))))))))
11737 (setq older (gnus-uncompress-range older))))
11738 (if (not older)
11739 (message "No old news.")
11740 (gnus-summary-insert-articles older)
11741 (gnus-summary-limit (gnus-sorted-nunion old older))))
11742 (gnus-summary-position-point)))
11743
11744 (defun gnus-summary-insert-new-articles ()
11745 "Insert all new articles in this group."
11746 (interactive)
11747 (prog1
11748 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11749 (old-active gnus-newsgroup-active)
11750 (nnmail-fetched-sources (list t))
11751 i new)
11752 (setq gnus-newsgroup-active
11753 (gnus-activate-group gnus-newsgroup-name 'scan))
11754 (setq i (cdr gnus-newsgroup-active))
11755 (while (> i (cdr old-active))
11756 (push i new)
11757 (decf i))
11758 (if (not new)
11759 (message "No gnus is bad news.")
11760 (gnus-summary-insert-articles new)
11761 (setq gnus-newsgroup-unreads
11762 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11763 (gnus-summary-limit (gnus-sorted-nunion old new))))
11764 (gnus-summary-position-point)))
11765
11766 (gnus-summary-make-all-marking-commands)
11767
11768 (gnus-ems-redefine)
11769
11770 (provide 'gnus-sum)
11771
11772 (run-hooks 'gnus-sum-load-hook)
11773
11774 ;; Local Variables:
11775 ;; coding: iso-8859-1
11776 ;; End:
11777
11778 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
11779 ;;; gnus-sum.el ends here