]> code.delx.au - gnu-emacs/blob - lisp/gnus/gnus-sum.el
*** empty log message ***
[gnu-emacs] / lisp / gnus / gnus-sum.el
1 ;;; gnus-sum.el --- summary mode commands for Gnus
2
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
5
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile
31 (require 'cl)
32 (defvar tool-bar-map))
33
34 (require 'gnus)
35 (require 'gnus-group)
36 (require 'gnus-spec)
37 (require 'gnus-range)
38 (require 'gnus-int)
39 (require 'gnus-undo)
40 (require 'gnus-util)
41 (require 'mm-decode)
42 (require 'nnoo)
43
44 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
45 (autoload 'gnus-cache-write-active "gnus-cache")
46 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
47 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
48 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
49 (autoload 'mm-uu-dissect "mm-uu")
50 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
51 "Deuglify broken Outlook (Express) articles and redisplay."
52 t)
53 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
54 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
55 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
56
57 (defcustom gnus-kill-summary-on-exit t
58 "*If non-nil, kill the summary buffer when you exit from it.
59 If nil, the summary will become a \"*Dead Summary*\" buffer, and
60 it will be killed sometime later."
61 :group 'gnus-summary-exit
62 :type 'boolean)
63
64 (defcustom gnus-fetch-old-headers nil
65 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
66 If an unread article in the group refers to an older, already read (or
67 just marked as read) article, the old article will not normally be
68 displayed in the Summary buffer. If this variable is t, Gnus
69 will attempt to grab the headers to the old articles, and thereby
70 build complete threads. If it has the value `some', only enough
71 headers to connect otherwise loose threads will be displayed. This
72 variable can also be a number. In that case, no more than that number
73 of old headers will be fetched. If it has the value `invisible', all
74 old headers will be fetched, but none will be displayed.
75
76 The server has to support NOV for any of this to work."
77 :group 'gnus-thread
78 :type '(choice (const :tag "off" nil)
79 (const :tag "on" t)
80 (const some)
81 (const invisible)
82 number
83 (sexp :menu-tag "other" t)))
84
85 (defcustom gnus-refer-thread-limit 200
86 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
87 If t, fetch all the available old headers."
88 :group 'gnus-thread
89 :type '(choice number
90 (sexp :menu-tag "other" t)))
91
92 (defcustom gnus-summary-make-false-root 'adopt
93 "*nil means that Gnus won't gather loose threads.
94 If the root of a thread has expired or been read in a previous
95 session, the information necessary to build a complete thread has been
96 lost. Instead of having many small sub-threads from this original thread
97 scattered all over the summary buffer, Gnus can gather them.
98
99 If non-nil, Gnus will try to gather all loose sub-threads from an
100 original thread into one large thread.
101
102 If this variable is non-nil, it should be one of `none', `adopt',
103 `dummy' or `empty'.
104
105 If this variable is `none', Gnus will not make a false root, but just
106 present the sub-threads after another.
107 If this variable is `dummy', Gnus will create a dummy root that will
108 have all the sub-threads as children.
109 If this variable is `adopt', Gnus will make one of the \"children\"
110 the parent and mark all the step-children as such.
111 If this variable is `empty', the \"children\" are printed with empty
112 subject fields. (Or rather, they will be printed with a string
113 given by the `gnus-summary-same-subject' variable.)"
114 :group 'gnus-thread
115 :type '(choice (const :tag "off" nil)
116 (const none)
117 (const dummy)
118 (const adopt)
119 (const empty)))
120
121 (defcustom gnus-summary-make-false-root-always nil
122 "Always make a false dummy root."
123 :version "22.1"
124 :group 'gnus-thread
125 :type 'boolean)
126
127 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
128 "*A regexp to match subjects to be excluded from loose thread gathering.
129 As loose thread gathering is done on subjects only, that means that
130 there can be many false gatherings performed. By rooting out certain
131 common subjects, gathering might become saner."
132 :group 'gnus-thread
133 :type 'regexp)
134
135 (defcustom gnus-summary-gather-subject-limit nil
136 "*Maximum length of subject comparisons when gathering loose threads.
137 Use nil to compare full subjects. Setting this variable to a low
138 number will help gather threads that have been corrupted by
139 newsreaders chopping off subject lines, but it might also mean that
140 unrelated articles that have subject that happen to begin with the
141 same few characters will be incorrectly gathered.
142
143 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
144 comparing subjects."
145 :group 'gnus-thread
146 :type '(choice (const :tag "off" nil)
147 (const fuzzy)
148 (sexp :menu-tag "on" t)))
149
150 (defcustom gnus-simplify-subject-functions nil
151 "List of functions taking a string argument that simplify subjects.
152 The functions are applied recursively.
153
154 Useful functions to put in this list include:
155 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
156 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
157 :group 'gnus-thread
158 :type '(repeat function))
159
160 (defcustom gnus-simplify-ignored-prefixes nil
161 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
162 :group 'gnus-thread
163 :type '(choice (const :tag "off" nil)
164 regexp))
165
166 (defcustom gnus-build-sparse-threads nil
167 "*If non-nil, fill in the gaps in threads.
168 If `some', only fill in the gaps that are needed to tie loose threads
169 together. If `more', fill in all leaf nodes that Gnus can find. If
170 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
171 :group 'gnus-thread
172 :type '(choice (const :tag "off" nil)
173 (const some)
174 (const more)
175 (sexp :menu-tag "all" t)))
176
177 (defcustom gnus-summary-thread-gathering-function
178 'gnus-gather-threads-by-subject
179 "*Function used for gathering loose threads.
180 There are two pre-defined functions: `gnus-gather-threads-by-subject',
181 which only takes Subjects into consideration; and
182 `gnus-gather-threads-by-references', which compared the References
183 headers of the articles to find matches."
184 :group 'gnus-thread
185 :type '(radio (function-item gnus-gather-threads-by-subject)
186 (function-item gnus-gather-threads-by-references)
187 (function :tag "other")))
188
189 (defcustom gnus-summary-same-subject ""
190 "*String indicating that the current article has the same subject as the previous.
191 This variable will only be used if the value of
192 `gnus-summary-make-false-root' is `empty'."
193 :group 'gnus-summary-format
194 :type 'string)
195
196 (defcustom gnus-summary-goto-unread t
197 "*If t, many commands will go to the next unread article.
198 This applies to marking commands as well as other commands that
199 \"naturally\" select the next article, like, for instance, `SPC' at
200 the end of an article.
201
202 If nil, the marking commands do NOT go to the next unread article
203 \(they go to the next article instead). If `never', commands that
204 usually go to the next unread article, will go to the next article,
205 whether it is read or not."
206 :group 'gnus-summary-marks
207 :link '(custom-manual "(gnus)Setting Marks")
208 :type '(choice (const :tag "off" nil)
209 (const never)
210 (sexp :menu-tag "on" t)))
211
212 (defcustom gnus-summary-default-score 0
213 "*Default article score level.
214 All scores generated by the score files will be added to this score.
215 If this variable is nil, scoring will be disabled."
216 :group 'gnus-score-default
217 :type '(choice (const :tag "disable")
218 integer))
219
220 (defcustom gnus-summary-default-high-score 0
221 "*Default threshold for a high scored article.
222 An article will be highlighted as high scored if its score is greater
223 than this score."
224 :version "22.1"
225 :group 'gnus-score-default
226 :type 'integer)
227
228 (defcustom gnus-summary-default-low-score 0
229 "*Default threshold for a low scored article.
230 An article will be highlighted as low scored if its score is smaller
231 than this score."
232 :version "22.1"
233 :group 'gnus-score-default
234 :type 'integer)
235
236 (defcustom gnus-summary-zcore-fuzz 0
237 "*Fuzziness factor for the zcore in the summary buffer.
238 Articles with scores closer than this to `gnus-summary-default-score'
239 will not be marked."
240 :group 'gnus-summary-format
241 :type 'integer)
242
243 (defcustom gnus-simplify-subject-fuzzy-regexp nil
244 "*Strings to be removed when doing fuzzy matches.
245 This can either be a regular expression or list of regular expressions
246 that will be removed from subject strings if fuzzy subject
247 simplification is selected."
248 :group 'gnus-thread
249 :type '(repeat regexp))
250
251 (defcustom gnus-show-threads t
252 "*If non-nil, display threads in summary mode."
253 :group 'gnus-thread
254 :type 'boolean)
255
256 (defcustom gnus-thread-hide-subtree nil
257 "*If non-nil, hide all threads initially.
258 This can be a predicate specifier which says which threads to hide.
259 If threads are hidden, you have to run the command
260 `gnus-summary-show-thread' by hand or select an article."
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
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)
930 ((and uncached (> score default-high))
931 . gnus-summary-high-undownloaded)
932 ((and uncached (< score default-low))
933 . gnus-summary-low-undownloaded)
934 (uncached
935 . gnus-summary-normal-undownloaded)
936 ((and (> score default-high)
937 (or (eq mark gnus-dormant-mark)
938 (eq mark gnus-ticked-mark)))
939 . gnus-summary-high-ticked)
940 ((and (< score default-low)
941 (or (eq mark gnus-dormant-mark)
942 (eq mark gnus-ticked-mark)))
943 . gnus-summary-low-ticked)
944 ((or (eq mark gnus-dormant-mark)
945 (eq mark gnus-ticked-mark))
946 . gnus-summary-normal-ticked)
947 ((and (> score default-high) (eq mark gnus-ancient-mark))
948 . gnus-summary-high-ancient)
949 ((and (< score default-low) (eq mark gnus-ancient-mark))
950 . gnus-summary-low-ancient)
951 ((eq mark gnus-ancient-mark)
952 . gnus-summary-normal-ancient)
953 ((and (> score default-high) (eq mark gnus-unread-mark))
954 . gnus-summary-high-unread)
955 ((and (< score default-low) (eq mark gnus-unread-mark))
956 . gnus-summary-low-unread)
957 ((eq mark gnus-unread-mark)
958 . gnus-summary-normal-unread)
959 ((> score default-high)
960 . gnus-summary-high-read)
961 ((< score default-low)
962 . gnus-summary-low-read)
963 (t
964 . gnus-summary-normal-read))
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
1004 (not (string= user-mail-address ""))
1005 (regexp-quote user-mail-address))
1006 "*Regexp of From headers that may be suppressed in favor of To headers."
1007 :version "21.1"
1008 :group 'gnus-summary
1009 :type 'regexp)
1010
1011 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1012 "List of charsets that should be ignored.
1013 When these charsets are used in the \"charset\" parameter, the
1014 default charset will be used instead."
1015 :version "21.1"
1016 :type '(repeat symbol)
1017 :group 'gnus-charset)
1018
1019 (gnus-define-group-parameter
1020 ignored-charsets
1021 :type list
1022 :function-document
1023 "Return the ignored charsets of GROUP."
1024 :variable gnus-group-ignored-charsets-alist
1025 :variable-default
1026 '(("alt\\.chinese\\.text" iso-8859-1))
1027 :variable-document
1028 "Alist of regexps (to match group names) and charsets that should be ignored.
1029 When these charsets are used in the \"charset\" parameter, the
1030 default charset will be used instead."
1031 :variable-group gnus-charset
1032 :variable-type '(repeat (cons (regexp :tag "Group")
1033 (repeat symbol)))
1034 :parameter-type '(choice :tag "Ignored charsets"
1035 :value nil
1036 (repeat (symbol)))
1037 :parameter-document "\
1038 List of charsets that should be ignored.
1039
1040 When these charsets are used in the \"charset\" parameter, the
1041 default charset will be used instead.")
1042
1043 (defcustom gnus-group-highlight-words-alist nil
1044 "Alist of group regexps and highlight regexps.
1045 This variable uses the same syntax as `gnus-emphasis-alist'."
1046 :version "21.1"
1047 :type '(repeat (cons (regexp :tag "Group")
1048 (repeat (list (regexp :tag "Highlight regexp")
1049 (number :tag "Group for entire word" 0)
1050 (number :tag "Group for displayed part" 0)
1051 (symbol :tag "Face"
1052 gnus-emphasis-highlight-words)))))
1053 :group 'gnus-summary-visual)
1054
1055 (defcustom gnus-summary-show-article-charset-alist
1056 nil
1057 "Alist of number and charset.
1058 The article will be shown with the charset corresponding to the
1059 numbered argument.
1060 For example: ((1 . cn-gb-2312) (2 . big5))."
1061 :version "21.1"
1062 :type '(repeat (cons (number :tag "Argument" 1)
1063 (symbol :tag "Charset")))
1064 :group 'gnus-charset)
1065
1066 (defcustom gnus-preserve-marks t
1067 "Whether marks are preserved when moving, copying and respooling messages."
1068 :version "21.1"
1069 :type 'boolean
1070 :group 'gnus-summary-marks)
1071
1072 (defcustom gnus-alter-articles-to-read-function nil
1073 "Function to be called to alter the list of articles to be selected."
1074 :type '(choice (const nil) function)
1075 :group 'gnus-summary)
1076
1077 (defcustom gnus-orphan-score nil
1078 "*All orphans get this score added. Set in the score file."
1079 :group 'gnus-score-default
1080 :type '(choice (const nil)
1081 integer))
1082
1083 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1084 "*A regexp to match MIME parts when saving multiple parts of a
1085 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1086 This regexp will be used by default when prompting the user for which
1087 type of files to save."
1088 :group 'gnus-summary
1089 :type 'regexp)
1090
1091 (defcustom gnus-read-all-available-headers nil
1092 "Whether Gnus should parse all headers made available to it.
1093 This is mostly relevant for slow back ends where the user may
1094 wish to widen the summary buffer to include all headers
1095 that were fetched. Say, for nnultimate groups."
1096 :version "22.1"
1097 :group 'gnus-summary
1098 :type '(choice boolean regexp))
1099
1100 (defcustom gnus-summary-muttprint-program "muttprint"
1101 "Command (and optional arguments) used to run Muttprint."
1102 :version "22.1"
1103 :group 'gnus-summary
1104 :type 'string)
1105
1106 (defcustom gnus-article-loose-mime nil
1107 "If non-nil, don't require MIME-Version header.
1108 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1109 supply the MIME-Version header or deliberately strip it from the mail.
1110 Set it to non-nil, Gnus will treat some articles as MIME even if
1111 the MIME-Version header is missed."
1112 :version "22.1"
1113 :type 'boolean
1114 :group 'gnus-article-mime)
1115
1116 (defcustom gnus-article-emulate-mime t
1117 "If non-nil, use MIME emulation for uuencode and the like.
1118 This means that Gnus will search message bodies for text that look
1119 like uuencoded bits, yEncoded bits, and so on, and present that using
1120 the normal Gnus MIME machinery."
1121 :version "22.1"
1122 :type 'boolean
1123 :group 'gnus-article-mime)
1124
1125 ;;; Internal variables
1126
1127 (defvar gnus-summary-display-cache nil)
1128 (defvar gnus-article-mime-handles nil)
1129 (defvar gnus-article-decoded-p nil)
1130 (defvar gnus-article-charset nil)
1131 (defvar gnus-article-ignored-charsets nil)
1132 (defvar gnus-scores-exclude-files nil)
1133 (defvar gnus-page-broken nil)
1134
1135 (defvar gnus-original-article nil)
1136 (defvar gnus-article-internal-prepare-hook nil)
1137 (defvar gnus-newsgroup-process-stack nil)
1138
1139 (defvar gnus-thread-indent-array nil)
1140 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1141 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1142 "Function called to sort the articles within a thread after it has been gathered together.")
1143
1144 (defvar gnus-summary-save-parts-type-history nil)
1145 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1146
1147 ;; Avoid highlighting in kill files.
1148 (defvar gnus-summary-inhibit-highlight nil)
1149 (defvar gnus-newsgroup-selected-overlay nil)
1150 (defvar gnus-inhibit-limiting nil)
1151 (defvar gnus-newsgroup-adaptive-score-file nil)
1152 (defvar gnus-current-score-file nil)
1153 (defvar gnus-current-move-group nil)
1154 (defvar gnus-current-copy-group nil)
1155 (defvar gnus-current-crosspost-group nil)
1156 (defvar gnus-newsgroup-display nil)
1157
1158 (defvar gnus-newsgroup-dependencies nil)
1159 (defvar gnus-newsgroup-adaptive nil)
1160 (defvar gnus-summary-display-article-function nil)
1161 (defvar gnus-summary-highlight-line-function nil
1162 "Function called after highlighting a summary line.")
1163
1164 (defvar gnus-summary-line-format-alist
1165 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1166 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1167 (?s gnus-tmp-subject-or-nil ?s)
1168 (?n gnus-tmp-name ?s)
1169 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1170 ?s)
1171 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1172 gnus-tmp-from) ?s)
1173 (?F gnus-tmp-from ?s)
1174 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1175 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1176 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1177 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1178 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1179 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1180 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1181 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1182 (?L gnus-tmp-lines ?s)
1183 (?O gnus-tmp-downloaded ?c)
1184 (?I gnus-tmp-indentation ?s)
1185 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1186 (?R gnus-tmp-replied ?c)
1187 (?\[ gnus-tmp-opening-bracket ?c)
1188 (?\] gnus-tmp-closing-bracket ?c)
1189 (?\> (make-string gnus-tmp-level ? ) ?s)
1190 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1191 (?i gnus-tmp-score ?d)
1192 (?z gnus-tmp-score-char ?c)
1193 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1194 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1195 (?U gnus-tmp-unread ?c)
1196 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1197 ?s)
1198 (?t (gnus-summary-number-of-articles-in-thread
1199 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1200 ?d)
1201 (?e (gnus-summary-number-of-articles-in-thread
1202 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1203 ?c)
1204 (?u gnus-tmp-user-defined ?s)
1205 (?P (gnus-pick-line-number) ?d)
1206 (?B gnus-tmp-thread-tree-header-string ?s)
1207 (user-date (gnus-user-date
1208 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1209 "An alist of format specifications that can appear in summary lines.
1210 These are paired with what variables they correspond with, along with
1211 the type of the variable (string, integer, character, etc).")
1212
1213 (defvar gnus-summary-dummy-line-format-alist
1214 `((?S gnus-tmp-subject ?s)
1215 (?N gnus-tmp-number ?d)
1216 (?u gnus-tmp-user-defined ?s)))
1217
1218 (defvar gnus-summary-mode-line-format-alist
1219 `((?G gnus-tmp-group-name ?s)
1220 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1221 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1222 (?A gnus-tmp-article-number ?d)
1223 (?Z gnus-tmp-unread-and-unselected ?s)
1224 (?V gnus-version ?s)
1225 (?U gnus-tmp-unread-and-unticked ?d)
1226 (?S gnus-tmp-subject ?s)
1227 (?e gnus-tmp-unselected ?d)
1228 (?u gnus-tmp-user-defined ?s)
1229 (?d (length gnus-newsgroup-dormant) ?d)
1230 (?t (length gnus-newsgroup-marked) ?d)
1231 (?h (length gnus-newsgroup-spam-marked) ?d)
1232 (?r (length gnus-newsgroup-reads) ?d)
1233 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1234 (?E gnus-newsgroup-expunged-tally ?d)
1235 (?s (gnus-current-score-file-nondirectory) ?s)))
1236
1237 (defvar gnus-last-search-regexp nil
1238 "Default regexp for article search command.")
1239
1240 (defvar gnus-last-shell-command nil
1241 "Default shell command on article.")
1242
1243 (defvar gnus-newsgroup-agentized nil
1244 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1245 (defvar gnus-newsgroup-begin nil)
1246 (defvar gnus-newsgroup-end nil)
1247 (defvar gnus-newsgroup-last-rmail nil)
1248 (defvar gnus-newsgroup-last-mail nil)
1249 (defvar gnus-newsgroup-last-folder nil)
1250 (defvar gnus-newsgroup-last-file nil)
1251 (defvar gnus-newsgroup-auto-expire nil)
1252 (defvar gnus-newsgroup-active nil)
1253
1254 (defvar gnus-newsgroup-data nil)
1255 (defvar gnus-newsgroup-data-reverse nil)
1256 (defvar gnus-newsgroup-limit nil)
1257 (defvar gnus-newsgroup-limits nil)
1258 (defvar gnus-summary-use-undownloaded-faces nil)
1259
1260 (defvar gnus-newsgroup-unreads nil
1261 "Sorted list of unread articles in the current newsgroup.")
1262
1263 (defvar gnus-newsgroup-unselected nil
1264 "Sorted list of unselected unread articles in the current newsgroup.")
1265
1266 (defvar gnus-newsgroup-reads nil
1267 "Alist of read articles and article marks in the current newsgroup.")
1268
1269 (defvar gnus-newsgroup-expunged-tally nil)
1270
1271 (defvar gnus-newsgroup-marked nil
1272 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1273
1274 (defvar gnus-newsgroup-spam-marked nil
1275 "List of ranges of articles that have been marked as spam.")
1276
1277 (defvar gnus-newsgroup-killed nil
1278 "List of ranges of articles that have been through the scoring process.")
1279
1280 (defvar gnus-newsgroup-cached nil
1281 "Sorted list of articles that come from the article cache.")
1282
1283 (defvar gnus-newsgroup-saved nil
1284 "List of articles that have been saved.")
1285
1286 (defvar gnus-newsgroup-kill-headers nil)
1287
1288 (defvar gnus-newsgroup-replied nil
1289 "List of articles that have been replied to in the current newsgroup.")
1290
1291 (defvar gnus-newsgroup-forwarded nil
1292 "List of articles that have been forwarded in the current newsgroup.")
1293
1294 (defvar gnus-newsgroup-recent nil
1295 "List of articles that have are recent in the current newsgroup.")
1296
1297 (defvar gnus-newsgroup-expirable nil
1298 "Sorted list of articles in the current newsgroup that can be expired.")
1299
1300 (defvar gnus-newsgroup-processable nil
1301 "List of articles in the current newsgroup that can be processed.")
1302
1303 (defvar gnus-newsgroup-downloadable nil
1304 "Sorted list of articles in the current newsgroup that can be processed.")
1305
1306 (defvar gnus-newsgroup-unfetched nil
1307 "Sorted list of articles in the current newsgroup whose headers have
1308 not been fetched into the agent.
1309
1310 This list will always be a subset of gnus-newsgroup-undownloaded.")
1311
1312 (defvar gnus-newsgroup-undownloaded nil
1313 "List of articles in the current newsgroup that haven't been downloaded.")
1314
1315 (defvar gnus-newsgroup-unsendable nil
1316 "List of articles in the current newsgroup that won't be sent.")
1317
1318 (defvar gnus-newsgroup-bookmarks nil
1319 "List of articles in the current newsgroup that have bookmarks.")
1320
1321 (defvar gnus-newsgroup-dormant nil
1322 "Sorted list of dormant articles in the current newsgroup.")
1323
1324 (defvar gnus-newsgroup-unseen nil
1325 "List of unseen articles in the current newsgroup.")
1326
1327 (defvar gnus-newsgroup-seen nil
1328 "Range of seen articles in the current newsgroup.")
1329
1330 (defvar gnus-newsgroup-articles nil
1331 "List of articles in the current newsgroup.")
1332
1333 (defvar gnus-newsgroup-scored nil
1334 "List of scored articles in the current newsgroup.")
1335
1336 (defvar gnus-newsgroup-headers nil
1337 "List of article headers in the current newsgroup.")
1338
1339 (defvar gnus-newsgroup-threads nil)
1340
1341 (defvar gnus-newsgroup-prepared nil
1342 "Whether the current group has been prepared properly.")
1343
1344 (defvar gnus-newsgroup-ancient nil
1345 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1346
1347 (defvar gnus-newsgroup-sparse nil)
1348
1349 (defvar gnus-current-article nil)
1350 (defvar gnus-article-current nil)
1351 (defvar gnus-current-headers nil)
1352 (defvar gnus-have-all-headers nil)
1353 (defvar gnus-last-article nil)
1354 (defvar gnus-newsgroup-history nil)
1355 (defvar gnus-newsgroup-charset nil)
1356 (defvar gnus-newsgroup-ephemeral-charset nil)
1357 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1358
1359 (defvar gnus-article-before-search nil)
1360
1361 (defvar gnus-summary-local-variables
1362 '(gnus-newsgroup-name
1363 gnus-newsgroup-begin gnus-newsgroup-end
1364 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1365 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1366 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1367 gnus-newsgroup-unselected gnus-newsgroup-marked
1368 gnus-newsgroup-spam-marked
1369 gnus-newsgroup-reads gnus-newsgroup-saved
1370 gnus-newsgroup-replied gnus-newsgroup-forwarded
1371 gnus-newsgroup-recent
1372 gnus-newsgroup-expirable
1373 gnus-newsgroup-processable gnus-newsgroup-killed
1374 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1375 gnus-newsgroup-unfetched
1376 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1377 gnus-newsgroup-seen gnus-newsgroup-articles
1378 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1379 gnus-newsgroup-headers gnus-newsgroup-threads
1380 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1381 gnus-current-article gnus-current-headers gnus-have-all-headers
1382 gnus-last-article gnus-article-internal-prepare-hook
1383 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1384 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1385 gnus-thread-expunge-below
1386 gnus-score-alist gnus-current-score-file
1387 (gnus-summary-expunge-below . global)
1388 (gnus-summary-mark-below . global)
1389 (gnus-orphan-score . global)
1390 gnus-newsgroup-active gnus-scores-exclude-files
1391 gnus-newsgroup-history gnus-newsgroup-ancient
1392 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1393 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1394 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1395 (gnus-newsgroup-expunged-tally . 0)
1396 gnus-cache-removable-articles gnus-newsgroup-cached
1397 gnus-newsgroup-data gnus-newsgroup-data-reverse
1398 gnus-newsgroup-limit gnus-newsgroup-limits
1399 gnus-newsgroup-charset gnus-newsgroup-display
1400 gnus-summary-use-undownloaded-faces)
1401 "Variables that are buffer-local to the summary buffers.")
1402
1403 (defvar gnus-newsgroup-variables nil
1404 "A list of variables that have separate values in different newsgroups.
1405 A list of newsgroup (summary buffer) local variables, or cons of
1406 variables and their default expressions to be evalled (when the default
1407 values are not nil), that should be made global while the summary buffer
1408 is active.
1409
1410 Note: The default expressions will be evaluated (using function `eval')
1411 before assignment to the local variable rather than just assigned to it.
1412 If the default expression is the symbol `global', that symbol will not
1413 be evaluated but the global value of the local variable will be used
1414 instead.
1415
1416 These variables can be used to set variables in the group parameters
1417 while still allowing them to affect operations done in other buffers.
1418 For example:
1419
1420 \(setq gnus-newsgroup-variables
1421 '(message-use-followup-to
1422 (gnus-visible-headers .
1423 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1424 ")
1425
1426 ;; Byte-compiler warning.
1427 (eval-when-compile
1428 ;; Bind features so that require will believe that gnus-sum has
1429 ;; already been loaded (avoids infinite recursion)
1430 (let ((features (cons 'gnus-sum features)))
1431 ;; Several of the declarations in gnus-sum are needed to load the
1432 ;; following files. Right now, these definitions have been
1433 ;; compiled but not defined (evaluated). We could either do a
1434 ;; eval-and-compile about all of the declarations or evaluate the
1435 ;; source file.
1436 (if (boundp 'gnus-newsgroup-variables)
1437 nil
1438 (load "gnus-sum.el" t t t))
1439 (require 'gnus)
1440 (require 'gnus-agent)
1441 (require 'gnus-art)))
1442
1443 ;; MIME stuff.
1444
1445 (defvar gnus-decode-encoded-word-methods
1446 '(mail-decode-encoded-word-string)
1447 "List of methods used to decode encoded words.
1448
1449 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1450 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1451 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1452 whose names match REGEXP.
1453
1454 For example:
1455 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1456 mail-decode-encoded-word-string
1457 (\"chinese\" . rfc1843-decode-string))")
1458
1459 (defvar gnus-decode-encoded-word-methods-cache nil)
1460
1461 (defun gnus-multi-decode-encoded-word-string (string)
1462 "Apply the functions from `gnus-encoded-word-methods' that match."
1463 (unless (and gnus-decode-encoded-word-methods-cache
1464 (eq gnus-newsgroup-name
1465 (car gnus-decode-encoded-word-methods-cache)))
1466 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1467 (mapcar (lambda (x)
1468 (if (symbolp x)
1469 (nconc gnus-decode-encoded-word-methods-cache (list x))
1470 (if (and gnus-newsgroup-name
1471 (string-match (car x) gnus-newsgroup-name))
1472 (nconc gnus-decode-encoded-word-methods-cache
1473 (list (cdr x))))))
1474 gnus-decode-encoded-word-methods))
1475 (let ((xlist gnus-decode-encoded-word-methods-cache))
1476 (pop xlist)
1477 (while xlist
1478 (setq string (funcall (pop xlist) string))))
1479 string)
1480
1481 ;; Subject simplification.
1482
1483 (defun gnus-simplify-whitespace (str)
1484 "Remove excessive whitespace from STR."
1485 ;; Multiple spaces.
1486 (while (string-match "[ \t][ \t]+" str)
1487 (setq str (concat (substring str 0 (match-beginning 0))
1488 " "
1489 (substring str (match-end 0)))))
1490 ;; Leading spaces.
1491 (when (string-match "^[ \t]+" str)
1492 (setq str (substring str (match-end 0))))
1493 ;; Trailing spaces.
1494 (when (string-match "[ \t]+$" str)
1495 (setq str (substring str 0 (match-beginning 0))))
1496 str)
1497
1498 (defun gnus-simplify-all-whitespace (str)
1499 "Remove all whitespace from STR."
1500 (while (string-match "[ \t\n]+" str)
1501 (setq str (replace-match "" nil nil str)))
1502 str)
1503
1504 (defsubst gnus-simplify-subject-re (subject)
1505 "Remove \"Re:\" from subject lines."
1506 (if (string-match message-subject-re-regexp subject)
1507 (substring subject (match-end 0))
1508 subject))
1509
1510 (defun gnus-simplify-subject (subject &optional re-only)
1511 "Remove `Re:' and words in parentheses.
1512 If RE-ONLY is non-nil, strip leading `Re:'s only."
1513 (let ((case-fold-search t)) ;Ignore case.
1514 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1515 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1516 (setq subject (substring subject (match-end 0))))
1517 ;; Remove uninteresting prefixes.
1518 (when (and (not re-only)
1519 gnus-simplify-ignored-prefixes
1520 (string-match gnus-simplify-ignored-prefixes subject))
1521 (setq subject (substring subject (match-end 0))))
1522 ;; Remove words in parentheses from end.
1523 (unless re-only
1524 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1525 (setq subject (substring subject 0 (match-beginning 0)))))
1526 ;; Return subject string.
1527 subject))
1528
1529 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1530 ;; all whitespace.
1531 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1532 (goto-char (point-min))
1533 (while (re-search-forward regexp nil t)
1534 (replace-match (or newtext ""))))
1535
1536 (defun gnus-simplify-buffer-fuzzy ()
1537 "Simplify string in the buffer fuzzily.
1538 The string in the accessible portion of the current buffer is simplified.
1539 It is assumed to be a single-line subject.
1540 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1541 matter is removed. Additional things can be deleted by setting
1542 `gnus-simplify-subject-fuzzy-regexp'."
1543 (let ((case-fold-search t)
1544 (modified-tick))
1545 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1546
1547 (while (not (eq modified-tick (buffer-modified-tick)))
1548 (setq modified-tick (buffer-modified-tick))
1549 (cond
1550 ((listp gnus-simplify-subject-fuzzy-regexp)
1551 (mapcar 'gnus-simplify-buffer-fuzzy-step
1552 gnus-simplify-subject-fuzzy-regexp))
1553 (gnus-simplify-subject-fuzzy-regexp
1554 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1555 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1556 (gnus-simplify-buffer-fuzzy-step
1557 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1558 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1559
1560 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1561 (gnus-simplify-buffer-fuzzy-step " +" " ")
1562 (gnus-simplify-buffer-fuzzy-step " $")
1563 (gnus-simplify-buffer-fuzzy-step "^ +")))
1564
1565 (defun gnus-simplify-subject-fuzzy (subject)
1566 "Simplify a subject string fuzzily.
1567 See `gnus-simplify-buffer-fuzzy' for details."
1568 (save-excursion
1569 (gnus-set-work-buffer)
1570 (let ((case-fold-search t))
1571 ;; Remove uninteresting prefixes.
1572 (when (and gnus-simplify-ignored-prefixes
1573 (string-match gnus-simplify-ignored-prefixes subject))
1574 (setq subject (substring subject (match-end 0))))
1575 (insert subject)
1576 (inline (gnus-simplify-buffer-fuzzy))
1577 (buffer-string))))
1578
1579 (defsubst gnus-simplify-subject-fully (subject)
1580 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1581 (cond
1582 (gnus-simplify-subject-functions
1583 (gnus-map-function gnus-simplify-subject-functions subject))
1584 ((null gnus-summary-gather-subject-limit)
1585 (gnus-simplify-subject-re subject))
1586 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1587 (gnus-simplify-subject-fuzzy subject))
1588 ((numberp gnus-summary-gather-subject-limit)
1589 (gnus-limit-string (gnus-simplify-subject-re subject)
1590 gnus-summary-gather-subject-limit))
1591 (t
1592 subject)))
1593
1594 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1595 "Check whether two subjects are equal.
1596 If optional argument SIMPLE-FIRST is t, first argument is already
1597 simplified."
1598 (cond
1599 ((null simple-first)
1600 (equal (gnus-simplify-subject-fully s1)
1601 (gnus-simplify-subject-fully s2)))
1602 (t
1603 (equal s1
1604 (gnus-simplify-subject-fully s2)))))
1605
1606 (defun gnus-summary-bubble-group ()
1607 "Increase the score of the current group.
1608 This is a handy function to add to `gnus-summary-exit-hook' to
1609 increase the score of each group you read."
1610 (gnus-group-add-score gnus-newsgroup-name))
1611
1612 \f
1613 ;;;
1614 ;;; Gnus summary mode
1615 ;;;
1616
1617 (put 'gnus-summary-mode 'mode-class 'special)
1618
1619 (defvar gnus-article-commands-menu)
1620
1621 ;; Non-orthogonal keys
1622
1623 (gnus-define-keys gnus-summary-mode-map
1624 " " gnus-summary-next-page
1625 "\177" gnus-summary-prev-page
1626 [delete] gnus-summary-prev-page
1627 [backspace] gnus-summary-prev-page
1628 "\r" gnus-summary-scroll-up
1629 "\M-\r" gnus-summary-scroll-down
1630 "n" gnus-summary-next-unread-article
1631 "p" gnus-summary-prev-unread-article
1632 "N" gnus-summary-next-article
1633 "P" gnus-summary-prev-article
1634 "\M-\C-n" gnus-summary-next-same-subject
1635 "\M-\C-p" gnus-summary-prev-same-subject
1636 "\M-n" gnus-summary-next-unread-subject
1637 "\M-p" gnus-summary-prev-unread-subject
1638 "." gnus-summary-first-unread-article
1639 "," gnus-summary-best-unread-article
1640 "\M-s" gnus-summary-search-article-forward
1641 "\M-r" gnus-summary-search-article-backward
1642 "<" gnus-summary-beginning-of-article
1643 ">" gnus-summary-end-of-article
1644 "j" gnus-summary-goto-article
1645 "^" gnus-summary-refer-parent-article
1646 "\M-^" gnus-summary-refer-article
1647 "u" gnus-summary-tick-article-forward
1648 "!" gnus-summary-tick-article-forward
1649 "U" gnus-summary-tick-article-backward
1650 "d" gnus-summary-mark-as-read-forward
1651 "D" gnus-summary-mark-as-read-backward
1652 "E" gnus-summary-mark-as-expirable
1653 "\M-u" gnus-summary-clear-mark-forward
1654 "\M-U" gnus-summary-clear-mark-backward
1655 "k" gnus-summary-kill-same-subject-and-select
1656 "\C-k" gnus-summary-kill-same-subject
1657 "\M-\C-k" gnus-summary-kill-thread
1658 "\M-\C-l" gnus-summary-lower-thread
1659 "e" gnus-summary-edit-article
1660 "#" gnus-summary-mark-as-processable
1661 "\M-#" gnus-summary-unmark-as-processable
1662 "\M-\C-t" gnus-summary-toggle-threads
1663 "\M-\C-s" gnus-summary-show-thread
1664 "\M-\C-h" gnus-summary-hide-thread
1665 "\M-\C-f" gnus-summary-next-thread
1666 "\M-\C-b" gnus-summary-prev-thread
1667 [(meta down)] gnus-summary-next-thread
1668 [(meta up)] gnus-summary-prev-thread
1669 "\M-\C-u" gnus-summary-up-thread
1670 "\M-\C-d" gnus-summary-down-thread
1671 "&" gnus-summary-execute-command
1672 "c" gnus-summary-catchup-and-exit
1673 "\C-w" gnus-summary-mark-region-as-read
1674 "\C-t" gnus-summary-toggle-truncation
1675 "?" gnus-summary-mark-as-dormant
1676 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1677 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1678 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1679 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1680 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1681 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1682 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1683 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1684 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1685 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1686 "=" gnus-summary-expand-window
1687 "\C-x\C-s" gnus-summary-reselect-current-group
1688 "\M-g" gnus-summary-rescan-group
1689 "w" gnus-summary-stop-page-breaking
1690 "\C-c\C-r" gnus-summary-caesar-message
1691 "f" gnus-summary-followup
1692 "F" gnus-summary-followup-with-original
1693 "C" gnus-summary-cancel-article
1694 "r" gnus-summary-reply
1695 "R" gnus-summary-reply-with-original
1696 "\C-c\C-f" gnus-summary-mail-forward
1697 "o" gnus-summary-save-article
1698 "\C-o" gnus-summary-save-article-mail
1699 "|" gnus-summary-pipe-output
1700 "\M-k" gnus-summary-edit-local-kill
1701 "\M-K" gnus-summary-edit-global-kill
1702 ;; "V" gnus-version
1703 "\C-c\C-d" gnus-summary-describe-group
1704 "q" gnus-summary-exit
1705 "Q" gnus-summary-exit-no-update
1706 "\C-c\C-i" gnus-info-find-node
1707 gnus-mouse-2 gnus-mouse-pick-article
1708 [follow-link] mouse-face
1709 "m" gnus-summary-mail-other-window
1710 "a" gnus-summary-post-news
1711 "i" gnus-summary-news-other-window
1712 "x" gnus-summary-limit-to-unread
1713 "s" gnus-summary-isearch-article
1714 "t" gnus-summary-toggle-header
1715 "g" gnus-summary-show-article
1716 "l" gnus-summary-goto-last-article
1717 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1718 "\C-d" gnus-summary-enter-digest-group
1719 "\M-\C-d" gnus-summary-read-document
1720 "\M-\C-e" gnus-summary-edit-parameters
1721 "\M-\C-a" gnus-summary-customize-parameters
1722 "\C-c\C-b" gnus-bug
1723 "*" gnus-cache-enter-article
1724 "\M-*" gnus-cache-remove-article
1725 "\M-&" gnus-summary-universal-argument
1726 "\C-l" gnus-recenter
1727 "I" gnus-summary-increase-score
1728 "L" gnus-summary-lower-score
1729 "\M-i" gnus-symbolic-argument
1730 "h" gnus-summary-select-article-buffer
1731
1732 "b" gnus-article-view-part
1733 "\M-t" gnus-summary-toggle-display-buttonized
1734
1735 "V" gnus-summary-score-map
1736 "X" gnus-uu-extract-map
1737 "S" gnus-summary-send-map)
1738
1739 ;; Sort of orthogonal keymap
1740 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1741 "t" gnus-summary-tick-article-forward
1742 "!" gnus-summary-tick-article-forward
1743 "d" gnus-summary-mark-as-read-forward
1744 "r" gnus-summary-mark-as-read-forward
1745 "c" gnus-summary-clear-mark-forward
1746 " " gnus-summary-clear-mark-forward
1747 "e" gnus-summary-mark-as-expirable
1748 "x" gnus-summary-mark-as-expirable
1749 "?" gnus-summary-mark-as-dormant
1750 "b" gnus-summary-set-bookmark
1751 "B" gnus-summary-remove-bookmark
1752 "#" gnus-summary-mark-as-processable
1753 "\M-#" gnus-summary-unmark-as-processable
1754 "S" gnus-summary-limit-include-expunged
1755 "C" gnus-summary-catchup
1756 "H" gnus-summary-catchup-to-here
1757 "h" gnus-summary-catchup-from-here
1758 "\C-c" gnus-summary-catchup-all
1759 "k" gnus-summary-kill-same-subject-and-select
1760 "K" gnus-summary-kill-same-subject
1761 "P" gnus-uu-mark-map)
1762
1763 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1764 "c" gnus-summary-clear-above
1765 "u" gnus-summary-tick-above
1766 "m" gnus-summary-mark-above
1767 "k" gnus-summary-kill-below)
1768
1769 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1770 "/" gnus-summary-limit-to-subject
1771 "n" gnus-summary-limit-to-articles
1772 "w" gnus-summary-pop-limit
1773 "s" gnus-summary-limit-to-subject
1774 "a" gnus-summary-limit-to-author
1775 "u" gnus-summary-limit-to-unread
1776 "m" gnus-summary-limit-to-marks
1777 "M" gnus-summary-limit-exclude-marks
1778 "v" gnus-summary-limit-to-score
1779 "*" gnus-summary-limit-include-cached
1780 "D" gnus-summary-limit-include-dormant
1781 "T" gnus-summary-limit-include-thread
1782 "d" gnus-summary-limit-exclude-dormant
1783 "t" gnus-summary-limit-to-age
1784 "." gnus-summary-limit-to-unseen
1785 "x" gnus-summary-limit-to-extra
1786 "p" gnus-summary-limit-to-display-predicate
1787 "E" gnus-summary-limit-include-expunged
1788 "c" gnus-summary-limit-exclude-childless-dormant
1789 "C" gnus-summary-limit-mark-excluded-as-read
1790 "o" gnus-summary-insert-old-articles
1791 "N" gnus-summary-insert-new-articles)
1792
1793 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1794 "n" gnus-summary-next-unread-article
1795 "p" gnus-summary-prev-unread-article
1796 "N" gnus-summary-next-article
1797 "P" gnus-summary-prev-article
1798 "\C-n" gnus-summary-next-same-subject
1799 "\C-p" gnus-summary-prev-same-subject
1800 "\M-n" gnus-summary-next-unread-subject
1801 "\M-p" gnus-summary-prev-unread-subject
1802 "f" gnus-summary-first-unread-article
1803 "b" gnus-summary-best-unread-article
1804 "j" gnus-summary-goto-article
1805 "g" gnus-summary-goto-subject
1806 "l" gnus-summary-goto-last-article
1807 "o" gnus-summary-pop-article)
1808
1809 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1810 "k" gnus-summary-kill-thread
1811 "l" gnus-summary-lower-thread
1812 "i" gnus-summary-raise-thread
1813 "T" gnus-summary-toggle-threads
1814 "t" gnus-summary-rethread-current
1815 "^" gnus-summary-reparent-thread
1816 "s" gnus-summary-show-thread
1817 "S" gnus-summary-show-all-threads
1818 "h" gnus-summary-hide-thread
1819 "H" gnus-summary-hide-all-threads
1820 "n" gnus-summary-next-thread
1821 "p" gnus-summary-prev-thread
1822 "u" gnus-summary-up-thread
1823 "o" gnus-summary-top-thread
1824 "d" gnus-summary-down-thread
1825 "#" gnus-uu-mark-thread
1826 "\M-#" gnus-uu-unmark-thread)
1827
1828 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1829 "g" gnus-summary-prepare
1830 "c" gnus-summary-insert-cached-articles
1831 "d" gnus-summary-insert-dormant-articles)
1832
1833 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1834 "c" gnus-summary-catchup-and-exit
1835 "C" gnus-summary-catchup-all-and-exit
1836 "E" gnus-summary-exit-no-update
1837 "Q" gnus-summary-exit
1838 "Z" gnus-summary-exit
1839 "n" gnus-summary-catchup-and-goto-next-group
1840 "R" gnus-summary-reselect-current-group
1841 "G" gnus-summary-rescan-group
1842 "N" gnus-summary-next-group
1843 "s" gnus-summary-save-newsrc
1844 "P" gnus-summary-prev-group)
1845
1846 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1847 " " gnus-summary-next-page
1848 "n" gnus-summary-next-page
1849 "\177" gnus-summary-prev-page
1850 [delete] gnus-summary-prev-page
1851 "p" gnus-summary-prev-page
1852 "\r" gnus-summary-scroll-up
1853 "\M-\r" gnus-summary-scroll-down
1854 "<" gnus-summary-beginning-of-article
1855 ">" gnus-summary-end-of-article
1856 "b" gnus-summary-beginning-of-article
1857 "e" gnus-summary-end-of-article
1858 "^" gnus-summary-refer-parent-article
1859 "r" gnus-summary-refer-parent-article
1860 "D" gnus-summary-enter-digest-group
1861 "R" gnus-summary-refer-references
1862 "T" gnus-summary-refer-thread
1863 "g" gnus-summary-show-article
1864 "s" gnus-summary-isearch-article
1865 "P" gnus-summary-print-article
1866 "M" gnus-mailing-list-insinuate
1867 "t" gnus-article-babel)
1868
1869 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1870 "b" gnus-article-add-buttons
1871 "B" gnus-article-add-buttons-to-head
1872 "o" gnus-article-treat-overstrike
1873 "e" gnus-article-emphasize
1874 "w" gnus-article-fill-cited-article
1875 "Q" gnus-article-fill-long-lines
1876 "C" gnus-article-capitalize-sentences
1877 "c" gnus-article-remove-cr
1878 "q" gnus-article-de-quoted-unreadable
1879 "6" gnus-article-de-base64-unreadable
1880 "Z" gnus-article-decode-HZ
1881 "h" gnus-article-wash-html
1882 "u" gnus-article-unsplit-urls
1883 "s" gnus-summary-force-verify-and-decrypt
1884 "f" gnus-article-display-x-face
1885 "l" gnus-summary-stop-page-breaking
1886 "r" gnus-summary-caesar-message
1887 "m" gnus-summary-morse-message
1888 "t" gnus-summary-toggle-header
1889 "g" gnus-treat-smiley
1890 "v" gnus-summary-verbose-headers
1891 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1892 "p" gnus-article-verify-x-pgp-sig
1893 "d" gnus-article-treat-dumbquotes)
1894
1895 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1896 ;; mnemonic: deuglif*Y*
1897 "u" gnus-article-outlook-unwrap-lines
1898 "a" gnus-article-outlook-repair-attribution
1899 "c" gnus-article-outlook-rearrange-citation
1900 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1901
1902 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1903 "a" gnus-article-hide
1904 "h" gnus-article-hide-headers
1905 "b" gnus-article-hide-boring-headers
1906 "s" gnus-article-hide-signature
1907 "c" gnus-article-hide-citation
1908 "C" gnus-article-hide-citation-in-followups
1909 "l" gnus-article-hide-list-identifiers
1910 "B" gnus-article-strip-banner
1911 "P" gnus-article-hide-pem
1912 "\C-c" gnus-article-hide-citation-maybe)
1913
1914 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1915 "a" gnus-article-highlight
1916 "h" gnus-article-highlight-headers
1917 "c" gnus-article-highlight-citation
1918 "s" gnus-article-highlight-signature)
1919
1920 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1921 "f" gnus-article-treat-fold-headers
1922 "u" gnus-article-treat-unfold-headers
1923 "n" gnus-article-treat-fold-newsgroups)
1924
1925 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1926 "x" gnus-article-display-x-face
1927 "d" gnus-article-display-face
1928 "s" gnus-treat-smiley
1929 "D" gnus-article-remove-images
1930 "f" gnus-treat-from-picon
1931 "m" gnus-treat-mail-picon
1932 "n" gnus-treat-newsgroups-picon)
1933
1934 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1935 "w" gnus-article-decode-mime-words
1936 "c" gnus-article-decode-charset
1937 "v" gnus-mime-view-all-parts
1938 "b" gnus-article-view-part)
1939
1940 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1941 "z" gnus-article-date-ut
1942 "u" gnus-article-date-ut
1943 "l" gnus-article-date-local
1944 "p" gnus-article-date-english
1945 "e" gnus-article-date-lapsed
1946 "o" gnus-article-date-original
1947 "i" gnus-article-date-iso8601
1948 "s" gnus-article-date-user)
1949
1950 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1951 "t" gnus-article-remove-trailing-blank-lines
1952 "l" gnus-article-strip-leading-blank-lines
1953 "m" gnus-article-strip-multiple-blank-lines
1954 "a" gnus-article-strip-blank-lines
1955 "A" gnus-article-strip-all-blank-lines
1956 "s" gnus-article-strip-leading-space
1957 "e" gnus-article-strip-trailing-space
1958 "w" gnus-article-remove-leading-whitespace)
1959
1960 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1961 "v" gnus-version
1962 "f" gnus-summary-fetch-faq
1963 "d" gnus-summary-describe-group
1964 "h" gnus-summary-describe-briefly
1965 "i" gnus-info-find-node
1966 "c" gnus-group-fetch-charter
1967 "C" gnus-group-fetch-control)
1968
1969 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1970 "e" gnus-summary-expire-articles
1971 "\M-\C-e" gnus-summary-expire-articles-now
1972 "\177" gnus-summary-delete-article
1973 [delete] gnus-summary-delete-article
1974 [backspace] gnus-summary-delete-article
1975 "m" gnus-summary-move-article
1976 "r" gnus-summary-respool-article
1977 "w" gnus-summary-edit-article
1978 "c" gnus-summary-copy-article
1979 "B" gnus-summary-crosspost-article
1980 "q" gnus-summary-respool-query
1981 "t" gnus-summary-respool-trace
1982 "i" gnus-summary-import-article
1983 "I" gnus-summary-create-article
1984 "p" gnus-summary-article-posted-p)
1985
1986 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1987 "o" gnus-summary-save-article
1988 "m" gnus-summary-save-article-mail
1989 "F" gnus-summary-write-article-file
1990 "r" gnus-summary-save-article-rmail
1991 "f" gnus-summary-save-article-file
1992 "b" gnus-summary-save-article-body-file
1993 "h" gnus-summary-save-article-folder
1994 "v" gnus-summary-save-article-vm
1995 "p" gnus-summary-pipe-output
1996 "P" gnus-summary-muttprint
1997 "s" gnus-soup-add-article)
1998
1999 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2000 "b" gnus-summary-display-buttonized
2001 "m" gnus-summary-repair-multipart
2002 "v" gnus-article-view-part
2003 "o" gnus-article-save-part
2004 "c" gnus-article-copy-part
2005 "C" gnus-article-view-part-as-charset
2006 "e" gnus-article-view-part-externally
2007 "E" gnus-article-encrypt-body
2008 "i" gnus-article-inline-part
2009 "|" gnus-article-pipe-part)
2010
2011 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2012 "p" gnus-summary-mark-as-processable
2013 "u" gnus-summary-unmark-as-processable
2014 "U" gnus-summary-unmark-all-processable
2015 "v" gnus-uu-mark-over
2016 "s" gnus-uu-mark-series
2017 "r" gnus-uu-mark-region
2018 "g" gnus-uu-unmark-region
2019 "R" gnus-uu-mark-by-regexp
2020 "G" gnus-uu-unmark-by-regexp
2021 "t" gnus-uu-mark-thread
2022 "T" gnus-uu-unmark-thread
2023 "a" gnus-uu-mark-all
2024 "b" gnus-uu-mark-buffer
2025 "S" gnus-uu-mark-sparse
2026 "k" gnus-summary-kill-process-mark
2027 "y" gnus-summary-yank-process-mark
2028 "w" gnus-summary-save-process-mark
2029 "i" gnus-uu-invert-processable)
2030
2031 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2032 ;;"x" gnus-uu-extract-any
2033 "m" gnus-summary-save-parts
2034 "u" gnus-uu-decode-uu
2035 "U" gnus-uu-decode-uu-and-save
2036 "s" gnus-uu-decode-unshar
2037 "S" gnus-uu-decode-unshar-and-save
2038 "o" gnus-uu-decode-save
2039 "O" gnus-uu-decode-save
2040 "b" gnus-uu-decode-binhex
2041 "B" gnus-uu-decode-binhex
2042 "p" gnus-uu-decode-postscript
2043 "P" gnus-uu-decode-postscript-and-save)
2044
2045 (gnus-define-keys
2046 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2047 "u" gnus-uu-decode-uu-view
2048 "U" gnus-uu-decode-uu-and-save-view
2049 "s" gnus-uu-decode-unshar-view
2050 "S" gnus-uu-decode-unshar-and-save-view
2051 "o" gnus-uu-decode-save-view
2052 "O" gnus-uu-decode-save-view
2053 "b" gnus-uu-decode-binhex-view
2054 "B" gnus-uu-decode-binhex-view
2055 "p" gnus-uu-decode-postscript-view
2056 "P" gnus-uu-decode-postscript-and-save-view)
2057
2058 (defvar gnus-article-post-menu nil)
2059
2060 (defconst gnus-summary-menu-maxlen 20)
2061
2062 (defun gnus-summary-menu-split (menu)
2063 ;; If we have lots of elements, divide them into groups of 20
2064 ;; and make a pane (or submenu) for each one.
2065 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2066 (let ((menu menu) sublists next
2067 (i 1))
2068 (while menu
2069 ;; Pull off the next gnus-summary-menu-maxlen elements
2070 ;; and make them the next element of sublist.
2071 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2072 (if next
2073 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2074 nil))
2075 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2076 (aref (car (last menu)) 0)) menu)
2077 sublists))
2078 (setq i (1+ i))
2079 (setq menu next))
2080 (nreverse sublists))
2081 ;; Few elements--put them all in one pane.
2082 menu))
2083
2084 (defun gnus-summary-make-menu-bar ()
2085 (gnus-turn-off-edit-menu 'summary)
2086
2087 (unless (boundp 'gnus-summary-misc-menu)
2088
2089 (easy-menu-define
2090 gnus-summary-kill-menu gnus-summary-mode-map ""
2091 (cons
2092 "Score"
2093 (nconc
2094 (list
2095 ["Customize" gnus-score-customize t])
2096 (gnus-make-score-map 'increase)
2097 (gnus-make-score-map 'lower)
2098 '(("Mark"
2099 ["Kill below" gnus-summary-kill-below t]
2100 ["Mark above" gnus-summary-mark-above t]
2101 ["Tick above" gnus-summary-tick-above t]
2102 ["Clear above" gnus-summary-clear-above t])
2103 ["Current score" gnus-summary-current-score t]
2104 ["Set score" gnus-summary-set-score t]
2105 ["Switch current score file..." gnus-score-change-score-file t]
2106 ["Set mark below..." gnus-score-set-mark-below t]
2107 ["Set expunge below..." gnus-score-set-expunge-below t]
2108 ["Edit current score file" gnus-score-edit-current-scores t]
2109 ["Edit score file" gnus-score-edit-file t]
2110 ["Trace score" gnus-score-find-trace t]
2111 ["Find words" gnus-score-find-favourite-words t]
2112 ["Rescore buffer" gnus-summary-rescore t]
2113 ["Increase score..." gnus-summary-increase-score t]
2114 ["Lower score..." gnus-summary-lower-score t]))))
2115
2116 ;; Define both the Article menu in the summary buffer and the
2117 ;; equivalent Commands menu in the article buffer here for
2118 ;; consistency.
2119 (let ((innards
2120 `(("Hide"
2121 ["All" gnus-article-hide t]
2122 ["Headers" gnus-article-hide-headers t]
2123 ["Signature" gnus-article-hide-signature t]
2124 ["Citation" gnus-article-hide-citation t]
2125 ["List identifiers" gnus-article-hide-list-identifiers t]
2126 ["Banner" gnus-article-strip-banner t]
2127 ["Boring headers" gnus-article-hide-boring-headers t])
2128 ("Highlight"
2129 ["All" gnus-article-highlight t]
2130 ["Headers" gnus-article-highlight-headers t]
2131 ["Signature" gnus-article-highlight-signature t]
2132 ["Citation" gnus-article-highlight-citation t])
2133 ("MIME"
2134 ["Words" gnus-article-decode-mime-words t]
2135 ["Charset" gnus-article-decode-charset t]
2136 ["QP" gnus-article-de-quoted-unreadable t]
2137 ["Base64" gnus-article-de-base64-unreadable t]
2138 ["View MIME buttons" gnus-summary-display-buttonized t]
2139 ["View all" gnus-mime-view-all-parts t]
2140 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2141 ["Encrypt body" gnus-article-encrypt-body
2142 :active (not (gnus-group-read-only-p))
2143 ,@(if (featurep 'xemacs) nil
2144 '(:help "Encrypt the message body on disk"))]
2145 ["Extract all parts..." gnus-summary-save-parts t]
2146 ("Multipart"
2147 ["Repair multipart" gnus-summary-repair-multipart t]
2148 ["Pipe part..." gnus-article-pipe-part t]
2149 ["Inline part" gnus-article-inline-part t]
2150 ["Encrypt body" gnus-article-encrypt-body
2151 :active (not (gnus-group-read-only-p))
2152 ,@(if (featurep 'xemacs) nil
2153 '(:help "Encrypt the message body on disk"))]
2154 ["View part externally" gnus-article-view-part-externally t]
2155 ["View part with charset..." gnus-article-view-part-as-charset t]
2156 ["Copy part" gnus-article-copy-part t]
2157 ["Save part..." gnus-article-save-part t]
2158 ["View part" gnus-article-view-part t]))
2159 ("Date"
2160 ["Local" gnus-article-date-local t]
2161 ["ISO8601" gnus-article-date-iso8601 t]
2162 ["UT" gnus-article-date-ut t]
2163 ["Original" gnus-article-date-original t]
2164 ["Lapsed" gnus-article-date-lapsed t]
2165 ["User-defined" gnus-article-date-user t])
2166 ("Display"
2167 ["Remove images" gnus-article-remove-images t]
2168 ["Toggle smiley" gnus-treat-smiley t]
2169 ["Show X-Face" gnus-article-display-x-face t]
2170 ["Show picons in From" gnus-treat-from-picon t]
2171 ["Show picons in mail headers" gnus-treat-mail-picon t]
2172 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2173 ("View as different encoding"
2174 ,@(gnus-summary-menu-split
2175 (mapcar
2176 (lambda (cs)
2177 ;; Since easymenu under Emacs doesn't allow
2178 ;; lambda forms for menu commands, we should
2179 ;; provide intern'ed function symbols.
2180 (let ((command (intern (format "\
2181 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2182 (fset command
2183 `(lambda ()
2184 (interactive)
2185 (let ((gnus-summary-show-article-charset-alist
2186 '((1 . ,cs))))
2187 (gnus-summary-show-article 1))))
2188 `[,(symbol-name cs) ,command t]))
2189 (sort (if (fboundp 'coding-system-list)
2190 (coding-system-list)
2191 (mapcar 'car mm-mime-mule-charset-alist))
2192 'string<)))))
2193 ("Washing"
2194 ("Remove Blanks"
2195 ["Leading" gnus-article-strip-leading-blank-lines t]
2196 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2197 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2198 ["All of the above" gnus-article-strip-blank-lines t]
2199 ["All" gnus-article-strip-all-blank-lines t]
2200 ["Leading space" gnus-article-strip-leading-space t]
2201 ["Trailing space" gnus-article-strip-trailing-space t]
2202 ["Leading space in headers"
2203 gnus-article-remove-leading-whitespace t])
2204 ["Overstrike" gnus-article-treat-overstrike t]
2205 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2206 ["Emphasis" gnus-article-emphasize t]
2207 ["Word wrap" gnus-article-fill-cited-article t]
2208 ["Fill long lines" gnus-article-fill-long-lines t]
2209 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2210 ["Remove CR" gnus-article-remove-cr t]
2211 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2212 ["Base64" gnus-article-de-base64-unreadable t]
2213 ["Rot 13" gnus-summary-caesar-message
2214 ,@(if (featurep 'xemacs) '(t)
2215 '(:help "\"Caesar rotate\" article by 13"))]
2216 ["Morse decode" gnus-summary-morse-message t]
2217 ["Unix pipe..." gnus-summary-pipe-message t]
2218 ["Add buttons" gnus-article-add-buttons t]
2219 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2220 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2221 ["Verbose header" gnus-summary-verbose-headers t]
2222 ["Toggle header" gnus-summary-toggle-header t]
2223 ["Unfold headers" gnus-article-treat-unfold-headers t]
2224 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2225 ["Html" gnus-article-wash-html t]
2226 ["Unsplit URLs" gnus-article-unsplit-urls t]
2227 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2228 ["Decode HZ" gnus-article-decode-HZ t]
2229 ("(Outlook) Deuglify"
2230 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2231 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2232 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2233 ["Full (Outlook) deuglify"
2234 gnus-article-outlook-deuglify-article t])
2235 )
2236 ("Output"
2237 ["Save in default format..." gnus-summary-save-article
2238 ,@(if (featurep 'xemacs) '(t)
2239 '(:help "Save article using default method"))]
2240 ["Save in file..." gnus-summary-save-article-file
2241 ,@(if (featurep 'xemacs) '(t)
2242 '(:help "Save article in file"))]
2243 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2244 ["Save in MH folder..." gnus-summary-save-article-folder t]
2245 ["Save in VM folder..." gnus-summary-save-article-vm t]
2246 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2247 ["Save body in file..." gnus-summary-save-article-body-file t]
2248 ["Pipe through a filter..." gnus-summary-pipe-output t]
2249 ["Add to SOUP packet" gnus-soup-add-article t]
2250 ["Print with Muttprint..." gnus-summary-muttprint t]
2251 ["Print" gnus-summary-print-article
2252 ,@(if (featurep 'xemacs) '(t)
2253 '(:help "Generate and print a PostScript image"))])
2254 ("Copy, move,... (Backend)"
2255 ,@(if (featurep 'xemacs) nil
2256 '(:help "Copying, moving, expiring articles..."))
2257 ["Respool article..." gnus-summary-respool-article t]
2258 ["Move article..." gnus-summary-move-article
2259 (gnus-check-backend-function
2260 'request-move-article gnus-newsgroup-name)]
2261 ["Copy article..." gnus-summary-copy-article t]
2262 ["Crosspost article..." gnus-summary-crosspost-article
2263 (gnus-check-backend-function
2264 'request-replace-article gnus-newsgroup-name)]
2265 ["Import file..." gnus-summary-import-article
2266 (gnus-check-backend-function
2267 'request-accept-article gnus-newsgroup-name)]
2268 ["Create article..." gnus-summary-create-article
2269 (gnus-check-backend-function
2270 'request-accept-article gnus-newsgroup-name)]
2271 ["Check if posted" gnus-summary-article-posted-p t]
2272 ["Edit article" gnus-summary-edit-article
2273 (not (gnus-group-read-only-p))]
2274 ["Delete article" gnus-summary-delete-article
2275 (gnus-check-backend-function
2276 'request-expire-articles gnus-newsgroup-name)]
2277 ["Query respool" gnus-summary-respool-query t]
2278 ["Trace respool" gnus-summary-respool-trace t]
2279 ["Delete expirable articles" gnus-summary-expire-articles-now
2280 (gnus-check-backend-function
2281 'request-expire-articles gnus-newsgroup-name)])
2282 ("Extract"
2283 ["Uudecode" gnus-uu-decode-uu
2284 ,@(if (featurep 'xemacs) '(t)
2285 '(:help "Decode uuencoded article(s)"))]
2286 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2287 ["Unshar" gnus-uu-decode-unshar t]
2288 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2289 ["Save" gnus-uu-decode-save t]
2290 ["Binhex" gnus-uu-decode-binhex t]
2291 ["Postscript" gnus-uu-decode-postscript t]
2292 ["All MIME parts" gnus-summary-save-parts t])
2293 ("Cache"
2294 ["Enter article" gnus-cache-enter-article t]
2295 ["Remove article" gnus-cache-remove-article t])
2296 ["Translate" gnus-article-babel t]
2297 ["Select article buffer" gnus-summary-select-article-buffer t]
2298 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2299 ["Isearch article..." gnus-summary-isearch-article t]
2300 ["Beginning of the article" gnus-summary-beginning-of-article t]
2301 ["End of the article" gnus-summary-end-of-article t]
2302 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2303 ["Fetch referenced articles" gnus-summary-refer-references t]
2304 ["Fetch current thread" gnus-summary-refer-thread t]
2305 ["Fetch article with id..." gnus-summary-refer-article t]
2306 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2307 ["Redisplay" gnus-summary-show-article t]
2308 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2309 (easy-menu-define
2310 gnus-summary-article-menu gnus-summary-mode-map ""
2311 (cons "Article" innards))
2312
2313 (if (not (keymapp gnus-summary-article-menu))
2314 (easy-menu-define
2315 gnus-article-commands-menu gnus-article-mode-map ""
2316 (cons "Commands" innards))
2317 ;; in Emacs, don't share menu.
2318 (setq gnus-article-commands-menu
2319 (copy-keymap gnus-summary-article-menu))
2320 (define-key gnus-article-mode-map [menu-bar commands]
2321 (cons "Commands" gnus-article-commands-menu))))
2322
2323 (easy-menu-define
2324 gnus-summary-thread-menu gnus-summary-mode-map ""
2325 '("Threads"
2326 ["Find all messages in thread" gnus-summary-refer-thread t]
2327 ["Toggle threading" gnus-summary-toggle-threads t]
2328 ["Hide threads" gnus-summary-hide-all-threads t]
2329 ["Show threads" gnus-summary-show-all-threads t]
2330 ["Hide thread" gnus-summary-hide-thread t]
2331 ["Show thread" gnus-summary-show-thread t]
2332 ["Go to next thread" gnus-summary-next-thread t]
2333 ["Go to previous thread" gnus-summary-prev-thread t]
2334 ["Go down thread" gnus-summary-down-thread t]
2335 ["Go up thread" gnus-summary-up-thread t]
2336 ["Top of thread" gnus-summary-top-thread t]
2337 ["Mark thread as read" gnus-summary-kill-thread t]
2338 ["Lower thread score" gnus-summary-lower-thread t]
2339 ["Raise thread score" gnus-summary-raise-thread t]
2340 ["Rethread current" gnus-summary-rethread-current t]))
2341
2342 (easy-menu-define
2343 gnus-summary-post-menu gnus-summary-mode-map ""
2344 `("Post"
2345 ["Send a message (mail or news)" gnus-summary-post-news
2346 ,@(if (featurep 'xemacs) '(t)
2347 '(:help "Compose a new message (mail or news)"))]
2348 ["Followup" gnus-summary-followup
2349 ,@(if (featurep 'xemacs) '(t)
2350 '(:help "Post followup to this article"))]
2351 ["Followup and yank" gnus-summary-followup-with-original
2352 ,@(if (featurep 'xemacs) '(t)
2353 '(:help "Post followup to this article, quoting its contents"))]
2354 ["Supersede article" gnus-summary-supersede-article t]
2355 ["Cancel article" gnus-summary-cancel-article
2356 ,@(if (featurep 'xemacs) '(t)
2357 '(:help "Cancel an article you posted"))]
2358 ["Reply" gnus-summary-reply t]
2359 ["Reply and yank" gnus-summary-reply-with-original t]
2360 ["Wide reply" gnus-summary-wide-reply t]
2361 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2362 ,@(if (featurep 'xemacs) '(t)
2363 '(:help "Mail a reply, quoting this article"))]
2364 ["Very wide reply" gnus-summary-very-wide-reply t]
2365 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2366 ,@(if (featurep 'xemacs) '(t)
2367 '(:help "Mail a very wide reply, quoting this article"))]
2368 ["Mail forward" gnus-summary-mail-forward t]
2369 ["Post forward" gnus-summary-post-forward t]
2370 ["Digest and mail" gnus-uu-digest-mail-forward t]
2371 ["Digest and post" gnus-uu-digest-post-forward t]
2372 ["Resend message" gnus-summary-resend-message t]
2373 ["Resend message edit" gnus-summary-resend-message-edit t]
2374 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2375 ["Send a mail" gnus-summary-mail-other-window t]
2376 ["Create a local message" gnus-summary-news-other-window t]
2377 ["Uuencode and post" gnus-uu-post-news
2378 ,@(if (featurep 'xemacs) '(t)
2379 '(:help "Post a uuencoded article"))]
2380 ["Followup via news" gnus-summary-followup-to-mail t]
2381 ["Followup via news and yank"
2382 gnus-summary-followup-to-mail-with-original t]
2383 ;;("Draft"
2384 ;;["Send" gnus-summary-send-draft t]
2385 ;;["Send bounced" gnus-resend-bounced-mail t])
2386 ))
2387
2388 (cond
2389 ((not (keymapp gnus-summary-post-menu))
2390 (setq gnus-article-post-menu gnus-summary-post-menu))
2391 ((not gnus-article-post-menu)
2392 ;; Don't share post menu.
2393 (setq gnus-article-post-menu
2394 (copy-keymap gnus-summary-post-menu))))
2395 (define-key gnus-article-mode-map [menu-bar post]
2396 (cons "Post" gnus-article-post-menu))
2397
2398 (easy-menu-define
2399 gnus-summary-misc-menu gnus-summary-mode-map ""
2400 `("Gnus"
2401 ("Mark Read"
2402 ["Mark as read" gnus-summary-mark-as-read-forward t]
2403 ["Mark same subject and select"
2404 gnus-summary-kill-same-subject-and-select t]
2405 ["Mark same subject" gnus-summary-kill-same-subject t]
2406 ["Catchup" gnus-summary-catchup
2407 ,@(if (featurep 'xemacs) '(t)
2408 '(:help "Mark unread articles in this group as read"))]
2409 ["Catchup all" gnus-summary-catchup-all t]
2410 ["Catchup to here" gnus-summary-catchup-to-here t]
2411 ["Catchup from here" gnus-summary-catchup-from-here t]
2412 ["Catchup region" gnus-summary-mark-region-as-read
2413 (gnus-mark-active-p)]
2414 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2415 ("Mark Various"
2416 ["Tick" gnus-summary-tick-article-forward t]
2417 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2418 ["Remove marks" gnus-summary-clear-mark-forward t]
2419 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2420 ["Set bookmark" gnus-summary-set-bookmark t]
2421 ["Remove bookmark" gnus-summary-remove-bookmark t])
2422 ("Limit to"
2423 ["Marks..." gnus-summary-limit-to-marks t]
2424 ["Subject..." gnus-summary-limit-to-subject t]
2425 ["Author..." gnus-summary-limit-to-author t]
2426 ["Age..." gnus-summary-limit-to-age t]
2427 ["Extra..." gnus-summary-limit-to-extra t]
2428 ["Score..." gnus-summary-limit-to-score t]
2429 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2430 ["Unread" gnus-summary-limit-to-unread t]
2431 ["Unseen" gnus-summary-limit-to-unseen t]
2432 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2433 ["Next articles" gnus-summary-limit-to-articles t]
2434 ["Pop limit" gnus-summary-pop-limit t]
2435 ["Show dormant" gnus-summary-limit-include-dormant t]
2436 ["Hide childless dormant"
2437 gnus-summary-limit-exclude-childless-dormant t]
2438 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2439 ["Hide marked" gnus-summary-limit-exclude-marks t]
2440 ["Show expunged" gnus-summary-limit-include-expunged t])
2441 ("Process Mark"
2442 ["Set mark" gnus-summary-mark-as-processable t]
2443 ["Remove mark" gnus-summary-unmark-as-processable t]
2444 ["Remove all marks" gnus-summary-unmark-all-processable t]
2445 ["Mark above" gnus-uu-mark-over t]
2446 ["Mark series" gnus-uu-mark-series t]
2447 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2448 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2449 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2450 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2451 ["Mark all" gnus-uu-mark-all t]
2452 ["Mark buffer" gnus-uu-mark-buffer t]
2453 ["Mark sparse" gnus-uu-mark-sparse t]
2454 ["Mark thread" gnus-uu-mark-thread t]
2455 ["Unmark thread" gnus-uu-unmark-thread t]
2456 ("Process Mark Sets"
2457 ["Kill" gnus-summary-kill-process-mark t]
2458 ["Yank" gnus-summary-yank-process-mark
2459 gnus-newsgroup-process-stack]
2460 ["Save" gnus-summary-save-process-mark t]
2461 ["Run command on marked..." gnus-summary-universal-argument t]))
2462 ("Scroll article"
2463 ["Page forward" gnus-summary-next-page
2464 ,@(if (featurep 'xemacs) '(t)
2465 '(:help "Show next page of article"))]
2466 ["Page backward" gnus-summary-prev-page
2467 ,@(if (featurep 'xemacs) '(t)
2468 '(:help "Show previous page of article"))]
2469 ["Line forward" gnus-summary-scroll-up t])
2470 ("Move"
2471 ["Next unread article" gnus-summary-next-unread-article t]
2472 ["Previous unread article" gnus-summary-prev-unread-article t]
2473 ["Next article" gnus-summary-next-article t]
2474 ["Previous article" gnus-summary-prev-article t]
2475 ["Next unread subject" gnus-summary-next-unread-subject t]
2476 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2477 ["Next article same subject" gnus-summary-next-same-subject t]
2478 ["Previous article same subject" gnus-summary-prev-same-subject t]
2479 ["First unread article" gnus-summary-first-unread-article t]
2480 ["Best unread article" gnus-summary-best-unread-article t]
2481 ["Go to subject number..." gnus-summary-goto-subject t]
2482 ["Go to article number..." gnus-summary-goto-article t]
2483 ["Go to the last article" gnus-summary-goto-last-article t]
2484 ["Pop article off history" gnus-summary-pop-article t])
2485 ("Sort"
2486 ["Sort by number" gnus-summary-sort-by-number t]
2487 ["Sort by author" gnus-summary-sort-by-author t]
2488 ["Sort by subject" gnus-summary-sort-by-subject t]
2489 ["Sort by date" gnus-summary-sort-by-date t]
2490 ["Sort by score" gnus-summary-sort-by-score t]
2491 ["Sort by lines" gnus-summary-sort-by-lines t]
2492 ["Sort by characters" gnus-summary-sort-by-chars t]
2493 ["Randomize" gnus-summary-sort-by-random t]
2494 ["Original sort" gnus-summary-sort-by-original t])
2495 ("Help"
2496 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2497 ["Describe group" gnus-summary-describe-group t]
2498 ["Fetch charter" gnus-group-fetch-charter
2499 ,@(if (featurep 'xemacs) nil
2500 '(:help "Display the charter of the current group"))]
2501 ["Fetch control message" gnus-group-fetch-control
2502 ,@(if (featurep 'xemacs) nil
2503 '(:help "Display the archived control message for the current group"))]
2504 ["Read manual" gnus-info-find-node t])
2505 ("Modes"
2506 ["Pick and read" gnus-pick-mode t]
2507 ["Binary" gnus-binary-mode t])
2508 ("Regeneration"
2509 ["Regenerate" gnus-summary-prepare t]
2510 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2511 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2512 ["Toggle threading" gnus-summary-toggle-threads t])
2513 ["See old articles" gnus-summary-insert-old-articles t]
2514 ["See new articles" gnus-summary-insert-new-articles t]
2515 ["Filter articles..." gnus-summary-execute-command t]
2516 ["Run command on articles..." gnus-summary-universal-argument t]
2517 ["Search articles forward..." gnus-summary-search-article-forward t]
2518 ["Search articles backward..." gnus-summary-search-article-backward t]
2519 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2520 ["Expand window" gnus-summary-expand-window t]
2521 ["Expire expirable articles" gnus-summary-expire-articles
2522 (gnus-check-backend-function
2523 'request-expire-articles gnus-newsgroup-name)]
2524 ["Edit local kill file" gnus-summary-edit-local-kill t]
2525 ["Edit main kill file" gnus-summary-edit-global-kill t]
2526 ["Edit group parameters" gnus-summary-edit-parameters t]
2527 ["Customize group parameters" gnus-summary-customize-parameters t]
2528 ["Send a bug report" gnus-bug t]
2529 ("Exit"
2530 ["Catchup and exit" gnus-summary-catchup-and-exit
2531 ,@(if (featurep 'xemacs) '(t)
2532 '(:help "Mark unread articles in this group as read, then exit"))]
2533 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2534 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2535 ["Exit group" gnus-summary-exit
2536 ,@(if (featurep 'xemacs) '(t)
2537 '(:help "Exit current group, return to group selection mode"))]
2538 ["Exit group without updating" gnus-summary-exit-no-update t]
2539 ["Exit and goto next group" gnus-summary-next-group t]
2540 ["Exit and goto prev group" gnus-summary-prev-group t]
2541 ["Reselect group" gnus-summary-reselect-current-group t]
2542 ["Rescan group" gnus-summary-rescan-group t]
2543 ["Update dribble" gnus-summary-save-newsrc t])))
2544
2545 (gnus-run-hooks 'gnus-summary-menu-hook)))
2546
2547 (defvar gnus-summary-tool-bar-map nil)
2548
2549 ;; Emacs 21 tool bar. Should be no-op otherwise.
2550 (defun gnus-summary-make-tool-bar ()
2551 (if (and (fboundp 'tool-bar-add-item-from-menu)
2552 (default-value 'tool-bar-mode)
2553 (not gnus-summary-tool-bar-map))
2554 (setq gnus-summary-tool-bar-map
2555 (let ((tool-bar-map (make-sparse-keymap))
2556 (load-path (mm-image-load-path)))
2557 (tool-bar-add-item-from-menu
2558 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2559 (tool-bar-add-item-from-menu
2560 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2561 (tool-bar-add-item-from-menu
2562 'gnus-summary-post-news "post" gnus-summary-mode-map)
2563 (tool-bar-add-item-from-menu
2564 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2565 (tool-bar-add-item-from-menu
2566 'gnus-summary-followup "followup" gnus-summary-mode-map)
2567 (tool-bar-add-item-from-menu
2568 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2569 (tool-bar-add-item-from-menu
2570 'gnus-summary-reply "reply" gnus-summary-mode-map)
2571 (tool-bar-add-item-from-menu
2572 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2573 (tool-bar-add-item-from-menu
2574 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2575 (tool-bar-add-item-from-menu
2576 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2577 (tool-bar-add-item-from-menu
2578 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2579 (tool-bar-add-item-from-menu
2580 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2581 (tool-bar-add-item-from-menu
2582 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2583 (tool-bar-add-item-from-menu
2584 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2585 (tool-bar-add-item-from-menu
2586 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2587 tool-bar-map)))
2588 (if gnus-summary-tool-bar-map
2589 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2590
2591 (defun gnus-score-set-default (var value)
2592 "A version of set that updates the GNU Emacs menu-bar."
2593 (set var value)
2594 ;; It is the message that forces the active status to be updated.
2595 (message ""))
2596
2597 (defun gnus-make-score-map (type)
2598 "Make a summary score map of type TYPE."
2599 (if t
2600 nil
2601 (let ((headers '(("author" "from" string)
2602 ("subject" "subject" string)
2603 ("article body" "body" string)
2604 ("article head" "head" string)
2605 ("xref" "xref" string)
2606 ("extra header" "extra" string)
2607 ("lines" "lines" number)
2608 ("followups to author" "followup" string)))
2609 (types '((number ("less than" <)
2610 ("greater than" >)
2611 ("equal" =))
2612 (string ("substring" s)
2613 ("exact string" e)
2614 ("fuzzy string" f)
2615 ("regexp" r))))
2616 (perms '(("temporary" (current-time-string))
2617 ("permanent" nil)
2618 ("immediate" now)))
2619 header)
2620 (list
2621 (apply
2622 'nconc
2623 (list
2624 (if (eq type 'lower)
2625 "Lower score"
2626 "Increase score"))
2627 (let (outh)
2628 (while headers
2629 (setq header (car headers))
2630 (setq outh
2631 (cons
2632 (apply
2633 'nconc
2634 (list (car header))
2635 (let ((ts (cdr (assoc (nth 2 header) types)))
2636 outt)
2637 (while ts
2638 (setq outt
2639 (cons
2640 (apply
2641 'nconc
2642 (list (caar ts))
2643 (let ((ps perms)
2644 outp)
2645 (while ps
2646 (setq outp
2647 (cons
2648 (vector
2649 (caar ps)
2650 (list
2651 'gnus-summary-score-entry
2652 (nth 1 header)
2653 (if (or (string= (nth 1 header)
2654 "head")
2655 (string= (nth 1 header)
2656 "body"))
2657 ""
2658 (list 'gnus-summary-header
2659 (nth 1 header)))
2660 (list 'quote (nth 1 (car ts)))
2661 (list 'gnus-score-delta-default
2662 nil)
2663 (nth 1 (car ps))
2664 t)
2665 t)
2666 outp))
2667 (setq ps (cdr ps)))
2668 (list (nreverse outp))))
2669 outt))
2670 (setq ts (cdr ts)))
2671 (list (nreverse outt))))
2672 outh))
2673 (setq headers (cdr headers)))
2674 (list (nreverse outh))))))))
2675
2676 \f
2677
2678 (defun gnus-summary-mode (&optional group)
2679 "Major mode for reading articles.
2680
2681 All normal editing commands are switched off.
2682 \\<gnus-summary-mode-map>
2683 Each line in this buffer represents one article. To read an
2684 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2685 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2686 respectively.
2687
2688 You can also post articles and send mail from this buffer. To
2689 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2690 of an article, type `\\[gnus-summary-reply]'.
2691
2692 There are approx. one gazillion commands you can execute in this
2693 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2694
2695 The following commands are available:
2696
2697 \\{gnus-summary-mode-map}"
2698 (interactive)
2699 (kill-all-local-variables)
2700 (when (gnus-visual-p 'summary-menu 'menu)
2701 (gnus-summary-make-menu-bar)
2702 (gnus-summary-make-tool-bar))
2703 (gnus-summary-make-local-variables)
2704 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2705 (gnus-summary-make-local-variables))
2706 (gnus-make-thread-indent-array)
2707 (gnus-simplify-mode-line)
2708 (setq major-mode 'gnus-summary-mode)
2709 (setq mode-name "Summary")
2710 (make-local-variable 'minor-mode-alist)
2711 (use-local-map gnus-summary-mode-map)
2712 (buffer-disable-undo)
2713 (setq buffer-read-only t) ;Disable modification
2714 (setq truncate-lines t)
2715 (setq selective-display t)
2716 (setq selective-display-ellipses t) ;Display `...'
2717 (gnus-summary-set-display-table)
2718 (gnus-set-default-directory)
2719 (setq gnus-newsgroup-name group)
2720 (make-local-variable 'gnus-summary-line-format)
2721 (make-local-variable 'gnus-summary-line-format-spec)
2722 (make-local-variable 'gnus-summary-dummy-line-format)
2723 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2724 (make-local-variable 'gnus-summary-mark-positions)
2725 (gnus-make-local-hook 'pre-command-hook)
2726 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2727 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2728 (turn-on-gnus-mailing-list-mode)
2729 (mm-enable-multibyte)
2730 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2731 (gnus-update-summary-mark-positions))
2732
2733 (defun gnus-summary-make-local-variables ()
2734 "Make all the local summary buffer variables."
2735 (let (global)
2736 (dolist (local gnus-summary-local-variables)
2737 (if (consp local)
2738 (progn
2739 (if (eq (cdr local) 'global)
2740 ;; Copy the global value of the variable.
2741 (setq global (symbol-value (car local)))
2742 ;; Use the value from the list.
2743 (setq global (eval (cdr local))))
2744 (set (make-local-variable (car local)) global))
2745 ;; Simple nil-valued local variable.
2746 (set (make-local-variable local) nil)))))
2747
2748 (defun gnus-summary-clear-local-variables ()
2749 (let ((locals gnus-summary-local-variables))
2750 (while locals
2751 (if (consp (car locals))
2752 (and (vectorp (caar locals))
2753 (set (caar locals) nil))
2754 (and (vectorp (car locals))
2755 (set (car locals) nil)))
2756 (setq locals (cdr locals)))))
2757
2758 ;; Summary data functions.
2759
2760 (defmacro gnus-data-number (data)
2761 `(car ,data))
2762
2763 (defmacro gnus-data-set-number (data number)
2764 `(setcar ,data ,number))
2765
2766 (defmacro gnus-data-mark (data)
2767 `(nth 1 ,data))
2768
2769 (defmacro gnus-data-set-mark (data mark)
2770 `(setcar (nthcdr 1 ,data) ,mark))
2771
2772 (defmacro gnus-data-pos (data)
2773 `(nth 2 ,data))
2774
2775 (defmacro gnus-data-set-pos (data pos)
2776 `(setcar (nthcdr 2 ,data) ,pos))
2777
2778 (defmacro gnus-data-header (data)
2779 `(nth 3 ,data))
2780
2781 (defmacro gnus-data-set-header (data header)
2782 `(setf (nth 3 ,data) ,header))
2783
2784 (defmacro gnus-data-level (data)
2785 `(nth 4 ,data))
2786
2787 (defmacro gnus-data-unread-p (data)
2788 `(= (nth 1 ,data) gnus-unread-mark))
2789
2790 (defmacro gnus-data-read-p (data)
2791 `(/= (nth 1 ,data) gnus-unread-mark))
2792
2793 (defmacro gnus-data-pseudo-p (data)
2794 `(consp (nth 3 ,data)))
2795
2796 (defmacro gnus-data-find (number)
2797 `(assq ,number gnus-newsgroup-data))
2798
2799 (defmacro gnus-data-find-list (number &optional data)
2800 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2801 (memq (assq ,number bdata)
2802 bdata)))
2803
2804 (defmacro gnus-data-make (number mark pos header level)
2805 `(list ,number ,mark ,pos ,header ,level))
2806
2807 (defun gnus-data-enter (after-article number mark pos header level offset)
2808 (let ((data (gnus-data-find-list after-article)))
2809 (unless data
2810 (error "No such article: %d" after-article))
2811 (setcdr data (cons (gnus-data-make number mark pos header level)
2812 (cdr data)))
2813 (setq gnus-newsgroup-data-reverse nil)
2814 (gnus-data-update-list (cddr data) offset)))
2815
2816 (defun gnus-data-enter-list (after-article list &optional offset)
2817 (when list
2818 (let ((data (and after-article (gnus-data-find-list after-article)))
2819 (ilist list))
2820 (if (not (or data
2821 after-article))
2822 (let ((odata gnus-newsgroup-data))
2823 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2824 (when offset
2825 (gnus-data-update-list odata offset)))
2826 ;; Find the last element in the list to be spliced into the main
2827 ;; list.
2828 (while (cdr list)
2829 (setq list (cdr list)))
2830 (if (not data)
2831 (progn
2832 (setcdr list gnus-newsgroup-data)
2833 (setq gnus-newsgroup-data ilist)
2834 (when offset
2835 (gnus-data-update-list (cdr list) offset)))
2836 (setcdr list (cdr data))
2837 (setcdr data ilist)
2838 (when offset
2839 (gnus-data-update-list (cdr list) offset))))
2840 (setq gnus-newsgroup-data-reverse nil))))
2841
2842 (defun gnus-data-remove (article &optional offset)
2843 (let ((data gnus-newsgroup-data))
2844 (if (= (gnus-data-number (car data)) article)
2845 (progn
2846 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2847 gnus-newsgroup-data-reverse nil)
2848 (when offset
2849 (gnus-data-update-list gnus-newsgroup-data offset)))
2850 (while (cdr data)
2851 (when (= (gnus-data-number (cadr data)) article)
2852 (setcdr data (cddr data))
2853 (when offset
2854 (gnus-data-update-list (cdr data) offset))
2855 (setq data nil
2856 gnus-newsgroup-data-reverse nil))
2857 (setq data (cdr data))))))
2858
2859 (defmacro gnus-data-list (backward)
2860 `(if ,backward
2861 (or gnus-newsgroup-data-reverse
2862 (setq gnus-newsgroup-data-reverse
2863 (reverse gnus-newsgroup-data)))
2864 gnus-newsgroup-data))
2865
2866 (defun gnus-data-update-list (data offset)
2867 "Add OFFSET to the POS of all data entries in DATA."
2868 (setq gnus-newsgroup-data-reverse nil)
2869 (while data
2870 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2871 (setq data (cdr data))))
2872
2873 (defun gnus-summary-article-pseudo-p (article)
2874 "Say whether this article is a pseudo article or not."
2875 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2876
2877 (defmacro gnus-summary-article-sparse-p (article)
2878 "Say whether this article is a sparse article or not."
2879 `(memq ,article gnus-newsgroup-sparse))
2880
2881 (defmacro gnus-summary-article-ancient-p (article)
2882 "Say whether this article is a sparse article or not."
2883 `(memq ,article gnus-newsgroup-ancient))
2884
2885 (defun gnus-article-parent-p (number)
2886 "Say whether this article is a parent or not."
2887 (let ((data (gnus-data-find-list number)))
2888 (and (cdr data) ; There has to be an article after...
2889 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2890 (gnus-data-level (nth 1 data))))))
2891
2892 (defun gnus-article-children (number)
2893 "Return a list of all children to NUMBER."
2894 (let* ((data (gnus-data-find-list number))
2895 (level (gnus-data-level (car data)))
2896 children)
2897 (setq data (cdr data))
2898 (while (and data
2899 (= (gnus-data-level (car data)) (1+ level)))
2900 (push (gnus-data-number (car data)) children)
2901 (setq data (cdr data)))
2902 children))
2903
2904 (defmacro gnus-summary-skip-intangible ()
2905 "If the current article is intangible, then jump to a different article."
2906 '(let ((to (get-text-property (point) 'gnus-intangible)))
2907 (and to (gnus-summary-goto-subject to))))
2908
2909 (defmacro gnus-summary-article-intangible-p ()
2910 "Say whether this article is intangible or not."
2911 '(get-text-property (point) 'gnus-intangible))
2912
2913 (defun gnus-article-read-p (article)
2914 "Say whether ARTICLE is read or not."
2915 (not (or (memq article gnus-newsgroup-marked)
2916 (memq article gnus-newsgroup-spam-marked)
2917 (memq article gnus-newsgroup-unreads)
2918 (memq article gnus-newsgroup-unselected)
2919 (memq article gnus-newsgroup-dormant))))
2920
2921 ;; Some summary mode macros.
2922
2923 (defmacro gnus-summary-article-number ()
2924 "The article number of the article on the current line.
2925 If there isn't an article number here, then we return the current
2926 article number."
2927 '(progn
2928 (gnus-summary-skip-intangible)
2929 (or (get-text-property (point) 'gnus-number)
2930 (gnus-summary-last-subject))))
2931
2932 (defmacro gnus-summary-article-header (&optional number)
2933 "Return the header of article NUMBER."
2934 `(gnus-data-header (gnus-data-find
2935 ,(or number '(gnus-summary-article-number)))))
2936
2937 (defmacro gnus-summary-thread-level (&optional number)
2938 "Return the level of thread that starts with article NUMBER."
2939 `(if (and (eq gnus-summary-make-false-root 'dummy)
2940 (get-text-property (point) 'gnus-intangible))
2941 0
2942 (gnus-data-level (gnus-data-find
2943 ,(or number '(gnus-summary-article-number))))))
2944
2945 (defmacro gnus-summary-article-mark (&optional number)
2946 "Return the mark of article NUMBER."
2947 `(gnus-data-mark (gnus-data-find
2948 ,(or number '(gnus-summary-article-number)))))
2949
2950 (defmacro gnus-summary-article-pos (&optional number)
2951 "Return the position of the line of article NUMBER."
2952 `(gnus-data-pos (gnus-data-find
2953 ,(or number '(gnus-summary-article-number)))))
2954
2955 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2956 (defmacro gnus-summary-article-subject (&optional number)
2957 "Return current subject string or nil if nothing."
2958 `(let ((headers
2959 ,(if number
2960 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2961 '(gnus-data-header (assq (gnus-summary-article-number)
2962 gnus-newsgroup-data)))))
2963 (and headers
2964 (vectorp headers)
2965 (mail-header-subject headers))))
2966
2967 (defmacro gnus-summary-article-score (&optional number)
2968 "Return current article score."
2969 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2970 gnus-newsgroup-scored))
2971 gnus-summary-default-score 0))
2972
2973 (defun gnus-summary-article-children (&optional number)
2974 "Return a list of article numbers that are children of article NUMBER."
2975 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2976 (level (gnus-data-level (car data)))
2977 l children)
2978 (while (and (setq data (cdr data))
2979 (> (setq l (gnus-data-level (car data))) level))
2980 (and (= (1+ level) l)
2981 (push (gnus-data-number (car data))
2982 children)))
2983 (nreverse children)))
2984
2985 (defun gnus-summary-article-parent (&optional number)
2986 "Return the article number of the parent of article NUMBER."
2987 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2988 (gnus-data-list t)))
2989 (level (gnus-data-level (car data))))
2990 (if (zerop level)
2991 () ; This is a root.
2992 ;; We search until we find an article with a level less than
2993 ;; this one. That function has to be the parent.
2994 (while (and (setq data (cdr data))
2995 (not (< (gnus-data-level (car data)) level))))
2996 (and data (gnus-data-number (car data))))))
2997
2998 (defun gnus-unread-mark-p (mark)
2999 "Say whether MARK is the unread mark."
3000 (= mark gnus-unread-mark))
3001
3002 (defun gnus-read-mark-p (mark)
3003 "Say whether MARK is one of the marks that mark as read.
3004 This is all marks except unread, ticked, dormant, and expirable."
3005 (not (or (= mark gnus-unread-mark)
3006 (= mark gnus-ticked-mark)
3007 (= mark gnus-spam-mark)
3008 (= mark gnus-dormant-mark)
3009 (= mark gnus-expirable-mark))))
3010
3011 (defmacro gnus-article-mark (number)
3012 "Return the MARK of article NUMBER.
3013 This macro should only be used when computing the mark the \"first\"
3014 time; i.e., when generating the summary lines. After that,
3015 `gnus-summary-article-mark' should be used to examine the
3016 marks of articles."
3017 `(cond
3018 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3019 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3020 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3021 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3022 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3023 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3024 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3025 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3026 gnus-ancient-mark))))
3027
3028 ;; Saving hidden threads.
3029
3030 (defmacro gnus-save-hidden-threads (&rest forms)
3031 "Save hidden threads, eval FORMS, and restore the hidden threads."
3032 (let ((config (make-symbol "config")))
3033 `(let ((,config (gnus-hidden-threads-configuration)))
3034 (unwind-protect
3035 (save-excursion
3036 ,@forms)
3037 (gnus-restore-hidden-threads-configuration ,config)))))
3038 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3039 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3040
3041 (defun gnus-data-compute-positions ()
3042 "Compute the positions of all articles."
3043 (setq gnus-newsgroup-data-reverse nil)
3044 (let ((data gnus-newsgroup-data))
3045 (save-excursion
3046 (gnus-save-hidden-threads
3047 (gnus-summary-show-all-threads)
3048 (goto-char (point-min))
3049 (while data
3050 (while (get-text-property (point) 'gnus-intangible)
3051 (forward-line 1))
3052 (gnus-data-set-pos (car data) (+ (point) 3))
3053 (setq data (cdr data))
3054 (forward-line 1))))))
3055
3056 (defun gnus-hidden-threads-configuration ()
3057 "Return the current hidden threads configuration."
3058 (save-excursion
3059 (let (config)
3060 (goto-char (point-min))
3061 (while (search-forward "\r" nil t)
3062 (push (1- (point)) config))
3063 config)))
3064
3065 (defun gnus-restore-hidden-threads-configuration (config)
3066 "Restore hidden threads configuration from CONFIG."
3067 (save-excursion
3068 (let (point buffer-read-only)
3069 (while (setq point (pop config))
3070 (when (and (< point (point-max))
3071 (goto-char point)
3072 (eq (char-after) ?\n))
3073 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3074
3075 ;; Various summary mode internalish functions.
3076
3077 (defun gnus-mouse-pick-article (e)
3078 (interactive "e")
3079 (mouse-set-point e)
3080 (gnus-summary-next-page nil t))
3081
3082 (defun gnus-summary-set-display-table ()
3083 "Change the display table.
3084 Odd characters have a tendency to mess
3085 up nicely formatted displays - we make all possible glyphs
3086 display only a single character."
3087
3088 ;; We start from the standard display table, if any.
3089 (let ((table (or (copy-sequence standard-display-table)
3090 (make-display-table)))
3091 (i 32))
3092 ;; Nix out all the control chars...
3093 (while (>= (setq i (1- i)) 0)
3094 (aset table i [??]))
3095 ;; ... but not newline and cr, of course. (cr is necessary for the
3096 ;; selective display).
3097 (aset table ?\n nil)
3098 (aset table ?\r nil)
3099 ;; We keep TAB as well.
3100 (aset table ?\t nil)
3101 ;; We nix out any glyphs over 126 that are not set already.
3102 (let ((i 256))
3103 (while (>= (setq i (1- i)) 127)
3104 ;; Only modify if the entry is nil.
3105 (unless (aref table i)
3106 (aset table i [??]))))
3107 (setq buffer-display-table table)))
3108
3109 (defun gnus-summary-set-article-display-arrow (pos)
3110 "Update the overlay arrow to point to line at position POS."
3111 (when (and gnus-summary-display-arrow
3112 (boundp 'overlay-arrow-position)
3113 (boundp 'overlay-arrow-string))
3114 (save-excursion
3115 (goto-char pos)
3116 (beginning-of-line)
3117 (unless overlay-arrow-position
3118 (setq overlay-arrow-position (make-marker)))
3119 (setq overlay-arrow-string "=>"
3120 overlay-arrow-position (set-marker overlay-arrow-position
3121 (point)
3122 (current-buffer))))))
3123
3124 (defun gnus-summary-setup-buffer (group)
3125 "Initialize summary buffer."
3126 (let ((buffer (gnus-summary-buffer-name group))
3127 (dead-name (concat "*Dead Summary "
3128 (gnus-group-decoded-name group) "*")))
3129 ;; If a dead summary buffer exists, we kill it.
3130 (when (gnus-buffer-live-p dead-name)
3131 (gnus-kill-buffer dead-name))
3132 (if (get-buffer buffer)
3133 (progn
3134 (set-buffer buffer)
3135 (setq gnus-summary-buffer (current-buffer))
3136 (not gnus-newsgroup-prepared))
3137 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3138 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3139 (gnus-summary-mode group)
3140 (when gnus-carpal
3141 (gnus-carpal-setup-buffer 'summary))
3142 (unless gnus-single-article-buffer
3143 (make-local-variable 'gnus-article-buffer)
3144 (make-local-variable 'gnus-article-current)
3145 (make-local-variable 'gnus-original-article-buffer))
3146 (setq gnus-newsgroup-name group)
3147 ;; Set any local variables in the group parameters.
3148 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3149 t)))
3150
3151 (defun gnus-set-global-variables ()
3152 "Set the global equivalents of the buffer-local variables.
3153 They are set to the latest values they had. These reflect the summary
3154 buffer that was in action when the last article was fetched."
3155 (when (eq major-mode 'gnus-summary-mode)
3156 (setq gnus-summary-buffer (current-buffer))
3157 (let ((name gnus-newsgroup-name)
3158 (marked gnus-newsgroup-marked)
3159 (spam gnus-newsgroup-spam-marked)
3160 (unread gnus-newsgroup-unreads)
3161 (headers gnus-current-headers)
3162 (data gnus-newsgroup-data)
3163 (summary gnus-summary-buffer)
3164 (article-buffer gnus-article-buffer)
3165 (original gnus-original-article-buffer)
3166 (gac gnus-article-current)
3167 (reffed gnus-reffed-article-number)
3168 (score-file gnus-current-score-file)
3169 (default-charset gnus-newsgroup-charset)
3170 vlist)
3171 (let ((locals gnus-newsgroup-variables))
3172 (while locals
3173 (if (consp (car locals))
3174 (push (eval (caar locals)) vlist)
3175 (push (eval (car locals)) vlist))
3176 (setq locals (cdr locals)))
3177 (setq vlist (nreverse vlist)))
3178 (save-excursion
3179 (set-buffer gnus-group-buffer)
3180 (setq gnus-newsgroup-name name
3181 gnus-newsgroup-marked marked
3182 gnus-newsgroup-spam-marked spam
3183 gnus-newsgroup-unreads unread
3184 gnus-current-headers headers
3185 gnus-newsgroup-data data
3186 gnus-article-current gac
3187 gnus-summary-buffer summary
3188 gnus-article-buffer article-buffer
3189 gnus-original-article-buffer original
3190 gnus-reffed-article-number reffed
3191 gnus-current-score-file score-file
3192 gnus-newsgroup-charset default-charset)
3193 (let ((locals gnus-newsgroup-variables))
3194 (while locals
3195 (if (consp (car locals))
3196 (set (caar locals) (pop vlist))
3197 (set (car locals) (pop vlist)))
3198 (setq locals (cdr locals))))
3199 ;; The article buffer also has local variables.
3200 (when (gnus-buffer-live-p gnus-article-buffer)
3201 (set-buffer gnus-article-buffer)
3202 (setq gnus-summary-buffer summary))))))
3203
3204 (defun gnus-summary-article-unread-p (article)
3205 "Say whether ARTICLE is unread or not."
3206 (memq article gnus-newsgroup-unreads))
3207
3208 (defun gnus-summary-first-article-p (&optional article)
3209 "Return whether ARTICLE is the first article in the buffer."
3210 (if (not (setq article (or article (gnus-summary-article-number))))
3211 nil
3212 (eq article (caar gnus-newsgroup-data))))
3213
3214 (defun gnus-summary-last-article-p (&optional article)
3215 "Return whether ARTICLE is the last article in the buffer."
3216 (if (not (setq article (or article (gnus-summary-article-number))))
3217 ;; All non-existent numbers are the last article. :-)
3218 t
3219 (not (cdr (gnus-data-find-list article)))))
3220
3221 (defun gnus-make-thread-indent-array ()
3222 (let ((n 200))
3223 (unless (and gnus-thread-indent-array
3224 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3225 (setq gnus-thread-indent-array (make-vector 201 "")
3226 gnus-thread-indent-array-level gnus-thread-indent-level)
3227 (while (>= n 0)
3228 (aset gnus-thread-indent-array n
3229 (make-string (* n gnus-thread-indent-level) ? ))
3230 (setq n (1- n))))))
3231
3232 (defun gnus-update-summary-mark-positions ()
3233 "Compute where the summary marks are to go."
3234 (save-excursion
3235 (when (gnus-buffer-exists-p gnus-summary-buffer)
3236 (set-buffer gnus-summary-buffer))
3237 (let ((spec gnus-summary-line-format-spec)
3238 pos)
3239 (save-excursion
3240 (gnus-set-work-buffer)
3241 (let ((gnus-tmp-unread ?Z)
3242 (gnus-replied-mark ?Z)
3243 (gnus-score-below-mark ?Z)
3244 (gnus-score-over-mark ?Z)
3245 (gnus-undownloaded-mark ?Z)
3246 (gnus-summary-line-format-spec spec)
3247 (gnus-newsgroup-downloadable '(0))
3248 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3249 case-fold-search ignores)
3250 ;; Here, all marks are bound to Z.
3251 (gnus-summary-insert-line header
3252 0 nil t gnus-tmp-unread t nil "" nil 1)
3253 (goto-char (point-min))
3254 ;; Memorize the positions of the same characters as dummy marks.
3255 (while (re-search-forward "[A-D]" nil t)
3256 (push (point) ignores))
3257 (erase-buffer)
3258 ;; We use A-D as dummy marks in order to know column positions
3259 ;; where marks should be inserted.
3260 (setq gnus-tmp-unread ?A
3261 gnus-replied-mark ?B
3262 gnus-score-below-mark ?C
3263 gnus-score-over-mark ?C
3264 gnus-undownloaded-mark ?D)
3265 (gnus-summary-insert-line header
3266 0 nil t gnus-tmp-unread t nil "" nil 1)
3267 ;; Ignore characters which aren't dummy marks.
3268 (dolist (p ignores)
3269 (delete-region (goto-char (1- p)) p)
3270 (insert ?Z))
3271 (goto-char (point-min))
3272 (setq pos (list (cons 'unread
3273 (and (search-forward "A" nil t)
3274 (- (point) (point-min) 1)))))
3275 (goto-char (point-min))
3276 (push (cons 'replied (and (search-forward "B" nil t)
3277 (- (point) (point-min) 1)))
3278 pos)
3279 (goto-char (point-min))
3280 (push (cons 'score (and (search-forward "C" nil t)
3281 (- (point) (point-min) 1)))
3282 pos)
3283 (goto-char (point-min))
3284 (push (cons 'download (and (search-forward "D" nil t)
3285 (- (point) (point-min) 1)))
3286 pos)))
3287 (setq gnus-summary-mark-positions pos))))
3288
3289 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3290 "Insert a dummy root in the summary buffer."
3291 (beginning-of-line)
3292 (gnus-add-text-properties
3293 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3294 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3295
3296 (defun gnus-summary-extract-address-component (from)
3297 (or (car (funcall gnus-extract-address-components from))
3298 from))
3299
3300 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3301 (let ((mail-parse-charset gnus-newsgroup-charset)
3302 ; Is it really necessary to do this next part for each summary line?
3303 ; Luckily, doesn't seem to slow things down much.
3304 (mail-parse-ignored-charsets
3305 (save-excursion (set-buffer gnus-summary-buffer)
3306 gnus-newsgroup-ignored-charsets)))
3307 (or
3308 (and gnus-ignored-from-addresses
3309 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3310 (let ((extra-headers (mail-header-extra header))
3311 to
3312 newsgroups)
3313 (cond
3314 ((setq to (cdr (assq 'To extra-headers)))
3315 (concat "-> "
3316 (inline
3317 (gnus-summary-extract-address-component
3318 (funcall gnus-decode-encoded-word-function to)))))
3319 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3320 (concat "=> " newsgroups)))))
3321 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3322
3323 (defun gnus-summary-insert-line (gnus-tmp-header
3324 gnus-tmp-level gnus-tmp-current
3325 undownloaded gnus-tmp-unread gnus-tmp-replied
3326 gnus-tmp-expirable gnus-tmp-subject-or-nil
3327 &optional gnus-tmp-dummy gnus-tmp-score
3328 gnus-tmp-process)
3329 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3330 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3331 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3332 (gnus-tmp-score-char
3333 (if (or (null gnus-summary-default-score)
3334 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3335 gnus-summary-zcore-fuzz))
3336 ? ;Whitespace
3337 (if (< gnus-tmp-score gnus-summary-default-score)
3338 gnus-score-below-mark gnus-score-over-mark)))
3339 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3340 (gnus-tmp-replied
3341 (cond (gnus-tmp-process gnus-process-mark)
3342 ((memq gnus-tmp-current gnus-newsgroup-cached)
3343 gnus-cached-mark)
3344 (gnus-tmp-replied gnus-replied-mark)
3345 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3346 gnus-forwarded-mark)
3347 ((memq gnus-tmp-current gnus-newsgroup-saved)
3348 gnus-saved-mark)
3349 ((memq gnus-tmp-number gnus-newsgroup-recent)
3350 gnus-recent-mark)
3351 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3352 gnus-unseen-mark)
3353 (t gnus-no-mark)))
3354 (gnus-tmp-downloaded
3355 (cond (undownloaded
3356 gnus-undownloaded-mark)
3357 (gnus-newsgroup-agentized
3358 gnus-downloaded-mark)
3359 (t
3360 gnus-no-mark)))
3361 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3362 (gnus-tmp-name
3363 (cond
3364 ((string-match "<[^>]+> *$" gnus-tmp-from)
3365 (let ((beg (match-beginning 0)))
3366 (or (and (string-match "^\".+\"" gnus-tmp-from)
3367 (substring gnus-tmp-from 1 (1- (match-end 0))))
3368 (substring gnus-tmp-from 0 beg))))
3369 ((string-match "(.+)" gnus-tmp-from)
3370 (substring gnus-tmp-from
3371 (1+ (match-beginning 0)) (1- (match-end 0))))
3372 (t gnus-tmp-from)))
3373 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3374 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3375 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3376 (buffer-read-only nil))
3377 (when (string= gnus-tmp-name "")
3378 (setq gnus-tmp-name gnus-tmp-from))
3379 (unless (numberp gnus-tmp-lines)
3380 (setq gnus-tmp-lines -1))
3381 (if (= gnus-tmp-lines -1)
3382 (setq gnus-tmp-lines "?")
3383 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3384 (gnus-put-text-property
3385 (point)
3386 (progn (eval gnus-summary-line-format-spec) (point))
3387 'gnus-number gnus-tmp-number)
3388 (when (gnus-visual-p 'summary-highlight 'highlight)
3389 (forward-line -1)
3390 (gnus-run-hooks 'gnus-summary-update-hook)
3391 (forward-line 1))))
3392
3393 (defun gnus-summary-update-line (&optional dont-update)
3394 "Update summary line after change."
3395 (when (and gnus-summary-default-score
3396 (not gnus-summary-inhibit-highlight))
3397 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3398 (article (gnus-summary-article-number))
3399 (score (gnus-summary-article-score article)))
3400 (unless dont-update
3401 (if (and gnus-summary-mark-below
3402 (< (gnus-summary-article-score)
3403 gnus-summary-mark-below))
3404 ;; This article has a low score, so we mark it as read.
3405 (when (memq article gnus-newsgroup-unreads)
3406 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3407 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3408 ;; This article was previously marked as read on account
3409 ;; of a low score, but now it has risen, so we mark it as
3410 ;; unread.
3411 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3412 (gnus-summary-update-mark
3413 (if (or (null gnus-summary-default-score)
3414 (<= (abs (- score gnus-summary-default-score))
3415 gnus-summary-zcore-fuzz))
3416 ? ;Whitespace
3417 (if (< score gnus-summary-default-score)
3418 gnus-score-below-mark gnus-score-over-mark))
3419 'score))
3420 ;; Do visual highlighting.
3421 (when (gnus-visual-p 'summary-highlight 'highlight)
3422 (gnus-run-hooks 'gnus-summary-update-hook)))))
3423
3424 (defvar gnus-tmp-new-adopts nil)
3425
3426 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3427 "Return the number of articles in THREAD.
3428 This may be 0 in some cases -- if none of the articles in
3429 the thread are to be displayed."
3430 (let* ((number
3431 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3432 (cond
3433 ((not (listp thread))
3434 1)
3435 ((and (consp thread) (cdr thread))
3436 (apply
3437 '+ 1 (mapcar
3438 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3439 ((null thread)
3440 1)
3441 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3442 1)
3443 (t 0))))
3444 (when (and level (zerop level) gnus-tmp-new-adopts)
3445 (incf number
3446 (apply '+ (mapcar
3447 'gnus-summary-number-of-articles-in-thread
3448 gnus-tmp-new-adopts))))
3449 (if char
3450 (if (> number 1) gnus-not-empty-thread-mark
3451 gnus-empty-thread-mark)
3452 number)))
3453
3454 (defsubst gnus-summary-line-message-size (head)
3455 "Return pretty-printed version of message size.
3456 This function is intended to be used in
3457 `gnus-summary-line-format-alist'."
3458 (let ((c (or (mail-header-chars head) -1)))
3459 (cond ((< c 0) "n/a") ; chars not available
3460 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3461 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3462 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3463 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3464
3465
3466 (defun gnus-summary-set-local-parameters (group)
3467 "Go through the local params of GROUP and set all variable specs in that list."
3468 (let ((params (gnus-group-find-parameter group))
3469 (vars '(quit-config)) ; Ignore quit-config.
3470 elem)
3471 (while params
3472 (setq elem (car params)
3473 params (cdr params))
3474 (and (consp elem) ; Has to be a cons.
3475 (consp (cdr elem)) ; The cdr has to be a list.
3476 (symbolp (car elem)) ; Has to be a symbol in there.
3477 (not (memq (car elem) vars))
3478 (ignore-errors ; So we set it.
3479 (push (car elem) vars)
3480 (make-local-variable (car elem))
3481 (set (car elem) (eval (nth 1 elem))))))))
3482
3483 (defun gnus-summary-read-group (group &optional show-all no-article
3484 kill-buffer no-display backward
3485 select-articles)
3486 "Start reading news in newsgroup GROUP.
3487 If SHOW-ALL is non-nil, already read articles are also listed.
3488 If NO-ARTICLE is non-nil, no article is selected initially.
3489 If NO-DISPLAY, don't generate a summary buffer."
3490 (let (result)
3491 (while (and group
3492 (null (setq result
3493 (let ((gnus-auto-select-next nil))
3494 (or (gnus-summary-read-group-1
3495 group show-all no-article
3496 kill-buffer no-display
3497 select-articles)
3498 (setq show-all nil
3499 select-articles nil)))))
3500 (eq gnus-auto-select-next 'quietly))
3501 (set-buffer gnus-group-buffer)
3502 ;; The entry function called above goes to the next
3503 ;; group automatically, so we go two groups back
3504 ;; if we are searching for the previous group.
3505 (when backward
3506 (gnus-group-prev-unread-group 2))
3507 (if (not (equal group (gnus-group-group-name)))
3508 (setq group (gnus-group-group-name))
3509 (setq group nil)))
3510 result))
3511
3512 (defun gnus-summary-read-group-1 (group show-all no-article
3513 kill-buffer no-display
3514 &optional select-articles)
3515 ;; Killed foreign groups can't be entered.
3516 ;; (when (and (not (gnus-group-native-p group))
3517 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3518 ;; (error "Dead non-native groups can't be entered"))
3519 (gnus-message 5 "Retrieving newsgroup: %s..."
3520 (gnus-group-decoded-name group))
3521 (let* ((new-group (gnus-summary-setup-buffer group))
3522 (quit-config (gnus-group-quit-config group))
3523 (did-select (and new-group (gnus-select-newsgroup
3524 group show-all select-articles))))
3525 (cond
3526 ;; This summary buffer exists already, so we just select it.
3527 ((not new-group)
3528 (gnus-set-global-variables)
3529 (when kill-buffer
3530 (gnus-kill-or-deaden-summary kill-buffer))
3531 (gnus-configure-windows 'summary 'force)
3532 (gnus-set-mode-line 'summary)
3533 (gnus-summary-position-point)
3534 (message "")
3535 t)
3536 ;; We couldn't select this group.
3537 ((null did-select)
3538 (when (and (eq major-mode 'gnus-summary-mode)
3539 (not (equal (current-buffer) kill-buffer)))
3540 (kill-buffer (current-buffer))
3541 (if (not quit-config)
3542 (progn
3543 ;; Update the info -- marks might need to be removed,
3544 ;; for instance.
3545 (gnus-summary-update-info)
3546 (set-buffer gnus-group-buffer)
3547 (gnus-group-jump-to-group group)
3548 (gnus-group-next-unread-group 1))
3549 (gnus-handle-ephemeral-exit quit-config)))
3550 (let ((grpinfo (gnus-get-info group)))
3551 (if (null (gnus-info-read grpinfo))
3552 (gnus-message 3 "Group %s contains no messages"
3553 (gnus-group-decoded-name group))
3554 (gnus-message 3 "Can't select group")))
3555 nil)
3556 ;; The user did a `C-g' while prompting for number of articles,
3557 ;; so we exit this group.
3558 ((eq did-select 'quit)
3559 (and (eq major-mode 'gnus-summary-mode)
3560 (not (equal (current-buffer) kill-buffer))
3561 (kill-buffer (current-buffer)))
3562 (when kill-buffer
3563 (gnus-kill-or-deaden-summary kill-buffer))
3564 (if (not quit-config)
3565 (progn
3566 (set-buffer gnus-group-buffer)
3567 (gnus-group-jump-to-group group)
3568 (gnus-group-next-unread-group 1)
3569 (gnus-configure-windows 'group 'force))
3570 (gnus-handle-ephemeral-exit quit-config))
3571 ;; Finally signal the quit.
3572 (signal 'quit nil))
3573 ;; The group was successfully selected.
3574 (t
3575 (gnus-set-global-variables)
3576 ;; Save the active value in effect when the group was entered.
3577 (setq gnus-newsgroup-active
3578 (gnus-copy-sequence
3579 (gnus-active gnus-newsgroup-name)))
3580 ;; You can change the summary buffer in some way with this hook.
3581 (gnus-run-hooks 'gnus-select-group-hook)
3582 (when (memq 'summary (gnus-update-format-specifications
3583 nil 'summary 'summary-mode 'summary-dummy))
3584 ;; The format specification for the summary line was updated,
3585 ;; so we need to update the mark positions as well.
3586 (gnus-update-summary-mark-positions))
3587 ;; Do score processing.
3588 (when gnus-use-scoring
3589 (gnus-possibly-score-headers))
3590 ;; Check whether to fill in the gaps in the threads.
3591 (when gnus-build-sparse-threads
3592 (gnus-build-sparse-threads))
3593 ;; Find the initial limit.
3594 (if gnus-show-threads
3595 (if show-all
3596 (let ((gnus-newsgroup-dormant nil))
3597 (gnus-summary-initial-limit show-all))
3598 (gnus-summary-initial-limit show-all))
3599 ;; When unthreaded, all articles are always shown.
3600 (setq gnus-newsgroup-limit
3601 (mapcar
3602 (lambda (header) (mail-header-number header))
3603 gnus-newsgroup-headers)))
3604 ;; Generate the summary buffer.
3605 (unless no-display
3606 (gnus-summary-prepare))
3607 (when gnus-use-trees
3608 (gnus-tree-open group)
3609 (setq gnus-summary-highlight-line-function
3610 'gnus-tree-highlight-article))
3611 ;; If the summary buffer is empty, but there are some low-scored
3612 ;; articles or some excluded dormants, we include these in the
3613 ;; buffer.
3614 (when (and (zerop (buffer-size))
3615 (not no-display))
3616 (cond (gnus-newsgroup-dormant
3617 (gnus-summary-limit-include-dormant))
3618 ((and gnus-newsgroup-scored show-all)
3619 (gnus-summary-limit-include-expunged t))))
3620 ;; Function `gnus-apply-kill-file' must be called in this hook.
3621 (gnus-run-hooks 'gnus-apply-kill-hook)
3622 (if (and (zerop (buffer-size))
3623 (not no-display))
3624 (progn
3625 ;; This newsgroup is empty.
3626 (gnus-summary-catchup-and-exit nil t)
3627 (gnus-message 6 "No unread news")
3628 (when kill-buffer
3629 (gnus-kill-or-deaden-summary kill-buffer))
3630 ;; Return nil from this function.
3631 nil)
3632 ;; Hide conversation thread subtrees. We cannot do this in
3633 ;; gnus-summary-prepare-hook since kill processing may not
3634 ;; work with hidden articles.
3635 (gnus-summary-maybe-hide-threads)
3636 (when kill-buffer
3637 (gnus-kill-or-deaden-summary kill-buffer))
3638 (gnus-summary-auto-select-subject)
3639 ;; Show first unread article if requested.
3640 (if (and (not no-article)
3641 (not no-display)
3642 gnus-newsgroup-unreads
3643 gnus-auto-select-first)
3644 (progn
3645 (gnus-configure-windows 'summary)
3646 (let ((art (gnus-summary-article-number)))
3647 (unless (and (not gnus-plugged)
3648 (or (memq art gnus-newsgroup-undownloaded)
3649 (memq art gnus-newsgroup-downloadable)))
3650 (gnus-summary-goto-article art))))
3651 ;; Don't select any articles.
3652 (gnus-summary-position-point)
3653 (gnus-configure-windows 'summary 'force)
3654 (gnus-set-mode-line 'summary))
3655 (when (and gnus-auto-center-group
3656 (get-buffer-window gnus-group-buffer t))
3657 ;; Gotta use windows, because recenter does weird stuff if
3658 ;; the current buffer ain't the displayed window.
3659 (let ((owin (selected-window)))
3660 (select-window (get-buffer-window gnus-group-buffer t))
3661 (when (gnus-group-goto-group group)
3662 (recenter))
3663 (select-window owin)))
3664 ;; Mark this buffer as "prepared".
3665 (setq gnus-newsgroup-prepared t)
3666 (gnus-run-hooks 'gnus-summary-prepared-hook)
3667 (unless (gnus-ephemeral-group-p group)
3668 (gnus-group-update-group group))
3669 t)))))
3670
3671 (defun gnus-summary-auto-select-subject ()
3672 "Select the subject line on initial group entry."
3673 (goto-char (point-min))
3674 (cond
3675 ((eq gnus-auto-select-subject 'best)
3676 (gnus-summary-best-unread-subject))
3677 ((eq gnus-auto-select-subject 'unread)
3678 (gnus-summary-first-unread-subject))
3679 ((eq gnus-auto-select-subject 'unseen)
3680 (gnus-summary-first-unseen-subject))
3681 ((eq gnus-auto-select-subject 'unseen-or-unread)
3682 (gnus-summary-first-unseen-or-unread-subject))
3683 ((eq gnus-auto-select-subject 'first)
3684 ;; Do nothing.
3685 )
3686 ((functionp gnus-auto-select-subject)
3687 (funcall gnus-auto-select-subject))))
3688
3689 (defun gnus-summary-prepare ()
3690 "Generate the summary buffer."
3691 (interactive)
3692 (let ((buffer-read-only nil))
3693 (erase-buffer)
3694 (setq gnus-newsgroup-data nil
3695 gnus-newsgroup-data-reverse nil)
3696 (gnus-run-hooks 'gnus-summary-generate-hook)
3697 ;; Generate the buffer, either with threads or without.
3698 (when gnus-newsgroup-headers
3699 (gnus-summary-prepare-threads
3700 (if gnus-show-threads
3701 (gnus-sort-gathered-threads
3702 (funcall gnus-summary-thread-gathering-function
3703 (gnus-sort-threads
3704 (gnus-cut-threads (gnus-make-threads)))))
3705 ;; Unthreaded display.
3706 (gnus-sort-articles gnus-newsgroup-headers))))
3707 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3708 ;; Call hooks for modifying summary buffer.
3709 (goto-char (point-min))
3710 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3711
3712 (defsubst gnus-general-simplify-subject (subject)
3713 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3714 (setq subject
3715 (cond
3716 ;; Truncate the subject.
3717 (gnus-simplify-subject-functions
3718 (gnus-map-function gnus-simplify-subject-functions subject))
3719 ((numberp gnus-summary-gather-subject-limit)
3720 (setq subject (gnus-simplify-subject-re subject))
3721 (if (> (length subject) gnus-summary-gather-subject-limit)
3722 (substring subject 0 gnus-summary-gather-subject-limit)
3723 subject))
3724 ;; Fuzzily simplify it.
3725 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3726 (gnus-simplify-subject-fuzzy subject))
3727 ;; Just remove the leading "Re:".
3728 (t
3729 (gnus-simplify-subject-re subject))))
3730
3731 (if (and gnus-summary-gather-exclude-subject
3732 (string-match gnus-summary-gather-exclude-subject subject))
3733 nil ; This article shouldn't be gathered
3734 subject))
3735
3736 (defun gnus-summary-simplify-subject-query ()
3737 "Query where the respool algorithm would put this article."
3738 (interactive)
3739 (gnus-summary-select-article)
3740 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3741
3742 (defun gnus-gather-threads-by-subject (threads)
3743 "Gather threads by looking at Subject headers."
3744 (if (not gnus-summary-make-false-root)
3745 threads
3746 (let ((hashtb (gnus-make-hashtable 1024))
3747 (prev threads)
3748 (result threads)
3749 subject hthread whole-subject)
3750 (while threads
3751 (setq subject (gnus-general-simplify-subject
3752 (setq whole-subject (mail-header-subject
3753 (caar threads)))))
3754 (when subject
3755 (if (setq hthread (gnus-gethash subject hashtb))
3756 (progn
3757 ;; We enter a dummy root into the thread, if we
3758 ;; haven't done that already.
3759 (unless (stringp (caar hthread))
3760 (setcar hthread (list whole-subject (car hthread))))
3761 ;; We add this new gathered thread to this gathered
3762 ;; thread.
3763 (setcdr (car hthread)
3764 (nconc (cdar hthread) (list (car threads))))
3765 ;; Remove it from the list of threads.
3766 (setcdr prev (cdr threads))
3767 (setq threads prev))
3768 ;; Enter this thread into the hash table.
3769 (gnus-sethash subject
3770 (if gnus-summary-make-false-root-always
3771 (progn
3772 ;; If you want a dummy root above all
3773 ;; threads...
3774 (setcar threads (list whole-subject
3775 (car threads)))
3776 threads)
3777 threads)
3778 hashtb)))
3779 (setq prev threads)
3780 (setq threads (cdr threads)))
3781 result)))
3782
3783 (defun gnus-gather-threads-by-references (threads)
3784 "Gather threads by looking at References headers."
3785 (let ((idhashtb (gnus-make-hashtable 1024))
3786 (thhashtb (gnus-make-hashtable 1024))
3787 (prev threads)
3788 (result threads)
3789 ids references id gthread gid entered ref)
3790 (while threads
3791 (when (setq references (mail-header-references (caar threads)))
3792 (setq id (mail-header-id (caar threads))
3793 ids (inline (gnus-split-references references))
3794 entered nil)
3795 (while (setq ref (pop ids))
3796 (setq ids (delete ref ids))
3797 (if (not (setq gid (gnus-gethash ref idhashtb)))
3798 (progn
3799 (gnus-sethash ref id idhashtb)
3800 (gnus-sethash id threads thhashtb))
3801 (setq gthread (gnus-gethash gid thhashtb))
3802 (unless entered
3803 ;; We enter a dummy root into the thread, if we
3804 ;; haven't done that already.
3805 (unless (stringp (caar gthread))
3806 (setcar gthread (list (mail-header-subject (caar gthread))
3807 (car gthread))))
3808 ;; We add this new gathered thread to this gathered
3809 ;; thread.
3810 (setcdr (car gthread)
3811 (nconc (cdar gthread) (list (car threads)))))
3812 ;; Add it into the thread hash table.
3813 (gnus-sethash id gthread thhashtb)
3814 (setq entered t)
3815 ;; Remove it from the list of threads.
3816 (setcdr prev (cdr threads))
3817 (setq threads prev))))
3818 (setq prev threads)
3819 (setq threads (cdr threads)))
3820 result))
3821
3822 (defun gnus-sort-gathered-threads (threads)
3823 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3824 (let ((result threads))
3825 (while threads
3826 (when (stringp (caar threads))
3827 (setcdr (car threads)
3828 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3829 (setq threads (cdr threads)))
3830 result))
3831
3832 (defun gnus-thread-loop-p (root thread)
3833 "Say whether ROOT is in THREAD."
3834 (let ((stack (list thread))
3835 (infloop 0)
3836 th)
3837 (while (setq thread (pop stack))
3838 (setq th (cdr thread))
3839 (while (and th
3840 (not (eq (caar th) root)))
3841 (pop th))
3842 (if th
3843 ;; We have found a loop.
3844 (let (ref-dep)
3845 (setcdr thread (delq (car th) (cdr thread)))
3846 (if (boundp (setq ref-dep (intern "none"
3847 gnus-newsgroup-dependencies)))
3848 (setcdr (symbol-value ref-dep)
3849 (nconc (cdr (symbol-value ref-dep))
3850 (list (car th))))
3851 (set ref-dep (list nil (car th))))
3852 (setq infloop 1
3853 stack nil))
3854 ;; Push all the subthreads onto the stack.
3855 (push (cdr thread) stack)))
3856 infloop))
3857
3858 (defun gnus-make-threads ()
3859 "Go through the dependency hashtb and find the roots. Return all threads."
3860 (let (threads)
3861 (while (catch 'infloop
3862 (mapatoms
3863 (lambda (refs)
3864 ;; Deal with self-referencing References loops.
3865 (when (and (car (symbol-value refs))
3866 (not (zerop
3867 (apply
3868 '+
3869 (mapcar
3870 (lambda (thread)
3871 (gnus-thread-loop-p
3872 (car (symbol-value refs)) thread))
3873 (cdr (symbol-value refs)))))))
3874 (setq threads nil)
3875 (throw 'infloop t))
3876 (unless (car (symbol-value refs))
3877 ;; These threads do not refer back to any other
3878 ;; articles, so they're roots.
3879 (setq threads (append (cdr (symbol-value refs)) threads))))
3880 gnus-newsgroup-dependencies)))
3881 threads))
3882
3883 ;; Build the thread tree.
3884 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3885 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3886
3887 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3888 if it was already present.
3889
3890 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3891 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3892 Message-IDs will be renamed to a unique Message-ID before being
3893 entered.
3894
3895 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3896 (let* ((id (mail-header-id header))
3897 (id-dep (and id (intern id dependencies)))
3898 parent-id ref ref-dep ref-header replaced)
3899 ;; Enter this `header' in the `dependencies' table.
3900 (cond
3901 ((not id-dep)
3902 (setq header nil))
3903 ;; The first two cases do the normal part: enter a new `header'
3904 ;; in the `dependencies' table.
3905 ((not (boundp id-dep))
3906 (set id-dep (list header)))
3907 ((null (car (symbol-value id-dep)))
3908 (setcar (symbol-value id-dep) header))
3909
3910 ;; From here the `header' was already present in the
3911 ;; `dependencies' table.
3912 (force-new
3913 ;; Overrides an existing entry;
3914 ;; just set the header part of the entry.
3915 (setcar (symbol-value id-dep) header)
3916 (setq replaced t))
3917
3918 ;; Renames the existing `header' to a unique Message-ID.
3919 ((not gnus-summary-ignore-duplicates)
3920 ;; An article with this Message-ID has already been seen.
3921 ;; We rename the Message-ID.
3922 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3923 (list header))
3924 (mail-header-set-id header id))
3925
3926 ;; The last case ignores an existing entry, except it adds any
3927 ;; additional Xrefs (in case the two articles came from different
3928 ;; servers.
3929 ;; Also sets `header' to `nil' meaning that the `dependencies'
3930 ;; table was *not* modified.
3931 (t
3932 (mail-header-set-xref
3933 (car (symbol-value id-dep))
3934 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3935 "")
3936 (or (mail-header-xref header) "")))
3937 (setq header nil)))
3938
3939 (when (and header (not replaced))
3940 ;; First check that we are not creating a References loop.
3941 (setq parent-id (gnus-parent-id (mail-header-references header)))
3942 (setq ref parent-id)
3943 (while (and ref
3944 (setq ref-dep (intern-soft ref dependencies))
3945 (boundp ref-dep)
3946 (setq ref-header (car (symbol-value ref-dep))))
3947 (if (string= id ref)
3948 ;; Yuk! This is a reference loop. Make the article be a
3949 ;; root article.
3950 (progn
3951 (mail-header-set-references (car (symbol-value id-dep)) "none")
3952 (setq ref nil)
3953 (setq parent-id nil))
3954 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3955 (setq ref-dep (intern (or parent-id "none") dependencies))
3956 (if (boundp ref-dep)
3957 (setcdr (symbol-value ref-dep)
3958 (nconc (cdr (symbol-value ref-dep))
3959 (list (symbol-value id-dep))))
3960 (set ref-dep (list nil (symbol-value id-dep)))))
3961 header))
3962
3963 (defun gnus-extract-message-id-from-in-reply-to (string)
3964 (if (string-match "<[^>]+>" string)
3965 (substring string (match-beginning 0) (match-end 0))
3966 nil))
3967
3968 (defun gnus-build-sparse-threads ()
3969 (let ((headers gnus-newsgroup-headers)
3970 (mail-parse-charset gnus-newsgroup-charset)
3971 (gnus-summary-ignore-duplicates t)
3972 header references generation relations
3973 subject child end new-child date)
3974 ;; First we create an alist of generations/relations, where
3975 ;; generations is how much we trust the relation, and the relation
3976 ;; is parent/child.
3977 (gnus-message 7 "Making sparse threads...")
3978 (save-excursion
3979 (nnheader-set-temp-buffer " *gnus sparse threads*")
3980 (while (setq header (pop headers))
3981 (when (and (setq references (mail-header-references header))
3982 (not (string= references "")))
3983 (insert references)
3984 (setq child (mail-header-id header)
3985 subject (mail-header-subject header)
3986 date (mail-header-date header)
3987 generation 0)
3988 (while (search-backward ">" nil t)
3989 (setq end (1+ (point)))
3990 (when (search-backward "<" nil t)
3991 (setq new-child (buffer-substring (point) end))
3992 (push (list (incf generation)
3993 child (setq child new-child)
3994 subject date)
3995 relations)))
3996 (when child
3997 (push (list (1+ generation) child nil subject) relations))
3998 (erase-buffer)))
3999 (kill-buffer (current-buffer)))
4000 ;; Sort over trustworthiness.
4001 (mapcar
4002 (lambda (relation)
4003 (when (gnus-dependencies-add-header
4004 (make-full-mail-header
4005 gnus-reffed-article-number
4006 (nth 3 relation) "" (or (nth 4 relation) "")
4007 (nth 1 relation)
4008 (or (nth 2 relation) "") 0 0 "")
4009 gnus-newsgroup-dependencies nil)
4010 (push gnus-reffed-article-number gnus-newsgroup-limit)
4011 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4012 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4013 gnus-newsgroup-reads)
4014 (decf gnus-reffed-article-number)))
4015 (sort relations 'car-less-than-car))
4016 (gnus-message 7 "Making sparse threads...done")))
4017
4018 (defun gnus-build-old-threads ()
4019 ;; Look at all the articles that refer back to old articles, and
4020 ;; fetch the headers for the articles that aren't there. This will
4021 ;; build complete threads - if the roots haven't been expired by the
4022 ;; server, that is.
4023 (let ((mail-parse-charset gnus-newsgroup-charset)
4024 id heads)
4025 (mapatoms
4026 (lambda (refs)
4027 (when (not (car (symbol-value refs)))
4028 (setq heads (cdr (symbol-value refs)))
4029 (while heads
4030 (if (memq (mail-header-number (caar heads))
4031 gnus-newsgroup-dormant)
4032 (setq heads (cdr heads))
4033 (setq id (symbol-name refs))
4034 (while (and (setq id (gnus-build-get-header id))
4035 (not (car (gnus-id-to-thread id)))))
4036 (setq heads nil)))))
4037 gnus-newsgroup-dependencies)))
4038
4039 (defsubst gnus-remove-odd-characters (string)
4040 "Translate STRING into something that doesn't contain weird characters."
4041 (mm-subst-char-in-string
4042 ?\r ?\-
4043 (mm-subst-char-in-string
4044 ?\n ?\- string)))
4045
4046 ;; This function has to be called with point after the article number
4047 ;; on the beginning of the line.
4048 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4049 (let ((eol (gnus-point-at-eol))
4050 (buffer (current-buffer))
4051 header references in-reply-to)
4052
4053 ;; overview: [num subject from date id refs chars lines misc]
4054 (unwind-protect
4055 (let (x)
4056 (narrow-to-region (point) eol)
4057 (unless (eobp)
4058 (forward-char))
4059
4060 (setq header
4061 (make-full-mail-header
4062 number ; number
4063 (condition-case () ; subject
4064 (gnus-remove-odd-characters
4065 (funcall gnus-decode-encoded-word-function
4066 (setq x (nnheader-nov-field))))
4067 (error x))
4068 (condition-case () ; from
4069 (gnus-remove-odd-characters
4070 (funcall gnus-decode-encoded-word-function
4071 (setq x (nnheader-nov-field))))
4072 (error x))
4073 (nnheader-nov-field) ; date
4074 (nnheader-nov-read-message-id) ; id
4075 (setq references (nnheader-nov-field)) ; refs
4076 (nnheader-nov-read-integer) ; chars
4077 (nnheader-nov-read-integer) ; lines
4078 (unless (eobp)
4079 (if (looking-at "Xref: ")
4080 (goto-char (match-end 0)))
4081 (nnheader-nov-field)) ; Xref
4082 (nnheader-nov-parse-extra)))) ; extra
4083
4084 (widen))
4085
4086 (when (and (string= references "")
4087 (setq in-reply-to (mail-header-extra header))
4088 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4089 (mail-header-set-references
4090 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4091
4092 (when gnus-alter-header-function
4093 (funcall gnus-alter-header-function header))
4094 (gnus-dependencies-add-header header dependencies force-new)))
4095
4096 (defun gnus-build-get-header (id)
4097 "Look through the buffer of NOV lines and find the header to ID.
4098 Enter this line into the dependencies hash table, and return
4099 the id of the parent article (if any)."
4100 (let ((deps gnus-newsgroup-dependencies)
4101 found header)
4102 (prog1
4103 (save-excursion
4104 (set-buffer nntp-server-buffer)
4105 (let ((case-fold-search nil))
4106 (goto-char (point-min))
4107 (while (and (not found)
4108 (search-forward id nil t))
4109 (beginning-of-line)
4110 (setq found (looking-at
4111 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4112 (regexp-quote id))))
4113 (or found (beginning-of-line 2)))
4114 (when found
4115 (beginning-of-line)
4116 (and
4117 (setq header (gnus-nov-parse-line
4118 (read (current-buffer)) deps))
4119 (gnus-parent-id (mail-header-references header))))))
4120 (when header
4121 (let ((number (mail-header-number header)))
4122 (push number gnus-newsgroup-limit)
4123 (push header gnus-newsgroup-headers)
4124 (if (memq number gnus-newsgroup-unselected)
4125 (progn
4126 (setq gnus-newsgroup-unreads
4127 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4128 number))
4129 (setq gnus-newsgroup-unselected
4130 (delq number gnus-newsgroup-unselected)))
4131 (push number gnus-newsgroup-ancient)))))))
4132
4133 (defun gnus-build-all-threads ()
4134 "Read all the headers."
4135 (let ((gnus-summary-ignore-duplicates t)
4136 (mail-parse-charset gnus-newsgroup-charset)
4137 (dependencies gnus-newsgroup-dependencies)
4138 header article)
4139 (save-excursion
4140 (set-buffer nntp-server-buffer)
4141 (let ((case-fold-search nil))
4142 (goto-char (point-min))
4143 (while (not (eobp))
4144 (ignore-errors
4145 (setq article (read (current-buffer))
4146 header (gnus-nov-parse-line article dependencies)))
4147 (when header
4148 (save-excursion
4149 (set-buffer gnus-summary-buffer)
4150 (push header gnus-newsgroup-headers)
4151 (if (memq (setq article (mail-header-number header))
4152 gnus-newsgroup-unselected)
4153 (progn
4154 (setq gnus-newsgroup-unreads
4155 (gnus-add-to-sorted-list
4156 gnus-newsgroup-unreads article))
4157 (setq gnus-newsgroup-unselected
4158 (delq article gnus-newsgroup-unselected)))
4159 (push article gnus-newsgroup-ancient)))
4160 (forward-line 1)))))))
4161
4162 (defun gnus-summary-update-article-line (article header)
4163 "Update the line for ARTICLE using HEADER."
4164 (let* ((id (mail-header-id header))
4165 (thread (gnus-id-to-thread id)))
4166 (unless thread
4167 (error "Article in no thread"))
4168 ;; Update the thread.
4169 (setcar thread header)
4170 (gnus-summary-goto-subject article)
4171 (let* ((datal (gnus-data-find-list article))
4172 (data (car datal))
4173 (buffer-read-only nil)
4174 (level (gnus-summary-thread-level)))
4175 (gnus-delete-line)
4176 (let ((inserted (- (point)
4177 (progn
4178 (gnus-summary-insert-line
4179 header level nil
4180 (memq article gnus-newsgroup-undownloaded)
4181 (gnus-article-mark article)
4182 (memq article gnus-newsgroup-replied)
4183 (memq article gnus-newsgroup-expirable)
4184 ;; Only insert the Subject string when it's different
4185 ;; from the previous Subject string.
4186 (if (and
4187 gnus-show-threads
4188 (gnus-subject-equal
4189 (condition-case ()
4190 (mail-header-subject
4191 (gnus-data-header
4192 (cadr
4193 (gnus-data-find-list
4194 article
4195 (gnus-data-list t)))))
4196 ;; Error on the side of excessive subjects.
4197 (error ""))
4198 (mail-header-subject header)))
4199 ""
4200 (mail-header-subject header))
4201 nil (cdr (assq article gnus-newsgroup-scored))
4202 (memq article gnus-newsgroup-processable))
4203 (point)))))
4204 (when (cdr datal)
4205 (gnus-data-update-list
4206 (cdr datal)
4207 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4208
4209 (defun gnus-summary-update-article (article &optional iheader)
4210 "Update ARTICLE in the summary buffer."
4211 (set-buffer gnus-summary-buffer)
4212 (let* ((header (gnus-summary-article-header article))
4213 (id (mail-header-id header))
4214 (data (gnus-data-find article))
4215 (thread (gnus-id-to-thread id))
4216 (references (mail-header-references header))
4217 (parent
4218 (gnus-id-to-thread
4219 (or (gnus-parent-id
4220 (when (and references
4221 (not (equal "" references)))
4222 references))
4223 "none")))
4224 (buffer-read-only nil)
4225 (old (car thread)))
4226 (when thread
4227 (unless iheader
4228 (setcar thread nil)
4229 (when parent
4230 (delq thread parent)))
4231 (if (gnus-summary-insert-subject id header)
4232 ;; Set the (possibly) new article number in the data structure.
4233 (gnus-data-set-number data (gnus-id-to-article id))
4234 (setcar thread old)
4235 nil))))
4236
4237 (defun gnus-rebuild-thread (id &optional line)
4238 "Rebuild the thread containing ID.
4239 If LINE, insert the rebuilt thread starting on line LINE."
4240 (let ((buffer-read-only nil)
4241 old-pos current thread data)
4242 (if (not gnus-show-threads)
4243 (setq thread (list (car (gnus-id-to-thread id))))
4244 ;; Get the thread this article is part of.
4245 (setq thread (gnus-remove-thread id)))
4246 (setq old-pos (gnus-point-at-bol))
4247 (setq current (save-excursion
4248 (and (re-search-backward "[\r\n]" nil t)
4249 (gnus-summary-article-number))))
4250 ;; If this is a gathered thread, we have to go some re-gathering.
4251 (when (stringp (car thread))
4252 (let ((subject (car thread))
4253 roots thr)
4254 (setq thread (cdr thread))
4255 (while thread
4256 (unless (memq (setq thr (gnus-id-to-thread
4257 (gnus-root-id
4258 (mail-header-id (caar thread)))))
4259 roots)
4260 (push thr roots))
4261 (setq thread (cdr thread)))
4262 ;; We now have all (unique) roots.
4263 (if (= (length roots) 1)
4264 ;; All the loose roots are now one solid root.
4265 (setq thread (car roots))
4266 (setq thread (cons subject (gnus-sort-threads roots))))))
4267 (let (threads)
4268 ;; We then insert this thread into the summary buffer.
4269 (when line
4270 (goto-char (point-min))
4271 (forward-line (1- line)))
4272 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4273 (if gnus-show-threads
4274 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4275 (gnus-summary-prepare-unthreaded thread))
4276 (setq data (nreverse gnus-newsgroup-data))
4277 (setq threads gnus-newsgroup-threads))
4278 ;; We splice the new data into the data structure.
4279 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4280 ;;!!! then we want to insert at the beginning of the buffer.
4281 ;;!!! That happens to be true with Gnus now, but that may
4282 ;;!!! change in the future. Perhaps.
4283 (gnus-data-enter-list
4284 (if line nil current) data (- (point) old-pos))
4285 (setq gnus-newsgroup-threads
4286 (nconc threads gnus-newsgroup-threads))
4287 (gnus-data-compute-positions))))
4288
4289 (defun gnus-number-to-header (number)
4290 "Return the header for article NUMBER."
4291 (let ((headers gnus-newsgroup-headers))
4292 (while (and headers
4293 (not (= number (mail-header-number (car headers)))))
4294 (pop headers))
4295 (when headers
4296 (car headers))))
4297
4298 (defun gnus-parent-headers (in-headers &optional generation)
4299 "Return the headers of the GENERATIONeth parent of HEADERS."
4300 (unless generation
4301 (setq generation 1))
4302 (let ((parent t)
4303 (headers in-headers)
4304 references)
4305 (while (and parent
4306 (not (zerop generation))
4307 (setq references (mail-header-references headers)))
4308 (setq headers (if (and references
4309 (setq parent (gnus-parent-id references)))
4310 (car (gnus-id-to-thread parent))
4311 nil))
4312 (decf generation))
4313 (and (not (eq headers in-headers))
4314 headers)))
4315
4316 (defun gnus-id-to-thread (id)
4317 "Return the (sub-)thread where ID appears."
4318 (gnus-gethash id gnus-newsgroup-dependencies))
4319
4320 (defun gnus-id-to-article (id)
4321 "Return the article number of ID."
4322 (let ((thread (gnus-id-to-thread id)))
4323 (when (and thread
4324 (car thread))
4325 (mail-header-number (car thread)))))
4326
4327 (defun gnus-id-to-header (id)
4328 "Return the article headers of ID."
4329 (car (gnus-id-to-thread id)))
4330
4331 (defun gnus-article-displayed-root-p (article)
4332 "Say whether ARTICLE is a root(ish) article."
4333 (let ((level (gnus-summary-thread-level article))
4334 (refs (mail-header-references (gnus-summary-article-header article)))
4335 particle)
4336 (cond
4337 ((null level) nil)
4338 ((zerop level) t)
4339 ((null refs) t)
4340 ((null (gnus-parent-id refs)) t)
4341 ((and (= 1 level)
4342 (null (setq particle (gnus-id-to-article
4343 (gnus-parent-id refs))))
4344 (null (gnus-summary-thread-level particle)))))))
4345
4346 (defun gnus-root-id (id)
4347 "Return the id of the root of the thread where ID appears."
4348 (let (last-id prev)
4349 (while (and id (setq prev (car (gnus-id-to-thread id))))
4350 (setq last-id id
4351 id (gnus-parent-id (mail-header-references prev))))
4352 last-id))
4353
4354 (defun gnus-articles-in-thread (thread)
4355 "Return the list of articles in THREAD."
4356 (cons (mail-header-number (car thread))
4357 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4358
4359 (defun gnus-remove-thread (id &optional dont-remove)
4360 "Remove the thread that has ID in it."
4361 (let (headers thread last-id)
4362 ;; First go up in this thread until we find the root.
4363 (setq last-id (gnus-root-id id)
4364 headers (message-flatten-list (gnus-id-to-thread last-id)))
4365 ;; We have now found the real root of this thread. It might have
4366 ;; been gathered into some loose thread, so we have to search
4367 ;; through the threads to find the thread we wanted.
4368 (let ((threads gnus-newsgroup-threads)
4369 sub)
4370 (while threads
4371 (setq sub (car threads))
4372 (if (stringp (car sub))
4373 ;; This is a gathered thread, so we look at the roots
4374 ;; below it to find whether this article is in this
4375 ;; gathered root.
4376 (progn
4377 (setq sub (cdr sub))
4378 (while sub
4379 (when (member (caar sub) headers)
4380 (setq thread (car threads)
4381 threads nil
4382 sub nil))
4383 (setq sub (cdr sub))))
4384 ;; It's an ordinary thread, so we check it.
4385 (when (eq (car sub) (car headers))
4386 (setq thread sub
4387 threads nil)))
4388 (setq threads (cdr threads)))
4389 ;; If this article is in no thread, then it's a root.
4390 (if thread
4391 (unless dont-remove
4392 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4393 (setq thread (gnus-id-to-thread last-id)))
4394 (when thread
4395 (prog1
4396 thread ; We return this thread.
4397 (unless dont-remove
4398 (if (stringp (car thread))
4399 (progn
4400 ;; If we use dummy roots, then we have to remove the
4401 ;; dummy root as well.
4402 (when (eq gnus-summary-make-false-root 'dummy)
4403 ;; We go to the dummy root by going to
4404 ;; the first sub-"thread", and then one line up.
4405 (gnus-summary-goto-article
4406 (mail-header-number (caadr thread)))
4407 (forward-line -1)
4408 (gnus-delete-line)
4409 (gnus-data-compute-positions))
4410 (setq thread (cdr thread))
4411 (while thread
4412 (gnus-remove-thread-1 (car thread))
4413 (setq thread (cdr thread))))
4414 (gnus-remove-thread-1 thread))))))))
4415
4416 (defun gnus-remove-thread-1 (thread)
4417 "Remove the thread THREAD recursively."
4418 (let ((number (mail-header-number (pop thread)))
4419 d)
4420 (setq thread (reverse thread))
4421 (while thread
4422 (gnus-remove-thread-1 (pop thread)))
4423 (when (setq d (gnus-data-find number))
4424 (goto-char (gnus-data-pos d))
4425 (gnus-summary-show-thread)
4426 (gnus-data-remove
4427 number
4428 (- (gnus-point-at-bol)
4429 (prog1
4430 (1+ (gnus-point-at-eol))
4431 (gnus-delete-line)))))))
4432
4433 (defun gnus-sort-threads-1 (threads func)
4434 (sort (mapcar (lambda (thread)
4435 (cons (car thread)
4436 (and (cdr thread)
4437 (gnus-sort-threads-1 (cdr thread) func))))
4438 threads) func))
4439
4440 (defun gnus-sort-threads (threads)
4441 "Sort THREADS."
4442 (if (not gnus-thread-sort-functions)
4443 threads
4444 (gnus-message 8 "Sorting threads...")
4445 (let ((max-lisp-eval-depth 5000))
4446 (prog1 (gnus-sort-threads-1
4447 threads
4448 (gnus-make-sort-function gnus-thread-sort-functions))
4449 (gnus-message 8 "Sorting threads...done")))))
4450
4451 (defun gnus-sort-articles (articles)
4452 "Sort ARTICLES."
4453 (when gnus-article-sort-functions
4454 (gnus-message 7 "Sorting articles...")
4455 (prog1
4456 (setq gnus-newsgroup-headers
4457 (sort articles (gnus-make-sort-function
4458 gnus-article-sort-functions)))
4459 (gnus-message 7 "Sorting articles...done"))))
4460
4461 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4462 (defmacro gnus-thread-header (thread)
4463 "Return header of first article in THREAD.
4464 Note that THREAD must never, ever be anything else than a variable -
4465 using some other form will lead to serious barfage."
4466 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4467 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4468 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4469 (vector thread) 2))
4470
4471 (defsubst gnus-article-sort-by-number (h1 h2)
4472 "Sort articles by article number."
4473 (< (mail-header-number h1)
4474 (mail-header-number h2)))
4475
4476 (defun gnus-thread-sort-by-number (h1 h2)
4477 "Sort threads by root article number."
4478 (gnus-article-sort-by-number
4479 (gnus-thread-header h1) (gnus-thread-header h2)))
4480
4481 (defsubst gnus-article-sort-by-random (h1 h2)
4482 "Sort articles by article number."
4483 (zerop (random 2)))
4484
4485 (defun gnus-thread-sort-by-random (h1 h2)
4486 "Sort threads by root article number."
4487 (gnus-article-sort-by-random
4488 (gnus-thread-header h1) (gnus-thread-header h2)))
4489
4490 (defsubst gnus-article-sort-by-lines (h1 h2)
4491 "Sort articles by article Lines header."
4492 (< (mail-header-lines h1)
4493 (mail-header-lines h2)))
4494
4495 (defun gnus-thread-sort-by-lines (h1 h2)
4496 "Sort threads by root article Lines header."
4497 (gnus-article-sort-by-lines
4498 (gnus-thread-header h1) (gnus-thread-header h2)))
4499
4500 (defsubst gnus-article-sort-by-chars (h1 h2)
4501 "Sort articles by octet length."
4502 (< (mail-header-chars h1)
4503 (mail-header-chars h2)))
4504
4505 (defun gnus-thread-sort-by-chars (h1 h2)
4506 "Sort threads by root article octet length."
4507 (gnus-article-sort-by-chars
4508 (gnus-thread-header h1) (gnus-thread-header h2)))
4509
4510 (defsubst gnus-article-sort-by-author (h1 h2)
4511 "Sort articles by root author."
4512 (string-lessp
4513 (let ((extract (funcall
4514 gnus-extract-address-components
4515 (mail-header-from h1))))
4516 (or (car extract) (cadr extract) ""))
4517 (let ((extract (funcall
4518 gnus-extract-address-components
4519 (mail-header-from h2))))
4520 (or (car extract) (cadr extract) ""))))
4521
4522 (defun gnus-thread-sort-by-author (h1 h2)
4523 "Sort threads by root author."
4524 (gnus-article-sort-by-author
4525 (gnus-thread-header h1) (gnus-thread-header h2)))
4526
4527 (defsubst gnus-article-sort-by-subject (h1 h2)
4528 "Sort articles by root subject."
4529 (string-lessp
4530 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4531 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4532
4533 (defun gnus-thread-sort-by-subject (h1 h2)
4534 "Sort threads by root subject."
4535 (gnus-article-sort-by-subject
4536 (gnus-thread-header h1) (gnus-thread-header h2)))
4537
4538 (defsubst gnus-article-sort-by-date (h1 h2)
4539 "Sort articles by root article date."
4540 (time-less-p
4541 (gnus-date-get-time (mail-header-date h1))
4542 (gnus-date-get-time (mail-header-date h2))))
4543
4544 (defun gnus-thread-sort-by-date (h1 h2)
4545 "Sort threads by root article date."
4546 (gnus-article-sort-by-date
4547 (gnus-thread-header h1) (gnus-thread-header h2)))
4548
4549 (defsubst gnus-article-sort-by-score (h1 h2)
4550 "Sort articles by root article score.
4551 Unscored articles will be counted as having a score of zero."
4552 (> (or (cdr (assq (mail-header-number h1)
4553 gnus-newsgroup-scored))
4554 gnus-summary-default-score 0)
4555 (or (cdr (assq (mail-header-number h2)
4556 gnus-newsgroup-scored))
4557 gnus-summary-default-score 0)))
4558
4559 (defun gnus-thread-sort-by-score (h1 h2)
4560 "Sort threads by root article score."
4561 (gnus-article-sort-by-score
4562 (gnus-thread-header h1) (gnus-thread-header h2)))
4563
4564 (defun gnus-thread-sort-by-total-score (h1 h2)
4565 "Sort threads by the sum of all scores in the thread.
4566 Unscored articles will be counted as having a score of zero."
4567 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4568
4569 (defun gnus-thread-total-score (thread)
4570 ;; This function find the total score of THREAD.
4571 (cond
4572 ((null thread)
4573 0)
4574 ((consp thread)
4575 (if (stringp (car thread))
4576 (apply gnus-thread-score-function 0
4577 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4578 (gnus-thread-total-score-1 thread)))
4579 (t
4580 (gnus-thread-total-score-1 (list thread)))))
4581
4582 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4583 "Sort threads such that the thread with the most recently arrived article comes first."
4584 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4585
4586 (defun gnus-thread-highest-number (thread)
4587 "Return the highest article number in THREAD."
4588 (apply 'max (mapcar (lambda (header)
4589 (mail-header-number header))
4590 (message-flatten-list thread))))
4591
4592 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4593 "Sort threads such that the thread with the most recently dated article comes first."
4594 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4595
4596 (defun gnus-thread-latest-date (thread)
4597 "Return the highest article date in THREAD."
4598 (let ((previous-time 0))
4599 (apply 'max
4600 (mapcar
4601 (lambda (header)
4602 (setq previous-time
4603 (condition-case ()
4604 (time-to-seconds (mail-header-parse-date
4605 (mail-header-date header)))
4606 (error previous-time))))
4607 (sort
4608 (message-flatten-list thread)
4609 (lambda (h1 h2)
4610 (< (mail-header-number h1)
4611 (mail-header-number h2))))))))
4612
4613 (defun gnus-thread-total-score-1 (root)
4614 ;; This function find the total score of the thread below ROOT.
4615 (setq root (car root))
4616 (apply gnus-thread-score-function
4617 (or (append
4618 (mapcar 'gnus-thread-total-score
4619 (cdr (gnus-id-to-thread (mail-header-id root))))
4620 (when (> (mail-header-number root) 0)
4621 (list (or (cdr (assq (mail-header-number root)
4622 gnus-newsgroup-scored))
4623 gnus-summary-default-score 0))))
4624 (list gnus-summary-default-score)
4625 '(0))))
4626
4627 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4628 (defvar gnus-tmp-prev-subject nil)
4629 (defvar gnus-tmp-false-parent nil)
4630 (defvar gnus-tmp-root-expunged nil)
4631 (defvar gnus-tmp-dummy-line nil)
4632
4633 (eval-when-compile (defvar gnus-tmp-header))
4634 (defun gnus-extra-header (type &optional header)
4635 "Return the extra header of TYPE."
4636 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4637 ""))
4638
4639 (defvar gnus-tmp-thread-tree-header-string "")
4640
4641 (defcustom gnus-sum-thread-tree-root "> "
4642 "With %B spec, used for the root of a thread.
4643 If nil, use subject instead."
4644 :version "22.1"
4645 :type '(radio (const :format "%v " nil) string)
4646 :group 'gnus-thread)
4647 (defcustom gnus-sum-thread-tree-false-root "> "
4648 "With %B spec, used for a false root of a thread.
4649 If nil, use subject instead."
4650 :version "22.1"
4651 :type '(radio (const :format "%v " nil) string)
4652 :group 'gnus-thread)
4653 (defcustom gnus-sum-thread-tree-single-indent ""
4654 "With %B spec, used for a thread with just one message.
4655 If nil, use subject instead."
4656 :version "22.1"
4657 :type '(radio (const :format "%v " nil) string)
4658 :group 'gnus-thread)
4659 (defcustom gnus-sum-thread-tree-vertical "| "
4660 "With %B spec, used for drawing a vertical line."
4661 :version "22.1"
4662 :type 'string
4663 :group 'gnus-thread)
4664 (defcustom gnus-sum-thread-tree-indent " "
4665 "With %B spec, used for indenting."
4666 :version "22.1"
4667 :type 'string
4668 :group 'gnus-thread)
4669 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4670 "With %B spec, used for a leaf with brothers."
4671 :version "22.1"
4672 :type 'string
4673 :group 'gnus-thread)
4674 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4675 "With %B spec, used for a leaf without brothers."
4676 :version "22.1"
4677 :type 'string
4678 :group 'gnus-thread)
4679
4680 (defun gnus-summary-prepare-threads (threads)
4681 "Prepare summary buffer from THREADS and indentation LEVEL.
4682 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4683 or a straight list of headers."
4684 (gnus-message 7 "Generating summary...")
4685
4686 (setq gnus-newsgroup-threads threads)
4687 (beginning-of-line)
4688
4689 (let ((gnus-tmp-level 0)
4690 (default-score (or gnus-summary-default-score 0))
4691 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4692 (building-line-count gnus-summary-display-while-building)
4693 (building-count (integerp gnus-summary-display-while-building))
4694 thread number subject stack state gnus-tmp-gathered beg-match
4695 new-roots gnus-tmp-new-adopts thread-end simp-subject
4696 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4697 gnus-tmp-replied gnus-tmp-subject-or-nil
4698 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4699 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4700 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4701 tree-stack)
4702
4703 (setq gnus-tmp-prev-subject nil
4704 gnus-tmp-thread-tree-header-string "")
4705
4706 (if (vectorp (car threads))
4707 ;; If this is a straight (sic) list of headers, then a
4708 ;; threaded summary display isn't required, so we just create
4709 ;; an unthreaded one.
4710 (gnus-summary-prepare-unthreaded threads)
4711
4712 ;; Do the threaded display.
4713
4714 (if gnus-summary-display-while-building
4715 (switch-to-buffer (buffer-name)))
4716 (while (or threads stack gnus-tmp-new-adopts new-roots)
4717
4718 (if (and (= gnus-tmp-level 0)
4719 (or (not stack)
4720 (= (caar stack) 0))
4721 (not gnus-tmp-false-parent)
4722 (or gnus-tmp-new-adopts new-roots))
4723 (if gnus-tmp-new-adopts
4724 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4725 thread (list (car gnus-tmp-new-adopts))
4726 gnus-tmp-header (caar thread)
4727 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4728 (when new-roots
4729 (setq thread (list (car new-roots))
4730 gnus-tmp-header (caar thread)
4731 new-roots (cdr new-roots))))
4732
4733 (if threads
4734 ;; If there are some threads, we do them before the
4735 ;; threads on the stack.
4736 (setq thread threads
4737 gnus-tmp-header (caar thread))
4738 ;; There were no current threads, so we pop something off
4739 ;; the stack.
4740 (setq state (car stack)
4741 gnus-tmp-level (car state)
4742 tree-stack (cadr state)
4743 thread (caddr state)
4744 stack (cdr stack)
4745 gnus-tmp-header (caar thread))))
4746
4747 (setq gnus-tmp-false-parent nil)
4748 (setq gnus-tmp-root-expunged nil)
4749 (setq thread-end nil)
4750
4751 (if (stringp gnus-tmp-header)
4752 ;; The header is a dummy root.
4753 (cond
4754 ((eq gnus-summary-make-false-root 'adopt)
4755 ;; We let the first article adopt the rest.
4756 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4757 (cddar thread)))
4758 (setq gnus-tmp-gathered
4759 (nconc (mapcar
4760 (lambda (h) (mail-header-number (car h)))
4761 (cddar thread))
4762 gnus-tmp-gathered))
4763 (setq thread (cons (list (caar thread)
4764 (cadar thread))
4765 (cdr thread)))
4766 (setq gnus-tmp-level -1
4767 gnus-tmp-false-parent t))
4768 ((eq gnus-summary-make-false-root 'empty)
4769 ;; We print adopted articles with empty subject fields.
4770 (setq gnus-tmp-gathered
4771 (nconc (mapcar
4772 (lambda (h) (mail-header-number (car h)))
4773 (cddar thread))
4774 gnus-tmp-gathered))
4775 (setq gnus-tmp-level -1))
4776 ((eq gnus-summary-make-false-root 'dummy)
4777 ;; We remember that we probably want to output a dummy
4778 ;; root.
4779 (setq gnus-tmp-dummy-line gnus-tmp-header)
4780 (setq gnus-tmp-prev-subject gnus-tmp-header))
4781 (t
4782 ;; We do not make a root for the gathered
4783 ;; sub-threads at all.
4784 (setq gnus-tmp-level -1)))
4785
4786 (setq number (mail-header-number gnus-tmp-header)
4787 subject (mail-header-subject gnus-tmp-header)
4788 simp-subject (gnus-simplify-subject-fully subject))
4789
4790 (cond
4791 ;; If the thread has changed subject, we might want to make
4792 ;; this subthread into a root.
4793 ((and (null gnus-thread-ignore-subject)
4794 (not (zerop gnus-tmp-level))
4795 gnus-tmp-prev-subject
4796 (not (string= gnus-tmp-prev-subject simp-subject)))
4797 (setq new-roots (nconc new-roots (list (car thread)))
4798 thread-end t
4799 gnus-tmp-header nil))
4800 ;; If the article lies outside the current limit,
4801 ;; then we do not display it.
4802 ((not (memq number gnus-newsgroup-limit))
4803 (setq gnus-tmp-gathered
4804 (nconc (mapcar
4805 (lambda (h) (mail-header-number (car h)))
4806 (cdar thread))
4807 gnus-tmp-gathered))
4808 (setq gnus-tmp-new-adopts (if (cdar thread)
4809 (append gnus-tmp-new-adopts
4810 (cdar thread))
4811 gnus-tmp-new-adopts)
4812 thread-end t
4813 gnus-tmp-header nil)
4814 (when (zerop gnus-tmp-level)
4815 (setq gnus-tmp-root-expunged t)))
4816 ;; Perhaps this article is to be marked as read?
4817 ((and gnus-summary-mark-below
4818 (< (or (cdr (assq number gnus-newsgroup-scored))
4819 default-score)
4820 gnus-summary-mark-below)
4821 ;; Don't touch sparse articles.
4822 (not (gnus-summary-article-sparse-p number))
4823 (not (gnus-summary-article-ancient-p number)))
4824 (setq gnus-newsgroup-unreads
4825 (delq number gnus-newsgroup-unreads))
4826 (if gnus-newsgroup-auto-expire
4827 (setq gnus-newsgroup-expirable
4828 (gnus-add-to-sorted-list
4829 gnus-newsgroup-expirable number))
4830 (push (cons number gnus-low-score-mark)
4831 gnus-newsgroup-reads))))
4832
4833 (when gnus-tmp-header
4834 ;; We may have an old dummy line to output before this
4835 ;; article.
4836 (when (and gnus-tmp-dummy-line
4837 (gnus-subject-equal
4838 gnus-tmp-dummy-line
4839 (mail-header-subject gnus-tmp-header)))
4840 (gnus-summary-insert-dummy-line
4841 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4842 (setq gnus-tmp-dummy-line nil))
4843
4844 ;; Compute the mark.
4845 (setq gnus-tmp-unread (gnus-article-mark number))
4846
4847 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4848 gnus-tmp-header gnus-tmp-level)
4849 gnus-newsgroup-data)
4850
4851 ;; Actually insert the line.
4852 (setq
4853 gnus-tmp-subject-or-nil
4854 (cond
4855 ((and gnus-thread-ignore-subject
4856 gnus-tmp-prev-subject
4857 (not (string= gnus-tmp-prev-subject simp-subject)))
4858 subject)
4859 ((zerop gnus-tmp-level)
4860 (if (and (eq gnus-summary-make-false-root 'empty)
4861 (memq number gnus-tmp-gathered)
4862 gnus-tmp-prev-subject
4863 (string= gnus-tmp-prev-subject simp-subject))
4864 gnus-summary-same-subject
4865 subject))
4866 (t gnus-summary-same-subject)))
4867 (if (and (eq gnus-summary-make-false-root 'adopt)
4868 (= gnus-tmp-level 1)
4869 (memq number gnus-tmp-gathered))
4870 (setq gnus-tmp-opening-bracket ?\<
4871 gnus-tmp-closing-bracket ?\>)
4872 (setq gnus-tmp-opening-bracket ?\[
4873 gnus-tmp-closing-bracket ?\]))
4874 (setq
4875 gnus-tmp-indentation
4876 (aref gnus-thread-indent-array gnus-tmp-level)
4877 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4878 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4879 gnus-summary-default-score 0)
4880 gnus-tmp-score-char
4881 (if (or (null gnus-summary-default-score)
4882 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4883 gnus-summary-zcore-fuzz))
4884 ? ;Whitespace
4885 (if (< gnus-tmp-score gnus-summary-default-score)
4886 gnus-score-below-mark gnus-score-over-mark))
4887 gnus-tmp-replied
4888 (cond ((memq number gnus-newsgroup-processable)
4889 gnus-process-mark)
4890 ((memq number gnus-newsgroup-cached)
4891 gnus-cached-mark)
4892 ((memq number gnus-newsgroup-replied)
4893 gnus-replied-mark)
4894 ((memq number gnus-newsgroup-forwarded)
4895 gnus-forwarded-mark)
4896 ((memq number gnus-newsgroup-saved)
4897 gnus-saved-mark)
4898 ((memq number gnus-newsgroup-recent)
4899 gnus-recent-mark)
4900 ((memq number gnus-newsgroup-unseen)
4901 gnus-unseen-mark)
4902 (t gnus-no-mark))
4903 gnus-tmp-downloaded
4904 (cond ((memq number gnus-newsgroup-undownloaded)
4905 gnus-undownloaded-mark)
4906 (gnus-newsgroup-agentized
4907 gnus-downloaded-mark)
4908 (t
4909 gnus-no-mark))
4910 gnus-tmp-from (mail-header-from gnus-tmp-header)
4911 gnus-tmp-name
4912 (cond
4913 ((string-match "<[^>]+> *$" gnus-tmp-from)
4914 (setq beg-match (match-beginning 0))
4915 (or (and (string-match "^\".+\"" gnus-tmp-from)
4916 (substring gnus-tmp-from 1 (1- (match-end 0))))
4917 (substring gnus-tmp-from 0 beg-match)))
4918 ((string-match "(.+)" gnus-tmp-from)
4919 (substring gnus-tmp-from
4920 (1+ (match-beginning 0)) (1- (match-end 0))))
4921 (t gnus-tmp-from))
4922
4923 ;; Do the %B string
4924 gnus-tmp-thread-tree-header-string
4925 (cond
4926 ((not gnus-show-threads) "")
4927 ((zerop gnus-tmp-level)
4928 (cond ((cdar thread)
4929 (or gnus-sum-thread-tree-root subject))
4930 (gnus-tmp-new-adopts
4931 (or gnus-sum-thread-tree-false-root subject))
4932 (t
4933 (or gnus-sum-thread-tree-single-indent subject))))
4934 (t
4935 (concat (apply 'concat
4936 (mapcar (lambda (item)
4937 (if (= item 1)
4938 gnus-sum-thread-tree-vertical
4939 gnus-sum-thread-tree-indent))
4940 (cdr (reverse tree-stack))))
4941 (if (nth 1 thread)
4942 gnus-sum-thread-tree-leaf-with-other
4943 gnus-sum-thread-tree-single-leaf)))))
4944 (when (string= gnus-tmp-name "")
4945 (setq gnus-tmp-name gnus-tmp-from))
4946 (unless (numberp gnus-tmp-lines)
4947 (setq gnus-tmp-lines -1))
4948 (if (= gnus-tmp-lines -1)
4949 (setq gnus-tmp-lines "?")
4950 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4951 (gnus-put-text-property
4952 (point)
4953 (progn (eval gnus-summary-line-format-spec) (point))
4954 'gnus-number number)
4955 (when gnus-visual-p
4956 (forward-line -1)
4957 (gnus-run-hooks 'gnus-summary-update-hook)
4958 (forward-line 1))
4959
4960 (setq gnus-tmp-prev-subject simp-subject)))
4961
4962 (when (nth 1 thread)
4963 (push (list (max 0 gnus-tmp-level)
4964 (copy-sequence tree-stack)
4965 (nthcdr 1 thread))
4966 stack))
4967 (push (if (nth 1 thread) 1 0) tree-stack)
4968 (incf gnus-tmp-level)
4969 (setq threads (if thread-end nil (cdar thread)))
4970 (if gnus-summary-display-while-building
4971 (if building-count
4972 (progn
4973 ;; use a set frequency
4974 (setq building-line-count (1- building-line-count))
4975 (when (= building-line-count 0)
4976 (sit-for 0)
4977 (setq building-line-count
4978 gnus-summary-display-while-building)))
4979 ;; always
4980 (sit-for 0)))
4981 (unless threads
4982 (setq gnus-tmp-level 0)))))
4983 (gnus-message 7 "Generating summary...done"))
4984
4985 (defun gnus-summary-prepare-unthreaded (headers)
4986 "Generate an unthreaded summary buffer based on HEADERS."
4987 (let (header number mark)
4988
4989 (beginning-of-line)
4990
4991 (while headers
4992 ;; We may have to root out some bad articles...
4993 (when (memq (setq number (mail-header-number
4994 (setq header (pop headers))))
4995 gnus-newsgroup-limit)
4996 ;; Mark article as read when it has a low score.
4997 (when (and gnus-summary-mark-below
4998 (< (or (cdr (assq number gnus-newsgroup-scored))
4999 gnus-summary-default-score 0)
5000 gnus-summary-mark-below)
5001 (not (gnus-summary-article-ancient-p number)))
5002 (setq gnus-newsgroup-unreads
5003 (delq number gnus-newsgroup-unreads))
5004 (if gnus-newsgroup-auto-expire
5005 (push number gnus-newsgroup-expirable)
5006 (push (cons number gnus-low-score-mark)
5007 gnus-newsgroup-reads)))
5008
5009 (setq mark (gnus-article-mark number))
5010 (push (gnus-data-make number mark (1+ (point)) header 0)
5011 gnus-newsgroup-data)
5012 (gnus-summary-insert-line
5013 header 0 number
5014 (memq number gnus-newsgroup-undownloaded)
5015 mark (memq number gnus-newsgroup-replied)
5016 (memq number gnus-newsgroup-expirable)
5017 (mail-header-subject header) nil
5018 (cdr (assq number gnus-newsgroup-scored))
5019 (memq number gnus-newsgroup-processable))))))
5020
5021 (defun gnus-summary-remove-list-identifiers ()
5022 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5023 (let ((regexp (if (consp gnus-list-identifiers)
5024 (mapconcat 'identity gnus-list-identifiers " *\\|")
5025 gnus-list-identifiers))
5026 changed subject)
5027 (when regexp
5028 (dolist (header gnus-newsgroup-headers)
5029 (setq subject (mail-header-subject header)
5030 changed nil)
5031 (while (string-match
5032 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
5033 subject)
5034 (setq subject
5035 (concat (substring subject 0 (match-beginning 2))
5036 (substring subject (match-end 0)))
5037 changed t))
5038 (when (and changed
5039 (string-match
5040 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
5041 (setq subject
5042 (concat (substring subject 0 (match-beginning 1))
5043 (substring subject (match-end 1)))))
5044 (when changed
5045 (mail-header-set-subject header subject))))))
5046
5047 (defun gnus-fetch-headers (articles)
5048 "Fetch headers of ARTICLES."
5049 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5050 (gnus-message 5 "Fetching headers for %s..." name)
5051 (prog1
5052 (if (eq 'nov
5053 (setq gnus-headers-retrieved-by
5054 (gnus-retrieve-headers
5055 articles gnus-newsgroup-name
5056 ;; We might want to fetch old headers, but
5057 ;; not if there is only 1 article.
5058 (and (or (and
5059 (not (eq gnus-fetch-old-headers 'some))
5060 (not (numberp gnus-fetch-old-headers)))
5061 (> (length articles) 1))
5062 gnus-fetch-old-headers))))
5063 (gnus-get-newsgroup-headers-xover
5064 articles nil nil gnus-newsgroup-name t)
5065 (gnus-get-newsgroup-headers))
5066 (gnus-message 5 "Fetching headers for %s...done" name))))
5067
5068 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5069 "Select newsgroup GROUP.
5070 If READ-ALL is non-nil, all articles in the group are selected.
5071 If SELECT-ARTICLES, only select those articles from GROUP."
5072 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5073 ;;!!! Dirty hack; should be removed.
5074 (gnus-summary-ignore-duplicates
5075 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5076 t
5077 gnus-summary-ignore-duplicates))
5078 (info (nth 2 entry))
5079 articles fetched-articles cached)
5080
5081 (unless (gnus-check-server
5082 (set (make-local-variable 'gnus-current-select-method)
5083 (gnus-find-method-for-group group)))
5084 (error "Couldn't open server"))
5085
5086 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5087 (gnus-activate-group group) ; Or we can activate it...
5088 (progn ; Or we bug out.
5089 (when (equal major-mode 'gnus-summary-mode)
5090 (gnus-kill-buffer (current-buffer)))
5091 (error "Couldn't activate group %s: %s"
5092 group (gnus-status-message group))))
5093
5094 (unless (gnus-request-group group t)
5095 (when (equal major-mode 'gnus-summary-mode)
5096 (gnus-kill-buffer (current-buffer)))
5097 (error "Couldn't request group %s: %s"
5098 group (gnus-status-message group)))
5099
5100 (when gnus-agent
5101 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5102
5103 (setq gnus-summary-use-undownloaded-faces
5104 (gnus-agent-find-parameter
5105 group
5106 'agent-enable-undownloaded-faces)))
5107
5108 (setq gnus-newsgroup-name group
5109 gnus-newsgroup-unselected nil
5110 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5111
5112 (let ((display (gnus-group-find-parameter group 'display)))
5113 (setq gnus-newsgroup-display
5114 (cond
5115 ((not (zerop (or (car-safe read-all) 0)))
5116 ;; The user entered the group with C-u SPC/RET, let's show
5117 ;; all articles.
5118 'gnus-not-ignore)
5119 ((eq display 'all)
5120 'gnus-not-ignore)
5121 ((arrayp display)
5122 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5123 ((numberp display)
5124 ;; The following is probably the "correct" solution, but
5125 ;; it makes Gnus fetch all headers and then limit the
5126 ;; articles (which is slow), so instead we hack the
5127 ;; select-articles parameter instead. -- Simon Josefsson
5128 ;; <jas@kth.se>
5129 ;;
5130 ;; (gnus-byte-compile
5131 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5132 ;; display)))))
5133 (setq select-articles
5134 (gnus-uncompress-range
5135 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5136 (if (> tmp 0)
5137 tmp
5138 1))
5139 (cdr (gnus-active group)))))
5140 nil)
5141 (t
5142 nil))))
5143
5144 (gnus-summary-setup-default-charset)
5145
5146 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5147 (when (gnus-virtual-group-p group)
5148 (setq cached gnus-newsgroup-cached))
5149
5150 (setq gnus-newsgroup-unreads
5151 (gnus-sorted-ndifference
5152 (gnus-sorted-ndifference gnus-newsgroup-unreads
5153 gnus-newsgroup-marked)
5154 gnus-newsgroup-dormant))
5155
5156 (setq gnus-newsgroup-processable nil)
5157
5158 (gnus-update-read-articles group gnus-newsgroup-unreads)
5159
5160 ;; Adjust and set lists of article marks.
5161 (when info
5162 (gnus-adjust-marked-articles info))
5163 (if (setq articles select-articles)
5164 (setq gnus-newsgroup-unselected
5165 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5166 (setq articles (gnus-articles-to-read group read-all)))
5167
5168 (cond
5169 ((null articles)
5170 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5171 'quit)
5172 ((eq articles 0) nil)
5173 (t
5174 ;; Init the dependencies hash table.
5175 (setq gnus-newsgroup-dependencies
5176 (gnus-make-hashtable (length articles)))
5177 (gnus-set-global-variables)
5178 ;; Retrieve the headers and read them in.
5179
5180 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5181
5182 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5183 (when cached
5184 (setq gnus-newsgroup-cached cached))
5185
5186 ;; Suppress duplicates?
5187 (when gnus-suppress-duplicates
5188 (gnus-dup-suppress-articles))
5189
5190 ;; Set the initial limit.
5191 (setq gnus-newsgroup-limit (copy-sequence articles))
5192 ;; Remove canceled articles from the list of unread articles.
5193 (setq fetched-articles
5194 (mapcar (lambda (headers) (mail-header-number headers))
5195 gnus-newsgroup-headers))
5196 (setq gnus-newsgroup-articles fetched-articles)
5197 (setq gnus-newsgroup-unreads
5198 (gnus-sorted-nintersection
5199 gnus-newsgroup-unreads fetched-articles))
5200 (gnus-compute-unseen-list)
5201
5202 ;; Removed marked articles that do not exist.
5203 (gnus-update-missing-marks
5204 (gnus-sorted-difference articles fetched-articles))
5205 ;; We might want to build some more threads first.
5206 (when (and gnus-fetch-old-headers
5207 (eq gnus-headers-retrieved-by 'nov))
5208 (if (eq gnus-fetch-old-headers 'invisible)
5209 (gnus-build-all-threads)
5210 (gnus-build-old-threads)))
5211 ;; Let the Gnus agent mark articles as read.
5212 (when gnus-agent
5213 (gnus-agent-get-undownloaded-list))
5214 ;; Remove list identifiers from subject
5215 (when gnus-list-identifiers
5216 (gnus-summary-remove-list-identifiers))
5217 ;; Check whether auto-expire is to be done in this group.
5218 (setq gnus-newsgroup-auto-expire
5219 (gnus-group-auto-expirable-p group))
5220 ;; Set up the article buffer now, if necessary.
5221 (unless gnus-single-article-buffer
5222 (gnus-article-setup-buffer))
5223 ;; First and last article in this newsgroup.
5224 (when gnus-newsgroup-headers
5225 (setq gnus-newsgroup-begin
5226 (mail-header-number (car gnus-newsgroup-headers))
5227 gnus-newsgroup-end
5228 (mail-header-number
5229 (gnus-last-element gnus-newsgroup-headers))))
5230 ;; GROUP is successfully selected.
5231 (or gnus-newsgroup-headers t)))))
5232
5233 (defun gnus-compute-unseen-list ()
5234 ;; The `seen' marks are treated specially.
5235 (if (not gnus-newsgroup-seen)
5236 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5237 (setq gnus-newsgroup-unseen
5238 (gnus-inverse-list-range-intersection
5239 gnus-newsgroup-articles gnus-newsgroup-seen))))
5240
5241 (defun gnus-summary-display-make-predicate (display)
5242 (require 'gnus-agent)
5243 (when (= (length display) 1)
5244 (setq display (car display)))
5245 (unless gnus-summary-display-cache
5246 (dolist (elem (append '((unread . unread)
5247 (read . read)
5248 (unseen . unseen))
5249 gnus-article-mark-lists))
5250 (push (cons (cdr elem)
5251 (gnus-byte-compile
5252 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5253 gnus-summary-display-cache)))
5254 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5255 (gnus-category-predicate-cache gnus-summary-display-cache))
5256 (gnus-get-predicate display)))
5257
5258 ;; Uses the dynamically bound `number' variable.
5259 (eval-when-compile
5260 (defvar number))
5261 (defun gnus-article-marked-p (type &optional article)
5262 (let ((article (or article number)))
5263 (cond
5264 ((eq type 'tick)
5265 (memq article gnus-newsgroup-marked))
5266 ((eq type 'spam)
5267 (memq article gnus-newsgroup-spam-marked))
5268 ((eq type 'unsend)
5269 (memq article gnus-newsgroup-unsendable))
5270 ((eq type 'undownload)
5271 (memq article gnus-newsgroup-undownloaded))
5272 ((eq type 'download)
5273 (memq article gnus-newsgroup-downloadable))
5274 ((eq type 'unread)
5275 (memq article gnus-newsgroup-unreads))
5276 ((eq type 'read)
5277 (memq article gnus-newsgroup-reads))
5278 ((eq type 'dormant)
5279 (memq article gnus-newsgroup-dormant) )
5280 ((eq type 'expire)
5281 (memq article gnus-newsgroup-expirable))
5282 ((eq type 'reply)
5283 (memq article gnus-newsgroup-replied))
5284 ((eq type 'killed)
5285 (memq article gnus-newsgroup-killed))
5286 ((eq type 'bookmark)
5287 (assq article gnus-newsgroup-bookmarks))
5288 ((eq type 'score)
5289 (assq article gnus-newsgroup-scored))
5290 ((eq type 'save)
5291 (memq article gnus-newsgroup-saved))
5292 ((eq type 'cache)
5293 (memq article gnus-newsgroup-cached))
5294 ((eq type 'forward)
5295 (memq article gnus-newsgroup-forwarded))
5296 ((eq type 'seen)
5297 (not (memq article gnus-newsgroup-unseen)))
5298 ((eq type 'recent)
5299 (memq article gnus-newsgroup-recent))
5300 (t t))))
5301
5302 (defun gnus-articles-to-read (group &optional read-all)
5303 "Find out what articles the user wants to read."
5304 (let* ((display (gnus-group-find-parameter group 'display))
5305 (articles
5306 ;; Select all articles if `read-all' is non-nil, or if there
5307 ;; are no unread articles.
5308 (if (or read-all
5309 (and (zerop (length gnus-newsgroup-marked))
5310 (zerop (length gnus-newsgroup-unreads)))
5311 ;; Fetch all if the predicate is non-nil.
5312 gnus-newsgroup-display)
5313 ;; We want to select the headers for all the articles in
5314 ;; the group, so we select either all the active
5315 ;; articles in the group, or (if that's nil), the
5316 ;; articles in the cache.
5317 (or
5318 (gnus-uncompress-range (gnus-active group))
5319 (gnus-cache-articles-in-group group))
5320 ;; Select only the "normal" subset of articles.
5321 (gnus-sorted-nunion
5322 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5323 gnus-newsgroup-unreads)))
5324 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5325 (scored (length scored-list))
5326 (number (length articles))
5327 (marked (+ (length gnus-newsgroup-marked)
5328 (length gnus-newsgroup-dormant)))
5329 (select
5330 (cond
5331 ((numberp read-all)
5332 read-all)
5333 ((numberp gnus-newsgroup-display)
5334 gnus-newsgroup-display)
5335 (t
5336 (condition-case ()
5337 (cond
5338 ((and (or (<= scored marked) (= scored number))
5339 (numberp gnus-large-newsgroup)
5340 (> number gnus-large-newsgroup))
5341 (let* ((cursor-in-echo-area nil)
5342 (initial (gnus-parameter-large-newsgroup-initial
5343 gnus-newsgroup-name))
5344 (input
5345 (read-string
5346 (format
5347 "How many articles from %s (%s %d): "
5348 (gnus-limit-string
5349 (gnus-group-decoded-name gnus-newsgroup-name)
5350 35)
5351 (if initial "max" "default")
5352 number)
5353 (if initial
5354 (cons (number-to-string initial)
5355 0)))))
5356 (if (string-match "^[ \t]*$" input) number input)))
5357 ((and (> scored marked) (< scored number)
5358 (> (- scored number) 20))
5359 (let ((input
5360 (read-string
5361 (format "%s %s (%d scored, %d total): "
5362 "How many articles from"
5363 (gnus-group-decoded-name group)
5364 scored number))))
5365 (if (string-match "^[ \t]*$" input)
5366 number input)))
5367 (t number))
5368 (quit
5369 (message "Quit getting the articles to read")
5370 nil))))))
5371 (setq select (if (stringp select) (string-to-number select) select))
5372 (if (or (null select) (zerop select))
5373 select
5374 (if (and (not (zerop scored)) (<= (abs select) scored))
5375 (progn
5376 (setq articles (sort scored-list '<))
5377 (setq number (length articles)))
5378 (setq articles (copy-sequence articles)))
5379
5380 (when (< (abs select) number)
5381 (if (< select 0)
5382 ;; Select the N oldest articles.
5383 (setcdr (nthcdr (1- (abs select)) articles) nil)
5384 ;; Select the N most recent articles.
5385 (setq articles (nthcdr (- number select) articles))))
5386 (setq gnus-newsgroup-unselected
5387 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5388 (when gnus-alter-articles-to-read-function
5389 (setq articles
5390 (sort
5391 (funcall gnus-alter-articles-to-read-function
5392 gnus-newsgroup-name articles)
5393 '<)))
5394 articles)))
5395
5396 (defun gnus-killed-articles (killed articles)
5397 (let (out)
5398 (while articles
5399 (when (inline (gnus-member-of-range (car articles) killed))
5400 (push (car articles) out))
5401 (setq articles (cdr articles)))
5402 out))
5403
5404 (defun gnus-uncompress-marks (marks)
5405 "Uncompress the mark ranges in MARKS."
5406 (let ((uncompressed '(score bookmark))
5407 out)
5408 (while marks
5409 (if (memq (caar marks) uncompressed)
5410 (push (car marks) out)
5411 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5412 (setq marks (cdr marks)))
5413 out))
5414
5415 (defun gnus-article-mark-to-type (mark)
5416 "Return the type of MARK."
5417 (or (cadr (assq mark gnus-article-special-mark-lists))
5418 'list))
5419
5420 (defun gnus-article-unpropagatable-p (mark)
5421 "Return whether MARK should be propagated to back end."
5422 (memq mark gnus-article-unpropagated-mark-lists))
5423
5424 (defun gnus-adjust-marked-articles (info)
5425 "Set all article lists and remove all marks that are no longer valid."
5426 (let* ((marked-lists (gnus-info-marks info))
5427 (active (gnus-active (gnus-info-group info)))
5428 (min (car active))
5429 (max (cdr active))
5430 (types gnus-article-mark-lists)
5431 marks var articles article mark mark-type
5432 bgn end)
5433
5434 (dolist (marks marked-lists)
5435 (setq mark (car marks)
5436 mark-type (gnus-article-mark-to-type mark)
5437 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5438
5439 ;; We set the variable according to the type of the marks list,
5440 ;; and then adjust the marks to a subset of the active articles.
5441 (cond
5442 ;; Adjust "simple" lists - compressed yet unsorted
5443 ((eq mark-type 'list)
5444 ;; Simultaneously uncompress and clip to active range
5445 ;; See gnus-uncompress-range for a description of possible marks
5446 (let (l lh)
5447 (if (not (cadr marks))
5448 (set var nil)
5449 (setq articles (if (numberp (cddr marks))
5450 (list (cdr marks))
5451 (cdr marks))
5452 lh (cons nil nil)
5453 l lh)
5454
5455 (while (setq article (pop articles))
5456 (cond ((consp article)
5457 (setq bgn (max (car article) min)
5458 end (min (cdr article) max))
5459 (while (<= bgn end)
5460 (setq l (setcdr l (cons bgn nil))
5461 bgn (1+ bgn))))
5462 ((and (<= min article)
5463 (>= max article))
5464 (setq l (setcdr l (cons article nil))))))
5465 (set var (cdr lh)))))
5466 ;; Adjust assocs.
5467 ((eq mark-type 'tuple)
5468 (set var (setq articles (cdr marks)))
5469 (when (not (listp (cdr (symbol-value var))))
5470 (set var (list (symbol-value var))))
5471 (when (not (listp (cdr articles)))
5472 (setq articles (list articles)))
5473 (while articles
5474 (when (or (not (consp (setq article (pop articles))))
5475 (< (car article) min)
5476 (> (car article) max))
5477 (set var (delq article (symbol-value var))))))
5478 ;; Adjust ranges (sloppily).
5479 ((eq mark-type 'range)
5480 (cond
5481 ((eq mark 'seen)
5482 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5483 ;; It should be (seen (NUM1 . NUM2)).
5484 (when (numberp (cddr marks))
5485 (setcdr marks (list (cdr marks))))
5486 (setq articles (cdr marks))
5487 (while (and articles
5488 (or (and (consp (car articles))
5489 (> min (cdar articles)))
5490 (and (numberp (car articles))
5491 (> min (car articles)))))
5492 (pop articles))
5493 (set var articles))))))))
5494
5495 (defun gnus-update-missing-marks (missing)
5496 "Go through the list of MISSING articles and remove them from the mark lists."
5497 (when missing
5498 (let (var m)
5499 ;; Go through all types.
5500 (dolist (elem gnus-article-mark-lists)
5501 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5502 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5503 (when (symbol-value var)
5504 ;; This list has articles. So we delete all missing
5505 ;; articles from it.
5506 (setq m missing)
5507 (while m
5508 (set var (delq (pop m) (symbol-value var))))))))))
5509
5510 (defun gnus-update-marks ()
5511 "Enter the various lists of marked articles into the newsgroup info list."
5512 (let ((types gnus-article-mark-lists)
5513 (info (gnus-get-info gnus-newsgroup-name))
5514 type list newmarked symbol delta-marks)
5515 (when info
5516 ;; Add all marks lists to the list of marks lists.
5517 (while (setq type (pop types))
5518 (setq list (symbol-value
5519 (setq symbol
5520 (intern (format "gnus-newsgroup-%s" (car type))))))
5521
5522 (when list
5523 ;; Get rid of the entries of the articles that have the
5524 ;; default score.
5525 (when (and (eq (cdr type) 'score)
5526 gnus-save-score
5527 list)
5528 (let* ((arts list)
5529 (prev (cons nil list))
5530 (all prev))
5531 (while arts
5532 (if (or (not (consp (car arts)))
5533 (= (cdar arts) gnus-summary-default-score))
5534 (setcdr prev (cdr arts))
5535 (setq prev arts))
5536 (setq arts (cdr arts)))
5537 (setq list (cdr all)))))
5538
5539 (when (eq (cdr type) 'seen)
5540 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5541
5542 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5543 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5544
5545 (when (and (gnus-check-backend-function
5546 'request-set-mark gnus-newsgroup-name)
5547 (not (gnus-article-unpropagatable-p (cdr type))))
5548 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5549 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5550 (add (gnus-remove-from-range
5551 (gnus-copy-sequence list) old)))
5552 (when add
5553 (push (list add 'add (list (cdr type))) delta-marks))
5554 (when del
5555 (push (list del 'del (list (cdr type))) delta-marks))))
5556
5557 (when list
5558 (push (cons (cdr type) list) newmarked)))
5559
5560 (when delta-marks
5561 (unless (gnus-check-group gnus-newsgroup-name)
5562 (error "Can't open server for %s" gnus-newsgroup-name))
5563 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5564
5565 ;; Enter these new marks into the info of the group.
5566 (if (nthcdr 3 info)
5567 (setcar (nthcdr 3 info) newmarked)
5568 ;; Add the marks lists to the end of the info.
5569 (when newmarked
5570 (setcdr (nthcdr 2 info) (list newmarked))))
5571
5572 ;; Cut off the end of the info if there's nothing else there.
5573 (let ((i 5))
5574 (while (and (> i 2)
5575 (not (nth i info)))
5576 (when (nthcdr (decf i) info)
5577 (setcdr (nthcdr i info) nil)))))))
5578
5579 (defun gnus-set-mode-line (where)
5580 "Set the mode line of the article or summary buffers.
5581 If WHERE is `summary', the summary mode line format will be used."
5582 ;; Is this mode line one we keep updated?
5583 (when (and (memq where gnus-updated-mode-lines)
5584 (symbol-value
5585 (intern (format "gnus-%s-mode-line-format-spec" where))))
5586 (let (mode-string)
5587 (save-excursion
5588 ;; We evaluate this in the summary buffer since these
5589 ;; variables are buffer-local to that buffer.
5590 (set-buffer gnus-summary-buffer)
5591 ;; We bind all these variables that are used in the `eval' form
5592 ;; below.
5593 (let* ((mformat (symbol-value
5594 (intern
5595 (format "gnus-%s-mode-line-format-spec" where))))
5596 (gnus-tmp-group-name (gnus-group-decoded-name
5597 gnus-newsgroup-name))
5598 (gnus-tmp-article-number (or gnus-current-article 0))
5599 (gnus-tmp-unread gnus-newsgroup-unreads)
5600 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5601 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5602 (gnus-tmp-unread-and-unselected
5603 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5604 (zerop gnus-tmp-unselected))
5605 "")
5606 ((zerop gnus-tmp-unselected)
5607 (format "{%d more}" gnus-tmp-unread-and-unticked))
5608 (t (format "{%d(+%d) more}"
5609 gnus-tmp-unread-and-unticked
5610 gnus-tmp-unselected))))
5611 (gnus-tmp-subject
5612 (if (and gnus-current-headers
5613 (vectorp gnus-current-headers))
5614 (gnus-mode-string-quote
5615 (mail-header-subject gnus-current-headers))
5616 ""))
5617 bufname-length max-len
5618 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5619 (setq mode-string (eval mformat))
5620 (setq bufname-length (if (string-match "%b" mode-string)
5621 (- (length
5622 (buffer-name
5623 (if (eq where 'summary)
5624 nil
5625 (get-buffer gnus-article-buffer))))
5626 2)
5627 0))
5628 (setq max-len (max 4 (if gnus-mode-non-string-length
5629 (- (window-width)
5630 gnus-mode-non-string-length
5631 bufname-length)
5632 (length mode-string))))
5633 ;; We might have to chop a bit of the string off...
5634 (when (> (length mode-string) max-len)
5635 (setq mode-string
5636 (concat (truncate-string-to-width mode-string (- max-len 3))
5637 "...")))
5638 ;; Pad the mode string a bit.
5639 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5640 ;; Update the mode line.
5641 (setq mode-line-buffer-identification
5642 (gnus-mode-line-buffer-identification (list mode-string)))
5643 (set-buffer-modified-p t))))
5644
5645 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5646 "Go through the HEADERS list and add all Xrefs to a hash table.
5647 The resulting hash table is returned, or nil if no Xrefs were found."
5648 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5649 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5650 (xref-hashtb (gnus-make-hashtable))
5651 start group entry number xrefs header)
5652 (while headers
5653 (setq header (pop headers))
5654 (when (and (setq xrefs (mail-header-xref header))
5655 (not (memq (setq number (mail-header-number header))
5656 unreads)))
5657 (setq start 0)
5658 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5659 (setq start (match-end 0))
5660 (setq group (if prefix
5661 (concat prefix (substring xrefs (match-beginning 1)
5662 (match-end 1)))
5663 (substring xrefs (match-beginning 1) (match-end 1))))
5664 (setq number
5665 (string-to-number (substring xrefs (match-beginning 2)
5666 (match-end 2))))
5667 (if (setq entry (gnus-gethash group xref-hashtb))
5668 (setcdr entry (cons number (cdr entry)))
5669 (gnus-sethash group (cons number nil) xref-hashtb)))))
5670 (and start xref-hashtb)))
5671
5672 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5673 "Look through all the headers and mark the Xrefs as read."
5674 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5675 name entry info xref-hashtb idlist method nth4)
5676 (save-excursion
5677 (set-buffer gnus-group-buffer)
5678 (when (setq xref-hashtb
5679 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5680 (mapatoms
5681 (lambda (group)
5682 (unless (string= from-newsgroup (setq name (symbol-name group)))
5683 (setq idlist (symbol-value group))
5684 ;; Dead groups are not updated.
5685 (and (prog1
5686 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5687 info (nth 2 entry))
5688 (when (stringp (setq nth4 (gnus-info-method info)))
5689 (setq nth4 (gnus-server-to-method nth4))))
5690 ;; Only do the xrefs if the group has the same
5691 ;; select method as the group we have just read.
5692 (or (gnus-methods-equal-p
5693 nth4 (gnus-find-method-for-group from-newsgroup))
5694 virtual
5695 (equal nth4 (setq method (gnus-find-method-for-group
5696 from-newsgroup)))
5697 (and (equal (car nth4) (car method))
5698 (equal (nth 1 nth4) (nth 1 method))))
5699 gnus-use-cross-reference
5700 (or (not (eq gnus-use-cross-reference t))
5701 virtual
5702 ;; Only do cross-references on subscribed
5703 ;; groups, if that is what is wanted.
5704 (<= (gnus-info-level info) gnus-level-subscribed))
5705 (gnus-group-make-articles-read name idlist))))
5706 xref-hashtb)))))
5707
5708 (defun gnus-compute-read-articles (group articles)
5709 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5710 (info (nth 2 entry))
5711 (active (gnus-active group))
5712 ninfo)
5713 (when entry
5714 ;; First peel off all invalid article numbers.
5715 (when active
5716 (let ((ids articles)
5717 id first)
5718 (while (setq id (pop ids))
5719 (when (and first (> id (cdr active)))
5720 ;; We'll end up in this situation in one particular
5721 ;; obscure situation. If you re-scan a group and get
5722 ;; a new article that is cross-posted to a different
5723 ;; group that has not been re-scanned, you might get
5724 ;; crossposted article that has a higher number than
5725 ;; Gnus believes possible. So we re-activate this
5726 ;; group as well. This might mean doing the
5727 ;; crossposting thingy will *increase* the number
5728 ;; of articles in some groups. Tsk, tsk.
5729 (setq active (or (gnus-activate-group group) active)))
5730 (when (or (> id (cdr active))
5731 (< id (car active)))
5732 (setq articles (delq id articles))))))
5733 ;; If the read list is nil, we init it.
5734 (if (and active
5735 (null (gnus-info-read info))
5736 (> (car active) 1))
5737 (setq ninfo (cons 1 (1- (car active))))
5738 (setq ninfo (gnus-info-read info)))
5739 ;; Then we add the read articles to the range.
5740 (gnus-add-to-range
5741 ninfo (setq articles (sort articles '<))))))
5742
5743 (defun gnus-group-make-articles-read (group articles)
5744 "Update the info of GROUP to say that ARTICLES are read."
5745 (let* ((num 0)
5746 (entry (gnus-gethash group gnus-newsrc-hashtb))
5747 (info (nth 2 entry))
5748 (active (gnus-active group))
5749 range)
5750 (when entry
5751 (setq range (gnus-compute-read-articles group articles))
5752 (save-excursion
5753 (set-buffer gnus-group-buffer)
5754 (gnus-undo-register
5755 `(progn
5756 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5757 (gnus-info-set-read ',info ',(gnus-info-read info))
5758 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5759 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5760 (gnus-group-update-group ,group t))))
5761 ;; Add the read articles to the range.
5762 (gnus-info-set-read info range)
5763 (gnus-request-set-mark group (list (list range 'add '(read))))
5764 ;; Then we have to re-compute how many unread
5765 ;; articles there are in this group.
5766 (when active
5767 (cond
5768 ((not range)
5769 (setq num (- (1+ (cdr active)) (car active))))
5770 ((not (listp (cdr range)))
5771 (setq num (- (cdr active) (- (1+ (cdr range))
5772 (car range)))))
5773 (t
5774 (while range
5775 (if (numberp (car range))
5776 (setq num (1+ num))
5777 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5778 (setq range (cdr range)))
5779 (setq num (- (cdr active) num))))
5780 ;; Update the number of unread articles.
5781 (setcar entry num)
5782 ;; Update the group buffer.
5783 (unless (gnus-ephemeral-group-p group)
5784 (gnus-group-update-group group t))))))
5785
5786 (defvar gnus-newsgroup-none-id 0)
5787
5788 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5789 (let ((cur nntp-server-buffer)
5790 (dependencies
5791 (or dependencies
5792 (save-excursion (set-buffer gnus-summary-buffer)
5793 gnus-newsgroup-dependencies)))
5794 headers id end ref
5795 (mail-parse-charset gnus-newsgroup-charset)
5796 (mail-parse-ignored-charsets
5797 (save-excursion (condition-case nil
5798 (set-buffer gnus-summary-buffer)
5799 (error))
5800 gnus-newsgroup-ignored-charsets)))
5801 (save-excursion
5802 (set-buffer nntp-server-buffer)
5803 ;; Translate all TAB characters into SPACE characters.
5804 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5805 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5806 (ietf-drums-unfold-fws)
5807 (gnus-run-hooks 'gnus-parse-headers-hook)
5808 (let ((case-fold-search t)
5809 in-reply-to header p lines chars)
5810 (goto-char (point-min))
5811 ;; Search to the beginning of the next header. Error messages
5812 ;; do not begin with 2 or 3.
5813 (while (re-search-forward "^[23][0-9]+ " nil t)
5814 (setq id nil
5815 ref nil)
5816 ;; This implementation of this function, with nine
5817 ;; search-forwards instead of the one re-search-forward and
5818 ;; a case (which basically was the old function) is actually
5819 ;; about twice as fast, even though it looks messier. You
5820 ;; can't have everything, I guess. Speed and elegance
5821 ;; doesn't always go hand in hand.
5822 (setq
5823 header
5824 (vector
5825 ;; Number.
5826 (prog1
5827 (read cur)
5828 (end-of-line)
5829 (setq p (point))
5830 (narrow-to-region (point)
5831 (or (and (search-forward "\n.\n" nil t)
5832 (- (point) 2))
5833 (point))))
5834 ;; Subject.
5835 (progn
5836 (goto-char p)
5837 (if (search-forward "\nsubject:" nil t)
5838 (funcall gnus-decode-encoded-word-function
5839 (nnheader-header-value))
5840 "(none)"))
5841 ;; From.
5842 (progn
5843 (goto-char p)
5844 (if (search-forward "\nfrom:" nil t)
5845 (funcall gnus-decode-encoded-word-function
5846 (nnheader-header-value))
5847 "(nobody)"))
5848 ;; Date.
5849 (progn
5850 (goto-char p)
5851 (if (search-forward "\ndate:" nil t)
5852 (nnheader-header-value) ""))
5853 ;; Message-ID.
5854 (progn
5855 (goto-char p)
5856 (setq id (if (re-search-forward
5857 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5858 ;; We do it this way to make sure the Message-ID
5859 ;; is (somewhat) syntactically valid.
5860 (buffer-substring (match-beginning 1)
5861 (match-end 1))
5862 ;; If there was no message-id, we just fake one
5863 ;; to make subsequent routines simpler.
5864 (nnheader-generate-fake-message-id))))
5865 ;; References.
5866 (progn
5867 (goto-char p)
5868 (if (search-forward "\nreferences:" nil t)
5869 (progn
5870 (setq end (point))
5871 (prog1
5872 (nnheader-header-value)
5873 (setq ref
5874 (buffer-substring
5875 (progn
5876 (end-of-line)
5877 (search-backward ">" end t)
5878 (1+ (point)))
5879 (progn
5880 (search-backward "<" end t)
5881 (point))))))
5882 ;; Get the references from the in-reply-to header if there
5883 ;; were no references and the in-reply-to header looks
5884 ;; promising.
5885 (if (and (search-forward "\nin-reply-to:" nil t)
5886 (setq in-reply-to (nnheader-header-value))
5887 (string-match "<[^>]+>" in-reply-to))
5888 (let (ref2)
5889 (setq ref (substring in-reply-to (match-beginning 0)
5890 (match-end 0)))
5891 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5892 (setq ref2 (substring in-reply-to (match-beginning 0)
5893 (match-end 0)))
5894 (when (> (length ref2) (length ref))
5895 (setq ref ref2)))
5896 ref)
5897 (setq ref nil))))
5898 ;; Chars.
5899 (progn
5900 (goto-char p)
5901 (if (search-forward "\nchars: " nil t)
5902 (if (numberp (setq chars (ignore-errors (read cur))))
5903 chars -1)
5904 -1))
5905 ;; Lines.
5906 (progn
5907 (goto-char p)
5908 (if (search-forward "\nlines: " nil t)
5909 (if (numberp (setq lines (ignore-errors (read cur))))
5910 lines -1)
5911 -1))
5912 ;; Xref.
5913 (progn
5914 (goto-char p)
5915 (and (search-forward "\nxref:" nil t)
5916 (nnheader-header-value)))
5917 ;; Extra.
5918 (when gnus-extra-headers
5919 (let ((extra gnus-extra-headers)
5920 out)
5921 (while extra
5922 (goto-char p)
5923 (when (search-forward
5924 (concat "\n" (symbol-name (car extra)) ":") nil t)
5925 (push (cons (car extra) (nnheader-header-value))
5926 out))
5927 (pop extra))
5928 out))))
5929 (when (equal id ref)
5930 (setq ref nil))
5931
5932 (when gnus-alter-header-function
5933 (funcall gnus-alter-header-function header)
5934 (setq id (mail-header-id header)
5935 ref (gnus-parent-id (mail-header-references header))))
5936
5937 (when (setq header
5938 (gnus-dependencies-add-header
5939 header dependencies force-new))
5940 (push header headers))
5941 (goto-char (point-max))
5942 (widen))
5943 (nreverse headers)))))
5944
5945 ;; Goes through the xover lines and returns a list of vectors
5946 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5947 force-new dependencies
5948 group also-fetch-heads)
5949 "Parse the news overview data in the server buffer.
5950 Return a list of headers that match SEQUENCE (see
5951 `nntp-retrieve-headers')."
5952 ;; Get the Xref when the users reads the articles since most/some
5953 ;; NNTP servers do not include Xrefs when using XOVER.
5954 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5955 (let ((mail-parse-charset gnus-newsgroup-charset)
5956 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5957 (cur nntp-server-buffer)
5958 (dependencies (or dependencies gnus-newsgroup-dependencies))
5959 (allp (cond
5960 ((eq gnus-read-all-available-headers t)
5961 t)
5962 ((stringp gnus-read-all-available-headers)
5963 (string-match gnus-read-all-available-headers group))
5964 (t
5965 nil)))
5966 number headers header)
5967 (save-excursion
5968 (set-buffer nntp-server-buffer)
5969 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5970 ;; Allow the user to mangle the headers before parsing them.
5971 (gnus-run-hooks 'gnus-parse-headers-hook)
5972 (goto-char (point-min))
5973 (gnus-parse-without-error
5974 (while (and (or sequence allp)
5975 (not (eobp)))
5976 (setq number (read cur))
5977 (when (not allp)
5978 (while (and sequence
5979 (< (car sequence) number))
5980 (setq sequence (cdr sequence))))
5981 (when (and (or allp
5982 (and sequence
5983 (eq number (car sequence))))
5984 (progn
5985 (setq sequence (cdr sequence))
5986 (setq header (inline
5987 (gnus-nov-parse-line
5988 number dependencies force-new)))))
5989 (push header headers))
5990 (forward-line 1)))
5991 ;; A common bug in inn is that if you have posted an article and
5992 ;; then retrieves the active file, it will answer correctly --
5993 ;; the new article is included. However, a NOV entry for the
5994 ;; article may not have been generated yet, so this may fail.
5995 ;; We work around this problem by retrieving the last few
5996 ;; headers using HEAD.
5997 (if (or (not also-fetch-heads)
5998 (not sequence))
5999 ;; We (probably) got all the headers.
6000 (nreverse headers)
6001 (let ((gnus-nov-is-evil t))
6002 (nconc
6003 (nreverse headers)
6004 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6005 (gnus-get-newsgroup-headers))))))))
6006
6007 (defun gnus-article-get-xrefs ()
6008 "Fill in the Xref value in `gnus-current-headers', if necessary.
6009 This is meant to be called in `gnus-article-internal-prepare-hook'."
6010 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6011 gnus-current-headers)))
6012 (or (not gnus-use-cross-reference)
6013 (not headers)
6014 (and (mail-header-xref headers)
6015 (not (string= (mail-header-xref headers) "")))
6016 (let ((case-fold-search t)
6017 xref)
6018 (save-restriction
6019 (nnheader-narrow-to-headers)
6020 (goto-char (point-min))
6021 (when (or (and (not (eobp))
6022 (eq (downcase (char-after)) ?x)
6023 (looking-at "Xref:"))
6024 (search-forward "\nXref:" nil t))
6025 (goto-char (1+ (match-end 0)))
6026 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
6027 (mail-header-set-xref headers xref)))))))
6028
6029 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6030 "Find article ID and insert the summary line for that article.
6031 OLD-HEADER can either be a header or a line number to insert
6032 the subject line on."
6033 (let* ((line (and (numberp old-header) old-header))
6034 (old-header (and (vectorp old-header) old-header))
6035 (header (cond ((and old-header use-old-header)
6036 old-header)
6037 ((and (numberp id)
6038 (gnus-number-to-header id))
6039 (gnus-number-to-header id))
6040 (t
6041 (gnus-read-header id))))
6042 (number (and (numberp id) id))
6043 d)
6044 (when header
6045 ;; Rebuild the thread that this article is part of and go to the
6046 ;; article we have fetched.
6047 (when (and (not gnus-show-threads)
6048 old-header)
6049 (when (and number
6050 (setq d (gnus-data-find (mail-header-number old-header))))
6051 (goto-char (gnus-data-pos d))
6052 (gnus-data-remove
6053 number
6054 (- (gnus-point-at-bol)
6055 (prog1
6056 (1+ (gnus-point-at-eol))
6057 (gnus-delete-line))))))
6058 ;; Remove list identifiers from subject.
6059 (when gnus-list-identifiers
6060 (let ((gnus-newsgroup-headers (list header)))
6061 (gnus-summary-remove-list-identifiers)))
6062 (when old-header
6063 (mail-header-set-number header (mail-header-number old-header)))
6064 (setq gnus-newsgroup-sparse
6065 (delq (setq number (mail-header-number header))
6066 gnus-newsgroup-sparse))
6067 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6068 (push number gnus-newsgroup-limit)
6069 (gnus-rebuild-thread (mail-header-id header) line)
6070 (gnus-summary-goto-subject number nil t))
6071 (when (and (numberp number)
6072 (> number 0))
6073 ;; We have to update the boundaries even if we can't fetch the
6074 ;; article if ID is a number -- so that the next `P' or `N'
6075 ;; command will fetch the previous (or next) article even
6076 ;; if the one we tried to fetch this time has been canceled.
6077 (when (> number gnus-newsgroup-end)
6078 (setq gnus-newsgroup-end number))
6079 (when (< number gnus-newsgroup-begin)
6080 (setq gnus-newsgroup-begin number))
6081 (setq gnus-newsgroup-unselected
6082 (delq number gnus-newsgroup-unselected)))
6083 ;; Report back a success?
6084 (and header (mail-header-number header))))
6085
6086 ;;; Process/prefix in the summary buffer
6087
6088 (defun gnus-summary-work-articles (n)
6089 "Return a list of articles to be worked upon.
6090 The prefix argument, the list of process marked articles, and the
6091 current article will be taken into consideration."
6092 (save-excursion
6093 (set-buffer gnus-summary-buffer)
6094 (cond
6095 (n
6096 ;; A numerical prefix has been given.
6097 (setq n (prefix-numeric-value n))
6098 (let ((backward (< n 0))
6099 (n (abs (prefix-numeric-value n)))
6100 articles article)
6101 (save-excursion
6102 (while
6103 (and (> n 0)
6104 (push (setq article (gnus-summary-article-number))
6105 articles)
6106 (if backward
6107 (gnus-summary-find-prev nil article)
6108 (gnus-summary-find-next nil article)))
6109 (decf n)))
6110 (nreverse articles)))
6111 ((and (gnus-region-active-p) (mark))
6112 (message "region active")
6113 ;; Work on the region between point and mark.
6114 (let ((max (max (point) (mark)))
6115 articles article)
6116 (save-excursion
6117 (goto-char (min (min (point) (mark))))
6118 (while
6119 (and
6120 (push (setq article (gnus-summary-article-number)) articles)
6121 (gnus-summary-find-next nil article)
6122 (< (point) max)))
6123 (nreverse articles))))
6124 (gnus-newsgroup-processable
6125 ;; There are process-marked articles present.
6126 ;; Save current state.
6127 (gnus-summary-save-process-mark)
6128 ;; Return the list.
6129 (reverse gnus-newsgroup-processable))
6130 (t
6131 ;; Just return the current article.
6132 (list (gnus-summary-article-number))))))
6133
6134 (defmacro gnus-summary-iterate (arg &rest forms)
6135 "Iterate over the process/prefixed articles and do FORMS.
6136 ARG is the interactive prefix given to the command. FORMS will be
6137 executed with point over the summary line of the articles."
6138 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6139 `(let ((,articles (gnus-summary-work-articles ,arg)))
6140 (while ,articles
6141 (gnus-summary-goto-subject (car ,articles))
6142 ,@forms
6143 (pop ,articles)))))
6144
6145 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6146 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6147
6148 (defun gnus-summary-save-process-mark ()
6149 "Push the current set of process marked articles on the stack."
6150 (interactive)
6151 (push (copy-sequence gnus-newsgroup-processable)
6152 gnus-newsgroup-process-stack))
6153
6154 (defun gnus-summary-kill-process-mark ()
6155 "Push the current set of process marked articles on the stack and unmark."
6156 (interactive)
6157 (gnus-summary-save-process-mark)
6158 (gnus-summary-unmark-all-processable))
6159
6160 (defun gnus-summary-yank-process-mark ()
6161 "Pop the last process mark state off the stack and restore it."
6162 (interactive)
6163 (unless gnus-newsgroup-process-stack
6164 (error "Empty mark stack"))
6165 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6166
6167 (defun gnus-summary-process-mark-set (set)
6168 "Make SET into the current process marked articles."
6169 (gnus-summary-unmark-all-processable)
6170 (while set
6171 (gnus-summary-set-process-mark (pop set))))
6172
6173 ;;; Searching and stuff
6174
6175 (defun gnus-summary-search-group (&optional backward use-level)
6176 "Search for next unread newsgroup.
6177 If optional argument BACKWARD is non-nil, search backward instead."
6178 (save-excursion
6179 (set-buffer gnus-group-buffer)
6180 (when (gnus-group-search-forward
6181 backward nil (if use-level (gnus-group-group-level) nil))
6182 (gnus-group-group-name))))
6183
6184 (defun gnus-summary-best-group (&optional exclude-group)
6185 "Find the name of the best unread group.
6186 If EXCLUDE-GROUP, do not go to this group."
6187 (save-excursion
6188 (set-buffer gnus-group-buffer)
6189 (save-excursion
6190 (gnus-group-best-unread-group exclude-group))))
6191
6192 (defun gnus-summary-find-next (&optional unread article backward)
6193 (if backward
6194 (gnus-summary-find-prev unread article)
6195 (let* ((dummy (gnus-summary-article-intangible-p))
6196 (article (or article (gnus-summary-article-number)))
6197 (data (gnus-data-find-list article))
6198 result)
6199 (when (and (not dummy)
6200 (or (not gnus-summary-check-current)
6201 (not unread)
6202 (not (gnus-data-unread-p (car data)))))
6203 (setq data (cdr data)))
6204 (when (setq result
6205 (if unread
6206 (progn
6207 (while data
6208 (unless (memq (gnus-data-number (car data))
6209 (cond
6210 ((eq gnus-auto-goto-ignores
6211 'always-undownloaded)
6212 gnus-newsgroup-undownloaded)
6213 (gnus-plugged
6214 nil)
6215 ((eq gnus-auto-goto-ignores
6216 'unfetched)
6217 gnus-newsgroup-unfetched)
6218 ((eq gnus-auto-goto-ignores
6219 'undownloaded)
6220 gnus-newsgroup-undownloaded)))
6221 (when (gnus-data-unread-p (car data))
6222 (setq result (car data)
6223 data nil)))
6224 (setq data (cdr data)))
6225 result)
6226 (car data)))
6227 (goto-char (gnus-data-pos result))
6228 (gnus-data-number result)))))
6229
6230 (defun gnus-summary-find-prev (&optional unread article)
6231 (let* ((eobp (eobp))
6232 (article (or article (gnus-summary-article-number)))
6233 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6234 result)
6235 (when (and (not eobp)
6236 (or (not gnus-summary-check-current)
6237 (not unread)
6238 (not (gnus-data-unread-p (car data)))))
6239 (setq data (cdr data)))
6240 (when (setq result
6241 (if unread
6242 (progn
6243 (while data
6244 (unless (memq (gnus-data-number (car data))
6245 (cond
6246 ((eq gnus-auto-goto-ignores
6247 'always-undownloaded)
6248 gnus-newsgroup-undownloaded)
6249 (gnus-plugged
6250 nil)
6251 ((eq gnus-auto-goto-ignores
6252 'unfetched)
6253 gnus-newsgroup-unfetched)
6254 ((eq gnus-auto-goto-ignores
6255 'undownloaded)
6256 gnus-newsgroup-undownloaded)))
6257 (when (gnus-data-unread-p (car data))
6258 (setq result (car data)
6259 data nil)))
6260 (setq data (cdr data)))
6261 result)
6262 (car data)))
6263 (goto-char (gnus-data-pos result))
6264 (gnus-data-number result))))
6265
6266 (defun gnus-summary-find-subject (subject &optional unread backward article)
6267 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6268 (article (or article (gnus-summary-article-number)))
6269 (articles (gnus-data-list backward))
6270 (arts (gnus-data-find-list article articles))
6271 result)
6272 (when (or (not gnus-summary-check-current)
6273 (not unread)
6274 (not (gnus-data-unread-p (car arts))))
6275 (setq arts (cdr arts)))
6276 (while arts
6277 (and (or (not unread)
6278 (gnus-data-unread-p (car arts)))
6279 (vectorp (gnus-data-header (car arts)))
6280 (gnus-subject-equal
6281 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6282 (setq result (car arts)
6283 arts nil))
6284 (setq arts (cdr arts)))
6285 (and result
6286 (goto-char (gnus-data-pos result))
6287 (gnus-data-number result))))
6288
6289 (defun gnus-summary-search-forward (&optional unread subject backward)
6290 "Search forward for an article.
6291 If UNREAD, look for unread articles. If SUBJECT, look for
6292 articles with that subject. If BACKWARD, search backward instead."
6293 (cond (subject (gnus-summary-find-subject subject unread backward))
6294 (backward (gnus-summary-find-prev unread))
6295 (t (gnus-summary-find-next unread))))
6296
6297 (defun gnus-recenter (&optional n)
6298 "Center point in window and redisplay frame.
6299 Also do horizontal recentering."
6300 (interactive "P")
6301 (when (and gnus-auto-center-summary
6302 (not (eq gnus-auto-center-summary 'vertical)))
6303 (gnus-horizontal-recenter))
6304 (recenter n))
6305
6306 (defun gnus-summary-recenter ()
6307 "Center point in the summary window.
6308 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6309 displayed, no centering will be performed."
6310 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6311 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6312 (interactive)
6313 ;; The user has to want it.
6314 (when gnus-auto-center-summary
6315 (let* ((top (cond ((< (window-height) 4) 0)
6316 ((< (window-height) 7) 1)
6317 (t (if (numberp gnus-auto-center-summary)
6318 gnus-auto-center-summary
6319 2))))
6320 (height (1- (window-height)))
6321 (bottom (save-excursion (goto-char (point-max))
6322 (forward-line (- height))
6323 (point)))
6324 (window (get-buffer-window (current-buffer))))
6325 (when (get-buffer-window gnus-article-buffer)
6326 ;; Only do recentering when the article buffer is displayed,
6327 ;; Set the window start to either `bottom', which is the biggest
6328 ;; possible valid number, or the second line from the top,
6329 ;; whichever is the least.
6330 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6331 (if (> bottom top-pos)
6332 ;; Keep the second line from the top visible
6333 (set-window-start window top-pos t)
6334 ;; Try to keep the bottom line visible; if it's partially
6335 ;; obscured, either scroll one more line to make it fully
6336 ;; visible, or revert to using TOP-POS.
6337 (save-excursion
6338 (goto-char (point-max))
6339 (forward-line -1)
6340 (let ((last-line-start (point)))
6341 (goto-char bottom)
6342 (set-window-start window (point) t)
6343 (when (not (pos-visible-in-window-p last-line-start window))
6344 (forward-line 1)
6345 (set-window-start window (min (point) top-pos) t)))))))
6346 ;; Do horizontal recentering while we're at it.
6347 (when (and (get-buffer-window (current-buffer) t)
6348 (not (eq gnus-auto-center-summary 'vertical)))
6349 (let ((selected (selected-window)))
6350 (select-window (get-buffer-window (current-buffer) t))
6351 (gnus-summary-position-point)
6352 (gnus-horizontal-recenter)
6353 (select-window selected))))))
6354
6355 (defun gnus-summary-jump-to-group (newsgroup)
6356 "Move point to NEWSGROUP in group mode buffer."
6357 ;; Keep update point of group mode buffer if visible.
6358 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6359 (save-window-excursion
6360 ;; Take care of tree window mode.
6361 (when (get-buffer-window gnus-group-buffer)
6362 (pop-to-buffer gnus-group-buffer))
6363 (gnus-group-jump-to-group newsgroup))
6364 (save-excursion
6365 ;; Take care of tree window mode.
6366 (if (get-buffer-window gnus-group-buffer)
6367 (pop-to-buffer gnus-group-buffer)
6368 (set-buffer gnus-group-buffer))
6369 (gnus-group-jump-to-group newsgroup))))
6370
6371 ;; This function returns a list of article numbers based on the
6372 ;; difference between the ranges of read articles in this group and
6373 ;; the range of active articles.
6374 (defun gnus-list-of-unread-articles (group)
6375 (let* ((read (gnus-info-read (gnus-get-info group)))
6376 (active (or (gnus-active group) (gnus-activate-group group)))
6377 (last (cdr active))
6378 first nlast unread)
6379 ;; If none are read, then all are unread.
6380 (if (not read)
6381 (setq first (car active))
6382 ;; If the range of read articles is a single range, then the
6383 ;; first unread article is the article after the last read
6384 ;; article. Sounds logical, doesn't it?
6385 (if (and (not (listp (cdr read)))
6386 (or (< (car read) (car active))
6387 (progn (setq read (list read))
6388 nil)))
6389 (setq first (max (car active) (1+ (cdr read))))
6390 ;; `read' is a list of ranges.
6391 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6392 (caar read)))
6393 1)
6394 (setq first (car active)))
6395 (while read
6396 (when first
6397 (while (< first nlast)
6398 (setq unread (cons first unread)
6399 first (1+ first))))
6400 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6401 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6402 (setq read (cdr read)))))
6403 ;; And add the last unread articles.
6404 (while (<= first last)
6405 (setq unread (cons first unread)
6406 first (1+ first)))
6407 ;; Return the list of unread articles.
6408 (delq 0 (nreverse unread))))
6409
6410 (defun gnus-list-of-read-articles (group)
6411 "Return a list of unread, unticked and non-dormant articles."
6412 (let* ((info (gnus-get-info group))
6413 (marked (gnus-info-marks info))
6414 (active (gnus-active group)))
6415 (and info active
6416 (gnus-list-range-difference
6417 (gnus-list-range-difference
6418 (gnus-sorted-complement
6419 (gnus-uncompress-range active)
6420 (gnus-list-of-unread-articles group))
6421 (cdr (assq 'dormant marked)))
6422 (cdr (assq 'tick marked))))))
6423
6424 ;; This function returns a sequence of article numbers based on the
6425 ;; difference between the ranges of read articles in this group and
6426 ;; the range of active articles.
6427 (defun gnus-sequence-of-unread-articles (group)
6428 (let* ((read (gnus-info-read (gnus-get-info group)))
6429 (active (or (gnus-active group) (gnus-activate-group group)))
6430 (last (cdr active))
6431 first nlast unread)
6432 ;; If none are read, then all are unread.
6433 (if (not read)
6434 (setq first (car active))
6435 ;; If the range of read articles is a single range, then the
6436 ;; first unread article is the article after the last read
6437 ;; article. Sounds logical, doesn't it?
6438 (if (and (not (listp (cdr read)))
6439 (or (< (car read) (car active))
6440 (progn (setq read (list read))
6441 nil)))
6442 (setq first (max (car active) (1+ (cdr read))))
6443 ;; `read' is a list of ranges.
6444 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6445 (caar read)))
6446 1)
6447 (setq first (car active)))
6448 (while read
6449 (when first
6450 (push (cons first nlast) unread))
6451 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6452 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6453 (setq read (cdr read)))))
6454 ;; And add the last unread articles.
6455 (cond ((< first last)
6456 (push (cons first last) unread))
6457 ((= first last)
6458 (push first unread)))
6459 ;; Return the sequence of unread articles.
6460 (delq 0 (nreverse unread))))
6461
6462 ;; Various summary commands
6463
6464 (defun gnus-summary-select-article-buffer ()
6465 "Reconfigure windows to show article buffer."
6466 (interactive)
6467 (if (not (gnus-buffer-live-p gnus-article-buffer))
6468 (error "There is no article buffer for this summary buffer")
6469 (gnus-configure-windows 'article)
6470 (select-window (get-buffer-window gnus-article-buffer))))
6471
6472 (defun gnus-summary-universal-argument (arg)
6473 "Perform any operation on all articles that are process/prefixed."
6474 (interactive "P")
6475 (let ((articles (gnus-summary-work-articles arg))
6476 func article)
6477 (if (eq
6478 (setq
6479 func
6480 (key-binding
6481 (read-key-sequence
6482 (substitute-command-keys
6483 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6484 'undefined)
6485 (gnus-error 1 "Undefined key")
6486 (save-excursion
6487 (while articles
6488 (gnus-summary-goto-subject (setq article (pop articles)))
6489 (let (gnus-newsgroup-processable)
6490 (command-execute func))
6491 (gnus-summary-remove-process-mark article)))))
6492 (gnus-summary-position-point))
6493
6494 (defun gnus-summary-toggle-truncation (&optional arg)
6495 "Toggle truncation of summary lines.
6496 With ARG, turn line truncation on if ARG is positive."
6497 (interactive "P")
6498 (setq truncate-lines
6499 (if (null arg) (not truncate-lines)
6500 (> (prefix-numeric-value arg) 0)))
6501 (redraw-display))
6502
6503 (defun gnus-summary-find-for-reselect ()
6504 "Return the number of an article to stay on across a reselect.
6505 The current article is considered, then following articles, then previous
6506 articles. An article is sought which is not cancelled and isn't a temporary
6507 insertion from another group. If there's no such then return a dummy 0."
6508 (let (found)
6509 (dolist (rev '(nil t))
6510 (unless found ; don't demand the reverse list if we don't need it
6511 (let ((data (gnus-data-find-list
6512 (gnus-summary-article-number) (gnus-data-list rev))))
6513 (while (and data (not found))
6514 (if (and (< 0 (gnus-data-number (car data)))
6515 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6516 (setq found (gnus-data-number (car data))))
6517 (setq data (cdr data))))))
6518 (or found 0)))
6519
6520 (defun gnus-summary-reselect-current-group (&optional all rescan)
6521 "Exit and then reselect the current newsgroup.
6522 The prefix argument ALL means to select all articles."
6523 (interactive "P")
6524 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6525 (error "Ephemeral groups can't be reselected"))
6526 (let ((current-subject (gnus-summary-find-for-reselect))
6527 (group gnus-newsgroup-name))
6528 (setq gnus-newsgroup-begin nil)
6529 (gnus-summary-exit nil 'leave-hidden)
6530 ;; We have to adjust the point of group mode buffer because
6531 ;; point was moved to the next unread newsgroup by exiting.
6532 (gnus-summary-jump-to-group group)
6533 (when rescan
6534 (save-excursion
6535 (gnus-group-get-new-news-this-group 1)))
6536 (gnus-group-read-group all t)
6537 (gnus-summary-goto-subject current-subject nil t)))
6538
6539 (defun gnus-summary-rescan-group (&optional all)
6540 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6541 (interactive "P")
6542 (gnus-summary-reselect-current-group all t))
6543
6544 (defun gnus-summary-update-info (&optional non-destructive)
6545 (save-excursion
6546 (let ((group gnus-newsgroup-name))
6547 (when group
6548 (when gnus-newsgroup-kill-headers
6549 (setq gnus-newsgroup-killed
6550 (gnus-compress-sequence
6551 (gnus-sorted-union
6552 (gnus-list-range-intersection
6553 gnus-newsgroup-unselected gnus-newsgroup-killed)
6554 gnus-newsgroup-unreads)
6555 t)))
6556 (unless (listp (cdr gnus-newsgroup-killed))
6557 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6558 (let ((headers gnus-newsgroup-headers))
6559 ;; Set the new ranges of read articles.
6560 (save-excursion
6561 (set-buffer gnus-group-buffer)
6562 (gnus-undo-force-boundary))
6563 (gnus-update-read-articles
6564 group (gnus-sorted-union
6565 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6566 ;; Set the current article marks.
6567 (let ((gnus-newsgroup-scored
6568 (if (and (not gnus-save-score)
6569 (not non-destructive))
6570 nil
6571 gnus-newsgroup-scored)))
6572 (save-excursion
6573 (gnus-update-marks)))
6574 ;; Do the cross-ref thing.
6575 (when gnus-use-cross-reference
6576 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6577 ;; Do not switch windows but change the buffer to work.
6578 (set-buffer gnus-group-buffer)
6579 (unless (gnus-ephemeral-group-p group)
6580 (gnus-group-update-group group)))))))
6581
6582 (defun gnus-summary-save-newsrc (&optional force)
6583 "Save the current number of read/marked articles in the dribble buffer.
6584 The dribble buffer will then be saved.
6585 If FORCE (the prefix), also save the .newsrc file(s)."
6586 (interactive "P")
6587 (gnus-summary-update-info t)
6588 (if force
6589 (gnus-save-newsrc-file)
6590 (gnus-dribble-save)))
6591
6592 (defun gnus-summary-exit (&optional temporary leave-hidden)
6593 "Exit reading current newsgroup, and then return to group selection mode.
6594 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6595 (interactive)
6596 (gnus-set-global-variables)
6597 (when (gnus-buffer-live-p gnus-article-buffer)
6598 (save-excursion
6599 (set-buffer gnus-article-buffer)
6600 (mm-destroy-parts gnus-article-mime-handles)
6601 ;; Set it to nil for safety reason.
6602 (setq gnus-article-mime-handle-alist nil)
6603 (setq gnus-article-mime-handles nil)))
6604 (gnus-kill-save-kill-buffer)
6605 (gnus-async-halt-prefetch)
6606 (let* ((group gnus-newsgroup-name)
6607 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6608 (gnus-group-is-exiting-p t)
6609 (mode major-mode)
6610 (group-point nil)
6611 (buf (current-buffer)))
6612 (unless quit-config
6613 ;; Do adaptive scoring, and possibly save score files.
6614 (when gnus-newsgroup-adaptive
6615 (gnus-score-adaptive))
6616 (when gnus-use-scoring
6617 (gnus-score-save)))
6618 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6619 ;; If we have several article buffers, we kill them at exit.
6620 (unless gnus-single-article-buffer
6621 (gnus-kill-buffer gnus-original-article-buffer)
6622 (setq gnus-article-current nil))
6623 (when gnus-use-cache
6624 (gnus-cache-possibly-remove-articles)
6625 (gnus-cache-save-buffers))
6626 (gnus-async-prefetch-remove-group group)
6627 (when gnus-suppress-duplicates
6628 (gnus-dup-enter-articles))
6629 (when gnus-use-trees
6630 (gnus-tree-close group))
6631 (when gnus-use-cache
6632 (gnus-cache-write-active))
6633 ;; Remove entries for this group.
6634 (nnmail-purge-split-history (gnus-group-real-name group))
6635 ;; Make all changes in this group permanent.
6636 (unless quit-config
6637 (gnus-run-hooks 'gnus-exit-group-hook)
6638 (gnus-summary-update-info))
6639 (gnus-close-group group)
6640 ;; Make sure where we were, and go to next newsgroup.
6641 (set-buffer gnus-group-buffer)
6642 (unless quit-config
6643 (gnus-group-jump-to-group group))
6644 (gnus-run-hooks 'gnus-summary-exit-hook)
6645 (unless (or quit-config
6646 ;; If this group has disappeared from the summary
6647 ;; buffer, don't skip forwards.
6648 (not (string= group (gnus-group-group-name))))
6649 (gnus-group-next-unread-group 1))
6650 (setq group-point (point))
6651 (if temporary
6652 nil ;Nothing to do.
6653 ;; If we have several article buffers, we kill them at exit.
6654 (unless gnus-single-article-buffer
6655 (gnus-kill-buffer gnus-article-buffer)
6656 (gnus-kill-buffer gnus-original-article-buffer)
6657 (setq gnus-article-current nil))
6658 (set-buffer buf)
6659 (if (not gnus-kill-summary-on-exit)
6660 (progn
6661 (gnus-deaden-summary)
6662 (setq mode nil))
6663 ;; We set all buffer-local variables to nil. It is unclear why
6664 ;; this is needed, but if we don't, buffer-local variables are
6665 ;; not garbage-collected, it seems. This would the lead to en
6666 ;; ever-growing Emacs.
6667 (gnus-summary-clear-local-variables)
6668 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6669 (gnus-summary-clear-local-variables))
6670 (when (get-buffer gnus-article-buffer)
6671 (bury-buffer gnus-article-buffer))
6672 ;; We clear the global counterparts of the buffer-local
6673 ;; variables as well, just to be on the safe side.
6674 (set-buffer gnus-group-buffer)
6675 (gnus-summary-clear-local-variables)
6676 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6677 (gnus-summary-clear-local-variables))
6678 ;; Return to group mode buffer.
6679 (when (eq mode 'gnus-summary-mode)
6680 (gnus-kill-buffer buf)))
6681 (setq gnus-current-select-method gnus-select-method)
6682 (set-buffer gnus-group-buffer)
6683 (if quit-config
6684 (gnus-handle-ephemeral-exit quit-config)
6685 (goto-char group-point)
6686 ;; If gnus-group-buffer is already displayed, make sure we also move
6687 ;; the cursor in the window that displays it.
6688 (let ((win (get-buffer-window (current-buffer) 0)))
6689 (if win (set-window-point win (point))))
6690 (unless leave-hidden
6691 (gnus-configure-windows 'group 'force)))
6692 ;; Clear the current group name.
6693 (unless quit-config
6694 (setq gnus-newsgroup-name nil)))))
6695
6696 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6697 (defun gnus-summary-exit-no-update (&optional no-questions)
6698 "Quit reading current newsgroup without updating read article info."
6699 (interactive)
6700 (let* ((group gnus-newsgroup-name)
6701 (gnus-group-is-exiting-p t)
6702 (gnus-group-is-exiting-without-update-p t)
6703 (quit-config (gnus-group-quit-config group)))
6704 (when (or no-questions
6705 gnus-expert-user
6706 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6707 (gnus-async-halt-prefetch)
6708 (run-hooks 'gnus-summary-prepare-exit-hook)
6709 (when (gnus-buffer-live-p gnus-article-buffer)
6710 (save-excursion
6711 (set-buffer gnus-article-buffer)
6712 (mm-destroy-parts gnus-article-mime-handles)
6713 ;; Set it to nil for safety reason.
6714 (setq gnus-article-mime-handle-alist nil)
6715 (setq gnus-article-mime-handles nil)))
6716 ;; If we have several article buffers, we kill them at exit.
6717 (unless gnus-single-article-buffer
6718 (gnus-kill-buffer gnus-article-buffer)
6719 (gnus-kill-buffer gnus-original-article-buffer)
6720 (setq gnus-article-current nil))
6721 (if (not gnus-kill-summary-on-exit)
6722 (gnus-deaden-summary)
6723 (gnus-close-group group)
6724 (gnus-summary-clear-local-variables)
6725 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6726 (gnus-summary-clear-local-variables))
6727 (set-buffer gnus-group-buffer)
6728 (gnus-summary-clear-local-variables)
6729 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6730 (gnus-summary-clear-local-variables))
6731 (gnus-kill-buffer gnus-summary-buffer))
6732 (unless gnus-single-article-buffer
6733 (setq gnus-article-current nil))
6734 (when gnus-use-trees
6735 (gnus-tree-close group))
6736 (gnus-async-prefetch-remove-group group)
6737 (when (get-buffer gnus-article-buffer)
6738 (bury-buffer gnus-article-buffer))
6739 ;; Return to the group buffer.
6740 (gnus-configure-windows 'group 'force)
6741 ;; Clear the current group name.
6742 (setq gnus-newsgroup-name nil)
6743 (unless (gnus-ephemeral-group-p group)
6744 (gnus-group-update-group group))
6745 (when (equal (gnus-group-group-name) group)
6746 (gnus-group-next-unread-group 1))
6747 (when quit-config
6748 (gnus-handle-ephemeral-exit quit-config)))))
6749
6750 (defun gnus-handle-ephemeral-exit (quit-config)
6751 "Handle movement when leaving an ephemeral group.
6752 The state which existed when entering the ephemeral is reset."
6753 (if (not (buffer-name (car quit-config)))
6754 (gnus-configure-windows 'group 'force)
6755 (set-buffer (car quit-config))
6756 (cond ((eq major-mode 'gnus-summary-mode)
6757 (gnus-set-global-variables))
6758 ((eq major-mode 'gnus-article-mode)
6759 (save-excursion
6760 ;; The `gnus-summary-buffer' variable may point
6761 ;; to the old summary buffer when using a single
6762 ;; article buffer.
6763 (unless (gnus-buffer-live-p gnus-summary-buffer)
6764 (set-buffer gnus-group-buffer))
6765 (set-buffer gnus-summary-buffer)
6766 (gnus-set-global-variables))))
6767 (if (or (eq (cdr quit-config) 'article)
6768 (eq (cdr quit-config) 'pick))
6769 (progn
6770 ;; The current article may be from the ephemeral group
6771 ;; thus it is best that we reload this article
6772 ;;
6773 ;; If we're exiting from a large digest, this can be
6774 ;; extremely slow. So, it's better not to reload it. -- jh.
6775 ;;(gnus-summary-show-article)
6776 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6777 (gnus-configure-windows 'pick 'force)
6778 (gnus-configure-windows (cdr quit-config) 'force)))
6779 (gnus-configure-windows (cdr quit-config) 'force))
6780 (when (eq major-mode 'gnus-summary-mode)
6781 (gnus-summary-next-subject 1 nil t)
6782 (gnus-summary-recenter)
6783 (gnus-summary-position-point))))
6784
6785 ;;; Dead summaries.
6786
6787 (defvar gnus-dead-summary-mode-map nil)
6788
6789 (unless gnus-dead-summary-mode-map
6790 (setq gnus-dead-summary-mode-map (make-keymap))
6791 (suppress-keymap gnus-dead-summary-mode-map)
6792 (substitute-key-definition
6793 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6794 (dolist (key '("\C-d" "\r" "\177" [delete]))
6795 (define-key gnus-dead-summary-mode-map
6796 key 'gnus-summary-wake-up-the-dead))
6797 (dolist (key '("q" "Q"))
6798 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6799
6800 (defvar gnus-dead-summary-mode nil
6801 "Minor mode for Gnus summary buffers.")
6802
6803 (defun gnus-dead-summary-mode (&optional arg)
6804 "Minor mode for Gnus summary buffers."
6805 (interactive "P")
6806 (when (eq major-mode 'gnus-summary-mode)
6807 (make-local-variable 'gnus-dead-summary-mode)
6808 (setq gnus-dead-summary-mode
6809 (if (null arg) (not gnus-dead-summary-mode)
6810 (> (prefix-numeric-value arg) 0)))
6811 (when gnus-dead-summary-mode
6812 (gnus-add-minor-mode
6813 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6814
6815 (defun gnus-deaden-summary ()
6816 "Make the current summary buffer into a dead summary buffer."
6817 ;; Kill any previous dead summary buffer.
6818 (when (and gnus-dead-summary
6819 (buffer-name gnus-dead-summary))
6820 (save-excursion
6821 (set-buffer gnus-dead-summary)
6822 (when gnus-dead-summary-mode
6823 (kill-buffer (current-buffer)))))
6824 ;; Make this the current dead summary.
6825 (setq gnus-dead-summary (current-buffer))
6826 (gnus-dead-summary-mode 1)
6827 (let ((name (buffer-name)))
6828 (when (string-match "Summary" name)
6829 (rename-buffer
6830 (concat (substring name 0 (match-beginning 0)) "Dead "
6831 (substring name (match-beginning 0)))
6832 t)
6833 (bury-buffer))))
6834
6835 (defun gnus-kill-or-deaden-summary (buffer)
6836 "Kill or deaden the summary BUFFER."
6837 (save-excursion
6838 (when (and (buffer-name buffer)
6839 (not gnus-single-article-buffer))
6840 (save-excursion
6841 (set-buffer buffer)
6842 (gnus-kill-buffer gnus-article-buffer)
6843 (gnus-kill-buffer gnus-original-article-buffer)))
6844 (cond
6845 ;; Kill the buffer.
6846 (gnus-kill-summary-on-exit
6847 (when (and gnus-use-trees
6848 (gnus-buffer-exists-p buffer))
6849 (save-excursion
6850 (set-buffer buffer)
6851 (gnus-tree-close gnus-newsgroup-name)))
6852 (gnus-kill-buffer buffer))
6853 ;; Deaden the buffer.
6854 ((gnus-buffer-exists-p buffer)
6855 (save-excursion
6856 (set-buffer buffer)
6857 (gnus-deaden-summary))))))
6858
6859 (defun gnus-summary-wake-up-the-dead (&rest args)
6860 "Wake up the dead summary buffer."
6861 (interactive)
6862 (gnus-dead-summary-mode -1)
6863 (let ((name (buffer-name)))
6864 (when (string-match "Dead " name)
6865 (rename-buffer
6866 (concat (substring name 0 (match-beginning 0))
6867 (substring name (match-end 0)))
6868 t)))
6869 (gnus-message 3 "This dead summary is now alive again"))
6870
6871 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6872 (defun gnus-summary-fetch-faq (&optional faq-dir)
6873 "Fetch the FAQ for the current group.
6874 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6875 in."
6876 (interactive
6877 (list
6878 (when current-prefix-arg
6879 (completing-read
6880 "FAQ dir: " (and (listp gnus-group-faq-directory)
6881 (mapcar (lambda (file) (list file))
6882 gnus-group-faq-directory))))))
6883 (let (gnus-faq-buffer)
6884 (when (setq gnus-faq-buffer
6885 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6886 (gnus-configure-windows 'summary-faq))))
6887
6888 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6889 (defun gnus-summary-describe-group (&optional force)
6890 "Describe the current newsgroup."
6891 (interactive "P")
6892 (gnus-group-describe-group force gnus-newsgroup-name))
6893
6894 (defun gnus-summary-describe-briefly ()
6895 "Describe summary mode commands briefly."
6896 (interactive)
6897 (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")))
6898
6899 ;; Walking around group mode buffer from summary mode.
6900
6901 (defun gnus-summary-next-group (&optional no-article target-group backward)
6902 "Exit current newsgroup and then select next unread newsgroup.
6903 If prefix argument NO-ARTICLE is non-nil, no article is selected
6904 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6905 previous group instead."
6906 (interactive "P")
6907 ;; Stop pre-fetching.
6908 (gnus-async-halt-prefetch)
6909 (let ((current-group gnus-newsgroup-name)
6910 (current-buffer (current-buffer))
6911 entered)
6912 ;; First we semi-exit this group to update Xrefs and all variables.
6913 ;; We can't do a real exit, because the window conf must remain
6914 ;; the same in case the user is prompted for info, and we don't
6915 ;; want the window conf to change before that...
6916 (gnus-summary-exit t)
6917 (while (not entered)
6918 ;; Then we find what group we are supposed to enter.
6919 (set-buffer gnus-group-buffer)
6920 (gnus-group-jump-to-group current-group)
6921 (setq target-group
6922 (or target-group
6923 (if (eq gnus-keep-same-level 'best)
6924 (gnus-summary-best-group gnus-newsgroup-name)
6925 (gnus-summary-search-group backward gnus-keep-same-level))))
6926 (if (not target-group)
6927 ;; There are no further groups, so we return to the group
6928 ;; buffer.
6929 (progn
6930 (gnus-message 5 "Returning to the group buffer")
6931 (setq entered t)
6932 (when (gnus-buffer-live-p current-buffer)
6933 (set-buffer current-buffer)
6934 (gnus-summary-exit))
6935 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6936 ;; We try to enter the target group.
6937 (gnus-group-jump-to-group target-group)
6938 (let ((unreads (gnus-group-group-unread)))
6939 (if (and (or (eq t unreads)
6940 (and unreads (not (zerop unreads))))
6941 (gnus-summary-read-group
6942 target-group nil no-article
6943 (and (buffer-name current-buffer) current-buffer)
6944 nil backward))
6945 (setq entered t)
6946 (setq current-group target-group
6947 target-group nil)))))))
6948
6949 (defun gnus-summary-prev-group (&optional no-article)
6950 "Exit current newsgroup and then select previous unread newsgroup.
6951 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6952 (interactive "P")
6953 (gnus-summary-next-group no-article nil t))
6954
6955 ;; Walking around summary lines.
6956
6957 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6958 "Go to the first subject satisfying any non-nil constraint.
6959 If UNREAD is non-nil, the article should be unread.
6960 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6961 If UNSEEN is non-nil, the article should be unseen.
6962 Returns the article selected or nil if there are no matching articles."
6963 (interactive "P")
6964 (cond
6965 ;; Empty summary.
6966 ((null gnus-newsgroup-data)
6967 (gnus-message 3 "No articles in the group")
6968 nil)
6969 ;; Pick the first article.
6970 ((not (or unread undownloaded unseen))
6971 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6972 (gnus-data-number (car gnus-newsgroup-data)))
6973 ;; Find the first unread article.
6974 (t
6975 (let ((data gnus-newsgroup-data))
6976 (while (and data
6977 (let ((num (gnus-data-number (car data))))
6978 (or (memq num gnus-newsgroup-unfetched)
6979 (not (or (and unread
6980 (memq num gnus-newsgroup-unreads))
6981 (and undownloaded
6982 (memq num gnus-newsgroup-undownloaded))
6983 (and unseen
6984 (memq num gnus-newsgroup-unseen)))))))
6985 (setq data (cdr data)))
6986 (prog1
6987 (if data
6988 (progn
6989 (goto-char (gnus-data-pos (car data)))
6990 (gnus-data-number (car data)))
6991 (gnus-message 3 "No more%s articles"
6992 (let* ((r (when unread " unread"))
6993 (d (when undownloaded " undownloaded"))
6994 (s (when unseen " unseen"))
6995 (l (delq nil (list r d s))))
6996 (cond ((= 3 (length l))
6997 (concat r "," d ", or" s))
6998 ((= 2 (length l))
6999 (concat (car l) ", or" (cadr l)))
7000 ((= 1 (length l))
7001 (car l))
7002 (t
7003 ""))))
7004 nil
7005 )
7006 (gnus-summary-position-point))))))
7007
7008 (defun gnus-summary-next-subject (n &optional unread dont-display)
7009 "Go to next N'th summary line.
7010 If N is negative, go to the previous N'th subject line.
7011 If UNREAD is non-nil, only unread articles are selected.
7012 The difference between N and the actual number of steps taken is
7013 returned."
7014 (interactive "p")
7015 (let ((backward (< n 0))
7016 (n (abs n)))
7017 (while (and (> n 0)
7018 (if backward
7019 (gnus-summary-find-prev unread)
7020 (gnus-summary-find-next unread)))
7021 (unless (zerop (setq n (1- n)))
7022 (gnus-summary-show-thread)))
7023 (when (/= 0 n)
7024 (gnus-message 7 "No more%s articles"
7025 (if unread " unread" "")))
7026 (unless dont-display
7027 (gnus-summary-recenter)
7028 (gnus-summary-position-point))
7029 n))
7030
7031 (defun gnus-summary-next-unread-subject (n)
7032 "Go to next N'th unread summary line."
7033 (interactive "p")
7034 (gnus-summary-next-subject n t))
7035
7036 (defun gnus-summary-prev-subject (n &optional unread)
7037 "Go to previous N'th summary line.
7038 If optional argument UNREAD is non-nil, only unread article is selected."
7039 (interactive "p")
7040 (gnus-summary-next-subject (- n) unread))
7041
7042 (defun gnus-summary-prev-unread-subject (n)
7043 "Go to previous N'th unread summary line."
7044 (interactive "p")
7045 (gnus-summary-next-subject (- n) t))
7046
7047 (defun gnus-summary-goto-subjects (articles)
7048 "Insert the subject header for ARTICLES in the current buffer."
7049 (save-excursion
7050 (dolist (article articles)
7051 (gnus-summary-goto-subject article t)))
7052 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7053 (gnus-summary-position-point))
7054
7055 (defun gnus-summary-goto-subject (article &optional force silent)
7056 "Go the subject line of ARTICLE.
7057 If FORCE, also allow jumping to articles not currently shown."
7058 (interactive "nArticle number: ")
7059 (unless (numberp article)
7060 (error "Article %s is not a number" article))
7061 (let ((b (point))
7062 (data (gnus-data-find article)))
7063 ;; We read in the article if we have to.
7064 (and (not data)
7065 force
7066 (gnus-summary-insert-subject
7067 article
7068 (if (or (numberp force) (vectorp force)) force)
7069 t)
7070 (setq data (gnus-data-find article)))
7071 (goto-char b)
7072 (if (not data)
7073 (progn
7074 (unless silent
7075 (gnus-message 3 "Can't find article %d" article))
7076 nil)
7077 (let ((pt (gnus-data-pos data)))
7078 (goto-char pt)
7079 (gnus-summary-set-article-display-arrow pt))
7080 (gnus-summary-position-point)
7081 article)))
7082
7083 ;; Walking around summary lines with displaying articles.
7084
7085 (defun gnus-summary-expand-window (&optional arg)
7086 "Make the summary buffer take up the entire Emacs frame.
7087 Given a prefix, will force an `article' buffer configuration."
7088 (interactive "P")
7089 (if arg
7090 (gnus-configure-windows 'article 'force)
7091 (gnus-configure-windows 'summary 'force)))
7092
7093 (defun gnus-summary-display-article (article &optional all-header)
7094 "Display ARTICLE in article buffer."
7095 (when (gnus-buffer-live-p gnus-article-buffer)
7096 (with-current-buffer gnus-article-buffer
7097 (mm-enable-multibyte)))
7098 (gnus-set-global-variables)
7099 (when (gnus-buffer-live-p gnus-article-buffer)
7100 (with-current-buffer gnus-article-buffer
7101 (setq gnus-article-charset gnus-newsgroup-charset)
7102 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7103 (mm-enable-multibyte)))
7104 (if (null article)
7105 nil
7106 (prog1
7107 (if gnus-summary-display-article-function
7108 (funcall gnus-summary-display-article-function article all-header)
7109 (gnus-article-prepare article all-header))
7110 (gnus-run-hooks 'gnus-select-article-hook)
7111 (when (and gnus-current-article
7112 (not (zerop gnus-current-article)))
7113 (gnus-summary-goto-subject gnus-current-article))
7114 (gnus-summary-recenter)
7115 (when (and gnus-use-trees gnus-show-threads)
7116 (gnus-possibly-generate-tree article)
7117 (gnus-highlight-selected-tree article))
7118 ;; Successfully display article.
7119 (gnus-article-set-window-start
7120 (cdr (assq article gnus-newsgroup-bookmarks))))))
7121
7122 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7123 "Select the current article.
7124 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7125 non-nil, the article will be re-fetched even if it already present in
7126 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7127 be displayed."
7128 ;; Make sure we are in the summary buffer to work around bbdb bug.
7129 (unless (eq major-mode 'gnus-summary-mode)
7130 (set-buffer gnus-summary-buffer))
7131 (let ((article (or article (gnus-summary-article-number)))
7132 (all-headers (not (not all-headers))) ;Must be t or nil.
7133 gnus-summary-display-article-function)
7134 (and (not pseudo)
7135 (gnus-summary-article-pseudo-p article)
7136 (error "This is a pseudo-article"))
7137 (save-excursion
7138 (set-buffer gnus-summary-buffer)
7139 (if (or (and gnus-single-article-buffer
7140 (or (null gnus-current-article)
7141 (null gnus-article-current)
7142 (null (get-buffer gnus-article-buffer))
7143 (not (eq article (cdr gnus-article-current)))
7144 (not (equal (car gnus-article-current)
7145 gnus-newsgroup-name))))
7146 (and (not gnus-single-article-buffer)
7147 (or (null gnus-current-article)
7148 (not (eq gnus-current-article article))))
7149 force)
7150 ;; The requested article is different from the current article.
7151 (progn
7152 (gnus-summary-display-article article all-headers)
7153 (when (gnus-buffer-live-p gnus-article-buffer)
7154 (with-current-buffer gnus-article-buffer
7155 (if (not gnus-article-decoded-p) ;; a local variable
7156 (mm-disable-multibyte))))
7157 (gnus-article-set-window-start
7158 (cdr (assq article gnus-newsgroup-bookmarks)))
7159 article)
7160 'old))))
7161
7162 (defun gnus-summary-force-verify-and-decrypt ()
7163 "Display buttons for signed/encrypted parts and verify/decrypt them."
7164 (interactive)
7165 (let ((mm-verify-option 'known)
7166 (mm-decrypt-option 'known)
7167 (gnus-article-emulate-mime t)
7168 (gnus-buttonized-mime-types (append (list "multipart/signed"
7169 "multipart/encrypted")
7170 gnus-buttonized-mime-types)))
7171 (gnus-summary-select-article nil 'force)))
7172
7173 (defun gnus-summary-set-current-mark (&optional current-mark)
7174 "Obsolete function."
7175 nil)
7176
7177 (defun gnus-summary-next-article (&optional unread subject backward push)
7178 "Select the next article.
7179 If UNREAD, only unread articles are selected.
7180 If SUBJECT, only articles with SUBJECT are selected.
7181 If BACKWARD, the previous article is selected instead of the next."
7182 (interactive "P")
7183 (cond
7184 ;; Is there such an article?
7185 ((and (gnus-summary-search-forward unread subject backward)
7186 (or (gnus-summary-display-article (gnus-summary-article-number))
7187 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7188 (gnus-summary-position-point))
7189 ;; If not, we try the first unread, if that is wanted.
7190 ((and subject
7191 gnus-auto-select-same
7192 (gnus-summary-first-unread-article))
7193 (gnus-summary-position-point)
7194 (gnus-message 6 "Wrapped"))
7195 ;; Try to get next/previous article not displayed in this group.
7196 ((and gnus-auto-extend-newsgroup
7197 (not unread) (not subject))
7198 (gnus-summary-goto-article
7199 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7200 nil (count-lines (point-min) (point))))
7201 ;; Go to next/previous group.
7202 (t
7203 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7204 (gnus-summary-jump-to-group gnus-newsgroup-name))
7205 (let ((cmd last-command-char)
7206 (point
7207 (save-excursion
7208 (set-buffer gnus-group-buffer)
7209 (point)))
7210 (group
7211 (if (eq gnus-keep-same-level 'best)
7212 (gnus-summary-best-group gnus-newsgroup-name)
7213 (gnus-summary-search-group backward gnus-keep-same-level))))
7214 ;; For some reason, the group window gets selected. We change
7215 ;; it back.
7216 (select-window (get-buffer-window (current-buffer)))
7217 ;; Select next unread newsgroup automagically.
7218 (cond
7219 ((or (not gnus-auto-select-next)
7220 (not cmd))
7221 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7222 ((or (eq gnus-auto-select-next 'quietly)
7223 (and (eq gnus-auto-select-next 'slightly-quietly)
7224 push)
7225 (and (eq gnus-auto-select-next 'almost-quietly)
7226 (gnus-summary-last-article-p)))
7227 ;; Select quietly.
7228 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7229 (gnus-summary-exit)
7230 (gnus-message 7 "No more%s articles (%s)..."
7231 (if unread " unread" "")
7232 (if group (concat "selecting " group)
7233 "exiting"))
7234 (gnus-summary-next-group nil group backward)))
7235 (t
7236 (when (gnus-key-press-event-p last-input-event)
7237 (gnus-summary-walk-group-buffer
7238 gnus-newsgroup-name cmd unread backward point))))))))
7239
7240 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7241 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7242 (?\C-p (gnus-group-prev-unread-group 1))))
7243 (cursor-in-echo-area t)
7244 keve key group ended prompt)
7245 (save-excursion
7246 (set-buffer gnus-group-buffer)
7247 (goto-char start)
7248 (setq group
7249 (if (eq gnus-keep-same-level 'best)
7250 (gnus-summary-best-group gnus-newsgroup-name)
7251 (gnus-summary-search-group backward gnus-keep-same-level))))
7252 (while (not ended)
7253 (setq prompt
7254 (format
7255 "No more%s articles%s " (if unread " unread" "")
7256 (if (and group
7257 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7258 (format " (Type %s for %s [%s])"
7259 (single-key-description cmd)
7260 (gnus-group-decoded-name group)
7261 (car (gnus-gethash group gnus-newsrc-hashtb)))
7262 (format " (Type %s to exit %s)"
7263 (single-key-description cmd)
7264 (gnus-group-decoded-name gnus-newsgroup-name)))))
7265 ;; Confirm auto selection.
7266 (setq key (car (setq keve (gnus-read-event-char prompt)))
7267 ended t)
7268 (cond
7269 ((assq key keystrokes)
7270 (let ((obuf (current-buffer)))
7271 (switch-to-buffer gnus-group-buffer)
7272 (when group
7273 (gnus-group-jump-to-group group))
7274 (eval (cadr (assq key keystrokes)))
7275 (setq group (gnus-group-group-name))
7276 (switch-to-buffer obuf))
7277 (setq ended nil))
7278 ((equal key cmd)
7279 (if (or (not group)
7280 (gnus-ephemeral-group-p gnus-newsgroup-name))
7281 (gnus-summary-exit)
7282 (gnus-summary-next-group nil group backward)))
7283 (t
7284 (push (cdr keve) unread-command-events))))))
7285
7286 (defun gnus-summary-next-unread-article ()
7287 "Select unread article after current one."
7288 (interactive)
7289 (gnus-summary-next-article
7290 (or (not (eq gnus-summary-goto-unread 'never))
7291 (gnus-summary-last-article-p (gnus-summary-article-number)))
7292 (and gnus-auto-select-same
7293 (gnus-summary-article-subject))))
7294
7295 (defun gnus-summary-prev-article (&optional unread subject)
7296 "Select the article after the current one.
7297 If UNREAD is non-nil, only unread articles are selected."
7298 (interactive "P")
7299 (gnus-summary-next-article unread subject t))
7300
7301 (defun gnus-summary-prev-unread-article ()
7302 "Select unread article before current one."
7303 (interactive)
7304 (gnus-summary-prev-article
7305 (or (not (eq gnus-summary-goto-unread 'never))
7306 (gnus-summary-first-article-p (gnus-summary-article-number)))
7307 (and gnus-auto-select-same
7308 (gnus-summary-article-subject))))
7309
7310 (defun gnus-summary-next-page (&optional lines circular stop)
7311 "Show next page of the selected article.
7312 If at the end of the current article, select the next article.
7313 LINES says how many lines should be scrolled up.
7314
7315 If CIRCULAR is non-nil, go to the start of the article instead of
7316 selecting the next article when reaching the end of the current
7317 article.
7318
7319 If STOP is non-nil, just stop when reaching the end of the message.
7320
7321 Also see the variable `gnus-article-skip-boring'."
7322 (interactive "P")
7323 (setq gnus-summary-buffer (current-buffer))
7324 (gnus-set-global-variables)
7325 (let ((article (gnus-summary-article-number))
7326 (article-window (get-buffer-window gnus-article-buffer t))
7327 endp)
7328 ;; If the buffer is empty, we have no article.
7329 (unless article
7330 (error "No article to select"))
7331 (gnus-configure-windows 'article)
7332 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7333 (if (and (eq gnus-summary-goto-unread 'never)
7334 (not (gnus-summary-last-article-p article)))
7335 (gnus-summary-next-article)
7336 (gnus-summary-next-unread-article))
7337 (if (or (null gnus-current-article)
7338 (null gnus-article-current)
7339 (/= article (cdr gnus-article-current))
7340 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7341 ;; Selected subject is different from current article's.
7342 (gnus-summary-display-article article)
7343 (when article-window
7344 (gnus-eval-in-buffer-window gnus-article-buffer
7345 (setq endp (or (gnus-article-next-page lines)
7346 (gnus-article-only-boring-p))))
7347 (when endp
7348 (cond (stop
7349 (gnus-message 3 "End of message"))
7350 (circular
7351 (gnus-summary-beginning-of-article))
7352 (lines
7353 (gnus-message 3 "End of message"))
7354 ((null lines)
7355 (if (and (eq gnus-summary-goto-unread 'never)
7356 (not (gnus-summary-last-article-p article)))
7357 (gnus-summary-next-article)
7358 (gnus-summary-next-unread-article))))))))
7359 (gnus-summary-recenter)
7360 (gnus-summary-position-point)))
7361
7362 (defun gnus-summary-prev-page (&optional lines move)
7363 "Show previous page of selected article.
7364 Argument LINES specifies lines to be scrolled down.
7365 If MOVE, move to the previous unread article if point is at
7366 the beginning of the buffer."
7367 (interactive "P")
7368 (let ((article (gnus-summary-article-number))
7369 (article-window (get-buffer-window gnus-article-buffer t))
7370 endp)
7371 (gnus-configure-windows 'article)
7372 (if (or (null gnus-current-article)
7373 (null gnus-article-current)
7374 (/= article (cdr gnus-article-current))
7375 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7376 ;; Selected subject is different from current article's.
7377 (gnus-summary-display-article article)
7378 (gnus-summary-recenter)
7379 (when article-window
7380 (gnus-eval-in-buffer-window gnus-article-buffer
7381 (setq endp (gnus-article-prev-page lines)))
7382 (when (and move endp)
7383 (cond (lines
7384 (gnus-message 3 "Beginning of message"))
7385 ((null lines)
7386 (if (and (eq gnus-summary-goto-unread 'never)
7387 (not (gnus-summary-first-article-p article)))
7388 (gnus-summary-prev-article)
7389 (gnus-summary-prev-unread-article))))))))
7390 (gnus-summary-position-point))
7391
7392 (defun gnus-summary-prev-page-or-article (&optional lines)
7393 "Show previous page of selected article.
7394 Argument LINES specifies lines to be scrolled down.
7395 If at the beginning of the article, go to the next article."
7396 (interactive "P")
7397 (gnus-summary-prev-page lines t))
7398
7399 (defun gnus-summary-scroll-up (lines)
7400 "Scroll up (or down) one line current article.
7401 Argument LINES specifies lines to be scrolled up (or down if negative)."
7402 (interactive "p")
7403 (gnus-configure-windows 'article)
7404 (gnus-summary-show-thread)
7405 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7406 (gnus-eval-in-buffer-window gnus-article-buffer
7407 (cond ((> lines 0)
7408 (when (gnus-article-next-page lines)
7409 (gnus-message 3 "End of message")))
7410 ((< lines 0)
7411 (gnus-article-prev-page (- lines))))))
7412 (gnus-summary-recenter)
7413 (gnus-summary-position-point))
7414
7415 (defun gnus-summary-scroll-down (lines)
7416 "Scroll down (or up) one line current article.
7417 Argument LINES specifies lines to be scrolled down (or up if negative)."
7418 (interactive "p")
7419 (gnus-summary-scroll-up (- lines)))
7420
7421 (defun gnus-summary-next-same-subject ()
7422 "Select next article which has the same subject as current one."
7423 (interactive)
7424 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7425
7426 (defun gnus-summary-prev-same-subject ()
7427 "Select previous article which has the same subject as current one."
7428 (interactive)
7429 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7430
7431 (defun gnus-summary-next-unread-same-subject ()
7432 "Select next unread article which has the same subject as current one."
7433 (interactive)
7434 (gnus-summary-next-article t (gnus-summary-article-subject)))
7435
7436 (defun gnus-summary-prev-unread-same-subject ()
7437 "Select previous unread article which has the same subject as current one."
7438 (interactive)
7439 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7440
7441 (defun gnus-summary-first-unread-article ()
7442 "Select the first unread article.
7443 Return nil if there are no unread articles."
7444 (interactive)
7445 (prog1
7446 (when (gnus-summary-first-subject t)
7447 (gnus-summary-show-thread)
7448 (gnus-summary-first-subject t)
7449 (gnus-summary-display-article (gnus-summary-article-number)))
7450 (gnus-summary-position-point)))
7451
7452 (defun gnus-summary-first-unread-subject ()
7453 "Place the point on the subject line of the first unread article.
7454 Return nil if there are no unread articles."
7455 (interactive)
7456 (prog1
7457 (when (gnus-summary-first-subject t)
7458 (gnus-summary-show-thread)
7459 (gnus-summary-first-subject t))
7460 (gnus-summary-position-point)))
7461
7462 (defun gnus-summary-first-unseen-subject ()
7463 "Place the point on the subject line of the first unseen article.
7464 Return nil if there are no unseen articles."
7465 (interactive)
7466 (prog1
7467 (when (gnus-summary-first-subject nil nil t)
7468 (gnus-summary-show-thread)
7469 (gnus-summary-first-subject nil nil t))
7470 (gnus-summary-position-point)))
7471
7472 (defun gnus-summary-first-unseen-or-unread-subject ()
7473 "Place the point on the subject line of the first unseen article or,
7474 if all article have been seen, on the subject line of the first unread
7475 article."
7476 (interactive)
7477 (prog1
7478 (unless (when (gnus-summary-first-subject nil nil t)
7479 (gnus-summary-show-thread)
7480 (gnus-summary-first-subject nil nil t))
7481 (when (gnus-summary-first-subject t)
7482 (gnus-summary-show-thread)
7483 (gnus-summary-first-subject t)))
7484 (gnus-summary-position-point)))
7485
7486 (defun gnus-summary-first-article ()
7487 "Select the first article.
7488 Return nil if there are no articles."
7489 (interactive)
7490 (prog1
7491 (when (gnus-summary-first-subject)
7492 (gnus-summary-show-thread)
7493 (gnus-summary-first-subject)
7494 (gnus-summary-display-article (gnus-summary-article-number)))
7495 (gnus-summary-position-point)))
7496
7497 (defun gnus-summary-best-unread-article (&optional arg)
7498 "Select the unread article with the highest score.
7499 If given a prefix argument, select the next unread article that has a
7500 score higher than the default score."
7501 (interactive "P")
7502 (let ((article (if arg
7503 (gnus-summary-better-unread-subject)
7504 (gnus-summary-best-unread-subject))))
7505 (if article
7506 (gnus-summary-goto-article article)
7507 (error "No unread articles"))))
7508
7509 (defun gnus-summary-best-unread-subject ()
7510 "Select the unread subject with the highest score."
7511 (interactive)
7512 (let ((best -1000000)
7513 (data gnus-newsgroup-data)
7514 article score)
7515 (while data
7516 (and (gnus-data-unread-p (car data))
7517 (> (setq score
7518 (gnus-summary-article-score (gnus-data-number (car data))))
7519 best)
7520 (setq best score
7521 article (gnus-data-number (car data))))
7522 (setq data (cdr data)))
7523 (when article
7524 (gnus-summary-goto-subject article))
7525 (gnus-summary-position-point)
7526 article))
7527
7528 (defun gnus-summary-better-unread-subject ()
7529 "Select the first unread subject that has a score over the default score."
7530 (interactive)
7531 (let ((data gnus-newsgroup-data)
7532 article score)
7533 (while (and (setq article (gnus-data-number (car data)))
7534 (or (gnus-data-read-p (car data))
7535 (not (> (gnus-summary-article-score article)
7536 gnus-summary-default-score))))
7537 (setq data (cdr data)))
7538 (when article
7539 (gnus-summary-goto-subject article))
7540 (gnus-summary-position-point)
7541 article))
7542
7543 (defun gnus-summary-last-subject ()
7544 "Go to the last displayed subject line in the group."
7545 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7546 (when article
7547 (gnus-summary-goto-subject article))))
7548
7549 (defun gnus-summary-goto-article (article &optional all-headers force)
7550 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7551 If ALL-HEADERS is non-nil, no header lines are hidden.
7552 If FORCE, go to the article even if it isn't displayed. If FORCE
7553 is a number, it is the line the article is to be displayed on."
7554 (interactive
7555 (list
7556 (completing-read
7557 "Article number or Message-ID: "
7558 (mapcar (lambda (number) (list (int-to-string number)))
7559 gnus-newsgroup-limit))
7560 current-prefix-arg
7561 t))
7562 (prog1
7563 (if (and (stringp article)
7564 (string-match "@\\|%40" article))
7565 (gnus-summary-refer-article article)
7566 (when (stringp article)
7567 (setq article (string-to-number article)))
7568 (if (gnus-summary-goto-subject article force)
7569 (gnus-summary-display-article article all-headers)
7570 (gnus-message 4 "Couldn't go to article %s" article) nil))
7571 (gnus-summary-position-point)))
7572
7573 (defun gnus-summary-goto-last-article ()
7574 "Go to the previously read article."
7575 (interactive)
7576 (prog1
7577 (when gnus-last-article
7578 (gnus-summary-goto-article gnus-last-article nil t))
7579 (gnus-summary-position-point)))
7580
7581 (defun gnus-summary-pop-article (number)
7582 "Pop one article off the history and go to the previous.
7583 NUMBER articles will be popped off."
7584 (interactive "p")
7585 (let (to)
7586 (setq gnus-newsgroup-history
7587 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7588 (if to
7589 (gnus-summary-goto-article (car to) nil t)
7590 (error "Article history empty")))
7591 (gnus-summary-position-point))
7592
7593 ;; Summary commands and functions for limiting the summary buffer.
7594
7595 (defun gnus-summary-limit-to-articles (n)
7596 "Limit the summary buffer to the next N articles.
7597 If not given a prefix, use the process marked articles instead."
7598 (interactive "P")
7599 (prog1
7600 (let ((articles (gnus-summary-work-articles n)))
7601 (setq gnus-newsgroup-processable nil)
7602 (gnus-summary-limit articles))
7603 (gnus-summary-position-point)))
7604
7605 (defun gnus-summary-pop-limit (&optional total)
7606 "Restore the previous limit.
7607 If given a prefix, remove all limits."
7608 (interactive "P")
7609 (when total
7610 (setq gnus-newsgroup-limits
7611 (list (mapcar (lambda (h) (mail-header-number h))
7612 gnus-newsgroup-headers))))
7613 (unless gnus-newsgroup-limits
7614 (error "No limit to pop"))
7615 (prog1
7616 (gnus-summary-limit nil 'pop)
7617 (gnus-summary-position-point)))
7618
7619 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7620 "Limit the summary buffer to articles that have subjects that match a regexp.
7621 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7622 (interactive
7623 (list (read-string (if current-prefix-arg
7624 "Exclude subject (regexp): "
7625 "Limit to subject (regexp): "))
7626 nil current-prefix-arg))
7627 (unless header
7628 (setq header "subject"))
7629 (when (not (equal "" subject))
7630 (prog1
7631 (let ((articles (gnus-summary-find-matching
7632 (or header "subject") subject 'all nil nil
7633 not-matching)))
7634 (unless articles
7635 (error "Found no matches for \"%s\"" subject))
7636 (gnus-summary-limit articles))
7637 (gnus-summary-position-point))))
7638
7639 (defun gnus-summary-limit-to-author (from &optional not-matching)
7640 "Limit the summary buffer to articles that have authors that match a regexp.
7641 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7642 (interactive
7643 (list (read-string (if current-prefix-arg
7644 "Exclude author (regexp): "
7645 "Limit to author (regexp): "))
7646 current-prefix-arg))
7647 (gnus-summary-limit-to-subject from "from" not-matching))
7648
7649 (defun gnus-summary-limit-to-age (age &optional younger-p)
7650 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7651 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7652 articles that are younger than AGE days."
7653 (interactive
7654 (let ((younger current-prefix-arg)
7655 (days-got nil)
7656 days)
7657 (while (not days-got)
7658 (setq days (if younger
7659 (read-string "Limit to articles younger than (in days, older when negative): ")
7660 (read-string
7661 "Limit to articles older than (in days, younger when negative): ")))
7662 (when (> (length days) 0)
7663 (setq days (read days)))
7664 (if (numberp days)
7665 (progn
7666 (setq days-got t)
7667 (if (< days 0)
7668 (progn
7669 (setq younger (not younger))
7670 (setq days (* days -1)))))
7671 (message "Please enter a number.")
7672 (sleep-for 1)))
7673 (list days younger)))
7674 (prog1
7675 (let ((data gnus-newsgroup-data)
7676 (cutoff (days-to-time age))
7677 articles d date is-younger)
7678 (while (setq d (pop data))
7679 (when (and (vectorp (gnus-data-header d))
7680 (setq date (mail-header-date (gnus-data-header d))))
7681 (setq is-younger (time-less-p
7682 (time-since (condition-case ()
7683 (date-to-time date)
7684 (error '(0 0))))
7685 cutoff))
7686 (when (if younger-p
7687 is-younger
7688 (not is-younger))
7689 (push (gnus-data-number d) articles))))
7690 (gnus-summary-limit (nreverse articles)))
7691 (gnus-summary-position-point)))
7692
7693 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7694 "Limit the summary buffer to articles that match an 'extra' header."
7695 (interactive
7696 (let ((header
7697 (intern
7698 (gnus-completing-read-with-default
7699 (symbol-name (car gnus-extra-headers))
7700 (if current-prefix-arg
7701 "Exclude extra header"
7702 "Limit extra header")
7703 (mapcar (lambda (x)
7704 (cons (symbol-name x) x))
7705 gnus-extra-headers)
7706 nil
7707 t))))
7708 (list header
7709 (read-string (format "%s header %s (regexp): "
7710 (if current-prefix-arg "Exclude" "Limit to")
7711 header))
7712 current-prefix-arg)))
7713 (when (not (equal "" regexp))
7714 (prog1
7715 (let ((articles (gnus-summary-find-matching
7716 (cons 'extra header) regexp 'all nil nil
7717 not-matching)))
7718 (unless articles
7719 (error "Found no matches for \"%s\"" regexp))
7720 (gnus-summary-limit articles))
7721 (gnus-summary-position-point))))
7722
7723 (defun gnus-summary-limit-to-display-predicate ()
7724 "Limit the summary buffer to the predicated in the `display' group parameter."
7725 (interactive)
7726 (unless gnus-newsgroup-display
7727 (error "There is no `display' group parameter"))
7728 (let (articles)
7729 (dolist (number gnus-newsgroup-articles)
7730 (when (funcall gnus-newsgroup-display)
7731 (push number articles)))
7732 (gnus-summary-limit articles))
7733 (gnus-summary-position-point))
7734
7735 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7736 (make-obsolete
7737 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7738
7739 (defun gnus-summary-limit-to-unread (&optional all)
7740 "Limit the summary buffer to articles that are not marked as read.
7741 If ALL is non-nil, limit strictly to unread articles."
7742 (interactive "P")
7743 (if all
7744 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7745 (gnus-summary-limit-to-marks
7746 ;; Concat all the marks that say that an article is read and have
7747 ;; those removed.
7748 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7749 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7750 gnus-low-score-mark gnus-expirable-mark
7751 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7752 gnus-duplicate-mark gnus-souped-mark)
7753 'reverse)))
7754
7755 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7756 (make-obsolete 'gnus-summary-delete-marked-with
7757 'gnus-summary-limit-exclude-marks)
7758
7759 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7760 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7761 If REVERSE, limit the summary buffer to articles that are marked
7762 with MARKS. MARKS can either be a string of marks or a list of marks.
7763 Returns how many articles were removed."
7764 (interactive "sMarks: ")
7765 (gnus-summary-limit-to-marks marks t))
7766
7767 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7768 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7769 If REVERSE (the prefix), limit the summary buffer to articles that are
7770 not marked with MARKS. MARKS can either be a string of marks or a
7771 list of marks.
7772 Returns how many articles were removed."
7773 (interactive "sMarks: \nP")
7774 (prog1
7775 (let ((data gnus-newsgroup-data)
7776 (marks (if (listp marks) marks
7777 (append marks nil))) ; Transform to list.
7778 articles)
7779 (while data
7780 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7781 (memq (gnus-data-mark (car data)) marks))
7782 (push (gnus-data-number (car data)) articles))
7783 (setq data (cdr data)))
7784 (gnus-summary-limit articles))
7785 (gnus-summary-position-point)))
7786
7787 (defun gnus-summary-limit-to-score (score)
7788 "Limit to articles with score at or above SCORE."
7789 (interactive "NLimit to articles with score of at least: ")
7790 (let ((data gnus-newsgroup-data)
7791 articles)
7792 (while data
7793 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7794 score)
7795 (push (gnus-data-number (car data)) articles))
7796 (setq data (cdr data)))
7797 (prog1
7798 (gnus-summary-limit articles)
7799 (gnus-summary-position-point))))
7800
7801 (defun gnus-summary-limit-to-unseen ()
7802 "Limit to unseen articles."
7803 (interactive)
7804 (prog1
7805 (gnus-summary-limit gnus-newsgroup-unseen)
7806 (gnus-summary-position-point)))
7807
7808 (defun gnus-summary-limit-include-thread (id)
7809 "Display all the hidden articles that is in the thread with ID in it.
7810 When called interactively, ID is the Message-ID of the current
7811 article."
7812 (interactive (list (mail-header-id (gnus-summary-article-header))))
7813 (let ((articles (gnus-articles-in-thread
7814 (gnus-id-to-thread (gnus-root-id id)))))
7815 (prog1
7816 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7817 (gnus-summary-limit-include-matching-articles
7818 "subject"
7819 (regexp-quote (gnus-simplify-subject-re
7820 (mail-header-subject (gnus-id-to-header id)))))
7821 (gnus-summary-position-point))))
7822
7823 (defun gnus-summary-limit-include-matching-articles (header regexp)
7824 "Display all the hidden articles that have HEADERs that match REGEXP."
7825 (interactive (list (read-string "Match on header: ")
7826 (read-string "Regexp: ")))
7827 (let ((articles (gnus-find-matching-articles header regexp)))
7828 (prog1
7829 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7830 (gnus-summary-position-point))))
7831
7832 (defun gnus-summary-insert-dormant-articles ()
7833 "Insert all the dormant articles for this group into the current buffer."
7834 (interactive)
7835 (let ((gnus-verbose (max 6 gnus-verbose)))
7836 (if (not gnus-newsgroup-dormant)
7837 (gnus-message 3 "No cached articles for this group")
7838 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7839
7840 (defun gnus-summary-limit-include-dormant ()
7841 "Display all the hidden articles that are marked as dormant.
7842 Note that this command only works on a subset of the articles currently
7843 fetched for this group."
7844 (interactive)
7845 (unless gnus-newsgroup-dormant
7846 (error "There are no dormant articles in this group"))
7847 (prog1
7848 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7849 (gnus-summary-position-point)))
7850
7851 (defun gnus-summary-limit-exclude-dormant ()
7852 "Hide all dormant articles."
7853 (interactive)
7854 (prog1
7855 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7856 (gnus-summary-position-point)))
7857
7858 (defun gnus-summary-limit-exclude-childless-dormant ()
7859 "Hide all dormant articles that have no children."
7860 (interactive)
7861 (let ((data (gnus-data-list t))
7862 articles d children)
7863 ;; Find all articles that are either not dormant or have
7864 ;; children.
7865 (while (setq d (pop data))
7866 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7867 (and (setq children
7868 (gnus-article-children (gnus-data-number d)))
7869 (let (found)
7870 (while children
7871 (when (memq (car children) articles)
7872 (setq children nil
7873 found t))
7874 (pop children))
7875 found)))
7876 (push (gnus-data-number d) articles)))
7877 ;; Do the limiting.
7878 (prog1
7879 (gnus-summary-limit articles)
7880 (gnus-summary-position-point))))
7881
7882 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7883 "Mark all unread excluded articles as read.
7884 If ALL, mark even excluded ticked and dormants as read."
7885 (interactive "P")
7886 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7887 (let ((articles (gnus-sorted-ndifference
7888 (sort
7889 (mapcar (lambda (h) (mail-header-number h))
7890 gnus-newsgroup-headers)
7891 '<)
7892 gnus-newsgroup-limit))
7893 article)
7894 (setq gnus-newsgroup-unreads
7895 (gnus-sorted-intersection gnus-newsgroup-unreads
7896 gnus-newsgroup-limit))
7897 (if all
7898 (setq gnus-newsgroup-dormant nil
7899 gnus-newsgroup-marked nil
7900 gnus-newsgroup-reads
7901 (nconc
7902 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7903 gnus-newsgroup-reads))
7904 (while (setq article (pop articles))
7905 (unless (or (memq article gnus-newsgroup-dormant)
7906 (memq article gnus-newsgroup-marked))
7907 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7908
7909 (defun gnus-summary-limit (articles &optional pop)
7910 (if pop
7911 ;; We pop the previous limit off the stack and use that.
7912 (setq articles (car gnus-newsgroup-limits)
7913 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7914 ;; We use the new limit, so we push the old limit on the stack.
7915 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7916 ;; Set the limit.
7917 (setq gnus-newsgroup-limit articles)
7918 (let ((total (length gnus-newsgroup-data))
7919 (data (gnus-data-find-list (gnus-summary-article-number)))
7920 (gnus-summary-mark-below nil) ; Inhibit this.
7921 found)
7922 ;; This will do all the work of generating the new summary buffer
7923 ;; according to the new limit.
7924 (gnus-summary-prepare)
7925 ;; Hide any threads, possibly.
7926 (gnus-summary-maybe-hide-threads)
7927 ;; Try to return to the article you were at, or one in the
7928 ;; neighborhood.
7929 (when data
7930 ;; We try to find some article after the current one.
7931 (while data
7932 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7933 (setq data nil
7934 found t))
7935 (setq data (cdr data))))
7936 (unless found
7937 ;; If there is no data, that means that we were after the last
7938 ;; article. The same goes when we can't find any articles
7939 ;; after the current one.
7940 (goto-char (point-max))
7941 (gnus-summary-find-prev))
7942 (gnus-set-mode-line 'summary)
7943 ;; We return how many articles were removed from the summary
7944 ;; buffer as a result of the new limit.
7945 (- total (length gnus-newsgroup-data))))
7946
7947 (defsubst gnus-invisible-cut-children (threads)
7948 (let ((num 0))
7949 (while threads
7950 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7951 (incf num))
7952 (pop threads))
7953 (< num 2)))
7954
7955 (defsubst gnus-cut-thread (thread)
7956 "Go forwards in the thread until we find an article that we want to display."
7957 (when (or (eq gnus-fetch-old-headers 'some)
7958 (eq gnus-fetch-old-headers 'invisible)
7959 (numberp gnus-fetch-old-headers)
7960 (eq gnus-build-sparse-threads 'some)
7961 (eq gnus-build-sparse-threads 'more))
7962 ;; Deal with old-fetched headers and sparse threads.
7963 (while (and
7964 thread
7965 (or
7966 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7967 (gnus-summary-article-ancient-p
7968 (mail-header-number (car thread))))
7969 (if (or (<= (length (cdr thread)) 1)
7970 (eq gnus-fetch-old-headers 'invisible))
7971 (setq gnus-newsgroup-limit
7972 (delq (mail-header-number (car thread))
7973 gnus-newsgroup-limit)
7974 thread (cadr thread))
7975 (when (gnus-invisible-cut-children (cdr thread))
7976 (let ((th (cdr thread)))
7977 (while th
7978 (if (memq (mail-header-number (caar th))
7979 gnus-newsgroup-limit)
7980 (setq thread (car th)
7981 th nil)
7982 (setq th (cdr th))))))))))
7983 thread)
7984
7985 (defun gnus-cut-threads (threads)
7986 "Cut off all uninteresting articles from the beginning of THREADS."
7987 (when (or (eq gnus-fetch-old-headers 'some)
7988 (eq gnus-fetch-old-headers 'invisible)
7989 (numberp gnus-fetch-old-headers)
7990 (eq gnus-build-sparse-threads 'some)
7991 (eq gnus-build-sparse-threads 'more))
7992 (let ((th threads))
7993 (while th
7994 (setcar th (gnus-cut-thread (car th)))
7995 (setq th (cdr th)))))
7996 ;; Remove nixed out threads.
7997 (delq nil threads))
7998
7999 (defun gnus-summary-initial-limit (&optional show-if-empty)
8000 "Figure out what the initial limit is supposed to be on group entry.
8001 This entails weeding out unwanted dormants, low-scored articles,
8002 fetch-old-headers verbiage, and so on."
8003 ;; Most groups have nothing to remove.
8004 (if (or gnus-inhibit-limiting
8005 (and (null gnus-newsgroup-dormant)
8006 (eq gnus-newsgroup-display 'gnus-not-ignore)
8007 (not (eq gnus-fetch-old-headers 'some))
8008 (not (numberp gnus-fetch-old-headers))
8009 (not (eq gnus-fetch-old-headers 'invisible))
8010 (null gnus-summary-expunge-below)
8011 (not (eq gnus-build-sparse-threads 'some))
8012 (not (eq gnus-build-sparse-threads 'more))
8013 (null gnus-thread-expunge-below)
8014 (not gnus-use-nocem)))
8015 () ; Do nothing.
8016 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8017 (setq gnus-newsgroup-limit nil)
8018 (mapatoms
8019 (lambda (node)
8020 (unless (car (symbol-value node))
8021 ;; These threads have no parents -- they are roots.
8022 (let ((nodes (cdr (symbol-value node)))
8023 thread)
8024 (while nodes
8025 (if (and gnus-thread-expunge-below
8026 (< (gnus-thread-total-score (car nodes))
8027 gnus-thread-expunge-below))
8028 (gnus-expunge-thread (pop nodes))
8029 (setq thread (pop nodes))
8030 (gnus-summary-limit-children thread))))))
8031 gnus-newsgroup-dependencies)
8032 ;; If this limitation resulted in an empty group, we might
8033 ;; pop the previous limit and use it instead.
8034 (when (and (not gnus-newsgroup-limit)
8035 show-if-empty)
8036 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8037 gnus-newsgroup-limit))
8038
8039 (defun gnus-summary-limit-children (thread)
8040 "Return 1 if this subthread is visible and 0 if it is not."
8041 ;; First we get the number of visible children to this thread. This
8042 ;; is done by recursing down the thread using this function, so this
8043 ;; will really go down to a leaf article first, before slowly
8044 ;; working its way up towards the root.
8045 (when thread
8046 (let* ((max-lisp-eval-depth 5000)
8047 (children
8048 (if (cdr thread)
8049 (apply '+ (mapcar 'gnus-summary-limit-children
8050 (cdr thread)))
8051 0))
8052 (number (mail-header-number (car thread)))
8053 score)
8054 (if (and
8055 (not (memq number gnus-newsgroup-marked))
8056 (or
8057 ;; If this article is dormant and has absolutely no visible
8058 ;; children, then this article isn't visible.
8059 (and (memq number gnus-newsgroup-dormant)
8060 (zerop children))
8061 ;; If this is "fetch-old-headered" and there is no
8062 ;; visible children, then we don't want this article.
8063 (and (or (eq gnus-fetch-old-headers 'some)
8064 (numberp gnus-fetch-old-headers))
8065 (gnus-summary-article-ancient-p number)
8066 (zerop children))
8067 ;; If this is "fetch-old-headered" and `invisible', then
8068 ;; we don't want this article.
8069 (and (eq gnus-fetch-old-headers 'invisible)
8070 (gnus-summary-article-ancient-p number))
8071 ;; If this is a sparsely inserted article with no children,
8072 ;; we don't want it.
8073 (and (eq gnus-build-sparse-threads 'some)
8074 (gnus-summary-article-sparse-p number)
8075 (zerop children))
8076 ;; If we use expunging, and this article is really
8077 ;; low-scored, then we don't want this article.
8078 (when (and gnus-summary-expunge-below
8079 (< (setq score
8080 (or (cdr (assq number gnus-newsgroup-scored))
8081 gnus-summary-default-score))
8082 gnus-summary-expunge-below))
8083 ;; We increase the expunge-tally here, but that has
8084 ;; nothing to do with the limits, really.
8085 (incf gnus-newsgroup-expunged-tally)
8086 ;; We also mark as read here, if that's wanted.
8087 (when (and gnus-summary-mark-below
8088 (< score gnus-summary-mark-below))
8089 (setq gnus-newsgroup-unreads
8090 (delq number gnus-newsgroup-unreads))
8091 (if gnus-newsgroup-auto-expire
8092 (push number gnus-newsgroup-expirable)
8093 (push (cons number gnus-low-score-mark)
8094 gnus-newsgroup-reads)))
8095 t)
8096 ;; Do the `display' group parameter.
8097 (and gnus-newsgroup-display
8098 (not (funcall gnus-newsgroup-display)))
8099 ;; Check NoCeM things.
8100 (if (and gnus-use-nocem
8101 (gnus-nocem-unwanted-article-p
8102 (mail-header-id (car thread))))
8103 (progn
8104 (setq gnus-newsgroup-unreads
8105 (delq number gnus-newsgroup-unreads))
8106 t))))
8107 ;; Nope, invisible article.
8108 0
8109 ;; Ok, this article is to be visible, so we add it to the limit
8110 ;; and return 1.
8111 (push number gnus-newsgroup-limit)
8112 1))))
8113
8114 (defun gnus-expunge-thread (thread)
8115 "Mark all articles in THREAD as read."
8116 (let* ((number (mail-header-number (car thread))))
8117 (incf gnus-newsgroup-expunged-tally)
8118 ;; We also mark as read here, if that's wanted.
8119 (setq gnus-newsgroup-unreads
8120 (delq number gnus-newsgroup-unreads))
8121 (if gnus-newsgroup-auto-expire
8122 (push number gnus-newsgroup-expirable)
8123 (push (cons number gnus-low-score-mark)
8124 gnus-newsgroup-reads)))
8125 ;; Go recursively through all subthreads.
8126 (mapcar 'gnus-expunge-thread (cdr thread)))
8127
8128 ;; Summary article oriented commands
8129
8130 (defun gnus-summary-refer-parent-article (n)
8131 "Refer parent article N times.
8132 If N is negative, go to ancestor -N instead.
8133 The difference between N and the number of articles fetched is returned."
8134 (interactive "p")
8135 (let ((skip 1)
8136 error header ref)
8137 (when (not (natnump n))
8138 (setq skip (abs n)
8139 n 1))
8140 (while (and (> n 0)
8141 (not error))
8142 (setq header (gnus-summary-article-header))
8143 (if (and (eq (mail-header-number header)
8144 (cdr gnus-article-current))
8145 (equal gnus-newsgroup-name
8146 (car gnus-article-current)))
8147 ;; If we try to find the parent of the currently
8148 ;; displayed article, then we take a look at the actual
8149 ;; References header, since this is slightly more
8150 ;; reliable than the References field we got from the
8151 ;; server.
8152 (save-excursion
8153 (set-buffer gnus-original-article-buffer)
8154 (nnheader-narrow-to-headers)
8155 (unless (setq ref (message-fetch-field "references"))
8156 (when (setq ref (message-fetch-field "in-reply-to"))
8157 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8158 (widen))
8159 (setq ref
8160 ;; It's not the current article, so we take a bet on
8161 ;; the value we got from the server.
8162 (mail-header-references header)))
8163 (if (and ref
8164 (not (equal ref "")))
8165 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8166 (gnus-message 1 "Couldn't find parent"))
8167 (gnus-message 1 "No references in article %d"
8168 (gnus-summary-article-number))
8169 (setq error t))
8170 (decf n))
8171 (gnus-summary-position-point)
8172 n))
8173
8174 (defun gnus-summary-refer-references ()
8175 "Fetch all articles mentioned in the References header.
8176 Return the number of articles fetched."
8177 (interactive)
8178 (let ((ref (mail-header-references (gnus-summary-article-header)))
8179 (current (gnus-summary-article-number))
8180 (n 0))
8181 (if (or (not ref)
8182 (equal ref ""))
8183 (error "No References in the current article")
8184 ;; For each Message-ID in the References header...
8185 (while (string-match "<[^>]*>" ref)
8186 (incf n)
8187 ;; ... fetch that article.
8188 (gnus-summary-refer-article
8189 (prog1 (match-string 0 ref)
8190 (setq ref (substring ref (match-end 0))))))
8191 (gnus-summary-goto-subject current)
8192 (gnus-summary-position-point)
8193 n)))
8194
8195 (defun gnus-summary-refer-thread (&optional limit)
8196 "Fetch all articles in the current thread.
8197 If LIMIT (the numerical prefix), fetch that many old headers instead
8198 of what's specified by the `gnus-refer-thread-limit' variable."
8199 (interactive "P")
8200 (let ((id (mail-header-id (gnus-summary-article-header)))
8201 (limit (if limit (prefix-numeric-value limit)
8202 gnus-refer-thread-limit)))
8203 (unless (eq gnus-fetch-old-headers 'invisible)
8204 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8205 ;; Retrieve the headers and read them in.
8206 (if (eq (if (numberp limit)
8207 (gnus-retrieve-headers
8208 (list (min
8209 (+ (mail-header-number
8210 (gnus-summary-article-header))
8211 limit)
8212 gnus-newsgroup-end))
8213 gnus-newsgroup-name (* limit 2))
8214 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8215 ;; headers.
8216 (gnus-retrieve-headers (list gnus-newsgroup-end)
8217 gnus-newsgroup-name limit))
8218 'nov)
8219 (gnus-build-all-threads)
8220 (error "Can't fetch thread from back ends that don't support NOV"))
8221 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8222 (gnus-summary-limit-include-thread id)))
8223
8224 (defun gnus-summary-refer-article (message-id)
8225 "Fetch an article specified by MESSAGE-ID."
8226 (interactive "sMessage-ID: ")
8227 (when (and (stringp message-id)
8228 (not (zerop (length message-id))))
8229 (setq message-id (gnus-replace-in-string message-id " " ""))
8230 ;; Construct the correct Message-ID if necessary.
8231 ;; Suggested by tale@pawl.rpi.edu.
8232 (unless (string-match "^<" message-id)
8233 (setq message-id (concat "<" message-id)))
8234 (unless (string-match ">$" message-id)
8235 (setq message-id (concat message-id ">")))
8236 ;; People often post MIDs from URLs, so unhex it:
8237 (unless (string-match "@" message-id)
8238 (setq message-id (gnus-url-unhex-string message-id)))
8239 (let* ((header (gnus-id-to-header message-id))
8240 (sparse (and header
8241 (gnus-summary-article-sparse-p
8242 (mail-header-number header))
8243 (memq (mail-header-number header)
8244 gnus-newsgroup-limit)))
8245 number)
8246 (cond
8247 ;; If the article is present in the buffer we just go to it.
8248 ((and header
8249 (or (not (gnus-summary-article-sparse-p
8250 (mail-header-number header)))
8251 sparse))
8252 (prog1
8253 (gnus-summary-goto-article
8254 (mail-header-number header) nil t)
8255 (when sparse
8256 (gnus-summary-update-article (mail-header-number header)))))
8257 (t
8258 ;; We fetch the article.
8259 (catch 'found
8260 (dolist (gnus-override-method (gnus-refer-article-methods))
8261 (when (and (gnus-check-server gnus-override-method)
8262 ;; Fetch the header,
8263 (setq number (gnus-summary-insert-subject message-id)))
8264 ;; and display the article.
8265 (gnus-summary-select-article nil nil nil number)
8266 (throw 'found t)))
8267 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8268
8269 (defun gnus-refer-article-methods ()
8270 "Return a list of referable methods."
8271 (cond
8272 ;; No method, so we default to current and native.
8273 ((null gnus-refer-article-method)
8274 (list gnus-current-select-method gnus-select-method))
8275 ;; Current.
8276 ((eq 'current gnus-refer-article-method)
8277 (list gnus-current-select-method))
8278 ;; List of select methods.
8279 ((not (and (symbolp (car gnus-refer-article-method))
8280 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8281 (let (out)
8282 (dolist (method gnus-refer-article-method)
8283 (push (if (eq 'current method)
8284 gnus-current-select-method
8285 method)
8286 out))
8287 (nreverse out)))
8288 ;; One single select method.
8289 (t
8290 (list gnus-refer-article-method))))
8291
8292 (defun gnus-summary-edit-parameters ()
8293 "Edit the group parameters of the current group."
8294 (interactive)
8295 (gnus-group-edit-group gnus-newsgroup-name 'params))
8296
8297 (defun gnus-summary-customize-parameters ()
8298 "Customize the group parameters of the current group."
8299 (interactive)
8300 (gnus-group-customize gnus-newsgroup-name))
8301
8302 (defun gnus-summary-enter-digest-group (&optional force)
8303 "Enter an nndoc group based on the current article.
8304 If FORCE, force a digest interpretation. If not, try
8305 to guess what the document format is."
8306 (interactive "P")
8307 (let ((conf gnus-current-window-configuration))
8308 (save-window-excursion
8309 (save-excursion
8310 (let (gnus-article-prepare-hook
8311 gnus-display-mime-function
8312 gnus-break-pages)
8313 (gnus-summary-select-article))))
8314 (setq gnus-current-window-configuration conf)
8315 (let* ((name (format "%s-%d"
8316 (gnus-group-prefixed-name
8317 gnus-newsgroup-name (list 'nndoc ""))
8318 (save-excursion
8319 (set-buffer gnus-summary-buffer)
8320 gnus-current-article)))
8321 (ogroup gnus-newsgroup-name)
8322 (params (append (gnus-info-params (gnus-get-info ogroup))
8323 (list (cons 'to-group ogroup))
8324 (list (cons 'parent-group ogroup))
8325 (list (cons 'save-article-group ogroup))))
8326 (case-fold-search t)
8327 (buf (current-buffer))
8328 dig to-address)
8329 (save-excursion
8330 (set-buffer gnus-original-article-buffer)
8331 ;; Have the digest group inherit the main mail address of
8332 ;; the parent article.
8333 (when (setq to-address (or (gnus-fetch-field "reply-to")
8334 (gnus-fetch-field "from")))
8335 (setq params (append
8336 (list (cons 'to-address
8337 (funcall gnus-decode-encoded-word-function
8338 to-address))))))
8339 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8340 (insert-buffer-substring gnus-original-article-buffer)
8341 ;; Remove lines that may lead nndoc to misinterpret the
8342 ;; document type.
8343 (narrow-to-region
8344 (goto-char (point-min))
8345 (or (search-forward "\n\n" nil t) (point)))
8346 (goto-char (point-min))
8347 (delete-matching-lines "^Path:\\|^From ")
8348 (widen))
8349 (unwind-protect
8350 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8351 (gnus-newsgroup-ephemeral-ignored-charsets
8352 gnus-newsgroup-ignored-charsets))
8353 (gnus-group-read-ephemeral-group
8354 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8355 (nndoc-article-type
8356 ,(if force 'mbox 'guess)))
8357 t nil nil nil
8358 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8359 "ADAPT")))))
8360 ;; Make all postings to this group go to the parent group.
8361 (nconc (gnus-info-params (gnus-get-info name))
8362 params)
8363 ;; Couldn't select this doc group.
8364 (switch-to-buffer buf)
8365 (gnus-set-global-variables)
8366 (gnus-configure-windows 'summary)
8367 (gnus-message 3 "Article couldn't be entered?"))
8368 (kill-buffer dig)))))
8369
8370 (defun gnus-summary-read-document (n)
8371 "Open a new group based on the current article(s).
8372 This will allow you to read digests and other similar
8373 documents as newsgroups.
8374 Obeys the standard process/prefix convention."
8375 (interactive "P")
8376 (let* ((articles (gnus-summary-work-articles n))
8377 (ogroup gnus-newsgroup-name)
8378 (params (append (gnus-info-params (gnus-get-info ogroup))
8379 (list (cons 'to-group ogroup))))
8380 article group egroup groups vgroup)
8381 (while (setq article (pop articles))
8382 (setq group (format "%s-%d" gnus-newsgroup-name article))
8383 (gnus-summary-remove-process-mark article)
8384 (when (gnus-summary-display-article article)
8385 (save-excursion
8386 (with-temp-buffer
8387 (insert-buffer-substring gnus-original-article-buffer)
8388 ;; Remove some headers that may lead nndoc to make
8389 ;; the wrong guess.
8390 (message-narrow-to-head)
8391 (goto-char (point-min))
8392 (delete-matching-lines "^\\(Path\\):\\|^From ")
8393 (widen)
8394 (if (setq egroup
8395 (gnus-group-read-ephemeral-group
8396 group `(nndoc ,group (nndoc-address ,(current-buffer))
8397 (nndoc-article-type guess))
8398 t nil t))
8399 (progn
8400 ;; Make all postings to this group go to the parent group.
8401 (nconc (gnus-info-params (gnus-get-info egroup))
8402 params)
8403 (push egroup groups))
8404 ;; Couldn't select this doc group.
8405 (gnus-error 3 "Article couldn't be entered"))))))
8406 ;; Now we have selected all the documents.
8407 (cond
8408 ((not groups)
8409 (error "None of the articles could be interpreted as documents"))
8410 ((gnus-group-read-ephemeral-group
8411 (setq vgroup (format
8412 "nnvirtual:%s-%s" gnus-newsgroup-name
8413 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8414 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8415 t
8416 (cons (current-buffer) 'summary)))
8417 (t
8418 (error "Couldn't select virtual nndoc group")))))
8419
8420 (defun gnus-summary-isearch-article (&optional regexp-p)
8421 "Do incremental search forward on the current article.
8422 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8423 (interactive "P")
8424 (gnus-summary-select-article)
8425 (gnus-configure-windows 'article)
8426 (gnus-eval-in-buffer-window gnus-article-buffer
8427 (save-restriction
8428 (widen)
8429 (isearch-forward regexp-p))))
8430
8431 (defun gnus-summary-search-article-forward (regexp &optional backward)
8432 "Search for an article containing REGEXP forward.
8433 If BACKWARD, search backward instead."
8434 (interactive
8435 (list (read-string
8436 (format "Search article %s (regexp%s): "
8437 (if current-prefix-arg "backward" "forward")
8438 (if gnus-last-search-regexp
8439 (concat ", default " gnus-last-search-regexp)
8440 "")))
8441 current-prefix-arg))
8442 (if (string-equal regexp "")
8443 (setq regexp (or gnus-last-search-regexp ""))
8444 (setq gnus-last-search-regexp regexp)
8445 (setq gnus-article-before-search gnus-current-article))
8446 ;; Intentionally set gnus-last-article.
8447 (setq gnus-last-article gnus-article-before-search)
8448 (let ((gnus-last-article gnus-last-article))
8449 (if (gnus-summary-search-article regexp backward)
8450 (gnus-summary-show-thread)
8451 (signal 'search-failed (list regexp)))))
8452
8453 (defun gnus-summary-search-article-backward (regexp)
8454 "Search for an article containing REGEXP backward."
8455 (interactive
8456 (list (read-string
8457 (format "Search article backward (regexp%s): "
8458 (if gnus-last-search-regexp
8459 (concat ", default " gnus-last-search-regexp)
8460 "")))))
8461 (gnus-summary-search-article-forward regexp 'backward))
8462
8463 (defun gnus-summary-search-article (regexp &optional backward)
8464 "Search for an article containing REGEXP.
8465 Optional argument BACKWARD means do search for backward.
8466 `gnus-select-article-hook' is not called during the search."
8467 ;; We have to require this here to make sure that the following
8468 ;; dynamic binding isn't shadowed by autoloading.
8469 (require 'gnus-async)
8470 (require 'gnus-art)
8471 (let ((gnus-select-article-hook nil) ;Disable hook.
8472 (gnus-article-prepare-hook nil)
8473 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8474 (gnus-use-article-prefetch nil)
8475 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8476 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8477 (gnus-visual nil)
8478 (gnus-keep-backlog nil)
8479 (gnus-break-pages nil)
8480 (gnus-summary-display-arrow nil)
8481 (gnus-updated-mode-lines nil)
8482 (gnus-auto-center-summary nil)
8483 (sum (current-buffer))
8484 (gnus-display-mime-function nil)
8485 (found nil)
8486 point)
8487 (gnus-save-hidden-threads
8488 (gnus-summary-select-article)
8489 (set-buffer gnus-article-buffer)
8490 (goto-char (window-point (get-buffer-window (current-buffer))))
8491 (when backward
8492 (forward-line -1))
8493 (while (not found)
8494 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8495 (if (if backward
8496 (re-search-backward regexp nil t)
8497 (re-search-forward regexp nil t))
8498 ;; We found the regexp.
8499 (progn
8500 (setq found 'found)
8501 (beginning-of-line)
8502 (set-window-start
8503 (get-buffer-window (current-buffer))
8504 (point))
8505 (forward-line 1)
8506 (set-window-point
8507 (get-buffer-window (current-buffer))
8508 (point))
8509 (set-buffer sum)
8510 (setq point (point)))
8511 ;; We didn't find it, so we go to the next article.
8512 (set-buffer sum)
8513 (setq found 'not)
8514 (while (eq found 'not)
8515 (if (not (if backward (gnus-summary-find-prev)
8516 (gnus-summary-find-next)))
8517 ;; No more articles.
8518 (setq found t)
8519 ;; Select the next article and adjust point.
8520 (unless (gnus-summary-article-sparse-p
8521 (gnus-summary-article-number))
8522 (setq found nil)
8523 (gnus-summary-select-article)
8524 (set-buffer gnus-article-buffer)
8525 (widen)
8526 (goto-char (if backward (point-max) (point-min))))))))
8527 (gnus-message 7 ""))
8528 ;; Return whether we found the regexp.
8529 (when (eq found 'found)
8530 (goto-char point)
8531 (gnus-summary-show-thread)
8532 (gnus-summary-goto-subject gnus-current-article)
8533 (gnus-summary-position-point)
8534 t)))
8535
8536 (defun gnus-find-matching-articles (header regexp)
8537 "Return a list of all articles that match REGEXP on HEADER.
8538 This search includes all articles in the current group that Gnus has
8539 fetched headers for, whether they are displayed or not."
8540 (let ((articles nil)
8541 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8542 (case-fold-search t))
8543 (dolist (header gnus-newsgroup-headers)
8544 (when (string-match regexp (funcall func header))
8545 (push (mail-header-number header) articles)))
8546 (nreverse articles)))
8547
8548 (defun gnus-summary-find-matching (header regexp &optional backward unread
8549 not-case-fold not-matching)
8550 "Return a list of all articles that match REGEXP on HEADER.
8551 The search stars on the current article and goes forwards unless
8552 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8553 If UNREAD is non-nil, only unread articles will
8554 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8555 in the comparisons. If NOT-MATCHING, return a list of all articles that
8556 not match REGEXP on HEADER."
8557 (let ((case-fold-search (not not-case-fold))
8558 articles d func)
8559 (if (consp header)
8560 (if (eq (car header) 'extra)
8561 (setq func
8562 `(lambda (h)
8563 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8564 "")))
8565 (error "%s is an invalid header" header))
8566 (unless (fboundp (intern (concat "mail-header-" header)))
8567 (error "%s is not a valid header" header))
8568 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8569 (dolist (d (if (eq backward 'all)
8570 gnus-newsgroup-data
8571 (gnus-data-find-list
8572 (gnus-summary-article-number)
8573 (gnus-data-list backward))))
8574 (when (and (or (not unread) ; We want all articles...
8575 (gnus-data-unread-p d)) ; Or just unreads.
8576 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8577 (if not-matching
8578 (not (string-match
8579 regexp
8580 (funcall func (gnus-data-header d))))
8581 (string-match regexp
8582 (funcall func (gnus-data-header d)))))
8583 (push (gnus-data-number d) articles))) ; Success!
8584 (nreverse articles)))
8585
8586 (defun gnus-summary-execute-command (header regexp command &optional backward)
8587 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8588 If HEADER is an empty string (or nil), the match is done on the entire
8589 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8590 (interactive
8591 (list (let ((completion-ignore-case t))
8592 (completing-read
8593 "Header name: "
8594 (mapcar (lambda (header) (list (format "%s" header)))
8595 (append
8596 '("Number" "Subject" "From" "Lines" "Date"
8597 "Message-ID" "Xref" "References" "Body")
8598 gnus-extra-headers))
8599 nil 'require-match))
8600 (read-string "Regexp: ")
8601 (read-key-sequence "Command: ")
8602 current-prefix-arg))
8603 (when (equal header "Body")
8604 (setq header ""))
8605 ;; Hidden thread subtrees must be searched as well.
8606 (gnus-summary-show-all-threads)
8607 ;; We don't want to change current point nor window configuration.
8608 (save-excursion
8609 (save-window-excursion
8610 (let (gnus-visual
8611 gnus-treat-strip-trailing-blank-lines
8612 gnus-treat-strip-leading-blank-lines
8613 gnus-treat-strip-multiple-blank-lines
8614 gnus-treat-hide-boring-headers
8615 gnus-treat-fold-newsgroups
8616 gnus-article-prepare-hook)
8617 (gnus-message 6 "Executing %s..." (key-description command))
8618 ;; We'd like to execute COMMAND interactively so as to give arguments.
8619 (gnus-execute header regexp
8620 `(call-interactively ',(key-binding command))
8621 backward)
8622 (gnus-message 6 "Executing %s...done" (key-description command))))))
8623
8624 (defun gnus-summary-beginning-of-article ()
8625 "Scroll the article back to the beginning."
8626 (interactive)
8627 (gnus-summary-select-article)
8628 (gnus-configure-windows 'article)
8629 (gnus-eval-in-buffer-window gnus-article-buffer
8630 (widen)
8631 (goto-char (point-min))
8632 (when gnus-break-pages
8633 (gnus-narrow-to-page))))
8634
8635 (defun gnus-summary-end-of-article ()
8636 "Scroll to the end of the article."
8637 (interactive)
8638 (gnus-summary-select-article)
8639 (gnus-configure-windows 'article)
8640 (gnus-eval-in-buffer-window gnus-article-buffer
8641 (widen)
8642 (goto-char (point-max))
8643 (recenter -3)
8644 (when gnus-break-pages
8645 (when (re-search-backward page-delimiter nil t)
8646 (narrow-to-region (match-end 0) (point-max)))
8647 (gnus-narrow-to-page))))
8648
8649 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8650 "Truncate to LEN and quote all \"(\"'s in STRING."
8651 (gnus-replace-in-string (if (and len (> (length string) len))
8652 (substring string 0 len)
8653 string)
8654 "[()]" "\\\\\\&"))
8655
8656 (defun gnus-summary-print-article (&optional filename n)
8657 "Generate and print a PostScript image of the process-marked (mail) articles.
8658
8659 If used interactively, print the current article if none are
8660 process-marked. With prefix arg, prompt the user for the name of the
8661 file to save in.
8662
8663 When used from Lisp, accept two optional args FILENAME and N. N means
8664 to print the next N articles. If N is negative, print the N previous
8665 articles. If N is nil and articles have been marked with the process
8666 mark, print these instead.
8667
8668 If the optional first argument FILENAME is nil, send the image to the
8669 printer. If FILENAME is a string, save the PostScript image in a file with
8670 that name. If FILENAME is a number, prompt the user for the name of the file
8671 to save in."
8672 (interactive (list (ps-print-preprint current-prefix-arg)))
8673 (dolist (article (gnus-summary-work-articles n))
8674 (gnus-summary-select-article nil nil 'pseudo article)
8675 (gnus-eval-in-buffer-window gnus-article-buffer
8676 (gnus-print-buffer))
8677 (gnus-summary-remove-process-mark article))
8678 (ps-despool filename))
8679
8680 (defun gnus-print-buffer ()
8681 (let ((buffer (generate-new-buffer " *print*")))
8682 (unwind-protect
8683 (progn
8684 (copy-to-buffer buffer (point-min) (point-max))
8685 (set-buffer buffer)
8686 (gnus-remove-text-with-property 'gnus-decoration)
8687 (when (gnus-visual-p 'article-highlight 'highlight)
8688 ;; Copy-to-buffer doesn't copy overlay. So redo
8689 ;; highlight.
8690 (let ((gnus-article-buffer buffer))
8691 (gnus-article-highlight-citation t)
8692 (gnus-article-highlight-signature)
8693 (gnus-article-emphasize)
8694 (gnus-article-delete-invisible-text)))
8695 (let ((ps-left-header
8696 (list
8697 (concat "("
8698 (gnus-summary-print-truncate-and-quote
8699 (mail-header-subject gnus-current-headers)
8700 66) ")")
8701 (concat "("
8702 (gnus-summary-print-truncate-and-quote
8703 (mail-header-from gnus-current-headers)
8704 45) ")")))
8705 (ps-right-header
8706 (list
8707 "/pagenumberstring load"
8708 (concat "("
8709 (mail-header-date gnus-current-headers) ")"))))
8710 (gnus-run-hooks 'gnus-ps-print-hook)
8711 (save-excursion
8712 (if window-system
8713 (ps-spool-buffer-with-faces)
8714 (ps-spool-buffer)))))
8715 (kill-buffer buffer))))
8716
8717 (defun gnus-summary-show-article (&optional arg)
8718 "Force redisplaying of the current article.
8719 If ARG (the prefix) is a number, show the article with the charset
8720 defined in `gnus-summary-show-article-charset-alist', or the charset
8721 input.
8722 If ARG (the prefix) is non-nil and not a number, show the raw article
8723 without any article massaging functions being run. Normally, the key
8724 strokes are `C-u g'."
8725 (interactive "P")
8726 (cond
8727 ((numberp arg)
8728 (gnus-summary-show-article t)
8729 (let ((gnus-newsgroup-charset
8730 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8731 (mm-read-coding-system
8732 "View as charset: " ;; actually it is coding system.
8733 (save-excursion
8734 (set-buffer gnus-article-buffer)
8735 (mm-detect-coding-region (point) (point-max))))))
8736 (gnus-newsgroup-ignored-charsets 'gnus-all))
8737 (gnus-summary-select-article nil 'force)
8738 (let ((deps gnus-newsgroup-dependencies)
8739 head header lines)
8740 (save-excursion
8741 (set-buffer gnus-original-article-buffer)
8742 (save-restriction
8743 (message-narrow-to-head)
8744 (setq head (buffer-string))
8745 (goto-char (point-min))
8746 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8747 (goto-char (point-max))
8748 (widen)
8749 (setq lines (1- (count-lines (point) (point-max))))))
8750 (with-temp-buffer
8751 (insert (format "211 %d Article retrieved.\n"
8752 (cdr gnus-article-current)))
8753 (insert head)
8754 (if lines (insert (format "Lines: %d\n" lines)))
8755 (insert ".\n")
8756 (let ((nntp-server-buffer (current-buffer)))
8757 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8758 (gnus-data-set-header
8759 (gnus-data-find (cdr gnus-article-current))
8760 header)
8761 (gnus-summary-update-article-line
8762 (cdr gnus-article-current) header)
8763 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8764 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8765 ((not arg)
8766 ;; Select the article the normal way.
8767 (gnus-summary-select-article nil 'force))
8768 (t
8769 ;; We have to require this here to make sure that the following
8770 ;; dynamic binding isn't shadowed by autoloading.
8771 (require 'gnus-async)
8772 (require 'gnus-art)
8773 ;; Bind the article treatment functions to nil.
8774 (let ((gnus-have-all-headers t)
8775 gnus-article-prepare-hook
8776 gnus-article-decode-hook
8777 gnus-display-mime-function
8778 gnus-break-pages)
8779 ;; Destroy any MIME parts.
8780 (when (gnus-buffer-live-p gnus-article-buffer)
8781 (save-excursion
8782 (set-buffer gnus-article-buffer)
8783 (mm-destroy-parts gnus-article-mime-handles)
8784 ;; Set it to nil for safety reason.
8785 (setq gnus-article-mime-handle-alist nil)
8786 (setq gnus-article-mime-handles nil)))
8787 (gnus-summary-select-article nil 'force))))
8788 (gnus-summary-goto-subject gnus-current-article)
8789 (gnus-summary-position-point))
8790
8791 (defun gnus-summary-show-raw-article ()
8792 "Show the raw article without any article massaging functions being run."
8793 (interactive)
8794 (gnus-summary-show-article t))
8795
8796 (defun gnus-summary-verbose-headers (&optional arg)
8797 "Toggle permanent full header display.
8798 If ARG is a positive number, turn header display on.
8799 If ARG is a negative number, turn header display off."
8800 (interactive "P")
8801 (setq gnus-show-all-headers
8802 (cond ((or (not (numberp arg))
8803 (zerop arg))
8804 (not gnus-show-all-headers))
8805 ((natnump arg)
8806 t)))
8807 (gnus-summary-show-article))
8808
8809 (defun gnus-summary-toggle-header (&optional arg)
8810 "Show the headers if they are hidden, or hide them if they are shown.
8811 If ARG is a positive number, show the entire header.
8812 If ARG is a negative number, hide the unwanted header lines."
8813 (interactive "P")
8814 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8815 (get-buffer-window gnus-article-buffer t))))
8816 (with-current-buffer gnus-article-buffer
8817 (widen)
8818 (article-narrow-to-head)
8819 (let* ((buffer-read-only nil)
8820 (inhibit-point-motion-hooks t)
8821 (hidden (if (numberp arg)
8822 (>= arg 0)
8823 (or (not (looking-at "[^ \t\n]+:"))
8824 (gnus-article-hidden-text-p 'headers))))
8825 s e)
8826 (delete-region (point-min) (point-max))
8827 (with-current-buffer gnus-original-article-buffer
8828 (goto-char (setq s (point-min)))
8829 (setq e (if (search-forward "\n\n" nil t)
8830 (1- (point))
8831 (point-max))))
8832 (insert-buffer-substring gnus-original-article-buffer s e)
8833 (run-hooks 'gnus-article-decode-hook)
8834 (if hidden
8835 (let ((gnus-treat-hide-headers nil)
8836 (gnus-treat-hide-boring-headers nil))
8837 (gnus-delete-wash-type 'headers)
8838 (gnus-treat-article 'head))
8839 (gnus-treat-article 'head))
8840 (widen)
8841 (if window
8842 (set-window-start window (goto-char (point-min))))
8843 (if gnus-break-pages
8844 (gnus-narrow-to-page)
8845 (when (gnus-visual-p 'page-marker)
8846 (let ((buffer-read-only nil))
8847 (gnus-remove-text-with-property 'gnus-prev)
8848 (gnus-remove-text-with-property 'gnus-next))))
8849 (gnus-set-mode-line 'article)))))
8850
8851 (defun gnus-summary-show-all-headers ()
8852 "Make all header lines visible."
8853 (interactive)
8854 (gnus-summary-toggle-header 1))
8855
8856 (defun gnus-summary-caesar-message (&optional arg)
8857 "Caesar rotate the current article by 13.
8858 The numerical prefix specifies how many places to rotate each letter
8859 forward."
8860 (interactive "P")
8861 (gnus-summary-select-article)
8862 (let ((mail-header-separator ""))
8863 (gnus-eval-in-buffer-window gnus-article-buffer
8864 (save-restriction
8865 (widen)
8866 (let ((start (window-start))
8867 buffer-read-only)
8868 (message-caesar-buffer-body arg)
8869 (set-window-start (get-buffer-window (current-buffer)) start)))))
8870 ;; Create buttons and stuff...
8871 (gnus-treat-article nil))
8872
8873 (autoload 'unmorse-region "morse"
8874 "Convert morse coded text in region to ordinary ASCII text."
8875 t)
8876
8877 (defun gnus-summary-morse-message (&optional arg)
8878 "Morse decode the current article."
8879 (interactive "P")
8880 (gnus-summary-select-article)
8881 (let ((mail-header-separator ""))
8882 (gnus-eval-in-buffer-window gnus-article-buffer
8883 (save-excursion
8884 (save-restriction
8885 (widen)
8886 (let ((pos (window-start))
8887 buffer-read-only)
8888 (goto-char (point-min))
8889 (when (message-goto-body)
8890 (gnus-narrow-to-body))
8891 (goto-char (point-min))
8892 (while (re-search-forward "·" (point-max) t)
8893 (replace-match "."))
8894 (unmorse-region (point-min) (point-max))
8895 (widen)
8896 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8897
8898 (defun gnus-summary-stop-page-breaking ()
8899 "Stop page breaking in the current article."
8900 (interactive)
8901 (gnus-summary-select-article)
8902 (gnus-eval-in-buffer-window gnus-article-buffer
8903 (widen)
8904 (when (gnus-visual-p 'page-marker)
8905 (let ((buffer-read-only nil))
8906 (gnus-remove-text-with-property 'gnus-prev)
8907 (gnus-remove-text-with-property 'gnus-next))
8908 (setq gnus-page-broken nil))))
8909
8910 (defun gnus-summary-move-article (&optional n to-newsgroup
8911 select-method action)
8912 "Move the current article to a different newsgroup.
8913 If N is a positive number, move the N next articles.
8914 If N is a negative number, move the N previous articles.
8915 If N is nil and any articles have been marked with the process mark,
8916 move those articles instead.
8917 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8918 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8919 re-spool using this method.
8920
8921 When called interactively with TO-NEWSGROUP being nil, the value of
8922 the variable `gnus-move-split-methods' is used for finding a default
8923 for the target newsgroup.
8924
8925 For this function to work, both the current newsgroup and the
8926 newsgroup that you want to move to have to support the `request-move'
8927 and `request-accept' functions.
8928
8929 ACTION can be either `move' (the default), `crosspost' or `copy'."
8930 (interactive "P")
8931 (unless action
8932 (setq action 'move))
8933 ;; Check whether the source group supports the required functions.
8934 (cond ((and (eq action 'move)
8935 (not (gnus-check-backend-function
8936 'request-move-article gnus-newsgroup-name)))
8937 (error "The current group does not support article moving"))
8938 ((and (eq action 'crosspost)
8939 (not (gnus-check-backend-function
8940 'request-replace-article gnus-newsgroup-name)))
8941 (error "The current group does not support article editing")))
8942 (let ((articles (gnus-summary-work-articles n))
8943 (prefix (if (gnus-check-backend-function
8944 'request-move-article gnus-newsgroup-name)
8945 (gnus-group-real-prefix gnus-newsgroup-name)
8946 ""))
8947 (names '((move "Move" "Moving")
8948 (copy "Copy" "Copying")
8949 (crosspost "Crosspost" "Crossposting")))
8950 (copy-buf (save-excursion
8951 (nnheader-set-temp-buffer " *copy article*")))
8952 art-group to-method new-xref article to-groups)
8953 (unless (assq action names)
8954 (error "Unknown action %s" action))
8955 ;; Read the newsgroup name.
8956 (when (and (not to-newsgroup)
8957 (not select-method))
8958 (if (and gnus-move-split-methods
8959 (not
8960 (and (memq gnus-current-article articles)
8961 (gnus-buffer-live-p gnus-original-article-buffer))))
8962 ;; When `gnus-move-split-methods' is non-nil, we have to
8963 ;; select an article to give `gnus-read-move-group-name' an
8964 ;; opportunity to suggest an appropriate default. However,
8965 ;; we needn't render or mark the article.
8966 (let ((gnus-display-mime-function nil)
8967 (gnus-article-prepare-hook nil)
8968 (gnus-mark-article-hook nil))
8969 (gnus-summary-select-article nil nil nil (car articles))))
8970 (setq to-newsgroup
8971 (gnus-read-move-group-name
8972 (cadr (assq action names))
8973 (symbol-value (intern (format "gnus-current-%s-group" action)))
8974 articles prefix))
8975 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8976 (setq to-method (or select-method
8977 (gnus-server-to-method
8978 (gnus-group-method to-newsgroup))))
8979 ;; Check the method we are to move this article to...
8980 (unless (gnus-check-backend-function
8981 'request-accept-article (car to-method))
8982 (error "%s does not support article copying" (car to-method)))
8983 (unless (gnus-check-server to-method)
8984 (error "Can't open server %s" (car to-method)))
8985 (gnus-message 6 "%s to %s: %s..."
8986 (caddr (assq action names))
8987 (or (car select-method) to-newsgroup) articles)
8988 (while articles
8989 (setq article (pop articles))
8990 (setq
8991 art-group
8992 (cond
8993 ;; Move the article.
8994 ((eq action 'move)
8995 ;; Remove this article from future suppression.
8996 (gnus-dup-unsuppress-article article)
8997 (gnus-request-move-article
8998 article ; Article to move
8999 gnus-newsgroup-name ; From newsgroup
9000 (nth 1 (gnus-find-method-for-group
9001 gnus-newsgroup-name)) ; Server
9002 (list 'gnus-request-accept-article
9003 to-newsgroup (list 'quote select-method)
9004 (not articles) t) ; Accept form
9005 (not articles))) ; Only save nov last time
9006 ;; Copy the article.
9007 ((eq action 'copy)
9008 (save-excursion
9009 (set-buffer copy-buf)
9010 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9011 (gnus-request-accept-article
9012 to-newsgroup select-method (not articles) t))))
9013 ;; Crosspost the article.
9014 ((eq action 'crosspost)
9015 (let ((xref (message-tokenize-header
9016 (mail-header-xref (gnus-summary-article-header article))
9017 " ")))
9018 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9019 ":" (number-to-string article)))
9020 (unless xref
9021 (setq xref (list (system-name))))
9022 (setq new-xref
9023 (concat
9024 (mapconcat 'identity
9025 (delete "Xref:" (delete new-xref xref))
9026 " ")
9027 " " new-xref))
9028 (save-excursion
9029 (set-buffer copy-buf)
9030 ;; First put the article in the destination group.
9031 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9032 (when (consp (setq art-group
9033 (gnus-request-accept-article
9034 to-newsgroup select-method (not articles))))
9035 (setq new-xref (concat new-xref " " (car art-group)
9036 ":"
9037 (number-to-string (cdr art-group))))
9038 ;; Now we have the new Xrefs header, so we insert
9039 ;; it and replace the new article.
9040 (nnheader-replace-header "Xref" new-xref)
9041 (gnus-request-replace-article
9042 (cdr art-group) to-newsgroup (current-buffer))
9043 art-group))))))
9044 (cond
9045 ((not art-group)
9046 (gnus-message 1 "Couldn't %s article %s: %s"
9047 (cadr (assq action names)) article
9048 (nnheader-get-report (car to-method))))
9049 ((eq art-group 'junk)
9050 (when (eq action 'move)
9051 (gnus-summary-mark-article article gnus-canceled-mark)
9052 (gnus-message 4 "Deleted article %s" article)
9053 ;; run the delete hook
9054 (run-hook-with-args 'gnus-summary-article-delete-hook
9055 action
9056 (gnus-data-header
9057 (assoc article (gnus-data-list nil)))
9058 gnus-newsgroup-name nil
9059 select-method)))
9060 (t
9061 (let* ((pto-group (gnus-group-prefixed-name
9062 (car art-group) to-method))
9063 (entry
9064 (gnus-gethash pto-group gnus-newsrc-hashtb))
9065 (info (nth 2 entry))
9066 (to-group (gnus-info-group info))
9067 to-marks)
9068 ;; Update the group that has been moved to.
9069 (when (and info
9070 (memq action '(move copy)))
9071 (unless (member to-group to-groups)
9072 (push to-group to-groups))
9073
9074 (unless (memq article gnus-newsgroup-unreads)
9075 (push 'read to-marks)
9076 (gnus-info-set-read
9077 info (gnus-add-to-range (gnus-info-read info)
9078 (list (cdr art-group)))))
9079
9080 ;; See whether the article is to be put in the cache.
9081 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9082 gnus-article-mark-lists
9083 (delete '(expirable . expire)
9084 (copy-sequence gnus-article-mark-lists))))
9085 (to-article (cdr art-group)))
9086
9087 ;; Enter the article into the cache in the new group,
9088 ;; if that is required.
9089 (when gnus-use-cache
9090 (gnus-cache-possibly-enter-article
9091 to-group to-article
9092 (memq article gnus-newsgroup-marked)
9093 (memq article gnus-newsgroup-dormant)
9094 (memq article gnus-newsgroup-unreads)))
9095
9096 (when gnus-preserve-marks
9097 ;; Copy any marks over to the new group.
9098 (when (and (equal to-group gnus-newsgroup-name)
9099 (not (memq article gnus-newsgroup-unreads)))
9100 ;; Mark this article as read in this group.
9101 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9102 (setcdr (gnus-active to-group) to-article)
9103 (setcdr gnus-newsgroup-active to-article))
9104
9105 (while marks
9106 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9107 (when (memq article (symbol-value
9108 (intern (format "gnus-newsgroup-%s"
9109 (caar marks)))))
9110 (push (cdar marks) to-marks)
9111 ;; If the other group is the same as this group,
9112 ;; then we have to add the mark to the list.
9113 (when (equal to-group gnus-newsgroup-name)
9114 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9115 (cons to-article
9116 (symbol-value
9117 (intern (format "gnus-newsgroup-%s"
9118 (caar marks)))))))
9119 ;; Copy the marks to other group.
9120 (gnus-add-marked-articles
9121 to-group (cdar marks) (list to-article) info)))
9122 (setq marks (cdr marks)))
9123
9124 (gnus-request-set-mark
9125 to-group (list (list (list to-article) 'add to-marks))))
9126
9127 (gnus-dribble-enter
9128 (concat "(gnus-group-set-info '"
9129 (gnus-prin1-to-string (gnus-get-info to-group))
9130 ")"))))
9131
9132 ;; Update the Xref header in this article to point to
9133 ;; the new crossposted article we have just created.
9134 (when (eq action 'crosspost)
9135 (save-excursion
9136 (set-buffer copy-buf)
9137 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9138 (nnheader-replace-header "Xref" new-xref)
9139 (gnus-request-replace-article
9140 article gnus-newsgroup-name (current-buffer))))
9141
9142 ;; run the move/copy/crosspost/respool hook
9143 (run-hook-with-args 'gnus-summary-article-move-hook
9144 action
9145 (gnus-data-header
9146 (assoc article (gnus-data-list nil)))
9147 gnus-newsgroup-name
9148 to-newsgroup
9149 select-method))
9150
9151 ;;;!!!Why is this necessary?
9152 (set-buffer gnus-summary-buffer)
9153
9154 (gnus-summary-goto-subject article)
9155 (when (eq action 'move)
9156 (gnus-summary-mark-article article gnus-canceled-mark))))
9157 (gnus-summary-remove-process-mark article))
9158 ;; Re-activate all groups that have been moved to.
9159 (save-excursion
9160 (set-buffer gnus-group-buffer)
9161 (let ((gnus-group-marked to-groups))
9162 (gnus-group-get-new-news-this-group nil t)))
9163
9164 (gnus-kill-buffer copy-buf)
9165 (gnus-summary-position-point)
9166 (gnus-set-mode-line 'summary)))
9167
9168 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9169 "Copy the current article to some other group.
9170 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9171 When called interactively, if TO-NEWSGROUP is nil, use the value of
9172 the variable `gnus-move-split-methods' for finding a default target
9173 newsgroup.
9174 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9175 re-spool using this method."
9176 (interactive "P")
9177 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9178
9179 (defun gnus-summary-crosspost-article (&optional n)
9180 "Crosspost the current article to some other group."
9181 (interactive "P")
9182 (gnus-summary-move-article n nil nil 'crosspost))
9183
9184 (defcustom gnus-summary-respool-default-method nil
9185 "Default method type for respooling an article.
9186 If nil, use to the current newsgroup method."
9187 :type 'symbol
9188 :group 'gnus-summary-mail)
9189
9190 (defcustom gnus-summary-display-while-building nil
9191 "If non-nil, show and update the summary buffer as it's being built.
9192 If the value is t, update the buffer after every line is inserted. If
9193 the value is an integer (N), update the display every N lines."
9194 :version "22.1"
9195 :group 'gnus-thread
9196 :type '(choice (const :tag "off" nil)
9197 number
9198 (const :tag "frequently" t)))
9199
9200 (defun gnus-summary-respool-article (&optional n method)
9201 "Respool the current article.
9202 The article will be squeezed through the mail spooling process again,
9203 which means that it will be put in some mail newsgroup or other
9204 depending on `nnmail-split-methods'.
9205 If N is a positive number, respool the N next articles.
9206 If N is a negative number, respool the N previous articles.
9207 If N is nil and any articles have been marked with the process mark,
9208 respool those articles instead.
9209
9210 Respooling can be done both from mail groups and \"real\" newsgroups.
9211 In the former case, the articles in question will be moved from the
9212 current group into whatever groups they are destined to. In the
9213 latter case, they will be copied into the relevant groups."
9214 (interactive
9215 (list current-prefix-arg
9216 (let* ((methods (gnus-methods-using 'respool))
9217 (methname
9218 (symbol-name (or gnus-summary-respool-default-method
9219 (car (gnus-find-method-for-group
9220 gnus-newsgroup-name)))))
9221 (method
9222 (gnus-completing-read-with-default
9223 methname "Backend to use when respooling"
9224 methods nil t nil 'gnus-mail-method-history))
9225 ms)
9226 (cond
9227 ((zerop (length (setq ms (gnus-servers-using-backend
9228 (intern method)))))
9229 (list (intern method) ""))
9230 ((= 1 (length ms))
9231 (car ms))
9232 (t
9233 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9234 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9235 ms-alist))))))))
9236 (unless method
9237 (error "No method given for respooling"))
9238 (if (assoc (symbol-name
9239 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9240 (gnus-methods-using 'respool))
9241 (gnus-summary-move-article n nil method)
9242 (gnus-summary-copy-article n nil method)))
9243
9244 (defun gnus-summary-import-article (file &optional edit)
9245 "Import an arbitrary file into a mail newsgroup."
9246 (interactive "fImport file: \nP")
9247 (let ((group gnus-newsgroup-name)
9248 (now (current-time))
9249 atts lines group-art)
9250 (unless (gnus-check-backend-function 'request-accept-article group)
9251 (error "%s does not support article importing" group))
9252 (or (file-readable-p file)
9253 (not (file-regular-p file))
9254 (error "Can't read %s" file))
9255 (save-excursion
9256 (set-buffer (gnus-get-buffer-create " *import file*"))
9257 (erase-buffer)
9258 (nnheader-insert-file-contents file)
9259 (goto-char (point-min))
9260 (if (nnheader-article-p)
9261 (save-restriction
9262 (goto-char (point-min))
9263 (search-forward "\n\n" nil t)
9264 (narrow-to-region (point-min) (1- (point)))
9265 (goto-char (point-min))
9266 (unless (re-search-forward "^date:" nil t)
9267 (goto-char (point-max))
9268 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9269 ;; This doesn't look like an article, so we fudge some headers.
9270 (setq atts (file-attributes file)
9271 lines (count-lines (point-min) (point-max)))
9272 (insert "From: " (read-string "From: ") "\n"
9273 "Subject: " (read-string "Subject: ") "\n"
9274 "Date: " (message-make-date (nth 5 atts)) "\n"
9275 "Message-ID: " (message-make-message-id) "\n"
9276 "Lines: " (int-to-string lines) "\n"
9277 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9278 (setq group-art (gnus-request-accept-article group nil t))
9279 (kill-buffer (current-buffer)))
9280 (setq gnus-newsgroup-active (gnus-activate-group group))
9281 (forward-line 1)
9282 (gnus-summary-goto-article (cdr group-art) nil t)
9283 (when edit
9284 (gnus-summary-edit-article))))
9285
9286 (defun gnus-summary-create-article ()
9287 "Create an article in a mail newsgroup."
9288 (interactive)
9289 (let ((group gnus-newsgroup-name)
9290 (now (current-time))
9291 group-art)
9292 (unless (gnus-check-backend-function 'request-accept-article group)
9293 (error "%s does not support article importing" group))
9294 (save-excursion
9295 (set-buffer (gnus-get-buffer-create " *import file*"))
9296 (erase-buffer)
9297 (goto-char (point-min))
9298 ;; This doesn't look like an article, so we fudge some headers.
9299 (insert "From: " (read-string "From: ") "\n"
9300 "Subject: " (read-string "Subject: ") "\n"
9301 "Date: " (message-make-date now) "\n"
9302 "Message-ID: " (message-make-message-id) "\n")
9303 (setq group-art (gnus-request-accept-article group nil t))
9304 (kill-buffer (current-buffer)))
9305 (setq gnus-newsgroup-active (gnus-activate-group group))
9306 (forward-line 1)
9307 (gnus-summary-goto-article (cdr group-art) nil t)
9308 (gnus-summary-edit-article)))
9309
9310 (defun gnus-summary-article-posted-p ()
9311 "Say whether the current (mail) article is available from news as well.
9312 This will be the case if the article has both been mailed and posted."
9313 (interactive)
9314 (let ((id (mail-header-references (gnus-summary-article-header)))
9315 (gnus-override-method (car (gnus-refer-article-methods))))
9316 (if (gnus-request-head id "")
9317 (gnus-message 2 "The current message was found on %s"
9318 gnus-override-method)
9319 (gnus-message 2 "The current message couldn't be found on %s"
9320 gnus-override-method)
9321 nil)))
9322
9323 (defun gnus-summary-expire-articles (&optional now)
9324 "Expire all articles that are marked as expirable in the current group."
9325 (interactive)
9326 (when (and (not gnus-group-is-exiting-without-update-p)
9327 (gnus-check-backend-function
9328 'request-expire-articles gnus-newsgroup-name))
9329 ;; This backend supports expiry.
9330 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9331 (expirable (if total
9332 (progn
9333 ;; We need to update the info for
9334 ;; this group for `gnus-list-of-read-articles'
9335 ;; to give us the right answer.
9336 (gnus-run-hooks 'gnus-exit-group-hook)
9337 (gnus-summary-update-info)
9338 (gnus-list-of-read-articles gnus-newsgroup-name))
9339 (setq gnus-newsgroup-expirable
9340 (sort gnus-newsgroup-expirable '<))))
9341 (expiry-wait (if now 'immediate
9342 (gnus-group-find-parameter
9343 gnus-newsgroup-name 'expiry-wait)))
9344 (nnmail-expiry-target
9345 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9346 nnmail-expiry-target))
9347 es)
9348 (when expirable
9349 ;; There are expirable articles in this group, so we run them
9350 ;; through the expiry process.
9351 (gnus-message 6 "Expiring articles...")
9352 (unless (gnus-check-group gnus-newsgroup-name)
9353 (error "Can't open server for %s" gnus-newsgroup-name))
9354 ;; The list of articles that weren't expired is returned.
9355 (save-excursion
9356 (if expiry-wait
9357 (let ((nnmail-expiry-wait-function nil)
9358 (nnmail-expiry-wait expiry-wait))
9359 (setq es (gnus-request-expire-articles
9360 expirable gnus-newsgroup-name)))
9361 (setq es (gnus-request-expire-articles
9362 expirable gnus-newsgroup-name)))
9363 (unless total
9364 (setq gnus-newsgroup-expirable es))
9365 ;; We go through the old list of expirable, and mark all
9366 ;; really expired articles as nonexistent.
9367 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9368 (let ((gnus-use-cache nil))
9369 (dolist (article expirable)
9370 (when (and (not (memq article es))
9371 (gnus-data-find article))
9372 (gnus-summary-mark-article article gnus-canceled-mark)
9373 (run-hook-with-args 'gnus-summary-article-expire-hook
9374 'delete
9375 (gnus-data-header
9376 (assoc article (gnus-data-list nil)))
9377 gnus-newsgroup-name
9378 nil
9379 nil))))))
9380 (gnus-message 6 "Expiring articles...done")))))
9381
9382 (defun gnus-summary-expire-articles-now ()
9383 "Expunge all expirable articles in the current group.
9384 This means that *all* articles that are marked as expirable will be
9385 deleted forever, right now."
9386 (interactive)
9387 (or gnus-expert-user
9388 (gnus-yes-or-no-p
9389 "Are you really, really, really sure you want to delete all these messages? ")
9390 (error "Phew!"))
9391 (gnus-summary-expire-articles t))
9392
9393 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9394 (defun gnus-summary-delete-article (&optional n)
9395 "Delete the N next (mail) articles.
9396 This command actually deletes articles. This is not a marking
9397 command. The article will disappear forever from your life, never to
9398 return.
9399
9400 If N is negative, delete backwards.
9401 If N is nil and articles have been marked with the process mark,
9402 delete these instead.
9403
9404 If `gnus-novice-user' is non-nil you will be asked for
9405 confirmation before the articles are deleted."
9406 (interactive "P")
9407 (unless (gnus-check-backend-function 'request-expire-articles
9408 gnus-newsgroup-name)
9409 (error "The current newsgroup does not support article deletion"))
9410 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9411 (error "Couldn't open server"))
9412 ;; Compute the list of articles to delete.
9413 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9414 (nnmail-expiry-target 'delete)
9415 not-deleted)
9416 (if (and gnus-novice-user
9417 (not (gnus-yes-or-no-p
9418 (format "Do you really want to delete %s forever? "
9419 (if (> (length articles) 1)
9420 (format "these %s articles" (length articles))
9421 "this article")))))
9422 ()
9423 ;; Delete the articles.
9424 (setq not-deleted (gnus-request-expire-articles
9425 articles gnus-newsgroup-name 'force))
9426 (while articles
9427 (gnus-summary-remove-process-mark (car articles))
9428 ;; The backend might not have been able to delete the article
9429 ;; after all.
9430 (unless (memq (car articles) not-deleted)
9431 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9432 (let* ((article (car articles))
9433 (id (mail-header-id (gnus-data-header
9434 (assoc article (gnus-data-list nil))))))
9435 (run-hook-with-args 'gnus-summary-article-delete-hook
9436 'delete id gnus-newsgroup-name nil
9437 nil))
9438 (setq articles (cdr articles)))
9439 (when not-deleted
9440 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9441 (gnus-summary-position-point)
9442 (gnus-set-mode-line 'summary)
9443 not-deleted))
9444
9445 (defun gnus-summary-edit-article (&optional arg)
9446 "Edit the current article.
9447 This will have permanent effect only in mail groups.
9448 If ARG is nil, edit the decoded articles.
9449 If ARG is 1, edit the raw articles.
9450 If ARG is 2, edit the raw articles even in read-only groups.
9451 If ARG is 3, edit the articles with the current handles.
9452 Otherwise, allow editing of articles even in read-only
9453 groups."
9454 (interactive "P")
9455 (let (force raw current-handles)
9456 (cond
9457 ((null arg))
9458 ((eq arg 1)
9459 (setq raw t))
9460 ((eq arg 2)
9461 (setq raw t
9462 force t))
9463 ((eq arg 3)
9464 (setq current-handles
9465 (and (gnus-buffer-live-p gnus-article-buffer)
9466 (with-current-buffer gnus-article-buffer
9467 (prog1
9468 gnus-article-mime-handles
9469 (setq gnus-article-mime-handles nil))))))
9470 (t
9471 (setq force t)))
9472 (when (and raw (not force)
9473 (member gnus-newsgroup-name '("nndraft:delayed"
9474 "nndraft:drafts"
9475 "nndraft:queue")))
9476 (error "Can't edit the raw article in group %s"
9477 gnus-newsgroup-name))
9478 (save-excursion
9479 (set-buffer gnus-summary-buffer)
9480 (let ((mail-parse-charset gnus-newsgroup-charset)
9481 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9482 (gnus-set-global-variables)
9483 (when (and (not force)
9484 (gnus-group-read-only-p))
9485 (error "The current newsgroup does not support article editing"))
9486 (gnus-summary-show-article t)
9487 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9488 (with-current-buffer gnus-article-buffer
9489 (mm-enable-multibyte)))
9490 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9491 (setq raw t))
9492 (gnus-article-edit-article
9493 (if raw 'ignore
9494 `(lambda ()
9495 (let ((mbl mml-buffer-list))
9496 (setq mml-buffer-list nil)
9497 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
9498 (mime-to-mml ,'current-handles))
9499 (let ((mbl1 mml-buffer-list))
9500 (setq mml-buffer-list mbl)
9501 (set (make-local-variable 'mml-buffer-list) mbl1))
9502 (gnus-make-local-hook 'kill-buffer-hook)
9503 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9504 `(lambda (no-highlight)
9505 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9506 (message-options message-options)
9507 (message-options-set-recipient)
9508 (mail-parse-ignored-charsets
9509 ',gnus-newsgroup-ignored-charsets))
9510 ,(if (not raw) '(progn
9511 (mml-to-mime)
9512 (mml-destroy-buffers)
9513 (remove-hook 'kill-buffer-hook
9514 'mml-destroy-buffers t)
9515 (kill-local-variable 'mml-buffer-list)))
9516 (gnus-summary-edit-article-done
9517 ,(or (mail-header-references gnus-current-headers) "")
9518 ,(gnus-group-read-only-p)
9519 ,gnus-summary-buffer no-highlight))))))))
9520
9521 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9522
9523 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9524 no-highlight)
9525 "Make edits to the current article permanent."
9526 (interactive)
9527 (save-excursion
9528 ;; The buffer restriction contains the entire article if it exists.
9529 (when (article-goto-body)
9530 (let ((lines (count-lines (point) (point-max)))
9531 (length (- (point-max) (point)))
9532 (case-fold-search t)
9533 (body (copy-marker (point))))
9534 (goto-char (point-min))
9535 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9536 (delete-region (match-beginning 1) (match-end 1))
9537 (insert (number-to-string length)))
9538 (goto-char (point-min))
9539 (when (re-search-forward
9540 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9541 (delete-region (match-beginning 1) (match-end 1))
9542 (insert (number-to-string length)))
9543 (goto-char (point-min))
9544 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9545 (delete-region (match-beginning 1) (match-end 1))
9546 (insert (number-to-string lines))))))
9547 ;; Replace the article.
9548 (let ((buf (current-buffer)))
9549 (with-temp-buffer
9550 (insert-buffer-substring buf)
9551
9552 (if (and (not read-only)
9553 (not (gnus-request-replace-article
9554 (cdr gnus-article-current) (car gnus-article-current)
9555 (current-buffer) t)))
9556 (error "Couldn't replace article")
9557 ;; Update the summary buffer.
9558 (if (and references
9559 (equal (message-tokenize-header references " ")
9560 (message-tokenize-header
9561 (or (message-fetch-field "references") "") " ")))
9562 ;; We only have to update this line.
9563 (save-excursion
9564 (save-restriction
9565 (message-narrow-to-head)
9566 (let ((head (buffer-substring-no-properties
9567 (point-min) (point-max)))
9568 header)
9569 (with-temp-buffer
9570 (insert (format "211 %d Article retrieved.\n"
9571 (cdr gnus-article-current)))
9572 (insert head)
9573 (insert ".\n")
9574 (let ((nntp-server-buffer (current-buffer)))
9575 (setq header (car (gnus-get-newsgroup-headers
9576 nil t))))
9577 (save-excursion
9578 (set-buffer gnus-summary-buffer)
9579 (gnus-data-set-header
9580 (gnus-data-find (cdr gnus-article-current))
9581 header)
9582 (gnus-summary-update-article-line
9583 (cdr gnus-article-current) header)
9584 (if (gnus-summary-goto-subject
9585 (cdr gnus-article-current) nil t)
9586 (gnus-summary-update-secondary-mark
9587 (cdr gnus-article-current))))))))
9588 ;; Update threads.
9589 (set-buffer (or buffer gnus-summary-buffer))
9590 (gnus-summary-update-article (cdr gnus-article-current))
9591 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9592 (gnus-summary-update-secondary-mark
9593 (cdr gnus-article-current))))
9594 ;; Prettify the article buffer again.
9595 (unless no-highlight
9596 (save-excursion
9597 (set-buffer gnus-article-buffer)
9598 ;;;!!! Fix this -- article should be rehighlighted.
9599 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9600 (set-buffer gnus-original-article-buffer)
9601 (gnus-request-article
9602 (cdr gnus-article-current)
9603 (car gnus-article-current) (current-buffer))))
9604 ;; Prettify the summary buffer line.
9605 (when (gnus-visual-p 'summary-highlight 'highlight)
9606 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9607
9608 (defun gnus-summary-edit-wash (key)
9609 "Perform editing command KEY in the article buffer."
9610 (interactive
9611 (list
9612 (progn
9613 (message "%s" (concat (this-command-keys) "- "))
9614 (read-char))))
9615 (message "")
9616 (gnus-summary-edit-article)
9617 (execute-kbd-macro (concat (this-command-keys) key))
9618 (gnus-article-edit-done))
9619
9620 ;;; Respooling
9621
9622 (defun gnus-summary-respool-query (&optional silent trace)
9623 "Query where the respool algorithm would put this article."
9624 (interactive)
9625 (let (gnus-mark-article-hook)
9626 (gnus-summary-select-article)
9627 (save-excursion
9628 (set-buffer gnus-original-article-buffer)
9629 (let ((groups (nnmail-article-group 'identity trace)))
9630 (unless silent
9631 (if groups
9632 (message "This message would go to %s"
9633 (mapconcat 'car groups ", "))
9634 (message "This message would go to no groups"))
9635 groups)))))
9636
9637 (defun gnus-summary-respool-trace ()
9638 "Trace where the respool algorithm would put this article.
9639 Display a buffer showing all fancy splitting patterns which matched."
9640 (interactive)
9641 (gnus-summary-respool-query nil t))
9642
9643 ;; Summary marking commands.
9644
9645 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9646 "Mark articles which has the same subject as read, and then select the next.
9647 If UNMARK is positive, remove any kind of mark.
9648 If UNMARK is negative, tick articles."
9649 (interactive "P")
9650 (when unmark
9651 (setq unmark (prefix-numeric-value unmark)))
9652 (let ((count
9653 (gnus-summary-mark-same-subject
9654 (gnus-summary-article-subject) unmark)))
9655 ;; Select next unread article. If auto-select-same mode, should
9656 ;; select the first unread article.
9657 (gnus-summary-next-article t (and gnus-auto-select-same
9658 (gnus-summary-article-subject)))
9659 (gnus-message 7 "%d article%s marked as %s"
9660 count (if (= count 1) " is" "s are")
9661 (if unmark "unread" "read"))))
9662
9663 (defun gnus-summary-kill-same-subject (&optional unmark)
9664 "Mark articles which has the same subject as read.
9665 If UNMARK is positive, remove any kind of mark.
9666 If UNMARK is negative, tick articles."
9667 (interactive "P")
9668 (when unmark
9669 (setq unmark (prefix-numeric-value unmark)))
9670 (let ((count
9671 (gnus-summary-mark-same-subject
9672 (gnus-summary-article-subject) unmark)))
9673 ;; If marked as read, go to next unread subject.
9674 (when (null unmark)
9675 ;; Go to next unread subject.
9676 (gnus-summary-next-subject 1 t))
9677 (gnus-message 7 "%d articles are marked as %s"
9678 count (if unmark "unread" "read"))))
9679
9680 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9681 "Mark articles with same SUBJECT as read, and return marked number.
9682 If optional argument UNMARK is positive, remove any kinds of marks.
9683 If optional argument UNMARK is negative, mark articles as unread instead."
9684 (let ((count 1))
9685 (save-excursion
9686 (cond
9687 ((null unmark) ; Mark as read.
9688 (while (and
9689 (progn
9690 (gnus-summary-mark-article-as-read gnus-killed-mark)
9691 (gnus-summary-show-thread) t)
9692 (gnus-summary-find-subject subject))
9693 (setq count (1+ count))))
9694 ((> unmark 0) ; Tick.
9695 (while (and
9696 (progn
9697 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9698 (gnus-summary-show-thread) t)
9699 (gnus-summary-find-subject subject))
9700 (setq count (1+ count))))
9701 (t ; Mark as unread.
9702 (while (and
9703 (progn
9704 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9705 (gnus-summary-show-thread) t)
9706 (gnus-summary-find-subject subject))
9707 (setq count (1+ count)))))
9708 (gnus-set-mode-line 'summary)
9709 ;; Return the number of marked articles.
9710 count)))
9711
9712 (defun gnus-summary-mark-as-processable (n &optional unmark)
9713 "Set the process mark on the next N articles.
9714 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9715 the process mark instead. The difference between N and the actual
9716 number of articles marked is returned."
9717 (interactive "P")
9718 (if (and (null n) (gnus-region-active-p))
9719 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9720 (setq n (prefix-numeric-value n))
9721 (let ((backward (< n 0))
9722 (n (abs n)))
9723 (while (and
9724 (> n 0)
9725 (if unmark
9726 (gnus-summary-remove-process-mark
9727 (gnus-summary-article-number))
9728 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9729 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9730 (setq n (1- n)))
9731 (when (/= 0 n)
9732 (gnus-message 7 "No more articles"))
9733 (gnus-summary-recenter)
9734 (gnus-summary-position-point)
9735 n)))
9736
9737 (defun gnus-summary-unmark-as-processable (n)
9738 "Remove the process mark from the next N articles.
9739 If N is negative, unmark backward instead. The difference between N and
9740 the actual number of articles unmarked is returned."
9741 (interactive "P")
9742 (gnus-summary-mark-as-processable n t))
9743
9744 (defun gnus-summary-unmark-all-processable ()
9745 "Remove the process mark from all articles."
9746 (interactive)
9747 (save-excursion
9748 (while gnus-newsgroup-processable
9749 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9750 (gnus-summary-position-point))
9751
9752 (defun gnus-summary-add-mark (article type)
9753 "Mark ARTICLE with a mark of TYPE."
9754 (let ((vtype (car (assq type gnus-article-mark-lists)))
9755 var)
9756 (if (not vtype)
9757 (error "No such mark type: %s" type)
9758 (setq var (intern (format "gnus-newsgroup-%s" type)))
9759 (set var (cons article (symbol-value var)))
9760 (if (memq type '(processable cached replied forwarded recent saved))
9761 (gnus-summary-update-secondary-mark article)
9762 ;;; !!! This is bogus. We should find out what primary
9763 ;;; !!! mark we want to set.
9764 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9765
9766 (defun gnus-summary-mark-as-expirable (n)
9767 "Mark N articles forward as expirable.
9768 If N is negative, mark backward instead. The difference between N and
9769 the actual number of articles marked is returned."
9770 (interactive "p")
9771 (gnus-summary-mark-forward n gnus-expirable-mark))
9772
9773 (defun gnus-summary-mark-as-spam (n)
9774 "Mark N articles forward as spam.
9775 If N is negative, mark backward instead. The difference between N and
9776 the actual number of articles marked is returned."
9777 (interactive "p")
9778 (gnus-summary-mark-forward n gnus-spam-mark))
9779
9780 (defun gnus-summary-mark-article-as-replied (article)
9781 "Mark ARTICLE as replied to and update the summary line.
9782 ARTICLE can also be a list of articles."
9783 (interactive (list (gnus-summary-article-number)))
9784 (let ((articles (if (listp article) article (list article))))
9785 (dolist (article articles)
9786 (unless (numberp article)
9787 (error "%s is not a number" article))
9788 (push article gnus-newsgroup-replied)
9789 (let ((buffer-read-only nil))
9790 (when (gnus-summary-goto-subject article nil t)
9791 (gnus-summary-update-secondary-mark article))))))
9792
9793 (defun gnus-summary-mark-article-as-forwarded (article)
9794 "Mark ARTICLE as forwarded and update the summary line.
9795 ARTICLE can also be a list of articles."
9796 (let ((articles (if (listp article) article (list article))))
9797 (dolist (article articles)
9798 (push article gnus-newsgroup-forwarded)
9799 (let ((buffer-read-only nil))
9800 (when (gnus-summary-goto-subject article nil t)
9801 (gnus-summary-update-secondary-mark article))))))
9802
9803 (defun gnus-summary-set-bookmark (article)
9804 "Set a bookmark in current article."
9805 (interactive (list (gnus-summary-article-number)))
9806 (when (or (not (get-buffer gnus-article-buffer))
9807 (not gnus-current-article)
9808 (not gnus-article-current)
9809 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9810 (error "No current article selected"))
9811 ;; Remove old bookmark, if one exists.
9812 (gnus-pull article gnus-newsgroup-bookmarks)
9813 ;; Set the new bookmark, which is on the form
9814 ;; (article-number . line-number-in-body).
9815 (push
9816 (cons article
9817 (save-excursion
9818 (set-buffer gnus-article-buffer)
9819 (count-lines
9820 (min (point)
9821 (save-excursion
9822 (article-goto-body)
9823 (point)))
9824 (point))))
9825 gnus-newsgroup-bookmarks)
9826 (gnus-message 6 "A bookmark has been added to the current article."))
9827
9828 (defun gnus-summary-remove-bookmark (article)
9829 "Remove the bookmark from the current article."
9830 (interactive (list (gnus-summary-article-number)))
9831 ;; Remove old bookmark, if one exists.
9832 (if (not (assq article gnus-newsgroup-bookmarks))
9833 (gnus-message 6 "No bookmark in current article.")
9834 (gnus-pull article gnus-newsgroup-bookmarks)
9835 (gnus-message 6 "Removed bookmark.")))
9836
9837 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9838 (defun gnus-summary-mark-as-dormant (n)
9839 "Mark N articles forward as dormant.
9840 If N is negative, mark backward instead. The difference between N and
9841 the actual number of articles marked is returned."
9842 (interactive "p")
9843 (gnus-summary-mark-forward n gnus-dormant-mark))
9844
9845 (defun gnus-summary-set-process-mark (article)
9846 "Set the process mark on ARTICLE and update the summary line."
9847 (setq gnus-newsgroup-processable
9848 (cons article
9849 (delq article gnus-newsgroup-processable)))
9850 (when (gnus-summary-goto-subject article)
9851 (gnus-summary-show-thread)
9852 (gnus-summary-goto-subject article)
9853 (gnus-summary-update-secondary-mark article)))
9854
9855 (defun gnus-summary-remove-process-mark (article)
9856 "Remove the process mark from ARTICLE and update the summary line."
9857 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9858 (when (gnus-summary-goto-subject article)
9859 (gnus-summary-show-thread)
9860 (gnus-summary-goto-subject article)
9861 (gnus-summary-update-secondary-mark article)))
9862
9863 (defun gnus-summary-set-saved-mark (article)
9864 "Set the process mark on ARTICLE and update the summary line."
9865 (push article gnus-newsgroup-saved)
9866 (when (gnus-summary-goto-subject article)
9867 (gnus-summary-update-secondary-mark article)))
9868
9869 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9870 "Mark N articles as read forwards.
9871 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9872 The difference between N and the actual number of articles marked is
9873 returned.
9874 If NO-EXPIRE, auto-expiry will be inhibited."
9875 (interactive "p")
9876 (gnus-summary-show-thread)
9877 (let ((backward (< n 0))
9878 (gnus-summary-goto-unread
9879 (and gnus-summary-goto-unread
9880 (not (eq gnus-summary-goto-unread 'never))
9881 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9882 gnus-ticked-mark gnus-dormant-mark)))))
9883 (n (abs n))
9884 (mark (or mark gnus-del-mark)))
9885 (while (and (> n 0)
9886 (gnus-summary-mark-article nil mark no-expire)
9887 (zerop (gnus-summary-next-subject
9888 (if backward -1 1)
9889 (and gnus-summary-goto-unread
9890 (not (eq gnus-summary-goto-unread 'never)))
9891 t)))
9892 (setq n (1- n)))
9893 (when (/= 0 n)
9894 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9895 (gnus-summary-recenter)
9896 (gnus-summary-position-point)
9897 (gnus-set-mode-line 'summary)
9898 n))
9899
9900 (defun gnus-summary-mark-article-as-read (mark)
9901 "Mark the current article quickly as read with MARK."
9902 (let ((article (gnus-summary-article-number)))
9903 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9904 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9905 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9906 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9907 (push (cons article mark) gnus-newsgroup-reads)
9908 ;; Possibly remove from cache, if that is used.
9909 (when gnus-use-cache
9910 (gnus-cache-enter-remove-article article))
9911 ;; Allow the backend to change the mark.
9912 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9913 ;; Check for auto-expiry.
9914 (when (and gnus-newsgroup-auto-expire
9915 (memq mark gnus-auto-expirable-marks))
9916 (setq mark gnus-expirable-mark)
9917 ;; Let the backend know about the mark change.
9918 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9919 (push article gnus-newsgroup-expirable))
9920 ;; Set the mark in the buffer.
9921 (gnus-summary-update-mark mark 'unread)
9922 t))
9923
9924 (defun gnus-summary-mark-article-as-unread (mark)
9925 "Mark the current article quickly as unread with MARK."
9926 (let* ((article (gnus-summary-article-number))
9927 (old-mark (gnus-summary-article-mark article)))
9928 ;; Allow the backend to change the mark.
9929 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9930 (if (eq mark old-mark)
9931 t
9932 (if (<= article 0)
9933 (progn
9934 (gnus-error 1 "Can't mark negative article numbers")
9935 nil)
9936 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9937 (setq gnus-newsgroup-spam-marked
9938 (delq article gnus-newsgroup-spam-marked))
9939 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9940 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9941 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9942 (cond ((= mark gnus-ticked-mark)
9943 (setq gnus-newsgroup-marked
9944 (gnus-add-to-sorted-list gnus-newsgroup-marked
9945 article)))
9946 ((= mark gnus-spam-mark)
9947 (setq gnus-newsgroup-spam-marked
9948 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9949 article)))
9950 ((= mark gnus-dormant-mark)
9951 (setq gnus-newsgroup-dormant
9952 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9953 article)))
9954 (t
9955 (setq gnus-newsgroup-unreads
9956 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9957 article))))
9958 (gnus-pull article gnus-newsgroup-reads)
9959
9960 ;; See whether the article is to be put in the cache.
9961 (and gnus-use-cache
9962 (vectorp (gnus-summary-article-header article))
9963 (save-excursion
9964 (gnus-cache-possibly-enter-article
9965 gnus-newsgroup-name article
9966 (= mark gnus-ticked-mark)
9967 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9968
9969 ;; Fix the mark.
9970 (gnus-summary-update-mark mark 'unread)
9971 t))))
9972
9973 (defun gnus-summary-mark-article (&optional article mark no-expire)
9974 "Mark ARTICLE with MARK. MARK can be any character.
9975 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9976 `??' (dormant) and `?E' (expirable).
9977 If MARK is nil, then the default character `?r' is used.
9978 If ARTICLE is nil, then the article on the current line will be
9979 marked.
9980 If NO-EXPIRE, auto-expiry will be inhibited."
9981 ;; The mark might be a string.
9982 (when (stringp mark)
9983 (setq mark (aref mark 0)))
9984 ;; If no mark is given, then we check auto-expiring.
9985 (when (null mark)
9986 (setq mark gnus-del-mark))
9987 (when (and (not no-expire)
9988 gnus-newsgroup-auto-expire
9989 (memq mark gnus-auto-expirable-marks))
9990 (setq mark gnus-expirable-mark))
9991 (let ((article (or article (gnus-summary-article-number)))
9992 (old-mark (gnus-summary-article-mark article)))
9993 ;; Allow the backend to change the mark.
9994 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9995 (if (eq mark old-mark)
9996 t
9997 (unless article
9998 (error "No article on current line"))
9999 (if (not (if (or (= mark gnus-unread-mark)
10000 (= mark gnus-ticked-mark)
10001 (= mark gnus-spam-mark)
10002 (= mark gnus-dormant-mark))
10003 (gnus-mark-article-as-unread article mark)
10004 (gnus-mark-article-as-read article mark)))
10005 t
10006 ;; See whether the article is to be put in the cache.
10007 (and gnus-use-cache
10008 (not (= mark gnus-canceled-mark))
10009 (vectorp (gnus-summary-article-header article))
10010 (save-excursion
10011 (gnus-cache-possibly-enter-article
10012 gnus-newsgroup-name article
10013 (= mark gnus-ticked-mark)
10014 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10015
10016 (when (gnus-summary-goto-subject article nil t)
10017 (let ((buffer-read-only nil))
10018 (gnus-summary-show-thread)
10019 ;; Fix the mark.
10020 (gnus-summary-update-mark mark 'unread)
10021 t))))))
10022
10023 (defun gnus-summary-update-secondary-mark (article)
10024 "Update the secondary (read, process, cache) mark."
10025 (gnus-summary-update-mark
10026 (cond ((memq article gnus-newsgroup-processable)
10027 gnus-process-mark)
10028 ((memq article gnus-newsgroup-cached)
10029 gnus-cached-mark)
10030 ((memq article gnus-newsgroup-replied)
10031 gnus-replied-mark)
10032 ((memq article gnus-newsgroup-forwarded)
10033 gnus-forwarded-mark)
10034 ((memq article gnus-newsgroup-saved)
10035 gnus-saved-mark)
10036 ((memq article gnus-newsgroup-recent)
10037 gnus-recent-mark)
10038 ((memq article gnus-newsgroup-unseen)
10039 gnus-unseen-mark)
10040 (t gnus-no-mark))
10041 'replied)
10042 (when (gnus-visual-p 'summary-highlight 'highlight)
10043 (gnus-run-hooks 'gnus-summary-update-hook))
10044 t)
10045
10046 (defun gnus-summary-update-download-mark (article)
10047 "Update the download mark."
10048 (gnus-summary-update-mark
10049 (cond ((memq article gnus-newsgroup-undownloaded)
10050 gnus-undownloaded-mark)
10051 (gnus-newsgroup-agentized
10052 gnus-downloaded-mark)
10053 (t
10054 gnus-no-mark))
10055 'download)
10056 (gnus-summary-update-line t)
10057 t)
10058
10059 (defun gnus-summary-update-mark (mark type)
10060 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10061 (buffer-read-only nil))
10062 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
10063 (when forward
10064 (when (looking-at "\r")
10065 (incf forward))
10066 (when (<= (+ forward (point)) (point-max))
10067 ;; Go to the right position on the line.
10068 (goto-char (+ forward (point)))
10069 ;; Replace the old mark with the new mark.
10070 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10071 ;; Optionally update the marks by some user rule.
10072 (when (eq type 'unread)
10073 (gnus-data-set-mark
10074 (gnus-data-find (gnus-summary-article-number)) mark)
10075 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10076
10077 (defun gnus-mark-article-as-read (article &optional mark)
10078 "Enter ARTICLE in the pertinent lists and remove it from others."
10079 ;; Make the article expirable.
10080 (let ((mark (or mark gnus-del-mark)))
10081 (setq gnus-newsgroup-expirable
10082 (if (= mark gnus-expirable-mark)
10083 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10084 (delq article gnus-newsgroup-expirable)))
10085 ;; Remove from unread and marked lists.
10086 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10087 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10088 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10089 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10090 (push (cons article mark) gnus-newsgroup-reads)
10091 ;; Possibly remove from cache, if that is used.
10092 (when gnus-use-cache
10093 (gnus-cache-enter-remove-article article))
10094 t))
10095
10096 (defun gnus-mark-article-as-unread (article &optional mark)
10097 "Enter ARTICLE in the pertinent lists and remove it from others."
10098 (let ((mark (or mark gnus-ticked-mark)))
10099 (if (<= article 0)
10100 (progn
10101 (gnus-error 1 "Can't mark negative article numbers")
10102 nil)
10103 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10104 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10105 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10106 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10107 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10108
10109 ;; Unsuppress duplicates?
10110 (when gnus-suppress-duplicates
10111 (gnus-dup-unsuppress-article article))
10112
10113 (cond ((= mark gnus-ticked-mark)
10114 (setq gnus-newsgroup-marked
10115 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10116 ((= mark gnus-spam-mark)
10117 (setq gnus-newsgroup-spam-marked
10118 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10119 article)))
10120 ((= mark gnus-dormant-mark)
10121 (setq gnus-newsgroup-dormant
10122 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10123 (t
10124 (setq gnus-newsgroup-unreads
10125 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10126 (gnus-pull article gnus-newsgroup-reads)
10127 t)))
10128
10129 (defalias 'gnus-summary-mark-as-unread-forward
10130 'gnus-summary-tick-article-forward)
10131 (make-obsolete 'gnus-summary-mark-as-unread-forward
10132 'gnus-summary-tick-article-forward)
10133 (defun gnus-summary-tick-article-forward (n)
10134 "Tick N articles forwards.
10135 If N is negative, tick backwards instead.
10136 The difference between N and the number of articles ticked is returned."
10137 (interactive "p")
10138 (gnus-summary-mark-forward n gnus-ticked-mark))
10139
10140 (defalias 'gnus-summary-mark-as-unread-backward
10141 'gnus-summary-tick-article-backward)
10142 (make-obsolete 'gnus-summary-mark-as-unread-backward
10143 'gnus-summary-tick-article-backward)
10144 (defun gnus-summary-tick-article-backward (n)
10145 "Tick N articles backwards.
10146 The difference between N and the number of articles ticked is returned."
10147 (interactive "p")
10148 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10149
10150 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10151 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10152 (defun gnus-summary-tick-article (&optional article clear-mark)
10153 "Mark current article as unread.
10154 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10155 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10156 (interactive)
10157 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10158 gnus-ticked-mark)))
10159
10160 (defun gnus-summary-mark-as-read-forward (n)
10161 "Mark N articles as read forwards.
10162 If N is negative, mark backwards instead.
10163 The difference between N and the actual number of articles marked is
10164 returned."
10165 (interactive "p")
10166 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10167
10168 (defun gnus-summary-mark-as-read-backward (n)
10169 "Mark the N articles as read backwards.
10170 The difference between N and the actual number of articles marked is
10171 returned."
10172 (interactive "p")
10173 (gnus-summary-mark-forward
10174 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10175
10176 (defun gnus-summary-mark-as-read (&optional article mark)
10177 "Mark current article as read.
10178 ARTICLE specifies the article to be marked as read.
10179 MARK specifies a string to be inserted at the beginning of the line."
10180 (gnus-summary-mark-article article mark))
10181
10182 (defun gnus-summary-clear-mark-forward (n)
10183 "Clear marks from N articles forward.
10184 If N is negative, clear backward instead.
10185 The difference between N and the number of marks cleared is returned."
10186 (interactive "p")
10187 (gnus-summary-mark-forward n gnus-unread-mark))
10188
10189 (defun gnus-summary-clear-mark-backward (n)
10190 "Clear marks from N articles backward.
10191 The difference between N and the number of marks cleared is returned."
10192 (interactive "p")
10193 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10194
10195 (defun gnus-summary-mark-unread-as-read ()
10196 "Intended to be used by `gnus-summary-mark-article-hook'."
10197 (when (memq gnus-current-article gnus-newsgroup-unreads)
10198 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10199
10200 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10201 "Intended to be used by `gnus-summary-mark-article-hook'."
10202 (let ((mark (gnus-summary-article-mark)))
10203 (when (or (gnus-unread-mark-p mark)
10204 (gnus-read-mark-p mark))
10205 (gnus-summary-mark-article gnus-current-article
10206 (or new-mark gnus-read-mark)))))
10207
10208 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10209 "Intended to be used by `gnus-summary-mark-article-hook'."
10210 (let ((mark (gnus-summary-article-mark)))
10211 (when (or (gnus-unread-mark-p mark)
10212 (gnus-read-mark-p mark))
10213 (gnus-summary-mark-article (gnus-summary-article-number)
10214 (or new-mark gnus-read-mark)))))
10215
10216 (defun gnus-summary-mark-unread-as-ticked ()
10217 "Intended to be used by `gnus-summary-mark-article-hook'."
10218 (when (memq gnus-current-article gnus-newsgroup-unreads)
10219 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10220
10221 (defun gnus-summary-mark-region-as-read (point mark all)
10222 "Mark all unread articles between point and mark as read.
10223 If given a prefix, mark all articles between point and mark as read,
10224 even ticked and dormant ones."
10225 (interactive "r\nP")
10226 (save-excursion
10227 (let (article)
10228 (goto-char point)
10229 (beginning-of-line)
10230 (while (and
10231 (< (point) mark)
10232 (progn
10233 (when (or all
10234 (memq (setq article (gnus-summary-article-number))
10235 gnus-newsgroup-unreads))
10236 (gnus-summary-mark-article article gnus-del-mark))
10237 t)
10238 (gnus-summary-find-next))))))
10239
10240 (defun gnus-summary-mark-below (score mark)
10241 "Mark articles with score less than SCORE with MARK."
10242 (interactive "P\ncMark: ")
10243 (setq score (if score
10244 (prefix-numeric-value score)
10245 (or gnus-summary-default-score 0)))
10246 (save-excursion
10247 (set-buffer gnus-summary-buffer)
10248 (goto-char (point-min))
10249 (while
10250 (progn
10251 (and (< (gnus-summary-article-score) score)
10252 (gnus-summary-mark-article nil mark))
10253 (gnus-summary-find-next)))))
10254
10255 (defun gnus-summary-kill-below (&optional score)
10256 "Mark articles with score below SCORE as read."
10257 (interactive "P")
10258 (gnus-summary-mark-below score gnus-killed-mark))
10259
10260 (defun gnus-summary-clear-above (&optional score)
10261 "Clear all marks from articles with score above SCORE."
10262 (interactive "P")
10263 (gnus-summary-mark-above score gnus-unread-mark))
10264
10265 (defun gnus-summary-tick-above (&optional score)
10266 "Tick all articles with score above SCORE."
10267 (interactive "P")
10268 (gnus-summary-mark-above score gnus-ticked-mark))
10269
10270 (defun gnus-summary-mark-above (score mark)
10271 "Mark articles with score over SCORE with MARK."
10272 (interactive "P\ncMark: ")
10273 (setq score (if score
10274 (prefix-numeric-value score)
10275 (or gnus-summary-default-score 0)))
10276 (save-excursion
10277 (set-buffer gnus-summary-buffer)
10278 (goto-char (point-min))
10279 (while (and (progn
10280 (when (> (gnus-summary-article-score) score)
10281 (gnus-summary-mark-article nil mark))
10282 t)
10283 (gnus-summary-find-next)))))
10284
10285 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10286 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10287 (defun gnus-summary-limit-include-expunged (&optional no-error)
10288 "Display all the hidden articles that were expunged for low scores."
10289 (interactive)
10290 (let ((buffer-read-only nil))
10291 (let ((scored gnus-newsgroup-scored)
10292 headers h)
10293 (while scored
10294 (unless (gnus-summary-article-header (caar scored))
10295 (and (setq h (gnus-number-to-header (caar scored)))
10296 (< (cdar scored) gnus-summary-expunge-below)
10297 (push h headers)))
10298 (setq scored (cdr scored)))
10299 (if (not headers)
10300 (when (not no-error)
10301 (error "No expunged articles hidden"))
10302 (goto-char (point-min))
10303 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10304 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10305 (mapcar (lambda (x) (push (mail-header-number x)
10306 gnus-newsgroup-limit))
10307 headers)
10308 (gnus-summary-prepare-unthreaded (nreverse headers))
10309 (goto-char (point-min))
10310 (gnus-summary-position-point)
10311 t))))
10312
10313 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10314 "Mark all unread articles in this newsgroup as read.
10315 If prefix argument ALL is non-nil, ticked and dormant articles will
10316 also be marked as read.
10317 If QUIETLY is non-nil, no questions will be asked.
10318
10319 If TO-HERE is non-nil, it should be a point in the buffer. All
10320 articles before (after, if REVERSE is set) this point will be marked
10321 as read.
10322
10323 Note that this function will only catch up the unread article
10324 in the current summary buffer limitation.
10325
10326 The number of articles marked as read is returned."
10327 (interactive "P")
10328 (prog1
10329 (save-excursion
10330 (when (or quietly
10331 (not gnus-interactive-catchup) ;Without confirmation?
10332 gnus-expert-user
10333 (gnus-y-or-n-p
10334 (if all
10335 "Mark absolutely all articles as read? "
10336 "Mark all unread articles as read? ")))
10337 (if (and not-mark
10338 (not gnus-newsgroup-adaptive)
10339 (not gnus-newsgroup-auto-expire)
10340 (not gnus-suppress-duplicates)
10341 (or (not gnus-use-cache)
10342 (eq gnus-use-cache 'passive)))
10343 (progn
10344 (when all
10345 (setq gnus-newsgroup-marked nil
10346 gnus-newsgroup-spam-marked nil
10347 gnus-newsgroup-dormant nil))
10348 (setq gnus-newsgroup-unreads
10349 (gnus-sorted-nunion
10350 (gnus-intersection gnus-newsgroup-unreads
10351 gnus-newsgroup-downloadable)
10352 gnus-newsgroup-unfetched)))
10353 ;; We actually mark all articles as canceled, which we
10354 ;; have to do when using auto-expiry or adaptive scoring.
10355 (gnus-summary-show-all-threads)
10356 (if (and to-here reverse)
10357 (progn
10358 (goto-char to-here)
10359 (gnus-summary-mark-current-read-and-unread-as-read
10360 gnus-catchup-mark)
10361 (while (gnus-summary-find-next (not all))
10362 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10363 (when (gnus-summary-first-subject (not all))
10364 (while (and
10365 (if to-here (< (point) to-here) t)
10366 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10367 (gnus-summary-find-next (not all))))))
10368 (gnus-set-mode-line 'summary))
10369 t))
10370 (gnus-summary-position-point)))
10371
10372 (defun gnus-summary-catchup-to-here (&optional all)
10373 "Mark all unticked articles before the current one as read.
10374 If ALL is non-nil, also mark ticked and dormant articles as read."
10375 (interactive "P")
10376 (save-excursion
10377 (gnus-save-hidden-threads
10378 (let ((beg (point)))
10379 ;; We check that there are unread articles.
10380 (when (or all (gnus-summary-find-prev))
10381 (gnus-summary-catchup all t beg)))))
10382 (gnus-summary-position-point))
10383
10384 (defun gnus-summary-catchup-from-here (&optional all)
10385 "Mark all unticked articles after (and including) the current one as read.
10386 If ALL is non-nil, also mark ticked and dormant articles as read."
10387 (interactive "P")
10388 (save-excursion
10389 (gnus-save-hidden-threads
10390 (let ((beg (point)))
10391 ;; We check that there are unread articles.
10392 (when (or all (gnus-summary-find-next))
10393 (gnus-summary-catchup all t beg nil t)))))
10394 (gnus-summary-position-point))
10395
10396 (defun gnus-summary-catchup-all (&optional quietly)
10397 "Mark all articles in this newsgroup as read.
10398 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10399 instead, which marks only unread articles as read."
10400 (interactive "P")
10401 (gnus-summary-catchup t quietly))
10402
10403 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10404 "Mark all unread articles in this group as read, then exit.
10405 If prefix argument ALL is non-nil, all articles are marked as read.
10406 If QUIETLY is non-nil, no questions will be asked."
10407 (interactive "P")
10408 (when (gnus-summary-catchup all quietly nil 'fast)
10409 ;; Select next newsgroup or exit.
10410 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10411 (eq gnus-auto-select-next 'quietly))
10412 (gnus-summary-next-group nil)
10413 (gnus-summary-exit))))
10414
10415 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10416 "Mark all articles in this newsgroup as read, and then exit.
10417 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10418 instead, which marks only unread articles as read."
10419 (interactive "P")
10420 (gnus-summary-catchup-and-exit t quietly))
10421
10422 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10423 "Mark all articles in this group as read and select the next group.
10424 If given a prefix, mark all articles, unread as well as ticked, as
10425 read."
10426 (interactive "P")
10427 (save-excursion
10428 (gnus-summary-catchup all))
10429 (gnus-summary-next-group))
10430
10431 ;;;
10432 ;;; with article
10433 ;;;
10434
10435 (defmacro gnus-with-article (article &rest forms)
10436 "Select ARTICLE and perform FORMS in the original article buffer.
10437 Then replace the article with the result."
10438 `(progn
10439 ;; We don't want the article to be marked as read.
10440 (let (gnus-mark-article-hook)
10441 (gnus-summary-select-article t t nil ,article))
10442 (set-buffer gnus-original-article-buffer)
10443 ,@forms
10444 (if (not (gnus-check-backend-function
10445 'request-replace-article (car gnus-article-current)))
10446 (gnus-message 5 "Read-only group; not replacing")
10447 (unless (gnus-request-replace-article
10448 ,article (car gnus-article-current)
10449 (current-buffer) t)
10450 (error "Couldn't replace article")))
10451 ;; The cache and backlog have to be flushed somewhat.
10452 (when gnus-keep-backlog
10453 (gnus-backlog-remove-article
10454 (car gnus-article-current) (cdr gnus-article-current)))
10455 (when gnus-use-cache
10456 (gnus-cache-update-article
10457 (car gnus-article-current) (cdr gnus-article-current)))))
10458
10459 (put 'gnus-with-article 'lisp-indent-function 1)
10460 (put 'gnus-with-article 'edebug-form-spec '(form body))
10461
10462 ;; Thread-based commands.
10463
10464 (defun gnus-summary-articles-in-thread (&optional article)
10465 "Return a list of all articles in the current thread.
10466 If ARTICLE is non-nil, return all articles in the thread that starts
10467 with that article."
10468 (let* ((article (or article (gnus-summary-article-number)))
10469 (data (gnus-data-find-list article))
10470 (top-level (gnus-data-level (car data)))
10471 (top-subject
10472 (cond ((null gnus-thread-operation-ignore-subject)
10473 (gnus-simplify-subject-re
10474 (mail-header-subject (gnus-data-header (car data)))))
10475 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10476 (gnus-simplify-subject-fuzzy
10477 (mail-header-subject (gnus-data-header (car data)))))
10478 (t nil)))
10479 (end-point (save-excursion
10480 (if (gnus-summary-go-to-next-thread)
10481 (point) (point-max))))
10482 articles)
10483 (while (and data
10484 (< (gnus-data-pos (car data)) end-point))
10485 (when (or (not top-subject)
10486 (string= top-subject
10487 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10488 (gnus-simplify-subject-fuzzy
10489 (mail-header-subject
10490 (gnus-data-header (car data))))
10491 (gnus-simplify-subject-re
10492 (mail-header-subject
10493 (gnus-data-header (car data)))))))
10494 (push (gnus-data-number (car data)) articles))
10495 (unless (and (setq data (cdr data))
10496 (> (gnus-data-level (car data)) top-level))
10497 (setq data nil)))
10498 ;; Return the list of articles.
10499 (nreverse articles)))
10500
10501 (defun gnus-summary-rethread-current ()
10502 "Rethread the thread the current article is part of."
10503 (interactive)
10504 (let* ((gnus-show-threads t)
10505 (article (gnus-summary-article-number))
10506 (id (mail-header-id (gnus-summary-article-header)))
10507 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10508 (unless id
10509 (error "No article on the current line"))
10510 (gnus-rebuild-thread id)
10511 (gnus-summary-goto-subject article)))
10512
10513 (defun gnus-summary-reparent-thread ()
10514 "Make the current article child of the marked (or previous) article.
10515
10516 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10517 is non-nil or the Subject: of both articles are the same."
10518 (interactive)
10519 (unless (not (gnus-group-read-only-p))
10520 (error "The current newsgroup does not support article editing"))
10521 (unless (<= (length gnus-newsgroup-processable) 1)
10522 (error "No more than one article may be marked"))
10523 (save-window-excursion
10524 (let ((gnus-article-buffer " *reparent*")
10525 (current-article (gnus-summary-article-number))
10526 ;; First grab the marked article, otherwise one line up.
10527 (parent-article (if (not (null gnus-newsgroup-processable))
10528 (car gnus-newsgroup-processable)
10529 (save-excursion
10530 (if (eq (forward-line -1) 0)
10531 (gnus-summary-article-number)
10532 (error "Beginning of summary buffer"))))))
10533 (unless (not (eq current-article parent-article))
10534 (error "An article may not be self-referential"))
10535 (let ((message-id (mail-header-id
10536 (gnus-summary-article-header parent-article))))
10537 (unless (and message-id (not (equal message-id "")))
10538 (error "No message-id in desired parent"))
10539 (gnus-with-article current-article
10540 (save-restriction
10541 (goto-char (point-min))
10542 (message-narrow-to-head)
10543 (if (re-search-forward "^References: " nil t)
10544 (progn
10545 (re-search-forward "^[^ \t]" nil t)
10546 (forward-line -1)
10547 (end-of-line)
10548 (insert " " message-id))
10549 (insert "References: " message-id "\n"))))
10550 (set-buffer gnus-summary-buffer)
10551 (gnus-summary-unmark-all-processable)
10552 (gnus-summary-update-article current-article)
10553 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10554 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10555 (gnus-summary-rethread-current)
10556 (gnus-message 3 "Article %d is now the child of article %d"
10557 current-article parent-article)))))
10558
10559 (defun gnus-summary-toggle-threads (&optional arg)
10560 "Toggle showing conversation threads.
10561 If ARG is positive number, turn showing conversation threads on."
10562 (interactive "P")
10563 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10564 (setq gnus-show-threads
10565 (if (null arg) (not gnus-show-threads)
10566 (> (prefix-numeric-value arg) 0)))
10567 (gnus-summary-prepare)
10568 (gnus-summary-goto-subject current)
10569 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10570 (gnus-summary-position-point)))
10571
10572 (defun gnus-summary-show-all-threads ()
10573 "Show all threads."
10574 (interactive)
10575 (save-excursion
10576 (let ((buffer-read-only nil))
10577 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10578 (gnus-summary-position-point))
10579
10580 (defun gnus-summary-show-thread ()
10581 "Show thread subtrees.
10582 Returns nil if no thread was there to be shown."
10583 (interactive)
10584 (let ((buffer-read-only nil)
10585 (orig (point))
10586 (end (gnus-point-at-eol))
10587 ;; Leave point at bol
10588 (beg (progn (beginning-of-line) (point))))
10589 (prog1
10590 ;; Any hidden lines here?
10591 (search-forward "\r" end t)
10592 (subst-char-in-region beg end ?\^M ?\n t)
10593 (goto-char orig)
10594 (gnus-summary-position-point))))
10595
10596 (defun gnus-summary-maybe-hide-threads ()
10597 "If requested, hide the threads that should be hidden."
10598 (when (and gnus-show-threads
10599 gnus-thread-hide-subtree)
10600 (gnus-summary-hide-all-threads
10601 (if (or (consp gnus-thread-hide-subtree)
10602 (functionp gnus-thread-hide-subtree))
10603 (gnus-make-predicate gnus-thread-hide-subtree)
10604 nil))))
10605
10606 ;;; Hiding predicates.
10607
10608 (defun gnus-article-unread-p (header)
10609 (memq (mail-header-number header) gnus-newsgroup-unreads))
10610
10611 (defun gnus-article-unseen-p (header)
10612 (memq (mail-header-number header) gnus-newsgroup-unseen))
10613
10614 (defun gnus-map-articles (predicate articles)
10615 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10616 (apply 'gnus-or (mapcar predicate
10617 (mapcar 'gnus-summary-article-header articles))))
10618
10619 (defun gnus-summary-hide-all-threads (&optional predicate)
10620 "Hide all thread subtrees.
10621 If PREDICATE is supplied, threads that satisfy this predicate
10622 will not be hidden."
10623 (interactive)
10624 (save-excursion
10625 (goto-char (point-min))
10626 (let ((end nil))
10627 (while (not end)
10628 (when (or (not predicate)
10629 (gnus-map-articles
10630 predicate (gnus-summary-article-children)))
10631 (gnus-summary-hide-thread))
10632 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10633 (gnus-summary-position-point))
10634
10635 (defun gnus-summary-hide-thread ()
10636 "Hide thread subtrees.
10637 If PREDICATE is supplied, threads that satisfy this predicate
10638 will not be hidden.
10639 Returns nil if no threads were there to be hidden."
10640 (interactive)
10641 (let ((buffer-read-only nil)
10642 (start (point))
10643 (article (gnus-summary-article-number)))
10644 (goto-char start)
10645 ;; Go forward until either the buffer ends or the subthread
10646 ;; ends.
10647 (when (and (not (eobp))
10648 (or (zerop (gnus-summary-next-thread 1 t))
10649 (goto-char (point-max))))
10650 (prog1
10651 (if (and (> (point) start)
10652 (search-backward "\n" start t))
10653 (progn
10654 (subst-char-in-region start (point) ?\n ?\^M)
10655 (gnus-summary-goto-subject article))
10656 (goto-char start)
10657 nil)))))
10658
10659 (defun gnus-summary-go-to-next-thread (&optional previous)
10660 "Go to the same level (or less) next thread.
10661 If PREVIOUS is non-nil, go to previous thread instead.
10662 Return the article number moved to, or nil if moving was impossible."
10663 (let ((level (gnus-summary-thread-level))
10664 (way (if previous -1 1))
10665 (beg (point)))
10666 (forward-line way)
10667 (while (and (not (eobp))
10668 (< level (gnus-summary-thread-level)))
10669 (forward-line way))
10670 (if (eobp)
10671 (progn
10672 (goto-char beg)
10673 nil)
10674 (setq beg (point))
10675 (prog1
10676 (gnus-summary-article-number)
10677 (goto-char beg)))))
10678
10679 (defun gnus-summary-next-thread (n &optional silent)
10680 "Go to the same level next N'th thread.
10681 If N is negative, search backward instead.
10682 Returns the difference between N and the number of skips actually
10683 done.
10684
10685 If SILENT, don't output messages."
10686 (interactive "p")
10687 (let ((backward (< n 0))
10688 (n (abs n)))
10689 (while (and (> n 0)
10690 (gnus-summary-go-to-next-thread backward))
10691 (decf n))
10692 (unless silent
10693 (gnus-summary-position-point))
10694 (when (and (not silent) (/= 0 n))
10695 (gnus-message 7 "No more threads"))
10696 n))
10697
10698 (defun gnus-summary-prev-thread (n)
10699 "Go to the same level previous N'th thread.
10700 Returns the difference between N and the number of skips actually
10701 done."
10702 (interactive "p")
10703 (gnus-summary-next-thread (- n)))
10704
10705 (defun gnus-summary-go-down-thread ()
10706 "Go down one level in the current thread."
10707 (let ((children (gnus-summary-article-children)))
10708 (when children
10709 (gnus-summary-goto-subject (car children)))))
10710
10711 (defun gnus-summary-go-up-thread ()
10712 "Go up one level in the current thread."
10713 (let ((parent (gnus-summary-article-parent)))
10714 (when parent
10715 (gnus-summary-goto-subject parent))))
10716
10717 (defun gnus-summary-down-thread (n)
10718 "Go down thread N steps.
10719 If N is negative, go up instead.
10720 Returns the difference between N and how many steps down that were
10721 taken."
10722 (interactive "p")
10723 (let ((up (< n 0))
10724 (n (abs n)))
10725 (while (and (> n 0)
10726 (if up (gnus-summary-go-up-thread)
10727 (gnus-summary-go-down-thread)))
10728 (setq n (1- n)))
10729 (gnus-summary-position-point)
10730 (when (/= 0 n)
10731 (gnus-message 7 "Can't go further"))
10732 n))
10733
10734 (defun gnus-summary-up-thread (n)
10735 "Go up thread N steps.
10736 If N is negative, go down instead.
10737 Returns the difference between N and how many steps down that were
10738 taken."
10739 (interactive "p")
10740 (gnus-summary-down-thread (- n)))
10741
10742 (defun gnus-summary-top-thread ()
10743 "Go to the top of the thread."
10744 (interactive)
10745 (while (gnus-summary-go-up-thread))
10746 (gnus-summary-article-number))
10747
10748 (defun gnus-summary-kill-thread (&optional unmark)
10749 "Mark articles under current thread as read.
10750 If the prefix argument is positive, remove any kinds of marks.
10751 If the prefix argument is negative, tick articles instead."
10752 (interactive "P")
10753 (when unmark
10754 (setq unmark (prefix-numeric-value unmark)))
10755 (let ((articles (gnus-summary-articles-in-thread)))
10756 (save-excursion
10757 ;; Expand the thread.
10758 (gnus-summary-show-thread)
10759 ;; Mark all the articles.
10760 (while articles
10761 (gnus-summary-goto-subject (car articles))
10762 (cond ((null unmark)
10763 (gnus-summary-mark-article-as-read gnus-killed-mark))
10764 ((> unmark 0)
10765 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10766 (t
10767 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10768 (setq articles (cdr articles))))
10769 ;; Hide killed subtrees.
10770 (and (null unmark)
10771 gnus-thread-hide-killed
10772 (gnus-summary-hide-thread))
10773 ;; If marked as read, go to next unread subject.
10774 (when (null unmark)
10775 ;; Go to next unread subject.
10776 (gnus-summary-next-subject 1 t)))
10777 (gnus-set-mode-line 'summary))
10778
10779 ;; Summary sorting commands
10780
10781 (defun gnus-summary-sort-by-number (&optional reverse)
10782 "Sort the summary buffer by article number.
10783 Argument REVERSE means reverse order."
10784 (interactive "P")
10785 (gnus-summary-sort 'number reverse))
10786
10787 (defun gnus-summary-sort-by-random (&optional reverse)
10788 "Randomize the order in the summary buffer.
10789 Argument REVERSE means to randomize in reverse order."
10790 (interactive "P")
10791 (gnus-summary-sort 'random reverse))
10792
10793 (defun gnus-summary-sort-by-author (&optional reverse)
10794 "Sort the summary buffer by author name alphabetically.
10795 If `case-fold-search' is non-nil, case of letters is ignored.
10796 Argument REVERSE means reverse order."
10797 (interactive "P")
10798 (gnus-summary-sort 'author reverse))
10799
10800 (defun gnus-summary-sort-by-subject (&optional reverse)
10801 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10802 If `case-fold-search' is non-nil, case of letters is ignored.
10803 Argument REVERSE means reverse order."
10804 (interactive "P")
10805 (gnus-summary-sort 'subject reverse))
10806
10807 (defun gnus-summary-sort-by-date (&optional reverse)
10808 "Sort the summary buffer by date.
10809 Argument REVERSE means reverse order."
10810 (interactive "P")
10811 (gnus-summary-sort 'date reverse))
10812
10813 (defun gnus-summary-sort-by-score (&optional reverse)
10814 "Sort the summary buffer by score.
10815 Argument REVERSE means reverse order."
10816 (interactive "P")
10817 (gnus-summary-sort 'score reverse))
10818
10819 (defun gnus-summary-sort-by-lines (&optional reverse)
10820 "Sort the summary buffer by the number of lines.
10821 Argument REVERSE means reverse order."
10822 (interactive "P")
10823 (gnus-summary-sort 'lines reverse))
10824
10825 (defun gnus-summary-sort-by-chars (&optional reverse)
10826 "Sort the summary buffer by article length.
10827 Argument REVERSE means reverse order."
10828 (interactive "P")
10829 (gnus-summary-sort 'chars reverse))
10830
10831 (defun gnus-summary-sort-by-original (&optional reverse)
10832 "Sort the summary buffer using the default sorting method.
10833 Argument REVERSE means reverse order."
10834 (interactive "P")
10835 (let* ((buffer-read-only)
10836 (gnus-summary-prepare-hook nil))
10837 ;; We do the sorting by regenerating the threads.
10838 (gnus-summary-prepare)
10839 ;; Hide subthreads if needed.
10840 (gnus-summary-maybe-hide-threads)))
10841
10842 (defun gnus-summary-sort (predicate reverse)
10843 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10844 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10845 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10846 (gnus-thread-sort-functions
10847 (if (not reverse)
10848 thread
10849 `(lambda (t1 t2)
10850 (,thread t2 t1))))
10851 (gnus-sort-gathered-threads-function
10852 gnus-thread-sort-functions)
10853 (gnus-article-sort-functions
10854 (if (not reverse)
10855 article
10856 `(lambda (t1 t2)
10857 (,article t2 t1))))
10858 (buffer-read-only)
10859 (gnus-summary-prepare-hook nil))
10860 ;; We do the sorting by regenerating the threads.
10861 (gnus-summary-prepare)
10862 ;; Hide subthreads if needed.
10863 (gnus-summary-maybe-hide-threads)))
10864
10865 ;; Summary saving commands.
10866
10867 (defun gnus-summary-save-article (&optional n not-saved)
10868 "Save the current article using the default saver function.
10869 If N is a positive number, save the N next articles.
10870 If N is a negative number, save the N previous articles.
10871 If N is nil and any articles have been marked with the process mark,
10872 save those articles instead.
10873 The variable `gnus-default-article-saver' specifies the saver function."
10874 (interactive "P")
10875 (let* ((articles (gnus-summary-work-articles n))
10876 (save-buffer (save-excursion
10877 (nnheader-set-temp-buffer " *Gnus Save*")))
10878 (num (length articles))
10879 header file)
10880 (dolist (article articles)
10881 (setq header (gnus-summary-article-header article))
10882 (if (not (vectorp header))
10883 ;; This is a pseudo-article.
10884 (if (assq 'name header)
10885 (gnus-copy-file (cdr (assq 'name header)))
10886 (gnus-message 1 "Article %d is unsaveable" article))
10887 ;; This is a real article.
10888 (save-window-excursion
10889 (let ((gnus-display-mime-function nil)
10890 (gnus-article-prepare-hook nil))
10891 (gnus-summary-select-article t nil nil article)))
10892 (save-excursion
10893 (set-buffer save-buffer)
10894 (erase-buffer)
10895 (insert-buffer-substring gnus-original-article-buffer))
10896 (setq file (gnus-article-save save-buffer file num))
10897 (gnus-summary-remove-process-mark article)
10898 (unless not-saved
10899 (gnus-summary-set-saved-mark article))))
10900 (gnus-kill-buffer save-buffer)
10901 (gnus-summary-position-point)
10902 (gnus-set-mode-line 'summary)
10903 n))
10904
10905 (defun gnus-summary-pipe-output (&optional arg headers)
10906 "Pipe the current article to a subprocess.
10907 If N is a positive number, pipe the N next articles.
10908 If N is a negative number, pipe the N previous articles.
10909 If N is nil and any articles have been marked with the process mark,
10910 pipe those articles instead.
10911 If HEADERS (the symbolic prefix), include the headers, too."
10912 (interactive (gnus-interactive "P\ny"))
10913 (require 'gnus-art)
10914 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10915 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10916 (gnus-summary-save-article arg t))
10917 (let ((buffer (get-buffer "*Shell Command Output*")))
10918 (when (and buffer
10919 (not (zerop (buffer-size buffer))))
10920 (gnus-configure-windows 'pipe))))
10921
10922 (defun gnus-summary-save-article-mail (&optional arg)
10923 "Append the current article to an mail file.
10924 If N is a positive number, save the N next articles.
10925 If N is a negative number, save the N previous articles.
10926 If N is nil and any articles have been marked with the process mark,
10927 save those articles instead."
10928 (interactive "P")
10929 (require 'gnus-art)
10930 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10931 (gnus-summary-save-article arg)))
10932
10933 (defun gnus-summary-save-article-rmail (&optional arg)
10934 "Append the current article to an rmail file.
10935 If N is a positive number, save the N next articles.
10936 If N is a negative number, save the N previous articles.
10937 If N is nil and any articles have been marked with the process mark,
10938 save those articles instead."
10939 (interactive "P")
10940 (require 'gnus-art)
10941 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10942 (gnus-summary-save-article arg)))
10943
10944 (defun gnus-summary-save-article-file (&optional arg)
10945 "Append the current article to a file.
10946 If N is a positive number, save the N next articles.
10947 If N is a negative number, save the N previous articles.
10948 If N is nil and any articles have been marked with the process mark,
10949 save those articles instead."
10950 (interactive "P")
10951 (require 'gnus-art)
10952 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10953 (gnus-summary-save-article arg)))
10954
10955 (defun gnus-summary-write-article-file (&optional arg)
10956 "Write the current article to a file, deleting the previous file.
10957 If N is a positive number, save the N next articles.
10958 If N is a negative number, save the N previous articles.
10959 If N is nil and any articles have been marked with the process mark,
10960 save those articles instead."
10961 (interactive "P")
10962 (require 'gnus-art)
10963 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10964 (gnus-summary-save-article arg)))
10965
10966 (defun gnus-summary-save-article-body-file (&optional arg)
10967 "Append the current article body to a file.
10968 If N is a positive number, save the N next articles.
10969 If N is a negative number, save the N previous articles.
10970 If N is nil and any articles have been marked with the process mark,
10971 save those articles instead."
10972 (interactive "P")
10973 (require 'gnus-art)
10974 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10975 (gnus-summary-save-article arg)))
10976
10977 (defun gnus-summary-muttprint (&optional arg)
10978 "Print the current article using Muttprint.
10979 If N is a positive number, save the N next articles.
10980 If N is a negative number, save the N previous articles.
10981 If N is nil and any articles have been marked with the process mark,
10982 save those articles instead."
10983 (interactive "P")
10984 (require 'gnus-art)
10985 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10986 (gnus-summary-save-article arg t)))
10987
10988 (defun gnus-summary-pipe-message (program)
10989 "Pipe the current article through PROGRAM."
10990 (interactive "sProgram: ")
10991 (gnus-summary-select-article)
10992 (let ((mail-header-separator ""))
10993 (gnus-eval-in-buffer-window gnus-article-buffer
10994 (save-restriction
10995 (widen)
10996 (let ((start (window-start))
10997 buffer-read-only)
10998 (message-pipe-buffer-body program)
10999 (set-window-start (get-buffer-window (current-buffer)) start))))))
11000
11001 (defun gnus-get-split-value (methods)
11002 "Return a value based on the split METHODS."
11003 (let (split-name method result match)
11004 (when methods
11005 (save-excursion
11006 (set-buffer gnus-original-article-buffer)
11007 (save-restriction
11008 (nnheader-narrow-to-headers)
11009 (while (and methods (not split-name))
11010 (goto-char (point-min))
11011 (setq method (pop methods))
11012 (setq match (car method))
11013 (when (cond
11014 ((stringp match)
11015 ;; Regular expression.
11016 (ignore-errors
11017 (re-search-forward match nil t)))
11018 ((functionp match)
11019 ;; Function.
11020 (save-restriction
11021 (widen)
11022 (setq result (funcall match gnus-newsgroup-name))))
11023 ((consp match)
11024 ;; Form.
11025 (save-restriction
11026 (widen)
11027 (setq result (eval match)))))
11028 (setq split-name (cdr method))
11029 (cond ((stringp result)
11030 (push (expand-file-name
11031 result gnus-article-save-directory)
11032 split-name))
11033 ((consp result)
11034 (setq split-name (append result split-name)))))))))
11035 (nreverse split-name)))
11036
11037 (defun gnus-valid-move-group-p (group)
11038 (and (boundp group)
11039 (symbol-name group)
11040 (symbol-value group)
11041 (gnus-get-function (gnus-find-method-for-group
11042 (symbol-name group)) 'request-accept-article t)))
11043
11044 (defun gnus-read-move-group-name (prompt default articles prefix)
11045 "Read a group name."
11046 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11047 (minibuffer-confirm-incomplete nil) ; XEmacs
11048 (prom
11049 (format "%s %s to"
11050 prompt
11051 (if (> (length articles) 1)
11052 (format "these %d articles" (length articles))
11053 "this article")))
11054 (to-newsgroup
11055 (cond
11056 ((null split-name)
11057 (gnus-completing-read-with-default
11058 default prom
11059 gnus-active-hashtb
11060 'gnus-valid-move-group-p
11061 nil prefix
11062 'gnus-group-history))
11063 ((= 1 (length split-name))
11064 (gnus-completing-read-with-default
11065 (car split-name) prom
11066 gnus-active-hashtb
11067 'gnus-valid-move-group-p
11068 nil nil
11069 'gnus-group-history))
11070 (t
11071 (gnus-completing-read-with-default
11072 nil prom
11073 (mapcar (lambda (el) (list el))
11074 (nreverse split-name))
11075 nil nil nil
11076 'gnus-group-history))))
11077 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11078 (when to-newsgroup
11079 (if (or (string= to-newsgroup "")
11080 (string= to-newsgroup prefix))
11081 (setq to-newsgroup default))
11082 (unless to-newsgroup
11083 (error "No group name entered"))
11084 (or (gnus-active to-newsgroup)
11085 (gnus-activate-group to-newsgroup nil nil to-method)
11086 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11087 to-newsgroup))
11088 (or (and (gnus-request-create-group to-newsgroup to-method)
11089 (gnus-activate-group
11090 to-newsgroup nil nil to-method)
11091 (gnus-subscribe-group to-newsgroup))
11092 (error "Couldn't create group %s" to-newsgroup)))
11093 (error "No such group: %s" to-newsgroup)))
11094 to-newsgroup))
11095
11096 (defun gnus-summary-save-parts (type dir n &optional reverse)
11097 "Save parts matching TYPE to DIR.
11098 If REVERSE, save parts that do not match TYPE."
11099 (interactive
11100 (list (read-string "Save parts of type: "
11101 (or (car gnus-summary-save-parts-type-history)
11102 gnus-summary-save-parts-default-mime)
11103 'gnus-summary-save-parts-type-history)
11104 (setq gnus-summary-save-parts-last-directory
11105 (read-file-name "Save to directory: "
11106 gnus-summary-save-parts-last-directory
11107 nil t))
11108 current-prefix-arg))
11109 (gnus-summary-iterate n
11110 (let ((gnus-display-mime-function nil)
11111 (gnus-inhibit-treatment t))
11112 (gnus-summary-select-article))
11113 (save-excursion
11114 (set-buffer gnus-article-buffer)
11115 (let ((handles (or gnus-article-mime-handles
11116 (mm-dissect-buffer nil gnus-article-loose-mime)
11117 (and gnus-article-emulate-mime
11118 (mm-uu-dissect)))))
11119 (when handles
11120 (gnus-summary-save-parts-1 type dir handles reverse)
11121 (unless gnus-article-mime-handles ;; Don't destroy this case.
11122 (mm-destroy-parts handles)))))))
11123
11124 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11125 (if (stringp (car handle))
11126 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11127 (cdr handle))
11128 (when (if reverse
11129 (not (string-match type (mm-handle-media-type handle)))
11130 (string-match type (mm-handle-media-type handle)))
11131 (let ((file (expand-file-name
11132 (gnus-map-function
11133 mm-file-name-rewrite-functions
11134 (file-name-nondirectory
11135 (or
11136 (mail-content-type-get
11137 (mm-handle-disposition handle) 'filename)
11138 (mail-content-type-get
11139 (mm-handle-type handle) 'name)
11140 (concat gnus-newsgroup-name
11141 "." (number-to-string
11142 (cdr gnus-article-current))))))
11143 dir)))
11144 (unless (file-exists-p file)
11145 (mm-save-part-to-file handle file))))))
11146
11147 ;; Summary extract commands
11148
11149 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11150 (let ((buffer-read-only nil)
11151 (article (gnus-summary-article-number))
11152 after-article b e)
11153 (unless (gnus-summary-goto-subject article)
11154 (error "No such article: %d" article))
11155 (gnus-summary-position-point)
11156 ;; If all commands are to be bunched up on one line, we collect
11157 ;; them here.
11158 (unless gnus-view-pseudos-separately
11159 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11160 files action)
11161 (while ps
11162 (setq action (cdr (assq 'action (car ps))))
11163 (setq files (list (cdr (assq 'name (car ps)))))
11164 (while (and ps (cdr ps)
11165 (string= (or action "1")
11166 (or (cdr (assq 'action (cadr ps))) "2")))
11167 (push (cdr (assq 'name (cadr ps))) files)
11168 (setcdr ps (cddr ps)))
11169 (when files
11170 (when (not (string-match "%s" action))
11171 (push " " files))
11172 (push " " files)
11173 (when (assq 'execute (car ps))
11174 (setcdr (assq 'execute (car ps))
11175 (funcall (if (string-match "%s" action)
11176 'format 'concat)
11177 action
11178 (mapconcat
11179 (lambda (f)
11180 (if (equal f " ")
11181 f
11182 (mm-quote-arg f)))
11183 files " ")))))
11184 (setq ps (cdr ps)))))
11185 (if (and gnus-view-pseudos (not not-view))
11186 (while pslist
11187 (when (assq 'execute (car pslist))
11188 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11189 (eq gnus-view-pseudos 'not-confirm)))
11190 (setq pslist (cdr pslist)))
11191 (save-excursion
11192 (while pslist
11193 (setq after-article (or (cdr (assq 'article (car pslist)))
11194 (gnus-summary-article-number)))
11195 (gnus-summary-goto-subject after-article)
11196 (forward-line 1)
11197 (setq b (point))
11198 (insert " " (file-name-nondirectory
11199 (cdr (assq 'name (car pslist))))
11200 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11201 (setq e (point))
11202 (forward-line -1) ; back to `b'
11203 (gnus-add-text-properties
11204 b (1- e) (list 'gnus-number gnus-reffed-article-number
11205 gnus-mouse-face-prop gnus-mouse-face))
11206 (gnus-data-enter
11207 after-article gnus-reffed-article-number
11208 gnus-unread-mark b (car pslist) 0 (- e b))
11209 (setq gnus-newsgroup-unreads
11210 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11211 gnus-reffed-article-number))
11212 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11213 (setq pslist (cdr pslist)))))))
11214
11215 (defun gnus-pseudos< (p1 p2)
11216 (let ((c1 (cdr (assq 'action p1)))
11217 (c2 (cdr (assq 'action p2))))
11218 (and c1 c2 (string< c1 c2))))
11219
11220 (defun gnus-request-pseudo-article (props)
11221 (cond ((assq 'execute props)
11222 (gnus-execute-command (cdr (assq 'execute props)))))
11223 (let ((gnus-current-article (gnus-summary-article-number)))
11224 (gnus-run-hooks 'gnus-mark-article-hook)))
11225
11226 (defun gnus-execute-command (command &optional automatic)
11227 (save-excursion
11228 (gnus-article-setup-buffer)
11229 (set-buffer gnus-article-buffer)
11230 (setq buffer-read-only nil)
11231 (let ((command (if automatic command
11232 (read-string "Command: " (cons command 0)))))
11233 (erase-buffer)
11234 (insert "$ " command "\n\n")
11235 (if gnus-view-pseudo-asynchronously
11236 (start-process "gnus-execute" (current-buffer) shell-file-name
11237 shell-command-switch command)
11238 (call-process shell-file-name nil t nil
11239 shell-command-switch command)))))
11240
11241 ;; Summary kill commands.
11242
11243 (defun gnus-summary-edit-global-kill (article)
11244 "Edit the \"global\" kill file."
11245 (interactive (list (gnus-summary-article-number)))
11246 (gnus-group-edit-global-kill article))
11247
11248 (defun gnus-summary-edit-local-kill ()
11249 "Edit a local kill file applied to the current newsgroup."
11250 (interactive)
11251 (setq gnus-current-headers (gnus-summary-article-header))
11252 (gnus-group-edit-local-kill
11253 (gnus-summary-article-number) gnus-newsgroup-name))
11254
11255 ;;; Header reading.
11256
11257 (defun gnus-read-header (id &optional header)
11258 "Read the headers of article ID and enter them into the Gnus system."
11259 (let ((group gnus-newsgroup-name)
11260 (gnus-override-method
11261 (or
11262 gnus-override-method
11263 (and (gnus-news-group-p gnus-newsgroup-name)
11264 (car (gnus-refer-article-methods)))))
11265 where)
11266 ;; First we check to see whether the header in question is already
11267 ;; fetched.
11268 (if (stringp id)
11269 ;; This is a Message-ID.
11270 (setq header (or header (gnus-id-to-header id)))
11271 ;; This is an article number.
11272 (setq header (or header (gnus-summary-article-header id))))
11273 (if (and header
11274 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11275 ;; We have found the header.
11276 header
11277 ;; We have to really fetch the header to this article.
11278 (save-excursion
11279 (set-buffer nntp-server-buffer)
11280 (when (setq where (gnus-request-head id group))
11281 (nnheader-fold-continuation-lines)
11282 (goto-char (point-max))
11283 (insert ".\n")
11284 (goto-char (point-min))
11285 (insert "211 ")
11286 (princ (cond
11287 ((numberp id) id)
11288 ((cdr where) (cdr where))
11289 (header (mail-header-number header))
11290 (t gnus-reffed-article-number))
11291 (current-buffer))
11292 (insert " Article retrieved.\n"))
11293 (if (or (not where)
11294 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11295 () ; Malformed head.
11296 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11297 (when (and (stringp id)
11298 (not (string= (gnus-group-real-name group)
11299 (car where))))
11300 ;; If we fetched by Message-ID and the article came
11301 ;; from a different group, we fudge some bogus article
11302 ;; numbers for this article.
11303 (mail-header-set-number header gnus-reffed-article-number))
11304 (save-excursion
11305 (set-buffer gnus-summary-buffer)
11306 (decf gnus-reffed-article-number)
11307 (gnus-remove-header (mail-header-number header))
11308 (push header gnus-newsgroup-headers)
11309 (setq gnus-current-headers header)
11310 (push (mail-header-number header) gnus-newsgroup-limit)))
11311 header)))))
11312
11313 (defun gnus-remove-header (number)
11314 "Remove header NUMBER from `gnus-newsgroup-headers'."
11315 (if (and gnus-newsgroup-headers
11316 (= number (mail-header-number (car gnus-newsgroup-headers))))
11317 (pop gnus-newsgroup-headers)
11318 (let ((headers gnus-newsgroup-headers))
11319 (while (and (cdr headers)
11320 (not (= number (mail-header-number (cadr headers)))))
11321 (pop headers))
11322 (when (cdr headers)
11323 (setcdr headers (cddr headers))))))
11324
11325 ;;;
11326 ;;; summary highlights
11327 ;;;
11328
11329 (defun gnus-highlight-selected-summary ()
11330 "Highlight selected article in summary buffer."
11331 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11332 (when gnus-summary-selected-face
11333 (save-excursion
11334 (let* ((beg (gnus-point-at-bol))
11335 (end (gnus-point-at-eol))
11336 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11337 (from (if (get-text-property beg gnus-mouse-face-prop)
11338 beg
11339 (or (next-single-property-change
11340 beg gnus-mouse-face-prop nil end)
11341 beg)))
11342 (to
11343 (if (= from end)
11344 (- from 2)
11345 (or (next-single-property-change
11346 from gnus-mouse-face-prop nil end)
11347 end))))
11348 ;; If no mouse-face prop on line we will have to = from = end,
11349 ;; so we highlight the entire line instead.
11350 (when (= (+ to 2) from)
11351 (setq from beg)
11352 (setq to end))
11353 (if gnus-newsgroup-selected-overlay
11354 ;; Move old overlay.
11355 (gnus-move-overlay
11356 gnus-newsgroup-selected-overlay from to (current-buffer))
11357 ;; Create new overlay.
11358 (gnus-overlay-put
11359 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11360 'face gnus-summary-selected-face))))))
11361
11362 (defvar gnus-summary-highlight-line-cached nil)
11363 (defvar gnus-summary-highlight-line-trigger nil)
11364
11365 (defun gnus-summary-highlight-line-0 ()
11366 (if (and (eq gnus-summary-highlight-line-trigger
11367 gnus-summary-highlight)
11368 gnus-summary-highlight-line-cached)
11369 gnus-summary-highlight-line-cached
11370 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11371 gnus-summary-highlight-line-cached
11372 (let* ((cond (list 'cond))
11373 (c cond)
11374 (list gnus-summary-highlight))
11375 (while list
11376 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11377 nil))
11378 (setq c (cdr c)
11379 list (cdr list)))
11380 (gnus-byte-compile (list 'lambda nil cond))))))
11381
11382 (defun gnus-summary-highlight-line ()
11383 "Highlight current line according to `gnus-summary-highlight'."
11384 (let* ((beg (gnus-point-at-bol))
11385 (article (or (gnus-summary-article-number) gnus-current-article))
11386 (score (or (cdr (assq article
11387 gnus-newsgroup-scored))
11388 gnus-summary-default-score 0))
11389 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11390 (inhibit-read-only t)
11391 (default gnus-summary-default-score)
11392 (default-high gnus-summary-default-high-score)
11393 (default-low gnus-summary-default-low-score)
11394 (uncached (and gnus-summary-use-undownloaded-faces
11395 (memq article gnus-newsgroup-undownloaded)
11396 (not (memq article gnus-newsgroup-cached)))))
11397 (let ((face (funcall (gnus-summary-highlight-line-0))))
11398 (unless (eq face (get-text-property beg 'face))
11399 (gnus-put-text-property-excluding-characters-with-faces
11400 beg (gnus-point-at-eol) 'face
11401 (setq face (if (boundp face) (symbol-value face) face)))
11402 (when gnus-summary-highlight-line-function
11403 (funcall gnus-summary-highlight-line-function article face))))))
11404
11405 (defun gnus-update-read-articles (group unread &optional compute)
11406 "Update the list of read articles in GROUP.
11407 UNREAD is a sorted list."
11408 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11409 (entry (gnus-gethash group gnus-newsrc-hashtb))
11410 (info (nth 2 entry))
11411 (prev 1)
11412 read)
11413 (if (or (not info) (not active))
11414 ;; There is no info on this group if it was, in fact,
11415 ;; killed. Gnus stores no information on killed groups, so
11416 ;; there's nothing to be done.
11417 ;; One could store the information somewhere temporarily,
11418 ;; perhaps... Hmmm...
11419 ()
11420 ;; Remove any negative articles numbers.
11421 (while (and unread (< (car unread) 0))
11422 (setq unread (cdr unread)))
11423 ;; Remove any expired article numbers
11424 (while (and unread (< (car unread) (car active)))
11425 (setq unread (cdr unread)))
11426 ;; Compute the ranges of read articles by looking at the list of
11427 ;; unread articles.
11428 (while unread
11429 (when (/= (car unread) prev)
11430 (push (if (= prev (1- (car unread))) prev
11431 (cons prev (1- (car unread))))
11432 read))
11433 (setq prev (1+ (car unread)))
11434 (setq unread (cdr unread)))
11435 (when (<= prev (cdr active))
11436 (push (cons prev (cdr active)) read))
11437 (setq read (if (> (length read) 1) (nreverse read) read))
11438 (if compute
11439 read
11440 (save-excursion
11441 (let (setmarkundo)
11442 ;; Propagate the read marks to the backend.
11443 (when (gnus-check-backend-function 'request-set-mark group)
11444 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11445 (add (gnus-remove-from-range read (gnus-info-read info))))
11446 (when (or add del)
11447 (unless (gnus-check-group group)
11448 (error "Can't open server for %s" group))
11449 (gnus-request-set-mark
11450 group (delq nil (list (if add (list add 'add '(read)))
11451 (if del (list del 'del '(read))))))
11452 (setq setmarkundo
11453 `(gnus-request-set-mark
11454 ,group
11455 ',(delq nil (list
11456 (if del (list del 'add '(read)))
11457 (if add (list add 'del '(read))))))))))
11458 (set-buffer gnus-group-buffer)
11459 (gnus-undo-register
11460 `(progn
11461 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11462 (gnus-info-set-read ',info ',(gnus-info-read info))
11463 (gnus-get-unread-articles-in-group ',info
11464 (gnus-active ,group))
11465 (gnus-group-update-group ,group t)
11466 ,setmarkundo))))
11467 ;; Enter this list into the group info.
11468 (gnus-info-set-read info read)
11469 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11470 (gnus-get-unread-articles-in-group info (gnus-active group))
11471 t))))
11472
11473 (defun gnus-offer-save-summaries ()
11474 "Offer to save all active summary buffers."
11475 (let (buffers)
11476 ;; Go through all buffers and find all summaries.
11477 (dolist (buffer (buffer-list))
11478 (when (and (setq buffer (buffer-name buffer))
11479 (string-match "Summary" buffer)
11480 (save-excursion
11481 (set-buffer buffer)
11482 ;; We check that this is, indeed, a summary buffer.
11483 (and (eq major-mode 'gnus-summary-mode)
11484 ;; Also make sure this isn't bogus.
11485 gnus-newsgroup-prepared
11486 ;; Also make sure that this isn't a
11487 ;; dead summary buffer.
11488 (not gnus-dead-summary-mode))))
11489 (push buffer buffers)))
11490 ;; Go through all these summary buffers and offer to save them.
11491 (when buffers
11492 (save-excursion
11493 (map-y-or-n-p
11494 "Update summary buffer %s? "
11495 (lambda (buf)
11496 (switch-to-buffer buf)
11497 (gnus-summary-exit))
11498 buffers)))))
11499
11500 (defun gnus-summary-setup-default-charset ()
11501 "Setup newsgroup default charset."
11502 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11503 (setq gnus-newsgroup-charset nil)
11504 (let* ((ignored-charsets
11505 (or gnus-newsgroup-ephemeral-ignored-charsets
11506 (append
11507 (and gnus-newsgroup-name
11508 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11509 gnus-newsgroup-ignored-charsets))))
11510 (setq gnus-newsgroup-charset
11511 (or gnus-newsgroup-ephemeral-charset
11512 (and gnus-newsgroup-name
11513 (gnus-parameter-charset gnus-newsgroup-name))
11514 gnus-default-charset))
11515 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11516 ignored-charsets))))
11517
11518 ;;;
11519 ;;; Mime Commands
11520 ;;;
11521
11522 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11523 "Display the current article buffer fully MIME-buttonized.
11524 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11525 treated as multipart/mixed."
11526 (interactive "P")
11527 (require 'gnus-art)
11528 (let ((gnus-unbuttonized-mime-types nil)
11529 (gnus-mime-display-multipart-as-mixed show-all-parts))
11530 (gnus-summary-show-article)))
11531
11532 (defun gnus-summary-repair-multipart (article)
11533 "Add a Content-Type header to a multipart article without one."
11534 (interactive (list (gnus-summary-article-number)))
11535 (gnus-with-article article
11536 (message-narrow-to-head)
11537 (message-remove-header "Mime-Version")
11538 (goto-char (point-max))
11539 (insert "Mime-Version: 1.0\n")
11540 (widen)
11541 (when (search-forward "\n--" nil t)
11542 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11543 (message-narrow-to-head)
11544 (message-remove-header "Content-Type")
11545 (goto-char (point-max))
11546 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11547 separator))
11548 (widen))))
11549 (let (gnus-mark-article-hook)
11550 (gnus-summary-select-article t t nil article)))
11551
11552 (defun gnus-summary-toggle-display-buttonized ()
11553 "Toggle the buttonizing of the article buffer."
11554 (interactive)
11555 (require 'gnus-art)
11556 (if (setq gnus-inhibit-mime-unbuttonizing
11557 (not gnus-inhibit-mime-unbuttonizing))
11558 (let ((gnus-unbuttonized-mime-types nil))
11559 (gnus-summary-show-article))
11560 (gnus-summary-show-article)))
11561
11562 ;;;
11563 ;;; Generic summary marking commands
11564 ;;;
11565
11566 (defvar gnus-summary-marking-alist
11567 '((read gnus-del-mark "d")
11568 (unread gnus-unread-mark "u")
11569 (ticked gnus-ticked-mark "!")
11570 (dormant gnus-dormant-mark "?")
11571 (expirable gnus-expirable-mark "e"))
11572 "An alist of names/marks/keystrokes.")
11573
11574 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11575 (defvar gnus-summary-mark-map)
11576
11577 (defun gnus-summary-make-all-marking-commands ()
11578 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11579 (dolist (elem gnus-summary-marking-alist)
11580 (apply 'gnus-summary-make-marking-command elem)))
11581
11582 (defun gnus-summary-make-marking-command (name mark keystroke)
11583 (let ((map (make-sparse-keymap)))
11584 (define-key gnus-summary-generic-mark-map keystroke map)
11585 (dolist (lway `((next "next" next nil "n")
11586 (next-unread "next unread" next t "N")
11587 (prev "previous" prev nil "p")
11588 (prev-unread "previous unread" prev t "P")
11589 (nomove "" nil nil ,keystroke)))
11590 (let ((func (gnus-summary-make-marking-command-1
11591 mark (car lway) lway name)))
11592 (setq func (eval func))
11593 (define-key map (nth 4 lway) func)))))
11594
11595 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11596 `(defun ,(intern
11597 (format "gnus-summary-put-mark-as-%s%s"
11598 name (if (eq way 'nomove)
11599 ""
11600 (concat "-" (symbol-name way)))))
11601 (n)
11602 ,(format
11603 "Mark the current article as %s%s.
11604 If N, the prefix, then repeat N times.
11605 If N is negative, move in reverse order.
11606 The difference between N and the actual number of articles marked is
11607 returned."
11608 name (cadr lway))
11609 (interactive "p")
11610 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11611
11612 (defun gnus-summary-generic-mark (n mark move unread)
11613 "Mark N articles with MARK."
11614 (unless (eq major-mode 'gnus-summary-mode)
11615 (error "This command can only be used in the summary buffer"))
11616 (gnus-summary-show-thread)
11617 (let ((nummove
11618 (cond
11619 ((eq move 'next) 1)
11620 ((eq move 'prev) -1)
11621 (t 0))))
11622 (if (zerop nummove)
11623 (setq n 1)
11624 (when (< n 0)
11625 (setq n (abs n)
11626 nummove (* -1 nummove))))
11627 (while (and (> n 0)
11628 (gnus-summary-mark-article nil mark)
11629 (zerop (gnus-summary-next-subject nummove unread t)))
11630 (setq n (1- n)))
11631 (when (/= 0 n)
11632 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11633 (gnus-summary-recenter)
11634 (gnus-summary-position-point)
11635 (gnus-set-mode-line 'summary)
11636 n))
11637
11638 (defun gnus-summary-insert-articles (articles)
11639 (when (setq articles
11640 (gnus-sorted-difference articles
11641 (mapcar (lambda (h)
11642 (mail-header-number h))
11643 gnus-newsgroup-headers)))
11644 (setq gnus-newsgroup-headers
11645 (gnus-merge 'list
11646 gnus-newsgroup-headers
11647 (gnus-fetch-headers articles)
11648 'gnus-article-sort-by-number))
11649 ;; Suppress duplicates?
11650 (when gnus-suppress-duplicates
11651 (gnus-dup-suppress-articles))
11652
11653 ;; We might want to build some more threads first.
11654 (when (and gnus-fetch-old-headers
11655 (eq gnus-headers-retrieved-by 'nov))
11656 (if (eq gnus-fetch-old-headers 'invisible)
11657 (gnus-build-all-threads)
11658 (gnus-build-old-threads)))
11659 ;; Let the Gnus agent mark articles as read.
11660 (when gnus-agent
11661 (gnus-agent-get-undownloaded-list))
11662 ;; Remove list identifiers from subject
11663 (when gnus-list-identifiers
11664 (gnus-summary-remove-list-identifiers))
11665 ;; First and last article in this newsgroup.
11666 (when gnus-newsgroup-headers
11667 (setq gnus-newsgroup-begin
11668 (mail-header-number (car gnus-newsgroup-headers))
11669 gnus-newsgroup-end
11670 (mail-header-number
11671 (gnus-last-element gnus-newsgroup-headers))))
11672 (when gnus-use-scoring
11673 (gnus-possibly-score-headers))))
11674
11675 (defun gnus-summary-insert-old-articles (&optional all)
11676 "Insert all old articles in this group.
11677 If ALL is non-nil, already read articles become readable.
11678 If ALL is a number, fetch this number of articles."
11679 (interactive "P")
11680 (prog1
11681 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11682 older len)
11683 (setq older
11684 ;; Some nntp servers lie about their active range. When
11685 ;; this happens, the active range can be in the millions.
11686 ;; Use a compressed range to avoid creating a huge list.
11687 (gnus-range-difference (list gnus-newsgroup-active) old))
11688 (setq len (gnus-range-length older))
11689 (cond
11690 ((null older) nil)
11691 ((numberp all)
11692 (if (< all len)
11693 (let ((older-range (nreverse older)))
11694 (setq older nil)
11695
11696 (while (> all 0)
11697 (let* ((r (pop older-range))
11698 (min (if (numberp r) r (car r)))
11699 (max (if (numberp r) r (cdr r))))
11700 (while (and (<= min max)
11701 (> all 0))
11702 (push max older)
11703 (setq all (1- all)
11704 max (1- max))))))
11705 (setq older (gnus-uncompress-range older))))
11706 (all
11707 (setq older (gnus-uncompress-range older)))
11708 (t
11709 (when (and (numberp gnus-large-newsgroup)
11710 (> len gnus-large-newsgroup))
11711 (let* ((cursor-in-echo-area nil)
11712 (initial (gnus-parameter-large-newsgroup-initial
11713 gnus-newsgroup-name))
11714 (input
11715 (read-string
11716 (format
11717 "How many articles from %s (%s %d): "
11718 (gnus-limit-string
11719 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11720 (if initial "max" "default")
11721 len)
11722 (if initial
11723 (cons (number-to-string initial)
11724 0)))))
11725 (unless (string-match "^[ \t]*$" input)
11726 (setq all (string-to-number input))
11727 (if (< all len)
11728 (let ((older-range (nreverse older)))
11729 (setq older nil)
11730
11731 (while (> all 0)
11732 (let* ((r (pop older-range))
11733 (min (if (numberp r) r (car r)))
11734 (max (if (numberp r) r (cdr r))))
11735 (while (and (<= min max)
11736 (> all 0))
11737 (push max older)
11738 (setq all (1- all)
11739 max (1- max))))))))))
11740 (setq older (gnus-uncompress-range older))))
11741 (if (not older)
11742 (message "No old news.")
11743 (gnus-summary-insert-articles older)
11744 (gnus-summary-limit (gnus-sorted-nunion old older))))
11745 (gnus-summary-position-point)))
11746
11747 (defun gnus-summary-insert-new-articles ()
11748 "Insert all new articles in this group."
11749 (interactive)
11750 (prog1
11751 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11752 (old-active gnus-newsgroup-active)
11753 (nnmail-fetched-sources (list t))
11754 i new)
11755 (setq gnus-newsgroup-active
11756 (gnus-activate-group gnus-newsgroup-name 'scan))
11757 (setq i (cdr gnus-newsgroup-active))
11758 (while (> i (cdr old-active))
11759 (push i new)
11760 (decf i))
11761 (if (not new)
11762 (message "No gnus is bad news.")
11763 (gnus-summary-insert-articles new)
11764 (setq gnus-newsgroup-unreads
11765 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11766 (gnus-summary-limit (gnus-sorted-nunion old new))))
11767 (gnus-summary-position-point)))
11768
11769 (gnus-summary-make-all-marking-commands)
11770
11771 (gnus-ems-redefine)
11772
11773 (provide 'gnus-sum)
11774
11775 (run-hooks 'gnus-sum-load-hook)
11776
11777 ;; Local Variables:
11778 ;; coding: iso-8859-1
11779 ;; End:
11780
11781 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
11782 ;;; gnus-sum.el ends here